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 6B87043C1F; Wed, 28 Feb 2024 11:17:59 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 84BA942D7B; Wed, 28 Feb 2024 11:17:39 +0100 (CET) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2085.outbound.protection.outlook.com [40.107.8.85]) by mails.dpdk.org (Postfix) with ESMTP id 59B6340DDB for ; Wed, 28 Feb 2024 11:17:25 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i/Zw9oycLmYtpe/VHYtep8+wB03v+U1OEwBqTsNs8/Sqneln8JeaZBvS7Ejo9VxhsGFgdiD3h5MUZaJNEesL3n43APcr4HVPE1x0fagloga4oV+85xWjjBjxrvkWiRQLgH9Ho+Nucajrmd8rBA+Q0ZkNtMW7ao3880Ej6M7pFmCiDz278wyr/+epZOsALpyuLsXDJJFF9nhXzP5qTYj/CGUjyy0oanGufApcMYYh5wQF0YnQ8GdcKTEq7SHmEp9u2B2V+rJZ2T2TZYPZbunoka/jgSDfJldG6+XTqNR0ehi5nvIpz1kRNgXE1RcP1+UXJJ3VhTZ1arjoKmcjPPJGKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=S/nn+/osSbRePXDyt2OXgfcTtQ3j8AB1+LstbQNCjHY=; b=aIVLcgEIdfgsznnyrdZeMATPw4y22jlLrvAjK+5V2khjKJI/f+my77Iiu7c/NsBwn2rJP6QJWxA+6Y5aQNfzghAeMyodTfADqbaPlAKz9wmkr5y2raGFvjd96A569LVQARhx9WgpxOIU2I6vZWzfKptD635J8rcnsKwgGBPh0fdci5oj9aYD8fwRlna56/cUoaYuqHXN6RziSpZBBqiqUBBIcG7NDL5x2PYNZNZmauOuay4eIj56LFltFx/riLx0mexAGuLmnYMvTNy6f20ypeXoAHy3LTi/Q+GYmfX/BnqpaIOhLwaV5yR8MTYHhVcF0DN3wcf5mOuMtw/jpS97rQ== 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=S/nn+/osSbRePXDyt2OXgfcTtQ3j8AB1+LstbQNCjHY=; b=QSnj+u13FULOpRtKZ11GPGrc4bqVw+Rl9A1g9rz5yavxBS2DAAZZhudRDamMP8U6UXpklBYLd66kxYLCcWI9hXhZhY4Xqpdhi2u5W6ocJJ2p2kXYK/uerYlGu6oQS/yJAqJk0IGKopW7n/zC9TMi8B8d7shIf3c4/HA0yLlqgeBB9XAciyL78sNEXi4znsPPuXzQRHGBMjIKTgWDbUDZrFsbZlv0XDPs6cVxnem+wiXuJjEXbSKxci0lX+1iBfJLW0o7zg1IiSQfzP0tDkzbXi2ZK5u0Z52GG6QWtl8NSi2cbTNuZAnVVml8V4ZP31ziPqg+diyeh/7BmWXAdlUP8Q== Received: from DB6PR0301CA0084.eurprd03.prod.outlook.com (2603:10a6:6:30::31) by AS8PR07MB7301.eurprd07.prod.outlook.com (2603:10a6:20b:23b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.41; Wed, 28 Feb 2024 10:17:23 +0000 Received: from DU6PEPF0000B61F.eurprd02.prod.outlook.com (2603:10a6:6:30:cafe::10) by DB6PR0301CA0084.outlook.office365.com (2603:10a6:6:30::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.27 via Frontend Transport; Wed, 28 Feb 2024 10:17:23 +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 DU6PEPF0000B61F.mail.protection.outlook.com (10.167.8.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.25 via Frontend Transport; Wed, 28 Feb 2024 10:17:23 +0000 Received: from seliicinfr00049.seli.gic.ericsson.se (153.88.142.248) by smtp-central.internal.ericsson.com (100.87.178.68) with Microsoft SMTP Server id 15.2.1258.12; Wed, 28 Feb 2024 11:17:23 +0100 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00049.seli.gic.ericsson.se (Postfix) with ESMTP id 1A220380061; Wed, 28 Feb 2024 11:17:23 +0100 (CET) From: =?UTF-8?q?Mattias=20R=C3=B6nnblom?= To: CC: , =?UTF-8?q?Morten=20Br=C3=B8rup?= , Stephen Hemminger , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= Subject: [RFC v5 6/6] eal: keep per-lcore power intrinsics state in lcore variable Date: Wed, 28 Feb 2024 11:09:28 +0100 Message-ID: <20240228100928.524277-7-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228100928.524277-1-mattias.ronnblom@ericsson.com> References: <20240225150330.517225-2-mattias.ronnblom@ericsson.com> <20240228100928.524277-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: DU6PEPF0000B61F:EE_|AS8PR07MB7301:EE_ X-MS-Office365-Filtering-Correlation-Id: daca5272-a3f4-4607-5d16-08dc384674ca X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GxklDXeZYGawrSnDY7TKUToc0PefaNiqUi5fSJ/7NeFbpWtsQTUyAF2QR7a2Jz31UH0De22iYgi5UnnNBl4tyNYSUOq28ua/1s231PXQ+KCvZzDfUdS+e2C2s9dT26KTyga/BwkinvPqYvXCVs4KmrB/oy1z5lI28MgzpTQnBsB0ShrNzZPkVDVKjpxacyqpjpHW/8vY0hxT5n6m8tvapIBl1eij9A9F5B9zGcnz6vO5O4NAidgZ2FL1Uyy+KE+GFndEKACXNO486T55dMqu75ASPlQd6+JuXwz0oyslbs+WQPxiB9+wDndpauKsFL2+SSz7VSPnRIkECb7lEPqiw/gnI7BV6wzOJf6lILiOItGUsNjQ1G2Kr+E4FYVinInclHNTxcCYXegPzChZ5cHHmtqZx2Tyajl61HhGrmhvw3KbzbQw1YkvXQYDwpx6Ct9Y3ek3b5JHPq2dZ8f5ycQnqI/Jfzwk8UWxZnARTA+uARKVHkFNTcYx/9n8o1smXPFkT/odN6gLqfIVufjdI9MjCePISpVbRhaz4yevQr8Kto2lPr5Fw0NjCmYTGXU+d79lia3cgcae0HtfhNm5sJvd9t05jMgz67DJkaCKKEYI0qfAh9AV+rBGtOfzfa9oyM7OeptWVUxinetoheRAh6IlUrxiuMKeejuy8Cgv0c4B6ptJnGNKHJ1xDLE+Q6kN/c/7z0A1HTko5Olw54FqglMzOrDh6XJcEBFpkqQOl78hTVrjdhJM1AjQiG0ci92ME47b 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:(13230031)(82310400014)(36860700004); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2024 10:17:23.7115 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: daca5272-a3f4-4607-5d16-08dc384674ca 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: DU6PEPF0000B61F.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB7301 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 532a2e646b..23d1761f0a 100644 --- a/lib/eal/x86/rte_power_intrinsics.c +++ b/lib/eal/x86/rte_power_intrinsics.c @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -12,10 +13,14 @@ /* * Per-lcore structure holding current status of C0.2 sleeps. */ -static struct power_wait_status { +struct power_wait_status { rte_spinlock_t lock; volatile void *monitor_addr; /**< NULL if not currently sleeping */ -} __rte_cache_aligned 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. @@ -170,7 +175,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); @@ -262,7 +267,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 @@ -301,8 +306,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