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 B60A445B50; Wed, 16 Oct 2024 15:28:56 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A5D464065F; Wed, 16 Oct 2024 15:28:34 +0200 (CEST) Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2082.outbound.protection.outlook.com [40.107.249.82]) by mails.dpdk.org (Postfix) with ESMTP id 322514042E for ; Wed, 16 Oct 2024 15:28:27 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=k2uKpZUJ+9MMGNXAuFJdodnuDBOwcDBik1K6NNnpfa4q94r8Ecz13Q1INwyECKgyYootoeQGJsyeOZmR4jQJ1eAxcVnw5ZQNW/WG+9xeKNQHpS4J7820uab44v5RUzA+un+XBV4QC7qafm+6JhAiY6/Zhu3JzL/MSuV3ZpbeWC3PZpIIRuV51Faqea+OKcSTKZ5gzOR6aAbeSPd3vpB94gs5T3CrqENDCEP+snatzCuEwT++H63TC06NhGuDiFGC1v5o0ENDrlOHU9dWnZFmbGsCQDahJct7QV1FWd4J7K5903iibo7jATRyBZLcd1vfHB9TJR4pE9zedS/PIElWNw== 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=cX4ufj1pN9MGR3XnbJ9151fWBNDYFHNFptwEX85LFw4=; b=Iyo6irUDBKjj/4zTCygS4HEyA/Pt2/Dq4TXsiWMKNWoghmYKLQ7tlO/SEVRHzLeBZsjcY9OB4xwPOx6PfqlzOIlM5yTmYlsZ9uW8au71vhU00bFhbE0F4OmfiyDrF3GJZYuvAKuEyAUchD7CcXILxVS+1KGfzGkbKmMOyBmSdaksNeDeiJULcURDzMj/NhJZXUvw8deHdK+K0CfK2qVVHXHmZydWlJqvIRdnFYFtw+g9+DvUnIVfnGnNZ+6D5wi8AnIqfJAYiG2JhJVyOr9UTbTqf4krHcFgXTTYDmguhwNV7z2MK7FcU5EjXPCZAgUesXZbDNeXWc6cdplPWIYI5A== 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=cX4ufj1pN9MGR3XnbJ9151fWBNDYFHNFptwEX85LFw4=; b=nrY+AQNscUBDghl8wGu0LvxcvCC7RQrOJrmthC7oVjOjSiPPgVrWWe1OPSJoW2MpJOjIC9i56VPjmKhh5JPRr2TTnsZUXO3PlcZG020vdngWE3fzaTy1epYBLuaq5WSnuftzmIvBX+UYlaEyNI/c3rMDoQ9QHKA4bvrZ2Z94wk4275HZfH2aMupTZwZYqqkoJaLgaUZVorODEqUdQYPsw7iMGPXsIGtuev64OTB7TyPPmjkHjTsHQOwHgUYr9yPvOWiuBbCEVnQFxfG81UUxfMZyl9lBtQzoL+cUIkt1H4M5gFcDamQcMMwiuCVdP53BSiQRsjivNULCN711VY8K3A== Received: from DU6P191CA0003.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:540::29) by DB8PR07MB6345.eurprd07.prod.outlook.com (2603:10a6:10:137::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17; Wed, 16 Oct 2024 13:28:24 +0000 Received: from DB1PEPF000509F4.eurprd02.prod.outlook.com (2603:10a6:10:540:cafe::63) by DU6P191CA0003.outlook.office365.com (2603:10a6:10:540::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18 via Frontend Transport; Wed, 16 Oct 2024 13:28:24 +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.8069.17 via Frontend Transport; Wed, 16 Oct 2024 13:28:24 +0000 Received: from seliicinfr00050.seli.gic.ericsson.se (153.88.142.248) by smtp-central.internal.ericsson.com (100.87.178.63) with Microsoft SMTP Server id 15.2.1544.11; Wed, 16 Oct 2024 15:28:21 +0200 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00050.seli.gic.ericsson.se (Postfix) with ESMTP id 1EEAD1C006B; Wed, 16 Oct 2024 15:28:21 +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 , Luka Jankovic , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= , Konstantin Ananyev , Chengwen Feng Subject: [PATCH v14 7/7] eal: keep per-lcore power intrinsics state in lcore variable Date: Wed, 16 Oct 2024 15:19:16 +0200 Message-ID: <20241016131916.827788-8-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241016131916.827788-1-mattias.ronnblom@ericsson.com> References: <20241015093344.824073-2-mattias.ronnblom@ericsson.com> <20241016131916.827788-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: DB1PEPF000509F4:EE_|DB8PR07MB6345:EE_ X-MS-Office365-Filtering-Correlation-Id: 929ad946-6c1f-4706-0def-08dcede66960 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|82310400026|1800799024|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?NUhhd2wrVDhDb1RPa0xueGJDSGplcVc3RzkyNy9rL1JHUDZURkxqc2tmdzNR?= =?utf-8?B?SG1ObDRkK2pSbVFFejVlUDBpcmo5RU5pU0ZETjUzUGc0eWxMMzlUL3RQMkM4?= =?utf-8?B?U0oxMzBVcEQ2bUY1ZWp5MzNSS1l2NUJYSlk2elVuT3l2TnM4ZkNRRWRGZUN6?= =?utf-8?B?OFdUNndlMTRoVzk0S2cwK0xsUGVvb0syMnFJUzBVaWJOUE51c0pPdUxOQ1JU?= =?utf-8?B?M21IREpHYUpHMjl1SW5LWTlUdkg0R0FTbzFpRXlmZ2NGN3BSSlFxQ3gwL3p2?= =?utf-8?B?VFNzVCtRTlM4T3BDR0kzN000SWQ3QVE3cmxVMlFmckg2ckk1dkVYR3VxMkNJ?= =?utf-8?B?NU1RakxheSttVlhFQVFRN3Ryb0Ftc0ZRT3M0akU4UEs4RmZqZXFkemZkdlBX?= =?utf-8?B?MkJUM3lrQ2p0QmNxcDlDQ3IvVEJ4c2ErM3RPRG1LWm9ka0ltMzI1dlZ3YTRs?= =?utf-8?B?Y3NLdzJOZ3cyeEJmZ242ckc2R29BRXh1UjluRG1QWXBSOFo4QzlQRlZldVhC?= =?utf-8?B?RkRqUGUyL2oramUvM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8?B?clo0bE1KUUNPK09qaFFVTWJJR0F2L3BLVXVqKzQ1SDd2eHBVaW5IWU5GYzNi?= =?utf-8?B?d1IwbW8wUE43SnJrSGRBMUUzdzZ2b0R4MEtEY0Z5V09yRTh6ZENQUCtZN2p0?= =?utf-8?B?ZXJiYWkwOGJXZnE0MjhRZW1MZGZveG54ek11SmZlZVlOT2YwbURhSkVSOVcr?= =?utf-8?B?VnM1RXBqQUFDQnhxTDY4WGswMUJIbFZLbktoODd0KzFzVlNyNkVpVjd0OVNn?= =?utf-8?B?Z1ppTXpiSmkyaGJaVWJVSk0xdVFuQ1dmMlZ4SVVnU0l2TFZPeFdIQ0dhMHdt?= =?utf-8?B?WTZvRnBQaFFVeFlWUHV1ek5aQ3lmN2ZIUGJBaldETUN3aGdqam82Ui9vZmQx?= =?utf-8?Q?j6pYlbQSaOrj8gk6M5AGbCTFY/QQTQnBb2d7M=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)(36860700013)(82310400026)(1800799024)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 13:28:24.5150 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 929ad946-6c1f-4706-0def-08dcede66960 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: DB8PR07MB6345 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..98a2cbc611 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(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(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(wait_status); + uint32_t i, rc; /* check if supported */ -- 2.43.0