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 4548C43FC4; Mon, 6 May 2024 10:39:15 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6B141406B7; Mon, 6 May 2024 10:38:37 +0200 (CEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2058.outbound.protection.outlook.com [40.107.22.58]) by mails.dpdk.org (Postfix) with ESMTP id 17344402EE for ; Mon, 6 May 2024 10:38:28 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NwUiKaldlBWp8CbBOZYmustWPDvmbr6zshvBxcQGy7we6MyO5q3utOPKXW4nS1Tc8AvQ1P1e+GwduKq1ogq9htxpMMqlcNTXqWr1IjHN8//uVWUmU8IJOiRH3SO7zZtuanv0/daHs+HE5oy123RUz++mDMTuRKNnmHHiqKAcCQ/qTbFqwxr9+d+DGSfPFbMhfXuSf5RFban5jRrxAi8SRjPzmkFWmsFRxjOW/gsU8h2LcYMpsaAb3UCcGhcENqz0YhdH/7Szv6UdiJMJhgMGOpr+u6LlVMu00xD6lkCQJLF/7YcTp8NynU/v4i4EMrrYHhgMmSZm+CmHh2VTNjpDxw== 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=5KgLIeJsoXsbjQgRv+axyk0s7Khi0OpcLSDJyLLTnRM=; b=BG3yx/rU7U+2Yhso2ozreNYU7OuJSI2HpQtXhql52RDbTdOIuwPqNAGvBEhiNSyYNslAB8Df2b++2J3Cb4I3Q4ZwlqQevcfg54JbttXwIE+Vn3F7UwiuF2PsWhj2WE2guHjjR1r60ReBRf2RmncSB2LeXBnTPb2ljIjosrpUE1cpalk8L3YvC5hp5YJSszQhvBii84qzLp8cokEZzUtcIy7Br2Gu1BwBTiaynbIy4/OXzaAJsOOY2GQE7ylXwsNyK5xBPUuw4vZ07lGNEJW8ZB1Q7/OpYCDzh3QvLzzA4i2NmVSy7h6FXAN43RspVn2abHDTQOU/g47Eojw7sZNcaA== 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=wnsuZz/4UsRchq06jSTs70lRNBieGqE7O7KeOwP4ttR0SlYhmzkn6sQsX6ZT3+AI+yvyO5ZevUaPTQ9euJkSd8r3Q92sibghqlJ0aT+urSpkuV9gw3ZuZ+yE47PY3xE+OD4kxTe+Zta/GAoiDL/LSV98z/BmYBTSkxsTqU0AQn7vXDW62ER6T0MOsLl2Rxf4RqNqTSjpK1f0nCo3Y4V57B8EqsWhyQvbZtj6n8faGZCF+6jBEwkb1U7p0SPvN5/e4pQfW5OdXW4H5oUtSFOnn30XPCJw997FnqcY4KH7H7zEfs1+rgdh6FR09qB9mT+FN6sXr/EonLz9Furkzu6mGg== Received: from AM0PR02CA0162.eurprd02.prod.outlook.com (2603:10a6:20b:28d::29) by VI1PR07MB6496.eurprd07.prod.outlook.com (2603:10a6:800:183::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41; Mon, 6 May 2024 08:38:26 +0000 Received: from AMS0EPF000001A8.eurprd05.prod.outlook.com (2603:10a6:20b:28d:cafe::d7) by AM0PR02CA0162.outlook.office365.com (2603:10a6:20b:28d::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41 via Frontend Transport; Mon, 6 May 2024 08:38:25 +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 AMS0EPF000001A8.mail.protection.outlook.com (10.167.16.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.18 via Frontend Transport; Mon, 6 May 2024 08:38:25 +0000 Received: from seliicinfr00050.seli.gic.ericsson.se (153.88.142.248) by smtp-central.internal.ericsson.com (100.87.178.64) with Microsoft SMTP Server id 15.2.1544.9; Mon, 6 May 2024 10:38:24 +0200 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00050.seli.gic.ericsson.se (Postfix) with ESMTP id 46CE51C006A; Mon, 6 May 2024 10:38:24 +0200 (CEST) From: =?UTF-8?q?Mattias=20R=C3=B6nnblom?= To: CC: , =?UTF-8?q?Morten=20Br=C3=B8rup?= , Stephen Hemminger , Konstantin Ananyev , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= Subject: [RFC v6 6/6] eal: keep per-lcore power intrinsics state in lcore variable Date: Mon, 6 May 2024 10:27:21 +0200 Message-ID: <20240506082721.120666-7-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240506082721.120666-1-mattias.ronnblom@ericsson.com> References: <20240228100928.524277-2-mattias.ronnblom@ericsson.com> <20240506082721.120666-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: AMS0EPF000001A8:EE_|VI1PR07MB6496:EE_ X-MS-Office365-Filtering-Correlation-Id: 8dd2bb80-bd0f-4d52-c949-08dc6da7e57d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|82310400017|376005|36860700004|1800799015; X-Microsoft-Antispam-Message-Info: =?utf-8?B?TWJZQ05sUGZJN3dXa2xxU2xuTHdXbE5TcnJldHQ4eDZWYjdacDlDQVlaZXlX?= =?utf-8?B?Q1NQQW5sMno1WHNHTDh5VDhseFdDaDREbGl2V0hiQUgxYTRiTDFTdXowZEF3?= =?utf-8?B?ZUc0cVNyS3VVaUxBTThtcEtFTGRxOWZ2MCtnNWhGWEJZK3FaNm53cmF5SVZa?= =?utf-8?B?bHJ6anhCQkZtUHZOVTBzRjhud0VaejFVUjd4a0g0eHRoYTZCM3YraVptWkF0?= =?utf-8?B?VkozbUwyR2VpSnNsRm1YNmxPT1NwMUFMUWdkdldzMzdvTlhGODZCdXNwcUdj?= =?utf-8?B?U0g2UVpUa1hpRUtZNzBNTERuRzh3ZFZCeDFIMGdzZGlxaFZZbkZyUDBtaDVq?= =?utf-8?B?c2RxV0ZBZkRVR0NXbzlLcFpiY2tkd1RFVDlxSjBiK1BaYkZPQWFOaEF3RHhY?= =?utf-8?B?TjMyVzJvNEJ0angxMitGZlRmeGNsVjBzUjVUMUtvSmxkYmloOVlHdmx2em5Z?= =?utf-8?B?TitVenpQdFJReUtxMEtXMENKZkpwbVppN0dVbklQT2lYRERMUkZxZXAvS0g1?= =?utf-8?B?eGNwR0hjcFNFaXZNU0JFckRCa0UwNHlNNDgrUi9HYkN3K1hDWUorOGdwSTVo?= =?utf-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XloaDZU?= =?utf-8?B?VkhVNkc4NmdIbUN0OG1ucjkyNlhpWStaUWFTZ3JxcEsrTmpSYkNueVpmQnZk?= =?utf-8?B?VFg4SDNsU3JnZXlWT0V6SUxDQ09LOFRDajNLenNrYjVjeTk2b2owRnBLNEFO?= =?utf-8?B?UXQ3c1h6K1V4dHZEeFhUL245SmtoUkw2YTFHTTBCZndBUWIvNzYrZVhuVU5X?= =?utf-8?B?aCt1Wmt6MWpsK1FwekpUbzBWbVJmaURpSThwWnZtRm11LzBUdkV6Sm4rUWRr?= =?utf-8?B?b3lpbEFhcHkzcFFvVlRXVm5PcVN1bHdsWmhKSkw2cGNxczljZmJ6cTRIQjNM?= =?utf-8?Q?l+EklVq+N9oueaXlFeNOZ6D2EALiGWeuqyXq0=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:(13230031)(82310400017)(376005)(36860700004)(1800799015); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2024 08:38:25.6334 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8dd2bb80-bd0f-4d52-c949-08dc6da7e57d 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: AMS0EPF000001A8.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR07MB6496 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