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 F0436459C6; Wed, 18 Sep 2024 10:35:45 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AFA594029B; Wed, 18 Sep 2024 10:35:45 +0200 (CEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2059.outbound.protection.outlook.com [40.107.22.59]) by mails.dpdk.org (Postfix) with ESMTP id 1BFFA40264 for ; Wed, 18 Sep 2024 10:35:44 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qLUgjf6+A2YbNeMW8S85tguKUIrRYKLDchphSAxI9H+QwqkZVpcufz9KCOg0U89LKVCxbSdIiV3nW2+mB9q8q3D2O4SeAC/4rzgQ0hSHwSscGcHS0GjYgHKZe5EYawRuZZRikw/rnFUGwbqhh78HWkzzFK2w3V19lzSpV0bHmxMjfBi5jIW/T33uwLlJ2rKdDd01y/wMHERMwm5PUylLgj52UMu8ADMiFJdbEGYtOfpYAeTAv/0mHeT+rI4xACv/EnXxNw+57m27iwSX/5yVvhPLKGGfzY//6LWqLVR8GzvOYSouPa8mvoEiuhetrMPWb/awhj5LZnUvHWAEYNzZvw== 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=8QXQ77grbyJlmyNASwM1pAhDRu4Dnhbhux/JOhk2I5Y=; b=w9avoNVERjqLe5TBsc6C3tPI4Q0rmtUk2MKCNYUn6lOXclSKu21gO1tQ56JkEO9wdlIL11tR+bpXpVx117DxiwNdYiNnJFy9f4tbnmnJ3bDZvtf1jL7V2g4Zf34lqaNZrlNLKfuAYOQBwFOMmd7viTYRnx2gsDRaqAGpQuU+viFYPHsyhjRARuQFRgXNySwh626SzKXA8daAEqaDb1yavNmXl814W8DN/tp8RO+AnUVGGTA2+TEgCZLmADwram+fJhESkB4Mfksw1WwH7ctJ5XOD84xGOtizB9v0DbPFPe275pYmOcjRvM79bDw23xleSoQJ6+Bjoe/pn0xZ/RjmeA== 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=8QXQ77grbyJlmyNASwM1pAhDRu4Dnhbhux/JOhk2I5Y=; b=tqvcOm2SqSzLHy8V4CC9mqfettnJ1O8lgOHl0upnkUFox+dahj6nvE0JnlW26Fu30+Pd8Ul7ULt8kA/1mGXhtcCfset7O09wE6cBDd+8S8muXN5+oAwEYZ/SBSLE5InDbF0on8oR/sFJ/rWwj8WW0A0AUUcnpY+T+DavALH5Tx84gFLwPX6sq0/j0WXMGnZmY3oF5rSdeUcF1ZxCsuX1aPhtHXCXqTSvYmlQ813ty2fH5rP6sBUfA5xUEBsW3JMjgAODpyibvDr83Hv+a+TA/Iu8LOS+yP0f0il5/Op29rfhgjIdbJC9cGOuFNe0HTxmVv+MRfIEAJUwMEq1wnby7g== Received: from AS9PR06CA0326.eurprd06.prod.outlook.com (2603:10a6:20b:45b::34) by DBAPR07MB6534.eurprd07.prod.outlook.com (2603:10a6:10:178::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.24; Wed, 18 Sep 2024 08:35:41 +0000 Received: from AM4PEPF00027A6A.eurprd04.prod.outlook.com (2603:10a6:20b:45b:cafe::ed) by AS9PR06CA0326.outlook.office365.com (2603:10a6:20b:45b::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.25 via Frontend Transport; Wed, 18 Sep 2024 08:35:41 +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 AM4PEPF00027A6A.mail.protection.outlook.com (10.167.16.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Wed, 18 Sep 2024 08:35:41 +0000 Received: from seliicinfr00049.seli.gic.ericsson.se (153.88.142.248) by smtp-central.internal.ericsson.com (100.87.178.60) with Microsoft SMTP Server id 15.2.1544.11; Wed, 18 Sep 2024 10:35:40 +0200 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00049.seli.gic.ericsson.se (Postfix) with ESMTP id AD67A380061; Wed, 18 Sep 2024 10:35:40 +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 , Jerin Jacob , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= , Konstantin Ananyev Subject: [PATCH v7 7/7] eal: keep per-lcore power intrinsics state in lcore variable Date: Wed, 18 Sep 2024 10:26:14 +0200 Message-ID: <20240918082614.725220-8-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240918082614.725220-1-mattias.ronnblom@ericsson.com> References: <20240918080054.725164-2-mattias.ronnblom@ericsson.com> <20240918082614.725220-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: AM4PEPF00027A6A:EE_|DBAPR07MB6534:EE_ X-MS-Office365-Filtering-Correlation-Id: 7a1ce989-234a-4b7a-a848-08dcd7bce17d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?B?UkdJOFRiZ296cEp6T3h1TFgyZThxbmVCdmFsZlMzSURHWElYSW9RUHlxT3NR?= =?utf-8?B?eW81bFVxQ0FmUjU0clZzOUJkaEFvc2ltbDJhcVovV2d6b2d4QXhnVGNTSm1m?= =?utf-8?B?SGlyYmF0azZ2L0hGb0tleldvc0EyRXYxaWJqZS95ZjhtalBrRFliUXBKQkJO?= =?utf-8?B?ZVMvS1dhUFBWRVYxL05YS1pnNU9nYnRqTHdRUWl5YkZnM3U3ME1xejZ4YXY5?= =?utf-8?B?T1VEQnNSSzIyU2JIS0JDb3R5K2tHR21zcTNVcWtvVXNNSHJ1R21rMWw4cmE1?= =?utf-8?B?YnJud0tMaGdHeXFPKzFmb3RvSFV6K3pXNEJXbzd3R1NaU2t6dUhvTlg2V3pQ?= =?utf-8?B?OFlHMm5lMThENE5FazRPRXRSZFFBK1hNTTZoUkdsQUlZRkUxbUZKeHNHS0I5?= =?utf-8?B?R2l3MGV6bzFhd0JDUkF2cGNVd3pIWWVLa3hHczVqbVlwRktmZUlRelo3Vnlv?= =?utf-8?B?aVBGVGc4dHhmSldja0p5bzZqcHZvRi9yVFZUQjNWLy9pTmdJMExMOS9LZFFO?= =?utf-8?B?ek5XblQxS3R4MkIrenpPTlFOeldDZWFmd0p0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g2T2xQRHNMYVcvSXVqTGUyM09hK2V4?= =?utf-8?B?V1Jnd3Nic2xjb0xWT1FNQXQyaDNQeHBlM2h2a1Btd0tTQWZobGdXa05tM25l?= =?utf-8?B?SFVYRlRLVTI5RXgvdWhJWkVza2NJUHRINXRySlNOQlUwVVFDMG5rUWpzZUd5?= =?utf-8?B?cThiTHZWblNvN0dtVHdreHAzeXdTaENHOWs5dEtmcldmNDVpNzVqTm9LQUg2?= =?utf-8?B?d1FqeWhDdG81TFFsb3ZXQUlGVVRBeHN0TWtBVHBaSVlaazBDTWh2aWhjTlRu?= =?utf-8?B?bUgwRG11bWVGbk84cjNxL1h6Q1phM1J1ejNTV0dhTjUrUnBkNUlHYXBtN3Yx?= =?utf-8?Q?4Md5+yexuU/Wxi6Eh+RpZ3D3MmqhkvrZOPR/8=3D?= 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)(376014)(36860700013)(82310400026)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2024 08:35:41.6074 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7a1ce989-234a-4b7a-a848-08dcd7bce17d 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: AM4PEPF00027A6A.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR07MB6534 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 Acked-by: Konstantin Ananyev --- 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