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 9AA7A459C6; Wed, 18 Sep 2024 10:10:45 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CE78442EAE; Wed, 18 Sep 2024 10:10:41 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2082.outbound.protection.outlook.com [40.107.21.82]) by mails.dpdk.org (Postfix) with ESMTP id DE81B4029B for ; Wed, 18 Sep 2024 10:10:39 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xS4nISgKevsfnG9lNZ7BwthBKOn1Jqi24qFsT924Bsj7l1t0OpWtcUJBrwe0xKl1nINJ57fuJlaV5nwu3iZl+vhzZfkgHIhPtmhhwWvbrXR748oJG5A9J9Rj4LO6zGV5miUy5T8UzbLXDy3FAeVz6vt1hVPx+2PvKjA1j7rDO7J32Qi1tmkth0XSsVl/0Kk+V7KWbnmJybQhsbqkML4iytu/s+N8TI2Lh705CJ3TEJu5rslnPCK7OTwuviedOGOLwo4BKyrq3oivR95LlvrxD8ru7zzzOhbkd2j1UojbCJNnNU5SMSIC+1fMhcW661TlsjkQhrqTn7Z1B6DwHj+SuQ== 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=ycR2PVp29gE39bOYYOSzZwn5L2eMA9JIFcDUAnEV+jtU/CzrupIxgUjt88Uyc4h+gaoeH+f2Rd7raXLBzP4/MxVusnCHsFFGtXfUg5nXtium4DF9fn+H9RMHIXc6yeitaYUgN+dgz2phhggkZb7Pbvx0PNUt7IpWQENYpMbfuvxGQYOQsZ/Rfzo5wlkfEUvHYp6MMjR09yo9kxKT5rihnjO3OR4STgOWgiFnaA/NmpEae/gAlix6+t2YnftGVoZtdX1KsAGpjXMANpd7gSIk0uLosMAiqCUaFUfAfEeHfrP5BAgrSg6EJ88yEcXUJFg34l+Z9M+JJZHQJTAsEF999g== 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=mbYb0zCE3jWPOS8Dc9e9D7s/fgfsDWjMi5mVU5HtFjcrLvkWYSQMgxygkunMx6J8xINx+oz3Gg1pcbn7L5oMr40XPZ3XjUiItuQDNNQZ2AqXPKO/01EEUK2Y7v8xOrp2CbTLxVhDhhxY3HblRo34RCTWHooXTVEzTBF0ZyvSGrXZlr/xONDABdiCT8Yc+DsjypR3GB52iF3ciEZEBCJTTZ6Tlt/Oyol/b3nG6tLV8F1eTkE15dfu6/GzrjnTKmrLWT0Fc7jtZAzaoZhJKFmpmV2A35us+hk1755GwD3cAL1XVQPYBCrOO6XGoZBHLpHLe3tsIg5GPKh4PeqtPaXAvw== Received: from AS4P190CA0008.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:5de::14) by PR3PR07MB6570.eurprd07.prod.outlook.com (2603:10a6:102:65::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.16; Wed, 18 Sep 2024 08:10:37 +0000 Received: from AM4PEPF00027A6B.eurprd04.prod.outlook.com (2603:10a6:20b:5de:cafe::42) by AS4P190CA0008.outlook.office365.com (2603:10a6:20b:5de::14) 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:10:37 +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 AM4PEPF00027A6B.mail.protection.outlook.com (10.167.16.89) 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:10:37 +0000 Received: from seliicinfr00050.seli.gic.ericsson.se (153.88.142.248) by smtp-central.internal.ericsson.com (100.87.178.62) with Microsoft SMTP Server id 15.2.1544.11; Wed, 18 Sep 2024 10:10:36 +0200 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00050.seli.gic.ericsson.se (Postfix) with ESMTP id 62D3B1C006A; Wed, 18 Sep 2024 10:10:36 +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 v6 7/7] eal: keep per-lcore power intrinsics state in lcore variable Date: Wed, 18 Sep 2024 10:00:54 +0200 Message-ID: <20240918080054.725164-8-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240918080054.725164-1-mattias.ronnblom@ericsson.com> References: <20240917143239.724069-2-mattias.ronnblom@ericsson.com> <20240918080054.725164-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: AM4PEPF00027A6B:EE_|PR3PR07MB6570:EE_ X-MS-Office365-Filtering-Correlation-Id: 496dc117-f8e5-4e68-a0b7-08dcd7b960bd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?B?NkhVRnhKbi9Zcm84OC9KakZ2c1c0NjFTYW5hTithODVDcVk3ZWp6OGFaKzFY?= =?utf-8?B?dnNWOU1LVE5LSVNsUEhYUUdscytUQUgrUnV4R2hlOXI0cUNJRmtYTkhadXZF?= =?utf-8?B?bitmUVcwVFZXdHUrRmZVSmFkZ21tVnRTKzNnbDVCSGJTRzF5SHA0c2syWVhx?= =?utf-8?B?bk0rM0VOZTZjZldYczNLSnI0OXdEUTRmNFpRbUJTTTBJbDg1d0w5QnZ3bXI3?= =?utf-8?B?N0hKakNDOTUwTkNyQVIyZmtmcVZoa0c4RFptWkdhK1JMT0NwTGZQdlRXb2Yx?= =?utf-8?B?M0JYSUhwL1hBV3VLSWwyeE01cmFZcGxxam05a2hiUmNVK2Q0ZmVlQ3NySDlF?= =?utf-8?B?V0NoWjZTWitHZlMxb3V6YW9ydllyWGt0bFBCd1RUOHNRSUFVR0JWY0VYa2Vi?= =?utf-8?B?VmZkUjhhVUQxWWVQQVVKaUxBZmtic0lyQks5WHBqOUFTalQ3Uk8rTE1rNWhM?= =?utf-8?B?S3ErWXNURHdzMXBuUWVSMnZ6cEkvQndiOW5ZQzNLWXNtemZzVDFLdmpnc1Y5?= =?utf-8?B?M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=?utf-8?B?a08zcUZQU1NwMGJXeFRPWEpldUplMXpTdURhQktNNWZGUVRMZ1ViTC9pUDNS?= =?utf-8?B?Wk1TeFE5ZEtGcStBOFppanRlRmJNNTdYRHM2ZURCTEpOWHhJZWZ4blZQcy9Q?= =?utf-8?B?TnU3K1pXVmJyb0pvcnc5OVNWM0kyRFFIcTF3K0U2NlRzZGM3eHA3VndQa09z?= =?utf-8?B?MWduZWYyajNIUjZqdVdvK1c5STJzdWc1NnVGWmZHRXZSSThQZFRqSGJOZzZx?= =?utf-8?B?ZVlnRGpOVGM5eG85N1UvWG8xMTU0MzZUS2k1aEppYkNaSWZXMG0wK21nYWd0?= =?utf-8?B?MlFNQTlnQlhvM1k1KzFpTzRPUHlLcGxYNE0ycGVpd0F3NGJvZWVJNUpsSzJu?= =?utf-8?Q?fRlBxdymyMc9bbVBy0uJv4JfiDKI9c9dz/nL0=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)(1800799024)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2024 08:10:37.1260 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 496dc117-f8e5-4e68-a0b7-08dcd7b960bd 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: AM4PEPF00027A6B.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR07MB6570 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