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 A413545879; Tue, 27 Aug 2024 17:11:22 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C291040E32; Tue, 27 Aug 2024 17:11:19 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2083.outbound.protection.outlook.com [40.107.236.83]) by mails.dpdk.org (Postfix) with ESMTP id AA9FC40E31 for ; Tue, 27 Aug 2024 17:11:18 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cNeIt/x4lbEHY9t1OODKMPiKPybSU+M0Hx2SELDI6WXhwFzvOmOyKNexzXt+rjTotjjhEXk/HpcI49TMhwYWLzdETnOh10bWNiSSvzaw+lVbKE8sQxGqxQRIc40LS2fyjQqYFU8UY2Bt598TcCzaswkVQFo4LFxA/hNl7HxiYqmitZJ1pnpbiifjglIf1TO4dhapBlOz+kN46Y2w7pV+GweLNiwdYl5/cg8yq3plLxjQLFH67QIjTpMu0mxcn3zSL+iULlV70dbLBPbN2yirxmCraneNxc1G2zwm3AwdQkTGOGsOVshCmeeP0tSFzhMVv1XWNZlYjnKwS8jFEvW4RA== 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=FDmqs8H0vFMrQ79G2aEXIUC9qbB4NfVmGUDL/CsO+bc=; b=OXs1oFuN+kM3qInlRBcfQ+pEIAahyABM5mJTKdVwhPjj6PousvrNJ6p9jSG3pQcGK3InBRacPLiA+fxLlIDjwjvEZhuu82v/wditcQJ1PssnP+kO/YclzdIJxLlLWX3hrQib/KZLA6EakXTddm8GfHtnnp+Aygn0LvDhwJPgFQ5HlIuTn7tEU6fTgorfVnf+lcWBnaQcPk0TjOr3nu3FUXpRVIekb5WhPPH1gd9NBqLTSXqq6fZWe3URVAvCLYTGDz4ZcQELvV74+HKOz9cGPd55UgkV9T6aOn84ezZtXFybB0V9OByI1kmpQdcpVvWm5vubi4u4n4X6cj9AUqDj7g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=dpdk.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FDmqs8H0vFMrQ79G2aEXIUC9qbB4NfVmGUDL/CsO+bc=; b=d29k55c5xiJ5TK6u9IRHxOFXV/8Iv1fwcaHhMWpZO3R4Zp0orlQ/bv+ZPQxxBbZdNzUy+Kd9wBpq9KviJ7rqClaGhzy0VejgD4CT8RyBowTPKDYlA1I4f/MntTuJUpR5d0ApZE1BgADHWMlBpxZ7UMgWI32oRcSsKKx24BopryE= Received: from BN8PR15CA0040.namprd15.prod.outlook.com (2603:10b6:408:80::17) by CH3PR12MB8995.namprd12.prod.outlook.com (2603:10b6:610:17e::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.26; Tue, 27 Aug 2024 15:11:13 +0000 Received: from BN1PEPF00006000.namprd05.prod.outlook.com (2603:10b6:408:80:cafe::ce) by BN8PR15CA0040.outlook.office365.com (2603:10b6:408:80::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.25 via Frontend Transport; Tue, 27 Aug 2024 15:11:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN1PEPF00006000.mail.protection.outlook.com (10.167.243.232) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Tue, 27 Aug 2024 15:11:12 +0000 Received: from BLR-5CG134626B.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 27 Aug 2024 10:11:07 -0500 From: Vipin Varghese To: , Subject: [RFC 2/2] eal/lcore: add llc aware for each macro Date: Tue, 27 Aug 2024 20:40:14 +0530 Message-ID: <20240827151014.201-3-vipin.varghese@amd.com> X-Mailer: git-send-email 2.41.0.windows.3 In-Reply-To: <20240827151014.201-1-vipin.varghese@amd.com> References: <20240827151014.201-1-vipin.varghese@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1PEPF00006000:EE_|CH3PR12MB8995:EE_ X-MS-Office365-Filtering-Correlation-Id: 8163c63c-a24f-4de4-198b-08dcc6aa7d5e 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: =?us-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OTP2k6wKr/YIpjA?= =?us-ascii?Q?vkSQTTQkOI0zQLyiWU4KTSGYQSwDIb3OOP3RWbxXYXNYQSvIomtgaQe+TMuW?= =?us-ascii?Q?VglL3hIo6Ro2WEdp3zxQo6MyC9L5IA3b7TrcLwZvzkSJTzRf57dJePNFOSU6?= =?us-ascii?Q?afsUPPGykZyOrra/j8O4qPOQ7/qJcnlo58HUSco5TKXc+FyI39rDhEhcTwAb?= =?us-ascii?Q?ft07zKlX2c70v0kAmPwik/9FjYZ638xo/1o/SRUX6EAGCGnSYwc3e705Bm/U?= =?us-ascii?Q?NDtQwptLcmssMDCM7tbwzWJdiHM8Qm6PPqiWaLr9g+RnSK1nz4Q4YzdmlHM1?= =?us-ascii?Q?FuDUk7AQB8lmoR2Jp4DEDkUF3B+uVm4hy07NEjW3FbkaIdKC6ZQHQU2SC9Df?= =?us-ascii?Q?ERQ30yAmFCp9Xy4tCyThUzSl3nfzbUKwlkKsT/3vVMYz2wNL9+qOGT3RW7IS?= =?us-ascii?Q?hEdVKpwKWS/Tw6M7G8lxuKt4hclM8hAr9v3tcBC/Qhtw/FgMyLCiyEsOu83E?= =?us-ascii?Q?wtyzASDm5EECsJWPbumNBzyTHc5KQhRGMVn6d7SSyevStB0GYoFZCBrEdSiy?= =?us-ascii?Q?MBprcjNSik5FbdKWpyEfK9wIvttJfyHF?= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(82310400026)(36860700013)(376014)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2024 15:11:12.7951 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8163c63c-a24f-4de4-198b-08dcc6aa7d5e X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN1PEPF00006000.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8995 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 add RTE_LCORE_FOREACH for dpdk lcore sharing the Last Level Cache. For core complexes with shared LLC, the macro iterates for same llc lcores. For cores within single LLC, the macro iterates over all availble lcores. MACRO added: - RTE_LCORE_FOREACH_LLC_FIRST - RTE_LCORE_FOREACH_LLC_FIRST_WORKER - RTE_LCORE_FOREACH_LLC_WORKER - RTE_LCORE_FOREACH_LLC_SKIP_FIRST_WORKER - RTE_LCORE_FOREACH_LLC_FIRST_N_WORKER - RTE_LCORE_FOREACH_LLC_SKIP_N_WORKER Signed-off-by: Vipin Varghese --- lib/eal/include/rte_lcore.h | 89 +++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/lib/eal/include/rte_lcore.h b/lib/eal/include/rte_lcore.h index 7deae47af3..7c1a240bde 100644 --- a/lib/eal/include/rte_lcore.h +++ b/lib/eal/include/rte_lcore.h @@ -18,6 +18,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { @@ -196,6 +197,21 @@ rte_cpuset_t rte_lcore_cpuset(unsigned int lcore_id); */ int rte_lcore_is_enabled(unsigned int lcore_id); +/** + * Get the next enabled lcore ID within same llc. + * + * @param i + * The current lcore (reference). + * @param skip_main + * If true, do not return the ID of the main lcore. + * @param wrap + * If true, go back to 0 when RTE_MAX_LCORE is reached; otherwise, + * return RTE_MAX_LCORE. + * @return + * The next lcore_id or RTE_MAX_LCORE if not found. + */ +unsigned int rte_get_next_llc_lcore(unsigned int i, int skip_main, int wrap); + /** * Get the next enabled lcore ID. * @@ -211,6 +227,11 @@ int rte_lcore_is_enabled(unsigned int lcore_id); */ unsigned int rte_get_next_lcore(unsigned int i, int skip_main, int wrap); +unsigned int rte_get_llc_lcore (unsigned int i, rte_cpuset_t *llc_cpu, unsigned int *start, unsigned int *end); +unsigned int rte_get_llc_first_lcores (rte_cpuset_t *llc_cpu); +unsigned int rte_get_llc_n_lcore (unsigned int i, rte_cpuset_t *llc_cpu, unsigned int *start, unsigned int *end, unsigned int n, bool skip); + + /** * Macro to browse all running lcores. */ @@ -219,6 +240,7 @@ unsigned int rte_get_next_lcore(unsigned int i, int skip_main, int wrap); i < RTE_MAX_LCORE; \ i = rte_get_next_lcore(i, 0, 0)) + /** * Macro to browse all running lcores except the main lcore. */ @@ -227,6 +249,73 @@ unsigned int rte_get_next_lcore(unsigned int i, int skip_main, int wrap); i < RTE_MAX_LCORE; \ i = rte_get_next_lcore(i, 1, 0)) +/** Browse all the the cores in the provided llc domain **/ + +#define RTE_LCORE_FOREACH_LLC_FIRST(i) \ + rte_cpuset_t llc_foreach_first_lcores; \ + CPU_ZERO(&llc_foreach_first_lcores); i = 0; \ + unsigned int llc_foreach_num_iter = rte_get_llc_first_lcores(&llc_foreach_first_lcores); \ + i = (0 == llc_foreach_num_iter) ? RTE_MAX_LCORE : i; \ + for (; i < RTE_MAX_LCORE; i++) \ + if (CPU_ISSET(i, &llc_foreach_first_lcores)) + +#define RTE_LCORE_FOREACH_LLC_FIRST_WORKER(i) \ + rte_cpuset_t llc_foreach_first_lcores; \ + CPU_ZERO(&llc_foreach_first_lcores); i = 0; \ + unsigned int llc_foreach_num_iter = rte_get_llc_first_lcores(&llc_foreach_first_lcores); \ + CPU_CLR(rte_get_main_lcore(), &llc_foreach_first_lcores); \ + i = (0 == llc_foreach_num_iter) ? RTE_MAX_LCORE : i; \ + for (; i < RTE_MAX_LCORE; i++) \ + if (CPU_ISSET(i, &llc_foreach_first_lcores)) + +#define RTE_LCORE_FOREACH_LLC_WORKER(i) \ + rte_cpuset_t llc_foreach_first_lcores; \ + rte_cpuset_t llc_foreach_lcore; \ + unsigned int start,end; \ + CPU_ZERO(&llc_foreach_first_lcores); i = 0; \ + unsigned int llc_foreach_num_iter = rte_get_llc_first_lcores(&llc_foreach_first_lcores); \ + i = (0 == llc_foreach_num_iter) ? RTE_MAX_LCORE : i; \ + for (unsigned int llc_i = i; llc_i < RTE_MAX_LCORE; llc_i++) \ + if (CPU_ISSET(llc_i, &llc_foreach_first_lcores) && rte_get_llc_lcore (llc_i, &llc_foreach_lcore, &start, &end)) \ + for (i = start; (i <= end); i++) \ + if (CPU_ISSET(i, &llc_foreach_lcore) && (i != rte_get_main_lcore())) + +#define RTE_LCORE_FOREACH_LLC_SKIP_FIRST_WORKER(i) \ + rte_cpuset_t llc_foreach_first_lcores; \ + rte_cpuset_t llc_foreach_lcore; \ + unsigned int start,end; \ + CPU_ZERO(&llc_foreach_first_lcores); i = 0; \ + unsigned int llc_foreach_num_iter = rte_get_llc_first_lcores(&llc_foreach_first_lcores); \ + i = (0 == llc_foreach_num_iter) ? RTE_MAX_LCORE : i; \ + for (unsigned int llc_i = i; llc_i < RTE_MAX_LCORE; llc_i++) \ + if (CPU_ISSET(llc_i, &llc_foreach_first_lcores) && rte_get_llc_lcore (llc_i, &llc_foreach_lcore, &start, &end)) \ + for (i = start + 1; (i <= end); i++) \ + if (CPU_ISSET(i, &llc_foreach_lcore) && (i != rte_get_main_lcore())) + +#define RTE_LCORE_FOREACH_LLC_FIRST_N_WORKER(i,n) \ + rte_cpuset_t llc_foreach_first_lcores; \ + rte_cpuset_t llc_foreach_lcore; \ + unsigned int start,end, temp_count; \ + CPU_ZERO(&llc_foreach_first_lcores); \ + unsigned int llc_foreach_num_iter = rte_get_llc_first_lcores(&llc_foreach_first_lcores); \ + i = (0 == llc_foreach_num_iter) ? RTE_MAX_LCORE : 0; \ + for (unsigned int llc_i = i; llc_i < RTE_MAX_LCORE; llc_i++) \ + if (CPU_ISSET(llc_i, &llc_foreach_first_lcores) && (rte_get_llc_n_lcore (llc_i, &llc_foreach_lcore, &start, &end, n, false) >= n)) \ + for (i = start, temp_count = n; (i <= end) && (temp_count); i++) \ + if (CPU_ISSET(i, &llc_foreach_lcore) && (i != rte_get_main_lcore()) && (temp_count--)) + +#define RTE_LCORE_FOREACH_LLC_SKIP_N_WORKER(i,n) \ + rte_cpuset_t llc_foreach_skip_first_lcores; \ + rte_cpuset_t llc_foreach_skip_lcore; \ + unsigned int start_skip,end_skip,llc_skip_i; \ + CPU_ZERO(&llc_foreach_skip_first_lcores); \ + unsigned int llc_foreach_skip_num_iter = rte_get_llc_first_lcores(&llc_foreach_skip_first_lcores); \ + i = (0 == llc_foreach_skip_num_iter) ? RTE_MAX_LCORE : 0; \ + for (llc_skip_i = i; llc_skip_i < RTE_MAX_LCORE; llc_skip_i++) \ + if (CPU_ISSET(llc_skip_i, &llc_foreach_skip_first_lcores) && (rte_get_llc_n_lcore (llc_skip_i, &llc_foreach_skip_lcore, &start_skip, &end_skip, n, true) > 0)) \ + for (i = start_skip; (i <= end_skip); i++) \ + if (CPU_ISSET(i, &llc_foreach_skip_lcore) && (i != rte_get_main_lcore())) + /** * Callback prototype for initializing lcores. * -- 2.34.1