From patchwork Tue Sep 10 07:03:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Mattias_R=C3=B6nnblom?= X-Patchwork-Id: 143840 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A23E045952; Tue, 10 Sep 2024 09:13:10 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3D3CA4021F; Tue, 10 Sep 2024 09:13:10 +0200 (CEST) Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2076.outbound.protection.outlook.com [40.107.249.76]) by mails.dpdk.org (Postfix) with ESMTP id C4FFB40151 for ; Tue, 10 Sep 2024 09:13:08 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=M/pRKUtS8GjsZYJ5o21H9DNhbC4OGZX1AePzf4SUYgduqLHWceAjq4Dg59I68D6WjtDooEmPU6EVsmfq1TvPLhnqsx5owS7S4sOHgXscRkz0R1MH4U05E9fNGfKmfHrecFriV8KjIX1lLA9NhUqdALF1bsy+8JZRmCjT9wZSdZGyKaELEVtGunE1ZWtrBqN05+Pd2imlRPI7BJSjudXe03ZuBVuRNWFlEcKYDl2yzRAl/SNMorH/cxRWLD4RTNL4dxc5ECz5ACpLvAozk2ItSS/bc25A/dP2pZdutekksqaq6nkAhGk1S4QtCbH0xE2tc28gmfIAK5Eti8RZ8wMHOQ== 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=hz2HBLmmAYkgskk82I8PbIVTGeNl8GChJgKaVGaHWYCrreFtAqxmWh2EeIi/SHrJnfINCUY2NxGuY6eiQKcn8FUtkDPKxPkLD3m1pbU6nK6PPSHZa5ogAD0KrUuubpZBn9Iof+iJHKfaCljHR/IWkRo01mj5pi4tlQEU45RXeUAObpbiRzZKx1+NGRnx1rtPB8jBXC4rjZjlJdBJTKIsNHZHyOQBDabvxiKpW603Se5jpl8PPujHKFm5CH4R5Tm0t6fuLY4qvwUaWu/Y5n1Pk2CX36RXIPL4yVc4SUeL6ePXSSK3t5VikDp6m16ryGjuxCag95Xb3/D5es++6tn6SQ== 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=Xp4M+bZKFrYmYN+WbVTX73Ie/bwGuVvn6PP4E2CvWiWnYCNOjyFD4aud7KOQn+w5r48Y6AK5px/77GMcK8Wl4CpcwbMayVTcKaz8g5tt7YjkxniIZOkLhaStXGIZ1UxYaTnm3VOloziXaUSWqKpjGPD+j8HGKT88lZpMa+0G42fJIUSoiTqUmx7nbxILZOUPf0YJpQecPAC7ECM9YlWMIwBFN4RNoG5qbtegIt/hdahnKsW3dxsKu+xewoh8+s9BWkM4K3u11TNEvGw9NZjd6CajCNwTb0xgLk1vTlz6suz254Xpc3NBfX39dLqt8c7PF0xyMBFI7NEvLOsz+qECFw== Received: from DU7PR01CA0004.eurprd01.prod.exchangelabs.com (2603:10a6:10:50f::18) by DB9PR07MB7771.eurprd07.prod.outlook.com (2603:10a6:10:2a6::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.24; Tue, 10 Sep 2024 07:13:06 +0000 Received: from DU6PEPF00009524.eurprd02.prod.outlook.com (2603:10a6:10:50f:cafe::c2) by DU7PR01CA0004.outlook.office365.com (2603:10a6:10:50f::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.24 via Frontend Transport; Tue, 10 Sep 2024 07:13:06 +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 DU6PEPF00009524.mail.protection.outlook.com (10.167.8.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Tue, 10 Sep 2024 07:13:06 +0000 Received: from seliicinfr00049.seli.gic.ericsson.se (153.88.142.248) by smtp-central.internal.ericsson.com (100.87.178.69) with Microsoft SMTP Server id 15.2.1544.11; Tue, 10 Sep 2024 09:13:05 +0200 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00049.seli.gic.ericsson.se (Postfix) with ESMTP id BB57E38007F; Tue, 10 Sep 2024 09:13:05 +0200 (CEST) From: =?utf-8?q?Mattias_R=C3=B6nnblom?= To: CC: , =?utf-8?q?Morten_Br=C3=B8rup?= , Stephen Hemminger , Konstantin Ananyev , David Marchand , =?utf-8?q?Mattias_R=C3=B6nnblom?= Subject: [PATCH 6/6] eal: keep per-lcore power intrinsics state in lcore variable Date: Tue, 10 Sep 2024 09:03:44 +0200 Message-ID: <20240910070344.699183-7-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240910070344.699183-1-mattias.ronnblom@ericsson.com> References: <20240506082721.120666-2-mattias.ronnblom@ericsson.com> <20240910070344.699183-1-mattias.ronnblom@ericsson.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU6PEPF00009524:EE_|DB9PR07MB7771:EE_ X-MS-Office365-Filtering-Correlation-Id: c422bb20-7c5f-48e0-ab89-08dcd16804f0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?Hb1wye8XgDfIKguHeUhlo7rStiac/la?= =?utf-8?q?WrRonVNcDFoG8BCdGrQiI88vop5CY6HwZYo0D+aEFjkZBjFriG3a3r+D9hL65k2TG?= =?utf-8?q?s/C6kNOYieTCKdNsV2MES+76IXbNICI44TJHAm3DgITqfWgvJoGId76hTv7hcBApN?= =?utf-8?q?dB+I9hQNoZSWxRDYXODJDnOD217JE3ty/WHE0D/1dO5aH/nTMUYJFCR/BSixU/BgJ?= =?utf-8?q?dN8fBC+OZEm0pPhNg2HQ7Y+2Yu9Z7rOLeJlQNh1zPF5cMMBsp21E6P4KBiPT1ZHON?= =?utf-8?q?D9HqFLKxN+872C1EuF9sQ+nR3A6WJqmlTdCc9WCsx4V7aZQVr0UA3eISDLHTXh+z9?= =?utf-8?q?ZeeOIGzJgjk2hlmjdtY4i/gUANVSZAJ7hpCP3lQD/c7npVqgZfyvReDbF1oZMoxgI?= =?utf-8?q?/6EkpjfISrBn5zKu42J90CLPhC5kGLcgNw/iL6lDH82qqDrceGu0mUNn2vTPOS5SP?= =?utf-8?q?QS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Qjv1A7pRu7vtfAZ0bXGQfyvuWUa2CPBv1/R21WPT1eqv7a83gXDBLiAa42i?= =?utf-8?q?ol/vXthPrSe?= 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)(36860700013)(376014)(1800799024)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2024 07:13:06.8671 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c422bb20-7c5f-48e0-ab89-08dcd16804f0 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: DU6PEPF00009524.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR07MB7771 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 */