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 20EEF45962; Wed, 11 Sep 2024 19:14:03 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2D1EA42FA7; Wed, 11 Sep 2024 19:13:58 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2041.outbound.protection.outlook.com [40.107.21.41]) by mails.dpdk.org (Postfix) with ESMTP id 8842440261 for ; Wed, 11 Sep 2024 19:13:55 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=zAhPGexQfzs6tOhNUp1uFPE5rDDqhLmQL9ny111uTbTpuTjVwkxAVrkoTVRoSV4ob+LTiBqEkH9Ta8q2ne1pYUYjyclBylsLd8R7h2Tyx03uA7WQAAuxSxwVsFdBUKKtokRChGFqCDOM9k4my5xSf3Y+1B+F1gRqWAgIENsM+r0n+gwQwMoTQ2F4jfmLCqemqvVM6G+x2vWvRqFQCU4kT8WpRGUsOFSi3anSM9RBBP427WDcZpeRyFycjF1vMqozA2rDc0vE945NE2p+lNaHbvy7XafsuC4Qpy2lVOQZwTGSw1P1VrXJC8tZ0qINFsV9onfDYv7WEm6ACp9GLpq/hA== 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=h9/dGCc0kWGPS5Q+Z6JY77jkhp6k9+9Bwv4/EutPiDMMYRsUAueZo88CLPrdAQXUvOfdzkN/vhpTcKjo2whcmLcfaHXVinodWt5OzalkpeUwWYAG2Jdqa7nBZE3LmFElGFUQvGGX1MHkBxUtGY66HPoVeXSlEb7105F+mxiI2d5HTRQ0DEe8prEpt7bN6DyvmniHw0Z7Wlc1L9p9HgMM/kMl64LO6QXGTBJmjCYtM6y4CRXpJMQABNBC/chngVhRv4Z0q+RoKRYLGi+wznH9UIzZGaSW7yWxyVp9ANVv7UF2gNyS9j2HnNofrj5EvoE9tP0LUu7KHxFDCtYNnPH5Jw== 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=v9NSUArcGmr5R4r54Fq8H1CR5NEy6k8EX6wS6l9knOB0iUFVMTZcKgvfgvWoRx//W19NU77WgvjjVhijUw85TjHrsQHLEr3bOdFAUfQKois/vS0ChkXNIpGZTJQKoy4XzYemTs6TIUWzdDcLXEPH5na8yv4WnhVkBNDhG6s4vJfTpLH/1MltTl8XWe5+ZAMHzNvatA4uG/Wgnrvha2h32x9twz9HJ4DgPotKMaxKwclTWG/tKjMBaceRckBi2ihfJtYucCRRKu2MhgKICe0lvBViuWHWmytEoQXN3T6PWPYfbRcV/UvVu+QHoAD+k8wV5CmDyK4HqBMR6dZudrdjrw== Received: from AS4P251CA0002.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:5d2::8) by PAWPR07MB10023.eurprd07.prod.outlook.com (2603:10a6:102:38f::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.17; Wed, 11 Sep 2024 17:13:52 +0000 Received: from AM4PEPF00027A65.eurprd04.prod.outlook.com (2603:10a6:20b:5d2:cafe::4f) by AS4P251CA0002.outlook.office365.com (2603:10a6:20b:5d2::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.25 via Frontend Transport; Wed, 11 Sep 2024 17:13:51 +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 AM4PEPF00027A65.mail.protection.outlook.com (10.167.16.86) 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, 11 Sep 2024 17:13:51 +0000 Received: from seliicinfr00049.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, 11 Sep 2024 19:13:50 +0200 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00049.seli.gic.ericsson.se (Postfix) with ESMTP id C172938007A; Wed, 11 Sep 2024 19:13:50 +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 , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= Subject: [PATCH v2 6/6] eal: keep per-lcore power intrinsics state in lcore variable Date: Wed, 11 Sep 2024 19:04:30 +0200 Message-ID: <20240911170430.701685-7-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240911170430.701685-1-mattias.ronnblom@ericsson.com> References: <20240910070344.699183-2-mattias.ronnblom@ericsson.com> <20240911170430.701685-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: AM4PEPF00027A65:EE_|PAWPR07MB10023:EE_ X-MS-Office365-Filtering-Correlation-Id: 044afbd1-37d7-4f1d-41de-08dcd2851bc2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|82310400026|376014|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?B?N1RNSTNFQndjeVljcUhFRXA4UHdnaW9ZVHJsczJMVlRkSUh0d0dxanh6V3RZ?= =?utf-8?B?YmJCY214ME5hZlEzVFF4d3VmTldsY3lZSjRrUklheS8xeXhNL3Evc0hqaFpF?= =?utf-8?B?Q05saUpTQWU5eTRZRk1ibVFpWXA4eEdpbS9pK3I1ang3MTRoSko2MHgyS3Fr?= =?utf-8?B?WHdSUGJoQ092K0NmVlZYZUpKVllkQmx2MVBPUTl5ekFYNk1VUVFlWG5kWjg3?= =?utf-8?B?VjFyMlgwNUNxaXBNTlBiNmFUYU9JSDRYN2VtK0RxRHoyZWJua1lpMzA0ejVX?= =?utf-8?B?eWhzbldZOGhNU0dQOCtMVHFWWEl6TnpsNGI0SHl2Vmh3eFZKSVR3ditBQkxX?= =?utf-8?B?dU5ZMTJKbFZEZThxdHJrTjhVTDd4RTZuRDFYZmg4WDNTaVkxakN3NktOS2dP?= =?utf-8?B?OHNTUHYrRjZGbDNRZ1FkTlIzb1ZFclZLMnJQMzZlbHAzdVppMW5iU2ExSjhS?= =?utf-8?B?U2g4bUpVRzZ2ais0M2xWMnpXMFVlQVNVT2Fxd0w2QkVuMDlLcGZUaUd5Tkwy?= =?utf-8?B?OU12dEZyaTkzWFgvbHk2NXJoa1FicGI2T2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Lb21nUStPY3N6MWNGMnpENzd1aHljaWQz?= =?utf-8?B?UlNUb0xWNlU2S2NsRVBRQTlJdXFTZ0c2bkxvUURlUjQ2MUowaUF5S3hvYjN1?= =?utf-8?B?N1huZjRJdk0vL3Z2ZlgzdjVxRUFDWjFEMGcyNEdpZUE2aFB5QWkzRXBkWDFR?= =?utf-8?B?dkV3NXVncW80OEVyNHFVSU1VeUNDR2dVdENaOTZKN1VOS3oxTHNWdk43Wlhr?= =?utf-8?B?WDI3dWhpZHc2SjcxcTBSOCtuUzg5aVRPN1Fob1lEbkhmKytwT3p4K1gyaGNn?= =?utf-8?B?TVMxbkhKa0FSZWRSSGk4WDRJOUttRWpMYkROVGYyTzhwd3lVcC9Sc3YvNEZH?= =?utf-8?B?dS9pNzRZT0xTMVByaWxsTFlON0N6YldwZG5idXl0bHNscjFRU3dpTnVPNG5w?= =?utf-8?B?czlBUDBSYnhrcnlJbTloTUlCWmRIZm1oMkIvTkNrZXg5MUNnMENycmpRbTUv?= =?utf-8?Q?iTP1LH9my1VbXg+CG7gacXz2tckNVYrE?= 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)(1800799024)(82310400026)(376014)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Sep 2024 17:13:51.7498 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 044afbd1-37d7-4f1d-41de-08dcd2851bc2 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: AM4PEPF00027A65.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR07MB10023 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