From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2083.outbound.protection.outlook.com [40.107.14.83]) by sourceware.org (Postfix) with ESMTPS id 4DB4F3858D32 for ; Mon, 8 Apr 2024 13:33:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4DB4F3858D32 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4DB4F3858D32 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.14.83 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1712583210; cv=pass; b=oEwpllQBguO8Egm8VuwhlE/XDQgnTU0LAGDJ7Mn3QvzBoYxjsyv6J7evYM499IbMZFoExGT/7qvLBqkGq5WQcAcr+z06xy2LKCAauXWKkoW2xjSD3Q1RKqVnzC2SvF3WSyTlYihf2vzyLLwQmrqyFfjC+E92noX3y2dmKj86Zr0= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1712583210; c=relaxed/simple; bh=Oi7CMgmGNAu399TzCUTvP9LXVtDiqpbhELkPQ1W8k3I=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=ZeyWefVQxV+h8mSjQtLZPvNmfUt2VO4OO/0hq5bmWrfXp+/XI9EqN31JZdIFK9x1x51ZAs2pv7rg0mTd6T9bE5UMi0K3ffyHPfUL4XtDaEs0aKTExzveHUaNybXLg0tzQcYddNiOI9zWp7O94b63Jkc2THlZn5pXPCqfIVN3sys= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=amq474KB2YVax+5QYFHn9MfRYMbb6Z8e9D6LscM2qJSWPs1qpFR3LX7F4qKIMoqm49F6x3R2nQEt2sZTnZlYdp+1h9zY1khP0Nz2Id3owI+r00ims9tvo0IsGUzUa/sXaOqSx+THxswFEuhnDoRvXiNHb/iFrcxMMPiQmDobT/zlBKiaDa7IoTpf1TnnH4nok9h705cuWMlVryI++2gPoHMnZOL40e8f2I7fdDVsACapZ8DoFDWys512YdGzCixPlCit7IWs0aRBImaXRV4xtAo2ILac5DM/GRH6Qz4qtHgzFnzTnWPcIzBpHM/QctDc2Iq5sV7wia92goUuKEUNMA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=UHmWkva0+ForWPJ/4MK6g4EMmyybluTmTu343mdc0s4=; b=UNU5Tj7Vltild0XSMDh0Ym7i6FT/sukdeNUS2f0PasBIaoxq1mkKCwFkMpTU4v5txdhMQNYIXWYoNHwVYgGqhB73HGm7BMSg31qxE3X0hnvGw4oukG/pQgkUqWxhDkGlB0DIr3xDrIWEKsVU2fP5kzMQSjFVIIeRDyraBYJc7wO/62odW2b5WHOxlwvCHrCHD9wy15aE3dwYyFgk/zuWg8InFWVRHt9OclQzcNR9GERzc5xcG9zld6hk6Accf1JDUNxgclv39Nj0JDzEzbcQmIxWXh2+1d0U3x4/zBnPIjYfttjfcrSf6aqHk0ZkBViQREdIuOJD3dA84kMaS8+Ilw== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UHmWkva0+ForWPJ/4MK6g4EMmyybluTmTu343mdc0s4=; b=Fijk0kKeqbRwWwiJCr8afVBGarv4zzDIzYxwR5lA4KNocdAmPU0lnlSbQzvq23ZY97y+wy6r6ZKcv/MEWBGKU+LVbPNj0pSCtUUa6qyx/Ca/YGgzn8GJaaBVg2Xt9yNMfYTxlmS6euS+TuQQLMJTzAz5VATWIMs9pXNm1v7ZLfc= Received: from AS4PR10CA0015.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:5dc::11) by AS8PR08MB6232.eurprd08.prod.outlook.com (2603:10a6:20b:296::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.54; Mon, 8 Apr 2024 13:33:21 +0000 Received: from AM3PEPF00009BA1.eurprd04.prod.outlook.com (2603:10a6:20b:5dc:cafe::ee) by AS4PR10CA0015.outlook.office365.com (2603:10a6:20b:5dc::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.33 via Frontend Transport; Mon, 8 Apr 2024 13:33:21 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM3PEPF00009BA1.mail.protection.outlook.com (10.167.16.26) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7452.22 via Frontend Transport; Mon, 8 Apr 2024 13:33:21 +0000 Received: ("Tessian outbound ff4e98f65004:v300"); Mon, 08 Apr 2024 13:33:20 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 686d5a9c242bf199 X-CR-MTA-TID: 64aa7808 Received: from d10e8d4d6ab6.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 116A864A-DED2-490E-BBBD-85E64654F2BA.1; Mon, 08 Apr 2024 13:33:14 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id d10e8d4d6ab6.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 08 Apr 2024 13:33:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jzR+sY5x7pngCiBqrqv+rAjHYOiGaduVaagpsB8U8y4c4RexenATL2A8bmii95PGAeBhU4pjldxWIH66H8Xaf60Fxts5LirIrOmEbpCwNddmXtY0Qs5LGKoVHi5EFCejub3C1UKm4f1f5szp+bz6ecg1WmYfxk12c8+0pgpuozlqRaSvJ8P6Bz4KbYYvDE2KkEYsobjAeMxGYrrTvCLpXCEKthMgKjk1gq8IRos/4rXLHjiF9d/W/6sF0adRG8gOGoVWYEDFD/6kEyOHe+NICLrAKsnapVT7NAqK0wv/bapF0BTtL7tHgrkaeAeYHnUW8i/O7V2JCtDpMk7QCT3+JA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=UHmWkva0+ForWPJ/4MK6g4EMmyybluTmTu343mdc0s4=; b=ezyqoTDSGzYkVgLM1SQLaqkQ2FYssnbHvg272u3aSZzjcjZYh4nAOch6LG9hA677qA9H9ksb2SFFnceioDtECjjbqFEuwxv2cpw15SjS7apYCiTvnAZz7I+0w3s5jovrsSvVJtvMXnJ2wjQjmXgmeipPeutvCF2u1YgqXrpQUgzH0i3AOHkQD5JFXTar0aY+O6jNBzaSev4FleymbVGcYy6zgBEDTOypoUYlWa8qLRhiHnrs87pGbTObSsoR+JFUTe37QJgsF9qPwJcStWiSVLsn+83dwEau2O0XU4BN74H3Fu17XSpv7mWIkB2FWxwCsyuvTVIGvOPY1J01Upu4IQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UHmWkva0+ForWPJ/4MK6g4EMmyybluTmTu343mdc0s4=; b=Fijk0kKeqbRwWwiJCr8afVBGarv4zzDIzYxwR5lA4KNocdAmPU0lnlSbQzvq23ZY97y+wy6r6ZKcv/MEWBGKU+LVbPNj0pSCtUUa6qyx/Ca/YGgzn8GJaaBVg2Xt9yNMfYTxlmS6euS+TuQQLMJTzAz5VATWIMs9pXNm1v7ZLfc= Received: from DB9PR08MB7179.eurprd08.prod.outlook.com (2603:10a6:10:2cc::19) by DB9PR08MB9658.eurprd08.prod.outlook.com (2603:10a6:10:461::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.55; Mon, 8 Apr 2024 13:33:12 +0000 Received: from DB9PR08MB7179.eurprd08.prod.outlook.com ([fe80::8c23:46ef:c2c9:ea91]) by DB9PR08MB7179.eurprd08.prod.outlook.com ([fe80::8c23:46ef:c2c9:ea91%4]) with mapi id 15.20.7409.042; Mon, 8 Apr 2024 13:33:12 +0000 Date: Mon, 8 Apr 2024 14:32:59 +0100 From: Szabolcs Nagy To: Florian Weimer , libc-alpha@sourceware.org Subject: Re: [PATCH v4 1/3] elf: Add CPU iteration support for future use in ld.so diagnostics Message-ID: References: Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: LO4P123CA0672.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:351::10) To DB9PR08MB7179.eurprd08.prod.outlook.com (2603:10a6:10:2cc::19) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: DB9PR08MB7179:EE_|DB9PR08MB9658:EE_|AM3PEPF00009BA1:EE_|AS8PR08MB6232:EE_ x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: vtC6p2GwUqqgDXcLhgPc7zl6f+qlNQC7bqxnZovTTVYL20aHQatmOZfftQ7OqrmknPrLhNgNIeNSvfdJz+eKdIaWdUOYOIdj/JKAMx/sJ/YET/LXPbTgPoidIog1eq8XM1x0pELZOMcmjRLrFt8KIt8+o7c36oO85/mnHozbw8+fGKBJZl8Bw44RFrmNaxX3F2ufjDolR9lqIwqqamXhtSOBP9SGQCWcF3pXy/uMSH3jiZoS+3T1HMcLGw5zviP1lhcRP8yBIf/YS43wcLZGN3gw2RCBOyqT7KK9G74h+peA+N+1/117aeaXYhlfRbIz0Omch9Z/QtLPT76Jgunge+8+3bcUqwfgW2bSdpJ6T/kK+Kl+p7DVRr6kMZbq32Q8FymJW8ITM+rhEVAi6h3wMHL8LLbRwHy3zTdnhU6zmzW50FlnGS/6C8hfdPuxD6jFLQVV0E/nluD1EaTtiSX6DkhSdsce3Y8R+7vSLsyOm5iq4eiTGuiLfYQ3iD7kDPz1iiFmVcPCExqeAP5Wyof//uDyJUGD73BhPV8bpuN0izoIiQeEGnW2Mt995Ou2qB8YXW1PXOccEBR1cNuJVBol9iGHnKdIQ1p0MnZUkhBwQ00= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR08MB7179.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366007)(376005)(1800799015);DIR:OUT;SFP:1102; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB9658 X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM3PEPF00009BA1.eurprd04.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 40e65c34-7f0a-4d29-5cac-08dc57d07541 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7y75ZX5S9KhU233vkmsGK7lmLzveYzQEmqQjk0mCHcyZVQ3x8Bih35qyQub69+yk/4iXAX1EwKo8WjQQohtCGaj/HI6gTQTMT9XmdreWs1f/ELiJjjWDzxFyEcxeXtrUg8zeRdzcIDSDLrDw76fGSVmooh/9Sq8Nc0/l20bEuXRz1zbz+FO3iu8iPlJpBmQpTEtyCQPpA3wCYJNoZqi7LSY9JPO4q7wxTKKAzKuhqKdbiY0fTmmFokE2QINxHjs6BUP0zhQXu4KJyGVGH1F5luhHv3YykrmUNU+lL1quSUhr3vxCtWfA9e51nMGHGvzP6jBK6UP66x8xJuUpPDob+kJmYhCc0aX/K9Kg72OduqMoZput3ZqO0hUkdp2Iq+GJxJZ5SW0kVj+wktBhbVPSvaEpTGj9FnGDqRyHzWCSky68Ic1b5bxYGOelUVKbNYJ0RyY7FwQf0AfwisNC5XelmuFwQc9lLZc1UBt1Sa9+x5ael56b9eNI8xP4FNs9LYhf6VlJiW3BGrqqsYvTidcWkzL68VWg2CPizmYQAg4ajIPXFxZ+ClRxp2qeUrwxKtMK+LOYCqkQsvr7YIN7UGt5fW2srm+hpc27kJ4yzoCJfY/uCEhbwDDZ4AG4Xvc8bc6PL8aNwtjC8FzyDYatSba5AEyWdXcGcoiDJYgVATeaL6zPGfnuJOf4natjhWmadhGzJZxdaYpPIYLP51jnpRxTKQ== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230031)(36860700004)(82310400014)(376005)(1800799015);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2024 13:33:21.1174 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 40e65c34-7f0a-4d29-5cac-08dc57d07541 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM3PEPF00009BA1.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6232 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,GIT_PATCH_0,KAM_DMARC_NONE,KAM_SHORT,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: The 04/08/2024 13:07, Florian Weimer wrote: > --- > v4: Include in the generic version, to fix the Hurd build. looks good. Reviewed-by: Szabolcs Nagy > > elf/dl-iterate_cpu.h | 136 ++++++++++++++++++++++++++ > sysdeps/generic/dl-affinity.h | 54 ++++++++++ > sysdeps/unix/sysv/linux/dl-affinity.h | 46 +++++++++ > 3 files changed, 236 insertions(+) > create mode 100644 elf/dl-iterate_cpu.h > create mode 100644 sysdeps/generic/dl-affinity.h > create mode 100644 sysdeps/unix/sysv/linux/dl-affinity.h > > diff --git a/elf/dl-iterate_cpu.h b/elf/dl-iterate_cpu.h > new file mode 100644 > index 0000000000..60db167b13 > --- /dev/null > +++ b/elf/dl-iterate_cpu.h > @@ -0,0 +1,136 @@ > +/* Iterate over all CPUs, for CPU-specific diagnostics. > + Copyright (C) 2024 Free Software Foundation, Inc. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library; if not, see > + . */ > + > +#ifndef DL_ITERATE_CPU_H > +#define DL_ITERATE_CPU_H > + > +#include > +#include > + > +struct dl_iterate_cpu > +{ > + /* Sequential iteration count, starting at 0. */ > + unsigned int processor_index; > + > + /* Requested CPU. Can be -1 if affinity could not be set. */ > + int requested_cpu; > + > + /* Observed current CPU. -1 if unavailable. */ > + int actual_cpu; > + > + /* Observed node ID for the CPU. -1 if unavailable. */ > + int actual_node; > + > + /* Internal fields to implement the iteration. */ > + > + /* Affinity as obtained by _dl_iterate_cpu_init, using > + _dl_getaffinity. Space for 8,192 CPUs. */ > + unsigned long int mask_reference[8192 / sizeof (unsigned long int) / 8]; > + > + /* This array is used by _dl_setaffinity calls. */ > + unsigned long int mask_request[8192 / sizeof (unsigned long int) / 8]; > + > + /* Return value from the initial _dl_getaffinity call. */ > + int length_reference; > +}; > + > +static void > +_dl_iterate_cpu_init (struct dl_iterate_cpu *dic) > +{ > + dic->length_reference > + = _dl_getaffinity (dic->mask_reference, sizeof (dic->mask_reference)); > + /* Prepare for the first _dl_iterate_cpu_next call. */ > + dic->processor_index = -1; > + dic->requested_cpu = -1; > +} > + > +static bool > +_dl_iterate_cpu_next (struct dl_iterate_cpu *dic) > +{ > + ++dic->processor_index; > + > + if (dic->length_reference > 0) > + { > + /* Search for the next CPU to switch to. */ > + while (true) > + { > + ++dic->requested_cpu; > + > + /* Array index and bit number within the array. */ > + unsigned int long_index > + = dic->requested_cpu / sizeof (unsigned long int) / 8; > + unsigned int bit_index > + = dic->requested_cpu % (sizeof (unsigned long int) * 8); > + > + if (long_index * sizeof (unsigned long int) >= dic->length_reference) > + /* All possible CPUs have been covered. */ > + return false; > + > + unsigned long int bit = 1UL << bit_index; > + if (dic->mask_reference[long_index] & bit) > + { > + /* The CPU is available. Try to select it. */ > + dic->mask_request[long_index] = bit; > + if (_dl_setaffinity (dic->mask_request, > + (long_index + 1) > + * sizeof (unsigned long int)) < 0) > + { > + /* Record that we could not perform a CPU request. */ > + dic->length_reference = -1; > + > + if (dic->processor_index > 0) > + /* We already reported something. There is no need to > + continue because the new data is probably not useful. */ > + return false; > + } > + > + /* Clear the bit in case the next iteration switches to the > + next long value. */ > + dic->mask_request[long_index] = 0; > + > + /* We found a CPU to run on. */ > + break; > + } > + } > + } > + else > + { > + /* No way to set CPU affinity. Iterate just once. */ > + if (dic->processor_index > 0) > + return false; > + } > + > + /* Fill in the actual CPU information. CPU pinning may not actually > + be effective, depending on the container host. */ > + unsigned int cpu, node; > + if (_dl_getcpu (&cpu, &node) < 0) > + { > + /* No CPU information available. */ > + dic->actual_cpu = -1; > + dic->actual_node = -1; > + } > + else > + { > + dic->actual_cpu = cpu; > + dic->actual_node = node; > + } > + > + return true; > +} > + > +#endif /* DL_ITERATE_CPU_H */ > diff --git a/sysdeps/generic/dl-affinity.h b/sysdeps/generic/dl-affinity.h > new file mode 100644 > index 0000000000..d117f737e9 > --- /dev/null > +++ b/sysdeps/generic/dl-affinity.h > @@ -0,0 +1,54 @@ > +/* CPU affinity handling for the dynamic linker. Stub version. > + Copyright (C) 2024 Free Software Foundation, Inc. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library; if not, see > + . */ > + > +#ifndef DL_AFFINITY_H > +#define DL_AFFINITY_H > + > +#include > +#include > + > +/* On success, write the current CPU ID to *CPU, and the current node > + ID to *NODE, and return 0. Return a negative error code on > + failure. */ > +static inline int > +_dl_getcpu (unsigned int *cpu, unsigned int *node) > +{ > + return -ENOSYS; > +} > + > +/* On success, write CPU ID affinity bits for the current thread to > + *BITS, which must be SIZE bytes long, and return the number of > + bytes updated, a multiple of sizeof (unsigned long int). On > + failure, return a negative error code. */ > +static int > +_dl_getaffinity (unsigned long int *bits, size_t size) > +{ > + return -ENOSYS; > +} > + > +/* Set the CPU affinity mask for the current thread to *BITS, using > + the SIZE bytes from that array, which should be a multiple of > + sizeof (unsigned long int). Return 0 on success, and a negative > + error code on failure. */ > +static int > +_dl_setaffinity (const unsigned long int *bits, size_t size) > +{ > + return -ENOSYS; > +} > + > +#endif /* DL_AFFINITY_H */ > diff --git a/sysdeps/unix/sysv/linux/dl-affinity.h b/sysdeps/unix/sysv/linux/dl-affinity.h > new file mode 100644 > index 0000000000..bbfede7750 > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/dl-affinity.h > @@ -0,0 +1,46 @@ > +/* CPU affinity handling for the dynamic linker. Linux version. > + Copyright (C) 2024 Free Software Foundation, Inc. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library; if not, see > + . */ > + > +/* See sysdeps/generic/dl-affinity.h for documentation of these interfaces. */ > + > +#ifndef DL_AFFINITY_H > +#define DL_AFFINITY_H > + > +#include > +#include > +#include > + > +static inline int > +_dl_getcpu (unsigned int *cpu, unsigned int *node) > +{ > + return INTERNAL_SYSCALL_CALL (getcpu, cpu, node); > +} > + > +static int > +_dl_getaffinity (unsigned long int *bits, size_t size) > +{ > + return INTERNAL_SYSCALL_CALL (sched_getaffinity, /* TID */ 0, size, bits); > +} > + > +static int > +_dl_setaffinity (const unsigned long int *bits, size_t size) > +{ > + return INTERNAL_SYSCALL_CALL (sched_setaffinity, /* TID */ 0, size, bits); > +} > + > +#endif /* DL_AFFINITY_H */ > -- > 2.44.0 > >