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 5C224A0542; Tue, 6 Sep 2022 18:16:35 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 097A940143; Tue, 6 Sep 2022 18:16:35 +0200 (CEST) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60060.outbound.protection.outlook.com [40.107.6.60]) by mails.dpdk.org (Postfix) with ESMTP id 9998E400D6 for ; Tue, 6 Sep 2022 18:16:33 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JLukPYzoZ1+KFN0wt1up49WwPN0XSxNP4bMsv0fheGxIeygBQ4RNCWPLWyUVUG/voXK4rSurQPYuK5IdRsAaUrt3e1F8rv/1p6TpjqRUIxwNx5oAZB5kQkrgpY3c/u8/nllJa097/kXB+3P0SQJTfIv7AlV4n9nXAsq2QFV+lvkzgEhgVcxMwnOIFEHT0oilp05HQ7pDMT9apEp3KD3ordIxH+d/mH/TRiLCBj9ctWCBptw88R06f4QFdd7iLiKeiz8udW6AsCeteJss29wgd9jyYS0UGVorxbtOvptBu5YD+uq8UA00usIXCdYPNjevtg5sW2RCmSh5c62xQHpWyA== 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=0tSQzgem4r0LhShtiU6p8Yc6xq4YhzAGqzI4smfF5Gs=; b=U5CFXPHxH8V+AqXOC2X9YkDHO+BBWOOv6NqqiyBXuQzcDVyotUnM9qivrla7LC7iCJ6onfBkKyST3LPNJyPoJO+9aVUl6gcXoiZd7DMKMEPB4hXBObahAYk3+kQwPANzpPse8fIvEcoIUhFUT0aBejYpkri43o7EPDP9cRbHUQRtbdSNK79TjWnguBI1GrD2TccM8E3JcHs4X3EgTBGqbQ/qD7kVkbmwuI2Xwo+VsjIFpuVacGSKhsSSoZLCo5WCD2lLmira3QskKInqRKNGT67cF6sZLqqbjHmbfJkgkeaI3THt4oecDMOLoyFKndFC2bv7ffxIjuQtVSGuAN8AZw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 192.176.1.74) smtp.rcpttodomain=arm.com 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 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=0tSQzgem4r0LhShtiU6p8Yc6xq4YhzAGqzI4smfF5Gs=; b=Nng1ayEBAqAwXFAdH0e2DYGJWPIw4ZRy9MUy1gq0uEmP2POktZFDNRihf/V5J61CSyAkLmgMYknvsOvLp8PmtY+Y5fKfI4nmz7B7mN0+Aq3fmsierbo6aloMuF2Ut1ORxuwaR9qBKxFL5f4ScSQQsr0O6r9m1Q6RvYhhXD4xnCM= Received: from OL1P279CA0034.NORP279.PROD.OUTLOOK.COM (2603:10a6:e10:13::21) by AM0PR07MB5202.eurprd07.prod.outlook.com (2603:10a6:208:f5::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.12; Tue, 6 Sep 2022 16:16:32 +0000 Received: from HE1EUR02FT101.eop-EUR02.prod.protection.outlook.com (2603:10a6:e10:13:cafe::66) by OL1P279CA0034.outlook.office365.com (2603:10a6:e10:13::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10 via Frontend Transport; Tue, 6 Sep 2022 16:16:32 +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 HE1EUR02FT101.mail.protection.outlook.com (10.152.11.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.5588.10 via Frontend Transport; Tue, 6 Sep 2022 16:16:31 +0000 Received: from ESESBMB505.ericsson.se (153.88.183.172) by ESESSMR502.ericsson.se (153.88.183.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2375.31; Tue, 6 Sep 2022 18:16:30 +0200 Received: from seliicinfr00049.seli.gic.ericsson.se (153.88.183.153) by smtp.internal.ericsson.com (153.88.183.188) with Microsoft SMTP Server id 15.1.2375.31 via Frontend Transport; Tue, 6 Sep 2022 18:16:30 +0200 Received: from localhost.localdomain (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00049.seli.gic.ericsson.se (Postfix) with ESMTP id 707B2380061; Tue, 6 Sep 2022 18:16:30 +0200 (CEST) From: =?UTF-8?q?Mattias=20R=C3=B6nnblom?= To: Van@dpdk.org, Haaren@dpdk.org, Harry CC: , Honnappa Nagarahalli , =?UTF-8?q?Morten=20Br=C3=B8rup?= , nd , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= Subject: [PATCH 3/6] service: reduce average case service core overhead Date: Tue, 6 Sep 2022 18:13:49 +0200 Message-ID: <20220906161352.296110-3-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220906161352.296110-1-mattias.ronnblom@ericsson.com> References: <20220708125645.3141464-2-harry.van.haaren@intel.com> <20220906161352.296110-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-Office365-Filtering-Correlation-Id: c1fc1c70-23bd-4b68-7446-08da90232970 X-MS-TrafficTypeDiagnostic: AM0PR07MB5202:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NQr+AVuv/dBKlEe6scVxa5DEFWyToT42yN/Y3iGMluNTmubA2KByY2mEUEehE+qCEqQD1esYqh3SPmSp6k24xvJOtPpZODOm8GL+1sNLfb6hfjuwiMu6byamZrbuFRsFSx0WT7m+Zpmw3+EFOKHYal7WZdbek8kdi3dvuGOtiteDaAeAzwj5LphGwPiV882hcfuekJ27kKPVmYGRQZXjERVXEt4yra5dEKNwI0H9Ab7AVs46720f6lQ5SfOv45PhebW1sdjTXt1G3MPLIkn0zCnYTS9dillqywfAUSK4GxP7H48EswYoW1CfuMYIff84An2/vcMCV5GlMEpR+19lgU02FBaT1bBuPklgNMVRrB4Q32j1Qq+lCDrRuG4NxeSK8tSah8+X/ChKeDhUpRkA0QBUJ6f1HpVtEW2a0QeoMmvZCflyRL7XH52wrj3LI+tKpe5IgPd03PWbVTh9h5aLznd6MLgpv9Jx2RZlryeHrwTXoS26gLGK6vj7BmYjuAkD15mskjIZU5tSMTr/uOf+b9jG5oqDObZ4eKgZQvGKO5gdSAfDWj2C0jsmQpcDNavOv0R+KDYCf1CjEpHqFqrGIv7W7Cbje4qXrnIP9E5NEYEwTY+TbwvOHIWDWEw5tApY4j+IEbl+njtyV3cGQTvE72fHktAWj9xn0wZBRLRm/FGR7RIwlZL17mKmFwzIOOhlUJa0rDB77TnfVny86YV2OJFzX08d2wIIOz+B1PzFFB8JzZ5WKTuKqCnuUA/yjZQxVwBcnfFbaGQUJiMeLLa18Q== 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:(13230016)(4636009)(39860400002)(136003)(396003)(376002)(346002)(40470700004)(36840700001)(46966006)(186003)(1076003)(8936002)(83380400001)(6266002)(2906002)(5660300002)(40480700001)(107886003)(6666004)(36756003)(86362001)(41300700001)(47076005)(66574015)(336012)(2616005)(54906003)(26005)(478600001)(40460700003)(82960400001)(7636003)(356005)(70206006)(70586007)(82310400005)(4326008)(8676002)(6916009)(316002)(36860700001)(82740400003); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR07MB5202 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 Optimize service loop so that the starting point is the lowest-indexed service mapped to the lcore in question, and terminate the loop at the highest-indexed service. While the worst case latency remains the same, this patch significantly reduces the service framework overhead for the average case. In particular, scenarios where an lcore only runs a single service, or multiple services which id values are close (e.g., three services with ids 17, 18 and 22), show significant improvements. The worse case is a where the lcore two services mapped to it; one with service id 0 and the other with id 63. On a service lcore serving a single service, the service loop overhead is reduced from ~190 core clock cycles to ~46. (On an Intel Cascade Lake generation Xeon.) On weakly ordered CPUs, the gain is larger, since the loop included load-acquire atomic operations. Signed-off-by: Mattias Rönnblom --- lib/eal/common/rte_service.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/eal/common/rte_service.c b/lib/eal/common/rte_service.c index 87df04e3ac..4cac866792 100644 --- a/lib/eal/common/rte_service.c +++ b/lib/eal/common/rte_service.c @@ -464,7 +464,6 @@ static int32_t service_runner_func(void *arg) { RTE_SET_USED(arg); - uint32_t i; const int lcore = rte_lcore_id(); struct core_state *cs = &lcore_states[lcore]; @@ -478,10 +477,17 @@ service_runner_func(void *arg) RUNSTATE_RUNNING) { const uint64_t service_mask = cs->service_mask; + uint8_t start_id; + uint8_t end_id; + uint8_t i; - for (i = 0; i < RTE_SERVICE_NUM_MAX; i++) { - if (!service_registered(i)) - continue; + if (service_mask == 0) + continue; + + start_id = __builtin_ctzl(service_mask); + end_id = 64 - __builtin_clzl(service_mask); + + for (i = start_id; i < end_id; i++) { /* return value ignored as no change to code flow */ service_run(i, cs, service_mask, service_get(i), 1); } -- 2.34.1