From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A23E045952; Tue, 10 Sep 2024 09:13:10 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3D3CA4021F; Tue, 10 Sep 2024 09:13:10 +0200 (CEST) Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2076.outbound.protection.outlook.com [40.107.249.76]) by mails.dpdk.org (Postfix) with ESMTP id C4FFB40151 for ; Tue, 10 Sep 2024 09:13:08 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=M/pRKUtS8GjsZYJ5o21H9DNhbC4OGZX1AePzf4SUYgduqLHWceAjq4Dg59I68D6WjtDooEmPU6EVsmfq1TvPLhnqsx5owS7S4sOHgXscRkz0R1MH4U05E9fNGfKmfHrecFriV8KjIX1lLA9NhUqdALF1bsy+8JZRmCjT9wZSdZGyKaELEVtGunE1ZWtrBqN05+Pd2imlRPI7BJSjudXe03ZuBVuRNWFlEcKYDl2yzRAl/SNMorH/cxRWLD4RTNL4dxc5ECz5ACpLvAozk2ItSS/bc25A/dP2pZdutekksqaq6nkAhGk1S4QtCbH0xE2tc28gmfIAK5Eti8RZ8wMHOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=5KgLIeJsoXsbjQgRv+axyk0s7Khi0OpcLSDJyLLTnRM=; b=hz2HBLmmAYkgskk82I8PbIVTGeNl8GChJgKaVGaHWYCrreFtAqxmWh2EeIi/SHrJnfINCUY2NxGuY6eiQKcn8FUtkDPKxPkLD3m1pbU6nK6PPSHZa5ogAD0KrUuubpZBn9Iof+iJHKfaCljHR/IWkRo01mj5pi4tlQEU45RXeUAObpbiRzZKx1+NGRnx1rtPB8jBXC4rjZjlJdBJTKIsNHZHyOQBDabvxiKpW603Se5jpl8PPujHKFm5CH4R5Tm0t6fuLY4qvwUaWu/Y5n1Pk2CX36RXIPL4yVc4SUeL6ePXSSK3t5VikDp6m16ryGjuxCag95Xb3/D5es++6tn6SQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 192.176.1.74) smtp.rcpttodomain=dpdk.org smtp.mailfrom=ericsson.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=ericsson.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5KgLIeJsoXsbjQgRv+axyk0s7Khi0OpcLSDJyLLTnRM=; b=Xp4M+bZKFrYmYN+WbVTX73Ie/bwGuVvn6PP4E2CvWiWnYCNOjyFD4aud7KOQn+w5r48Y6AK5px/77GMcK8Wl4CpcwbMayVTcKaz8g5tt7YjkxniIZOkLhaStXGIZ1UxYaTnm3VOloziXaUSWqKpjGPD+j8HGKT88lZpMa+0G42fJIUSoiTqUmx7nbxILZOUPf0YJpQecPAC7ECM9YlWMIwBFN4RNoG5qbtegIt/hdahnKsW3dxsKu+xewoh8+s9BWkM4K3u11TNEvGw9NZjd6CajCNwTb0xgLk1vTlz6suz254Xpc3NBfX39dLqt8c7PF0xyMBFI7NEvLOsz+qECFw== Received: from DU7PR01CA0004.eurprd01.prod.exchangelabs.com (2603:10a6:10:50f::18) by DB9PR07MB7771.eurprd07.prod.outlook.com (2603:10a6:10:2a6::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.24; Tue, 10 Sep 2024 07:13:06 +0000 Received: from DU6PEPF00009524.eurprd02.prod.outlook.com (2603:10a6:10:50f:cafe::c2) by DU7PR01CA0004.outlook.office365.com (2603:10a6:10:50f::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.24 via Frontend Transport; Tue, 10 Sep 2024 07:13:06 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 192.176.1.74) smtp.mailfrom=ericsson.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ericsson.com; Received-SPF: Pass (protection.outlook.com: domain of ericsson.com designates 192.176.1.74 as permitted sender) receiver=protection.outlook.com; client-ip=192.176.1.74; helo=oa.msg.ericsson.com; pr=C Received: from oa.msg.ericsson.com (192.176.1.74) by DU6PEPF00009524.mail.protection.outlook.com (10.167.8.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Tue, 10 Sep 2024 07:13:06 +0000 Received: from seliicinfr00049.seli.gic.ericsson.se (153.88.142.248) by smtp-central.internal.ericsson.com (100.87.178.69) with Microsoft SMTP Server id 15.2.1544.11; Tue, 10 Sep 2024 09:13:05 +0200 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00049.seli.gic.ericsson.se (Postfix) with ESMTP id BB57E38007F; Tue, 10 Sep 2024 09:13:05 +0200 (CEST) From: =?UTF-8?q?Mattias=20R=C3=B6nnblom?= To: CC: , =?UTF-8?q?Morten=20Br=C3=B8rup?= , Stephen Hemminger , Konstantin Ananyev , David Marchand , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= Subject: [PATCH 6/6] eal: keep per-lcore power intrinsics state in lcore variable Date: Tue, 10 Sep 2024 09:03:44 +0200 Message-ID: <20240910070344.699183-7-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240910070344.699183-1-mattias.ronnblom@ericsson.com> References: <20240506082721.120666-2-mattias.ronnblom@ericsson.com> <20240910070344.699183-1-mattias.ronnblom@ericsson.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU6PEPF00009524:EE_|DB9PR07MB7771:EE_ X-MS-Office365-Filtering-Correlation-Id: c422bb20-7c5f-48e0-ab89-08dcd16804f0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?B?SGIxd3llOFhnRGZJS2d1SGVVaGxvN3JTdGlhYy9sYVdyUm9uVk5jREZvRzhC?= =?utf-8?B?Q2RHclFpSTg4dm9wNUNZNkh3WllvMEQrYUVGamtaQmpGcmlHM2EzcitEOWhM?= =?utf-8?B?NjVrMlRHcy9DNmtOT1lpZVRDS2ROc1YyTUVTKzc2SVhiTklDSTQ0VEpIQW0z?= =?utf-8?B?RGdJVHFmV2d2Sm9HSWQ3NmhUdjdoY0JBcE5kQitJOWhRTm9aU1d4UkRZWE9E?= =?utf-8?B?SkRuT0QyMTdKRTN0eS9XSEUwRC8xZE81YUgvblRNVVlKRkNSL0JTaXhVL0Jn?= =?utf-8?B?SmROOGZCQytPWkVtMHBQaE5nMkhRN1krMll1OVo3ck9MZUpsUU5oMXpQRjVj?= =?utf-8?B?TU1Cc3AyMUU2UDRLQmlQVDFaSE9ORDlIcUZMS3hOKzg3MkMxRXVGOXNRK25S?= =?utf-8?B?M0E2V0pxbWxUZENjOVdDc3g0VjdhWlFWcjBVQTNlSVNETEhUWGgrejlaZWVP?= =?utf-8?B?SUd6SmdqazJobG1qZHRZNGkvZ1VBTlZTWkFKN2hwQ1AzbFFEL2M3bnBWcWda?= =?utf-8?B?Znl2UmVEYkYxb1pNb3hnSS82RWtwamZJU3JCbjV6S3U0Mko5MEN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URxNFg0UXdCU2tMQi96TGhZRjY0MHdv?= =?utf-8?B?a0h3S21WbFdMcW1ZNlVsdnJRVkg2bENmMmRHeXdBL0xQUHlubitiS3E3dUhF?= =?utf-8?B?SVJXQ1AwRmtlTWQxdlpuKzFnOHB5UUVuUVhCbUV0d2x4aEw1THhVVkJ3Q1dx?= =?utf-8?B?ZEhFbmZJdm8zMFQrNktmMEE5OVI0ejBVZVo3T3kyT3FKcWYyc21pSWFuNlp5?= =?utf-8?B?eHpEZEN5d0JDMFhtVWQ2V0VHU054QjNsNXpPS3dVRFFnZy9KcUdqbDEzdTEz?= =?utf-8?B?a0kxaVFFT3h1bnNxZFdtQ3R6ZUt0NklsNm9JMjllWG0va0Zud1kxR3MrUFNL?= =?utf-8?B?clcydTRtUEJHNTVpamFlUmVpWW02SmVaNDNTRUFjYmhRRFg3dHk1aUlYQ1Ay?= =?utf-8?B?ZTNtc3kxblFqdjFBN3BSdTd2dGZBWjBiWEdRZnl2dVdVYTJDUEJ2MS9SMjFX?= =?utf-8?Q?PT1eqv7a83gXDBLiAa42iol/vXthPrSe?= X-Forefront-Antispam-Report: CIP:192.176.1.74; CTRY:SE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:oa.msg.ericsson.com; PTR:office365.se.ericsson.net; CAT:NONE; SFS:(13230040)(36860700013)(376014)(1800799024)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2024 07:13:06.8671 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c422bb20-7c5f-48e0-ab89-08dcd16804f0 X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=92e84ceb-fbfd-47ab-be52-080c6b87953f; Ip=[192.176.1.74]; Helo=[oa.msg.ericsson.com] X-MS-Exchange-CrossTenant-AuthSource: DU6PEPF00009524.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR07MB7771 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Keep per-lcore power intrinsics state in a lcore variable to reduce cache working set size and avoid any CPU next-line-prefetching causing false sharing. Signed-off-by: Mattias Rönnblom Acked-by: Morten Brørup --- lib/eal/x86/rte_power_intrinsics.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/eal/x86/rte_power_intrinsics.c b/lib/eal/x86/rte_power_intrinsics.c index 6d9b64240c..f4ba2c8ecb 100644 --- a/lib/eal/x86/rte_power_intrinsics.c +++ b/lib/eal/x86/rte_power_intrinsics.c @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -14,10 +15,14 @@ /* * Per-lcore structure holding current status of C0.2 sleeps. */ -static alignas(RTE_CACHE_LINE_SIZE) struct power_wait_status { +struct power_wait_status { rte_spinlock_t lock; volatile void *monitor_addr; /**< NULL if not currently sleeping */ -} wait_status[RTE_MAX_LCORE]; +}; + +RTE_LCORE_VAR_HANDLE(struct power_wait_status, wait_status); + +RTE_LCORE_VAR_INIT(wait_status); /* * This function uses UMONITOR/UMWAIT instructions and will enter C0.2 state. @@ -172,7 +177,7 @@ rte_power_monitor(const struct rte_power_monitor_cond *pmc, if (pmc->fn == NULL) return -EINVAL; - s = &wait_status[lcore_id]; + s = RTE_LCORE_VAR_LCORE_VALUE(lcore_id, wait_status); /* update sleep address */ rte_spinlock_lock(&s->lock); @@ -264,7 +269,7 @@ rte_power_monitor_wakeup(const unsigned int lcore_id) if (lcore_id >= RTE_MAX_LCORE) return -EINVAL; - s = &wait_status[lcore_id]; + s = RTE_LCORE_VAR_LCORE_VALUE(lcore_id, wait_status); /* * There is a race condition between sleep, wakeup and locking, but we @@ -303,8 +308,8 @@ int rte_power_monitor_multi(const struct rte_power_monitor_cond pmc[], const uint32_t num, const uint64_t tsc_timestamp) { - const unsigned int lcore_id = rte_lcore_id(); - struct power_wait_status *s = &wait_status[lcore_id]; + struct power_wait_status *s = RTE_LCORE_VAR_VALUE(wait_status); + uint32_t i, rc; /* check if supported */ -- 2.34.1