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 F0FB04596C; Thu, 12 Sep 2024 10:54:09 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7969942793; Thu, 12 Sep 2024 10:54:04 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2061.outbound.protection.outlook.com [40.107.20.61]) by mails.dpdk.org (Postfix) with ESMTP id 67ADD402CB for ; Thu, 12 Sep 2024 10:54:01 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QuezHs+pCAte5O6RFYImp0F1EwhCj9h8xKilDjrxzGbuoQx087/4A6JcmwNOVDG3zuEkxCofZAQa/He49SRFtCiGck/I7/j9AgWtMhJAW9ySPp4iI2f0hYjYkwqv/3ccNJqwYveYogkkzksjMAdF+7o9DfJn3/tuf2Ooy7AjH/NeYwZrEdtg29iQ3Jnna6EM5tGBHSTIa0Fjbd53FzscHrHJaNSsPv53ClqUCkhIBM5CNfxAFP/H7t70dwaNdlE3gFxvatFpTEK2gIk4INtNOE79U2Xblc7Y/eP31X/SoeUbSf7pOqG6l7khAXxjaJU1qCEEqiCP8KwHoV/jwa7X2g== 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=odt9mHiJRPtM0YsqgRGKgBHby25eUzHTc9uehGHilNT+24jmjr9/8MESobNsvQl8eF1459MC83kjFm/r8oug6Qdex622ED2ZL1r50bBMrhS6X249yuBHVdxNS9u9/n3lR1roi5lNAGJFzWv+CLqsb4wONrkl7J1+GLhqXNgt7L5rkUIFs298wB6+YMJQy3xsgaXweFjf0Kwbot1Lz3gImauZzNB+Pp/MTO+wlSCqnOVf39+y16VOEa0Hygsh0GdK/yW1+r0YxFlVLuMhrXC6ToVOihdFSv+w2QHTXZjvWwNfIdSQZvZwtvxu+U93iT4OwV1HsWNBgABjwx/iVQKlXg== 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=ywtyGsA2Qei3zR9ax7oTiCBggrzwUT/afxUEazbidYNdu6nIj2ERfgbCMDTsotZfuVunkqSRNpWhZF8SPIHic3s0nr4UkvOuWpnZe4tFGHR4+QMC2+85S5JEI+Eh7oN0Z00JRZfVW3Ab7ad9zGO8ZCsQ2EP76hdq19xBemi6t4hbq8Ca8IhuYgjP1ASdXGVLzGmUGA27ILpEdwnUi4xOjqSPVLhfRmYB//QvzEQCSDBW7+bc/2uvE8ttfgGdOwqCnImyv15YMMgAdAdKwDsbpV+Qhms0I4Hoyjhh4sS+gM8kQMuVEKeO4TG73NyzS2chee4mWA0fkeHouRi/pPk0aQ== Received: from DU7P194CA0014.EURP194.PROD.OUTLOOK.COM (2603:10a6:10:553::31) by PR3PR07MB8289.eurprd07.prod.outlook.com (2603:10a6:102:17c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.18; Thu, 12 Sep 2024 08:53:59 +0000 Received: from DB3PEPF00008860.eurprd02.prod.outlook.com (2603:10a6:10:553:cafe::b2) by DU7P194CA0014.outlook.office365.com (2603:10a6:10:553::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.25 via Frontend Transport; Thu, 12 Sep 2024 08:53:59 +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 DB3PEPF00008860.mail.protection.outlook.com (10.167.242.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Thu, 12 Sep 2024 08:53:59 +0000 Received: from seliicinfr00049.seli.gic.ericsson.se (153.88.142.248) by smtp-central.internal.ericsson.com (100.87.178.66) with Microsoft SMTP Server id 15.2.1544.11; Thu, 12 Sep 2024 10:53:51 +0200 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00049.seli.gic.ericsson.se (Postfix) with ESMTP id C7949380061; Thu, 12 Sep 2024 10:53:51 +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?= Subject: [PATCH v3 7/7] eal: keep per-lcore power intrinsics state in lcore variable Date: Thu, 12 Sep 2024 10:44:29 +0200 Message-ID: <20240912084429.703405-8-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240912084429.703405-1-mattias.ronnblom@ericsson.com> References: <20240911170430.701685-2-mattias.ronnblom@ericsson.com> <20240912084429.703405-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: DB3PEPF00008860:EE_|PR3PR07MB8289:EE_ X-MS-Office365-Filtering-Correlation-Id: 992c11f5-e362-4547-aa73-08dcd3087151 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|36860700013|1800799024|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?VXcybzhxZVdGQVp0T1MzK2Q4czRyd0kzM2hLV2tYNFJjMXB2dE5IU2dDWFFK?= =?utf-8?B?c1ZqZFhxUUZQb3lwR2l1YzRBV1Q4bjhIWEdDTlRyU21kY1YxaHJJOCtDMTBR?= =?utf-8?B?dmorQklkdGp4NDliVzM4dlNjR0JZT0pta0s3T3RGejJMeGlZbERTT0dJanpv?= =?utf-8?B?VlhTUnZkalk1VkdaUHk1VEhEMGEwZ3J2R1BOUmlsbzRFRzIvNVZBSGVKMlhi?= =?utf-8?B?b04ycTdXTjV4NWl2bGlUR0d0cFVxQjcrcm12d2xMV3NaUGZNVlFKNWFYZHp4?= =?utf-8?B?OE4vNzV2elZrbnM5OURDNVBVbHBZaWR3YzA0UzhIWHBiTnRWRUVTaWh0ODRV?= =?utf-8?B?cXJ1Z1lKNkgwcHFkQ1I2OXJXR1VWOURLR2dzWXkrUHFQV0ZDZFVsVUttaWxL?= =?utf-8?B?c3VseWJWcXdKc0FQck82WlVTdStEK3lzRi9naklhdFhLSGFwaEMzNld2YTlM?= =?utf-8?B?enNDbXI5SmEzUXY5RmJlWlBvdDBjU2ltT3FWQkMyWENiMU1PcWdsdWFPc0RN?= =?utf-8?B?TUs5allKd3Y4NW5XbFNPMFp1NzA0U0VRSWU2K3pTYjJCWmlYMDE5ZFE1Y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Yjh1amhO?= =?utf-8?B?Q01xMGF5UDNNZGhLQXU2ZFpibXdxbk5LZEVjYzhIYVBRY1BSYVc1M1ZraEtU?= =?utf-8?B?RWJnU3c1amJ2cDFXZWFoQXlkVm4yd3RWRVRaSW5VZmR0MmpoSExFbTZta1pn?= =?utf-8?B?NGdRQ3hhNXBXU2dkaTNhQUNCbktGVGg1WEpYc2RXK2xScVVQcmVlL1VVeW50?= =?utf-8?B?MW40SkNkL3MxWjdLQ0lqYzYrVDdjR0oyTnpUWWxaMERwYnBoanpOS0hYQmlm?= =?utf-8?B?RFBNZWIwbEE4TkVMbkw3bmFtb2RwNlhSanY2SkpXOUxKZEdUTlF4OG05YVNF?= =?utf-8?B?QnA1cW1WVEtpaVJWWU9OQncyd1FNT2ZUUFl1cGlNUFIyWkNES0hGMEFHWG9Y?= =?utf-8?B?OGlyejFtc2Zyb1llZWJTaVJOUGh3NGhobi9mZ25LTFljd2JLNUR6VWxYMEJj?= =?utf-8?Q?oX6GURcYmbdywMw9rFL3Ys9A+IXaBwN0?= 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)(82310400026)(36860700013)(1800799024)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Sep 2024 08:53:59.3519 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 992c11f5-e362-4547-aa73-08dcd3087151 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: DB3PEPF00008860.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR07MB8289 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