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 81CEA45BAE; Wed, 23 Oct 2024 10:02:49 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6087041132; Wed, 23 Oct 2024 10:02:21 +0200 (CEST) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2046.outbound.protection.outlook.com [40.107.104.46]) by mails.dpdk.org (Postfix) with ESMTP id 798B340E48 for ; Wed, 23 Oct 2024 10:02:10 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yM2xGRi1NB+r5Kp+fhH4gHA/06d8kdclDhfOm480fWT0VAqVbFGPW4YxPqm0lOIJU5s4GEWoJ5XyCJz01VSGbg0fck5IS9C+YPsWFecIDU9JTSwc3lBP6bTtcl4eNCvJGBYDHCCks3rK+mjmhqw6b6E/uvrXKNnVrJt77omNuOO9+8AGmEeg2Wplc5/lDrU1FwEk4cTY5WX+0M+OSWeiHniS6f7Cp8aMnn9TgC8QnoetTZLLkqj3gJRym1WqWliiuYNArCr73pmgy1PWIYOurXgkWIwRVlR/DCfQ7Qy/VCLJ/vx9TzqxhUYClbkPeoIijslUpUUVi+mOgyoIkDxF5Q== 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=IXJ2DX7oy9XrGpJ2627Rt9460B97I4RVAD1efTc8tTG0a7E9IwPNpGgN2MMqQJUAaYCq922Ih5vwndkVclMS5L6voyGnPXKRoOAlhApkxkNyz7Hool855i17OAQ9mIPyGFcqXDdyhrRMctk0hh+tFXNJNx14XaVFXN4Z4i78xVZT8Ee3L9TgfypYNJLnNSQ+Vyf3i356VMeHxrC55EL1tafJO4nycbF5ElMf3mnyBCuvl/EmcNYqw5JGdxjKl8nvxgRIpn+WE58sUpgTsCbobaHN3zlmxO1mdeO0Um+Dl2CvNUzjBHKAGvuqZqd1zjSZKP5dPi9fJfts916FtUHxFg== 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=Wv0BaQL86KQXfCZ61LB6z3msAahsstvGLalb7MOFrg5jKQaHr3dK8YmCoV6sgc9+pfzRhGEg8K7GZANyDqFphWb3hNVAAOu3uJOYWRRbH144lzaohy6jusy1DeondcMavcFFDCq0cdW7EiSinxlgAJ8Mgd++Z3dAVf9GsM028Fhf+sg6Ci9sAVHoZEF3Pjb03BV2YACvqNJlbOz/1HDnjeTPqK9yDgIx2FWdXvBkawyOTARfsAB64qLeA1oPw8f45klu/+4piL5Kc8/aj5m3+lb8e5jZHghWvA8WH/r3k6a7o1TE9LAlTbJiKiwSkoFlzqHnuUCdOQzliVdJPQJIVw== Received: from AM0PR02CA0121.eurprd02.prod.outlook.com (2603:10a6:20b:28c::18) by AS1PR07MB8616.eurprd07.prod.outlook.com (2603:10a6:20b:474::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28; Wed, 23 Oct 2024 08:02:06 +0000 Received: from AMS0EPF00000194.eurprd05.prod.outlook.com (2603:10a6:20b:28c:cafe::52) by AM0PR02CA0121.outlook.office365.com (2603:10a6:20b:28c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28 via Frontend Transport; Wed, 23 Oct 2024 08:02:05 +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 AMS0EPF00000194.mail.protection.outlook.com (10.167.16.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.14 via Frontend Transport; Wed, 23 Oct 2024 08:02:05 +0000 Received: from seliicinfr00049.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, 23 Oct 2024 10:02:03 +0200 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00049.seli.gic.ericsson.se (Postfix) with ESMTP id 783EA3800BB; Wed, 23 Oct 2024 10:02:03 +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 , Thomas Monjalon , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= , Konstantin Ananyev , Chengwen Feng Subject: [PATCH v16 8/8] eal: keep per-lcore power intrinsics state in lcore variable Date: Wed, 23 Oct 2024 09:53:02 +0200 Message-ID: <20241023075302.869008-9-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241023075302.869008-1-mattias.ronnblom@ericsson.com> References: <20241017055743.848292-1-mattias.ronnblom@ericsson.com> <20241023075302.869008-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: AMS0EPF00000194:EE_|AS1PR07MB8616:EE_ X-MS-Office365-Filtering-Correlation-Id: c12767fc-2627-4f4c-8db6-08dcf338fbfc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|376014|1800799024|7416014|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?B?WXdvQjgzRDRUanZWU0p2TUFPa3NQYldObVExdGxIcE82WDh4Q3Q2V3pSbUNj?= =?utf-8?B?Mklra2JCZXMwc0hXSnhRbnNUVnlONDRUU1RXSURKNXpNTVB6WFpHeEp5bG1j?= =?utf-8?B?U1JNaXBJRnFLNWNrVC9KaW52bm9XRjhHNzZzUTRBWHl0WVNqSi81dDkrN2xs?= =?utf-8?B?ckYxVlFpY0UwSkxpZ3hJZVpVd29kQUkrK2xQYWZXMjhydWJ0RGxob2paYkZ0?= =?utf-8?B?aEhVQnFyblNXZnV4UUxjYytsaWY4eFp6dG9FZDA0U1hFUWRTZ0cvVlk3Z2Fo?= =?utf-8?B?RTB0TG9FRTlzOFkxcCtRTWI5YVVLUW1lSkxmdUU0cDVpbDdyczR4aVVMdU1V?= =?utf-8?B?bkJIQWFIZ29ERGJVQWhsYWFaWVIyWGhodlphcndkbUlXWHBVOWZNWFl4UmRa?= =?utf-8?B?aVFnKzZ3MjIwR2xFSVh2aWRxeXg2SCtEcE9sbVZRT1RhRHdydkJtWlFGMGtx?= =?utf-8?B?d2VhcCtRdWVuOGZPSnhUMW9yQWRISFlnZDIvSzFHUmNpTUN5dFM0KzdUNmhu?= =?utf-8?B?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9FUlBC?= =?utf-8?B?eEk1RzFiL0RibWlhelVDdXBLTEkvZXdEUDg4d3V1eEUxeDdpaFdGWWQrSmRt?= =?utf-8?B?UXc2eEdOL3NNMXE4K2toZ0xaaFJ6L3NFYm93dUVMdWFXZE8vY3FXNkVUeGpk?= =?utf-8?B?ajdMN2NSbjI1akNJN2paUFRnNWczSS8vdDZKdzNOaTlEYmwxbWRMRTBWSFNY?= =?utf-8?B?a0NleCsrajRmWXdEbk9CVkhXb1UzM3FzYlNVckRyRzFMaS96blZSaUVqRUFy?= =?utf-8?B?Zm9QbFUxUmNVRlpRcmIvM0djakh0OW5RbGVRZlpxb1NPVVMwT3pSSUl6NEJq?= =?utf-8?B?Y1l5VHZhejZDaXNyM2JMemZNaTJtSUJ4MkJvUGhaRWpldlpDZ1YxZlkwdk4x?= =?utf-8?B?WVpjdWdMVmlpSHl2NzZCeVpnS0djYzhUN0Y3NnI2NHh4Njc0TENHR01PbkVU?= =?utf-8?B?T2dvVmpOTTBhTDhRN3FkSUJOTDRRL3JjWGdKN29Jdzc5OHc9PQ==?= 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)(7416014)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2024 08:02:05.0649 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c12767fc-2627-4f4c-8db6-08dcf338fbfc 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: AMS0EPF00000194.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR07MB8616 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