From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8BFD7A0542 for ; Fri, 7 Feb 2020 16:14:27 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 82EE71BF8E; Fri, 7 Feb 2020 16:14:27 +0100 (CET) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by dpdk.org (Postfix) with ESMTP id 16A5C1BF8E for ; Fri, 7 Feb 2020 16:14:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581088465; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NyvCesXn3Ep6rHUD6CMFDzvcRxHP3+k6WaYxAyQqiEc=; b=b5TclNnT9xIeDiHFEtjlqa8KjN/g9npBB3B+t2j8+DXc8dIDOrd/oMnRge9IEYBvAWy83o BxrZ8rt3g27ZGSxQg7SHOQfbZere0fMAS1ozuxdhk1BeHm+cFBHQcJMEg8hsitBnhnNLpj vR3CZgFb6ijyNkTfhe5Pvr56gO64kh4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-156-fZacP1MsPdiadLce74HTpw-1; Fri, 07 Feb 2020 10:14:07 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CCC688010D6; Fri, 7 Feb 2020 15:14:06 +0000 (UTC) Received: from rh.redhat.com (unknown [10.33.36.76]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E1C910016DA; Fri, 7 Feb 2020 15:14:05 +0000 (UTC) From: Kevin Traynor To: Nikhil Rao Cc: Gage Eads , Harry van Haaren , dpdk stable Date: Fri, 7 Feb 2020 15:12:47 +0000 Message-Id: <20200207151248.29804-35-ktraynor@redhat.com> In-Reply-To: <20200207151248.29804-1-ktraynor@redhat.com> References: <20200207151248.29804-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: fZacP1MsPdiadLce74HTpw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Subject: [dpdk-stable] patch 'service: avoid false sharing on core state' has been queued to LTS release 18.11.7 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to LTS release 18.11.7 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/13/20. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasi= ng (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/kevintraynor/dpdk-stable-queue This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable-queue/commit/e07f5531f86e3dfadd= a1f52129cc2b61370e3e74 Thanks. Kevin. --- >From e07f5531f86e3dfadda1f52129cc2b61370e3e74 Mon Sep 17 00:00:00 2001 From: Nikhil Rao Date: Mon, 16 Sep 2019 15:31:02 +0530 Subject: [PATCH] service: avoid false sharing on core state [ upstream commit e484ccddbe1b41886fef1e445ef2fdfa55086198 ] For a valid service, the core mask of the service is checked against the current core and the corresponding entry in the active_on_lcore array is set or reset. Upto 8 cores share the same cache line for their service active_on_lcore array entries since each entry is a uint8_t. Some number of these entries also share the cache line with the internal_flags member of struct rte_service_spec_impl, hence this false sharing also makes the service_valid() check expensive. Eliminate false sharing by moving the active_on_lcore array to a per-core data structure. The array is now indexed by service id. Signed-off-by: Nikhil Rao Acked-by: Gage Eads Acked-by: Harry van Haaren --- lib/librte_eal/common/rte_service.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/librte_eal/common/rte_service.c b/lib/librte_eal/common/rt= e_service.c index e7d3e51443..97449460dc 100644 --- a/lib/librte_eal/common/rte_service.c +++ b/lib/librte_eal/common/rte_service.c @@ -53,5 +53,4 @@ struct rte_service_spec_impl { =09uint64_t calls; =09uint64_t cycles_spent; -=09uint8_t active_on_lcore[RTE_MAX_LCORE]; } __rte_cache_aligned; =20 @@ -62,5 +61,5 @@ struct core_state { =09uint8_t runstate; /* running or stopped */ =09uint8_t is_service_core; /* set if core is currently a service core */ - +=09uint8_t service_active_on_lcore[RTE_SERVICE_NUM_MAX]; =09uint64_t loops; =09uint64_t calls_per_service[RTE_SERVICE_NUM_MAX]; @@ -346,5 +345,5 @@ rte_service_runner_do_callback(struct rte_service_spec_= impl *s, =20 static inline int32_t -service_run(uint32_t i, int lcore, struct core_state *cs, uint64_t service= _mask) +service_run(uint32_t i, struct core_state *cs, uint64_t service_mask) { =09if (!service_valid(i)) @@ -354,9 +353,9 @@ service_run(uint32_t i, int lcore, struct core_state *c= s, uint64_t service_mask) =09=09=09s->app_runstate !=3D RUNSTATE_RUNNING || =09=09=09!(service_mask & (UINT64_C(1) << i))) { -=09=09s->active_on_lcore[lcore] =3D 0; +=09=09cs->service_active_on_lcore[i] =3D 0; =09=09return -ENOEXEC; =09} =20 -=09s->active_on_lcore[lcore] =3D 1; +=09cs->service_active_on_lcore[i] =3D 1; =20 =09/* check do we need cmpset, if MT safe or <=3D 1 core @@ -381,5 +380,4 @@ rte_service_may_be_active(uint32_t id) { =09uint32_t ids[RTE_MAX_LCORE] =3D {0}; -=09struct rte_service_spec_impl *s =3D &rte_services[id]; =09int32_t lcore_count =3D rte_service_lcore_list(ids, RTE_MAX_LCORE); =09int i; @@ -389,5 +387,5 @@ rte_service_may_be_active(uint32_t id) =20 =09for (i =3D 0; i < lcore_count; i++) { -=09=09if (s->active_on_lcore[ids[i]]) +=09=09if (lcore_states[i].service_active_on_lcore[id]) =09=09=09return 1; =09} @@ -420,5 +418,5 @@ rte_service_run_iter_on_app_lcore(uint32_t id, uint32_t= serialize_mt_unsafe) =09} =20 -=09int ret =3D service_run(id, rte_lcore_id(), cs, UINT64_MAX); +=09int ret =3D service_run(id, cs, UINT64_MAX); =20 =09if (serialize_mt_unsafe) @@ -441,5 +439,5 @@ rte_service_runner_func(void *arg) =09=09for (i =3D 0; i < RTE_SERVICE_NUM_MAX; i++) { =09=09=09/* return value ignored as no change to code flow */ -=09=09=09service_run(i, lcore, cs, service_mask); +=09=09=09service_run(i, cs, service_mask); =09=09} =20 --=20 2.21.1 --- Diff of the applied patch vs upstream commit (please double-check if non-= empty: --- --- -=092020-02-07 15:08:19.343140553 +0000 +++ 0035-service-avoid-false-sharing-on-core-state.patch=092020-02-07 15:08= :17.571062192 +0000 @@ -1 +1 @@ -From e484ccddbe1b41886fef1e445ef2fdfa55086198 Mon Sep 17 00:00:00 2001 +From e07f5531f86e3dfadda1f52129cc2b61370e3e74 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit e484ccddbe1b41886fef1e445ef2fdfa55086198 ] + @@ -28 +30 @@ -index fe09077200..beb9691b23 100644 +index e7d3e51443..97449460dc 100644 @@ -31 +33 @@ -@@ -52,5 +52,4 @@ struct rte_service_spec_impl { +@@ -53,5 +53,4 @@ struct rte_service_spec_impl { @@ -37 +39 @@ -@@ -61,5 +60,5 @@ struct core_state { +@@ -62,5 +61,5 @@ struct core_state { @@ -44 +46 @@ -@@ -345,5 +344,5 @@ rte_service_runner_do_callback(struct rte_service_spec= _impl *s, +@@ -346,5 +345,5 @@ rte_service_runner_do_callback(struct rte_service_spec= _impl *s, @@ -51 +53 @@ -@@ -353,9 +352,9 @@ service_run(uint32_t i, int lcore, struct core_state *= cs, uint64_t service_mask) +@@ -354,9 +353,9 @@ service_run(uint32_t i, int lcore, struct core_state *= cs, uint64_t service_mask) @@ -63 +65 @@ -@@ -380,5 +379,4 @@ rte_service_may_be_active(uint32_t id) +@@ -381,5 +380,4 @@ rte_service_may_be_active(uint32_t id) @@ -69 +71 @@ -@@ -388,5 +386,5 @@ rte_service_may_be_active(uint32_t id) +@@ -389,5 +387,5 @@ rte_service_may_be_active(uint32_t id) @@ -76 +78 @@ -@@ -419,5 +417,5 @@ rte_service_run_iter_on_app_lcore(uint32_t id, uint32_= t serialize_mt_unsafe) +@@ -420,5 +418,5 @@ rte_service_run_iter_on_app_lcore(uint32_t id, uint32_= t serialize_mt_unsafe) @@ -83 +85 @@ -@@ -440,5 +438,5 @@ rte_service_runner_func(void *arg) +@@ -441,5 +439,5 @@ rte_service_runner_func(void *arg)