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 2659843BD2; Sun, 25 Feb 2024 16:12:27 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 30E9D42D9F; Sun, 25 Feb 2024 16:12:05 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2068.outbound.protection.outlook.com [40.107.20.68]) by mails.dpdk.org (Postfix) with ESMTP id 7A54342C24 for ; Sun, 25 Feb 2024 16:11:57 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cIn4G04g03ga2lGHEA53XkHorLxHVquvMy8f3h2SFisUHwLoHBdcwdLWyR64q2XoGDhfBjQCdKa3JSjeQTjXTon6H7kU1xGtZUZj9wvKTBKhWG1j8e70UMPyxXWW6ZxElbpkMy5401FhfURZgN4F8RpNede01g05YxUzRaBmh05uiCBED9/qAvCz1EM1hEqtG6xkkWDtYmrw1cqyma+ekZ3yp+iZ2AjJXZzXeUrQfGy46zG59WQOhRGo6iNuQX0lXgf5voY/ylMSbJh//P/qHyImGQq6w23bmsSw/Nosm8mhA88/yt9dRdUQ0OlVCQADMYEy24UiIj5V/GkFUzJc+Q== 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=XtXEWg+/T4E4itTAs6atvniqRZGc93gwtZptQTWWciM=; b=mRapGCAwA17/2YD0Pvwq71u73m7qi1uKSoUioP72mgUQpPVuPTpgyGmO+/YPoT30VPSjxkxcAXobR0uOevmNYap+k8BnC3sF/qtpcTU2Nc917NJgwdvNH0WFjgx66WtNsT6P/fXjGSEVkBrtwGKvVaOM4AA0pD+9pb4S0Q7IzK41pr/BKFd2Vwl71bR/Ew/s1VE0tfpaKQqIkdLfPCVyRPP94GZdn3VMAQZj4mDa5eeveENh02DvU86ihGs7KWxIcDeBXY7LA2bl2jDKNmAhZDOZ30QgbDk2cA3/DPcI1osBGoHSVnPnMf/Xa6HacpMqB5Hz3V279NgPh4g7w8E2eg== 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=XtXEWg+/T4E4itTAs6atvniqRZGc93gwtZptQTWWciM=; b=Wt7iCpDYhQvlC9G4zzSSMeiza78hDsMWdn6uC6fCFdTYVf1t1RFDRpyZSrG14uTLpAu1VmKWmcB0SY8mRxwqkNsa198sFRT3ej78p52FbF3IX1WPxzzbzKXca8B0o1xIoWjoSbttP5a6qXtELn1PS4Fp+0bqjY+P/AAPHGq0U+N9RsbbTcrTmsGbNMF1pAdjsLU6C7Du24K1bVx2m//ketToDriSIpUiSzs31+3NRcYOnR3Kx0/X3jo9Ep2FYlsLWtYMyxgKrjGviGIRRXHw6bkm1RAm98b2dibJWUshyOKyrggKs8FoPE7ynT9NJsnVqHCo/2Un7S5HCx0QsPO1tw== Received: from DU2PR04CA0260.eurprd04.prod.outlook.com (2603:10a6:10:28e::25) by DB8PR07MB6265.eurprd07.prod.outlook.com (2603:10a6:10:13a::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.34; Sun, 25 Feb 2024 15:11:56 +0000 Received: from DB1PEPF00039231.eurprd03.prod.outlook.com (2603:10a6:10:28e:cafe::55) by DU2PR04CA0260.outlook.office365.com (2603:10a6:10:28e::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.49 via Frontend Transport; Sun, 25 Feb 2024 15:11:56 +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 DB1PEPF00039231.mail.protection.outlook.com (10.167.8.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.25 via Frontend Transport; Sun, 25 Feb 2024 15:11:55 +0000 Received: from seliicinfr00049.seli.gic.ericsson.se (153.88.142.248) by smtp-central.internal.ericsson.com (100.87.178.61) with Microsoft SMTP Server id 15.2.1258.12; Sun, 25 Feb 2024 16:11:55 +0100 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00049.seli.gic.ericsson.se (Postfix) with ESMTP id 38F72380061; Sun, 25 Feb 2024 16:11:55 +0100 (CET) From: =?UTF-8?q?Mattias=20R=C3=B6nnblom?= To: CC: , =?UTF-8?q?Morten=20Br=C3=B8rup?= , Stephen Hemminger , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= Subject: [RFC v4 6/6] eal: keep per-lcore power intrinsics state in lcore variable Date: Sun, 25 Feb 2024 16:03:30 +0100 Message-ID: <20240225150330.517225-7-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240225150330.517225-1-mattias.ronnblom@ericsson.com> References: <20240220084908.488252-2-mattias.ronnblom@ericsson.com> <20240225150330.517225-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: DB1PEPF00039231:EE_|DB8PR07MB6265:EE_ X-MS-Office365-Filtering-Correlation-Id: df34afdf-c027-430b-da29-08dc36141b04 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tpg82IwhBmOxP3m9R9KKeBLgjSh6FBE5r2UlGdAfZn5vS857qXNe/CaRCv0yhplzJgyvMxKlLmWi3QLO4OmahJA88eBdCNDJA/GE3f/5krE5S96JE1RpY9sncjHmADsLlrbhZQkx08YfVAconpen/HFSjmT13RBk7OR351foScp3nuwFgfuR3ZcEREUiKl4f8yoDe14qK21CgR8S1fE5J7rD0aAJ2xUax8I509+byhnR96MnebmoZx2rPhmANtN8Say/3h7Nl8eZSDlZdAJuXFr7+OfhpgzB8Tx58UpadJs5uCF5KT8ALLA5u5zMjEp27zsWhI4OrlU8wA9roIzCAjU0L3DPPzGTxvUfl+50cheoav3/xQ3s94X/WAerZ+O32LSS2tRzK6AP0aKlYv3VfFCEt8vse+8zYt4Hxn2seqzL0/C4b1U3fgM+LswKgCP6+fR7LM8g7B0Nxo2MMU5Xg8WSkyVQS7WJ3mhl/U8DuXkduFe2ki2DK7g7ixBG6vdTOEk0mo9M6cmJ4Q5ha/VyQQTudvWFPyPmNJca53FzTwG3+OFiy3YA65VXv7Ox4pc2O4nkzaTqf3H88osL7lkmi1pWemtBxOKr2MbQv7whizVI2RycY3whWQknbjP12aYNno0HxeQ+FDBMUo9vhFPJpA== 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:(13230031)(36860700004)(40470700004)(46966006); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Feb 2024 15:11:55.9379 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: df34afdf-c027-430b-da29-08dc36141b04 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: DB1PEPF00039231.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR07MB6265 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 --- 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 532a2e646b..f4659af77e 100644 --- a/lib/eal/x86/rte_power_intrinsics.c +++ b/lib/eal/x86/rte_power_intrinsics.c @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -12,10 +13,14 @@ /* * Per-lcore structure holding current status of C0.2 sleeps. */ -static struct power_wait_status { +struct power_wait_status { rte_spinlock_t lock; volatile void *monitor_addr; /**< NULL if not currently sleeping */ -} __rte_cache_aligned 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. @@ -170,7 +175,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_PTR(lcore_id, wait_status); /* update sleep address */ rte_spinlock_lock(&s->lock); @@ -262,7 +267,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_PTR(lcore_id, wait_status); /* * There is a race condition between sleep, wakeup and locking, but we @@ -301,8 +306,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_PTR(wait_status); + uint32_t i, rc; /* check if supported */ -- 2.34.1