From patchwork Fri Oct 11 08:19:01 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: 145738 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 B04A445B12; Fri, 11 Oct 2024 10:28:29 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 29B1A40395; Fri, 11 Oct 2024 10:28:25 +0200 (CEST) Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03on2042.outbound.protection.outlook.com [40.107.103.42]) by mails.dpdk.org (Postfix) with ESMTP id BBD8F402E2 for ; Fri, 11 Oct 2024 10:28:20 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=i2GaPyzV5xm6saaFNuiDcrcMC5BfD3tW0y4hzzzmH7U0smkbKETRnU0Wiw0MNtaGebTtdExLWSUh1EmNJ476R5NiGl6NYrFURUULYSR81AhPwhsDy7K0YBC72/oca+AESQbBEMc38k8E81KAKWDPd0ZrrWJNzLhyt8Vw8hr1kvOLMpkKM1gcIZJ+ULwsaGv8jSisWK6d/9xOUBBYo98m0cLpf+dgCRZ5lsj5x1f1jeCU2uGVZ8r+GmcqBqvRizqXeOXDkqF6b5E+Bd53KJ39S0JexqZJM9ltfV93sIAv41CVPFqUQ6sZ0g4g7MX4L5qOZtJCt5YEiXBI68YeWN15mw== 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=PTgJESNpXPAbYyilhrJD+JxRLMhMHZz2uCopWS6Fc6Y=; b=F1/3SuDwW2rl0HFjonfpL39DIJIcfR+IKkmZUpj8121yFw0pdj+lQO+p65Wad3demAgdKytOoL6eYsuCYV38fy5+DhHAMVSJYeISK6cCCOBiWa2mBMFG7vJ4b7RoiyVDftjJ1dWL0OxKfapEQ7QYxCnxeCGySwqksfEvnY2O0XPqe/J9j1DtSqjLPkKfKWt6vsmaDZvGqHhvS1O49eDAUX4Q0Z7oSqRZ+BOPfrREg6a+8mgymy0kFcpzplj03pzzP/aZZXqHp5bcrUkwaq/X91AVRS+TznD/oq/0Os3wXWHObW20C4v89WxYy8sV9rtqhkxs+ZV4E/c7oBQzKtjL6Q== 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=PTgJESNpXPAbYyilhrJD+JxRLMhMHZz2uCopWS6Fc6Y=; b=NQziRtGOfWdACkI7xUtUD/tbEppXHNNzwLTe/U3ZGWOIFzpaN9Kzn7psFS1pDZiNvjH7sKaTrSgeXfZKDTOjgl29JELzFmNzsDjpaLJLs4XAo+CVRZBi5zYWLzBKZVZ45OVp6FIua6gcSrg7p/XhhZ8400ugmHSMtX503tzsAm+1Q2md++643oaATBdiYSiTtErK4ikBEl4EH64+eYzbgHHymTkjrtfw6uTa4+NPmcFyykTb+BVFXQsbN6jBjOHua4voLxgpqq+CBSy6Ns5gkj6dPfIVTT2y380JUYGSi9xCdLLAU2z/AkKmeKrWTPkLrussKTywp9z6hY9+DEM7+A== Received: from DUZPR01CA0275.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b9::6) by DUZPR07MB9980.eurprd07.prod.outlook.com (2603:10a6:10:4af::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.18; Fri, 11 Oct 2024 08:28:17 +0000 Received: from DB1PEPF000509F4.eurprd02.prod.outlook.com (2603:10a6:10:4b9:cafe::2a) by DUZPR01CA0275.outlook.office365.com (2603:10a6:10:4b9::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.20 via Frontend Transport; Fri, 11 Oct 2024 08:28:17 +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 DB1PEPF000509F4.mail.protection.outlook.com (10.167.242.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.13 via Frontend Transport; Fri, 11 Oct 2024 08:28:17 +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; Fri, 11 Oct 2024 10:28:16 +0200 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00049.seli.gic.ericsson.se (Postfix) with ESMTP id 35ADA380070; Fri, 11 Oct 2024 10:28:16 +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 , Jerin Jacob , Luka Jankovic , =?utf-8?q?Mattias_R=C3=B6nnblom?= , Konstantin Ananyev , Chengwen Feng Subject: [PATCH v10 7/7] eal: keep per-lcore power intrinsics state in lcore variable Date: Fri, 11 Oct 2024 10:19:01 +0200 Message-ID: <20241011081901.816211-8-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241011081901.816211-1-mattias.ronnblom@ericsson.com> References: <20241010142205.813134-2-mattias.ronnblom@ericsson.com> <20241011081901.816211-1-mattias.ronnblom@ericsson.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB1PEPF000509F4:EE_|DUZPR07MB9980:EE_ X-MS-Office365-Filtering-Correlation-Id: f8c7f828-0e49-44fd-a163-08dce9cea840 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|36860700013|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?KQzKxCY2gYUk9ZO0xWWS001btPvgJ9l?= =?utf-8?q?sfohpxHVrPdsaRXgn7uEI8H1jx7GC5bJ4ezBZpMDx+tZ6KoOunb9Ipf2LvlgCFxnP?= =?utf-8?q?dPqtAazIdcQQGQgsVzZRMu//TlFsbgOCuKqYfBV2b/ZrUh9jX4924T8fDSYS2tOsU?= =?utf-8?q?rPJn5XWMxuXlV55a4PIhPHs6xu4lBuuxZvvSdhJQmrWtnWLYvLDqaDqGSiLaOnerw?= =?utf-8?q?kX0+xodeVwr9hFmXgoZOw2PX3+9klvNKr0RAM6Jik52ObPK0O94fHX0EydLgu34BU?= =?utf-8?q?mo/gjaGtRKUTiDEnngWJ6bL3B9IFN2Tnz7LlYAwvvKwbo4ec5isGgbn6n/1nz6UP2?= =?utf-8?q?SRMlX0YVzbnz515jYh8YUYYawBj/+R876LQidBbRDusxwNXH7DiiRMEevA23uJMBp?= =?utf-8?q?ZbaWqY+uUq3qOpZ3WM349Yth3bz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z9YC0ayiOhMVIimlacDmpO6LXilPNJ9s=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)(82310400026)(36860700013)(376014)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Oct 2024 08:28:17.4329 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f8c7f828-0e49-44fd-a163-08dce9cea840 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: DB1PEPF000509F4.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DUZPR07MB9980 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 Acked-by: Chengwen Feng Acked-by: Stephen Hemminger --- 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 */