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 7BF8CA04DD for ; Wed, 18 Nov 2020 17:37:45 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A4EF3C8FA; Wed, 18 Nov 2020 17:37:31 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by dpdk.org (Postfix) with ESMTP id EA88D4C90 for ; Wed, 18 Nov 2020 17:37:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605717446; 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=ZKMzw1toDvjlZXASAcN4dG/iTRaQy9tjF8ueHbHIhE4=; b=PnY7ivtnLloIhZQQxTOqqxmqctqVimxtnYYE5euolZJW/3kNp3wXHvpCjO71a0NtgBZgQf i4ik2QKyx7Mat7dCXi+vnC/08gcv4M7qbly35OBOYsNRLk8Qpo2ftttRtR3v/J79+nZ2CV 4pte6138yeONrzz4sq3gFhQJk7VTVqA= 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-512-07MfFj9jPMehfr5r4KgNAg-1; Wed, 18 Nov 2020 11:37:21 -0500 X-MC-Unique: 07MfFj9jPMehfr5r4KgNAg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7AB6413215D; Wed, 18 Nov 2020 16:36:59 +0000 (UTC) Received: from rh.redhat.com (ovpn-113-249.ams2.redhat.com [10.36.113.249]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3CCA25C1A3; Wed, 18 Nov 2020 16:36:57 +0000 (UTC) From: Kevin Traynor To: Lukasz Wojciechowski Cc: David Hunt , Honnappa Nagarahalli , dpdk stable Date: Wed, 18 Nov 2020 16:35:11 +0000 Message-Id: <20201118163558.1101823-25-ktraynor@redhat.com> In-Reply-To: <20201118163558.1101823-1-ktraynor@redhat.com> References: <20201118163558.1101823-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ktraynor@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Subject: [dpdk-stable] patch 'test/distributor: fix lcores statistics' has been queued to LTS release 18.11.11 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.11 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/24/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 rebasing (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/4852ea2b3d0cbd694b1515fb3bc58a1cc3320a02 Thanks. Kevin. --- >From 4852ea2b3d0cbd694b1515fb3bc58a1cc3320a02 Mon Sep 17 00:00:00 2001 From: Lukasz Wojciechowski Date: Sat, 17 Oct 2020 05:06:52 +0200 Subject: [PATCH] test/distributor: fix lcores statistics [ upstream commit 2dfdfcb404493a781d152afbc85a2a8a5b90580b ] Statistics of handled packets are cleared and read on main lcore, while they are increased in workers handlers on different lcores. Without synchronization occasionally showed invalid values. This patch uses atomic mechanisms to synchronize. Relaxed memory model is used. Fixes: c3eabff124e6 ("distributor: add unit tests") Signed-off-by: Lukasz Wojciechowski Acked-by: David Hunt Reviewed-by: Honnappa Nagarahalli --- test/test/test_distributor.c | 39 +++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/test/test/test_distributor.c b/test/test/test_distributor.c index d13e38f062..d8e007c47b 100644 --- a/test/test/test_distributor.c +++ b/test/test/test_distributor.c @@ -44,5 +44,6 @@ total_packet_count(void) unsigned i, count = 0; for (i = 0; i < worker_idx; i++) - count += worker_stats[i].handled_packets; + count += __atomic_load_n(&worker_stats[i].handled_packets, + __ATOMIC_RELAXED); return count; } @@ -52,5 +53,8 @@ static inline void clear_packet_count(void) { - memset(&worker_stats, 0, sizeof(worker_stats)); + unsigned int i; + for (i = 0; i < RTE_MAX_LCORE; i++) + __atomic_store_n(&worker_stats[i].handled_packets, 0, + __ATOMIC_RELAXED); } @@ -130,5 +134,6 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p) for (i = 0; i < rte_lcore_count() - 1; i++) printf("Worker %u handled %u packets\n", i, - worker_stats[i].handled_packets); + __atomic_load_n(&worker_stats[i].handled_packets, + __ATOMIC_RELAXED)); printf("Sanity test with all zero hashes done.\n"); @@ -155,5 +160,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p) for (i = 0; i < rte_lcore_count() - 1; i++) printf("Worker %u handled %u packets\n", i, - worker_stats[i].handled_packets); + __atomic_load_n( + &worker_stats[i].handled_packets, + __ATOMIC_RELAXED)); printf("Sanity test with two hash values done\n"); } @@ -181,5 +188,6 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p) for (i = 0; i < rte_lcore_count() - 1; i++) printf("Worker %u handled %u packets\n", i, - worker_stats[i].handled_packets); + __atomic_load_n(&worker_stats[i].handled_packets, + __ATOMIC_RELAXED)); printf("Sanity test with non-zero hashes done\n"); @@ -273,10 +281,12 @@ handle_work_with_free_mbufs(void *arg) num = rte_distributor_get_pkt(d, id, buf, NULL, 0); while (!quit) { - worker_stats[id].handled_packets += num; + __atomic_fetch_add(&worker_stats[id].handled_packets, num, + __ATOMIC_RELAXED); for (i = 0; i < num; i++) rte_pktmbuf_free(buf[i]); num = rte_distributor_get_pkt(d, id, buf, NULL, 0); } - worker_stats[id].handled_packets += num; + __atomic_fetch_add(&worker_stats[id].handled_packets, num, + __ATOMIC_RELAXED); rte_distributor_return_pkt(d, id, buf, num); return 0; @@ -347,5 +357,6 @@ handle_work_for_shutdown_test(void *arg) * for zero_quit */ while (!quit && !(id == zero_id && zero_quit)) { - worker_stats[id].handled_packets += num; + __atomic_fetch_add(&worker_stats[id].handled_packets, num, + __ATOMIC_RELAXED); num = rte_distributor_get_pkt(d, id, buf, NULL, 0); @@ -357,6 +368,7 @@ handle_work_for_shutdown_test(void *arg) zero_id = __atomic_load_n(&zero_idx, __ATOMIC_ACQUIRE); } - worker_stats[id].handled_packets += num; + __atomic_fetch_add(&worker_stats[id].handled_packets, num, + __ATOMIC_RELAXED); if (id == zero_id) { rte_distributor_return_pkt(d, id, NULL, 0); @@ -371,5 +383,6 @@ handle_work_for_shutdown_test(void *arg) while (!quit) { - worker_stats[id].handled_packets += num; + __atomic_fetch_add(&worker_stats[id].handled_packets, + num, __ATOMIC_RELAXED); num = rte_distributor_get_pkt(d, id, buf, NULL, 0); } @@ -437,5 +450,6 @@ sanity_test_with_worker_shutdown(struct worker_params *wp, for (i = 0; i < rte_lcore_count() - 1; i++) printf("Worker %u handled %u packets\n", i, - worker_stats[i].handled_packets); + __atomic_load_n(&worker_stats[i].handled_packets, + __ATOMIC_RELAXED)); if (total_packet_count() != BURST * 2) { @@ -497,5 +511,6 @@ test_flush_with_worker_shutdown(struct worker_params *wp, for (i = 0; i < rte_lcore_count() - 1; i++) printf("Worker %u handled %u packets\n", i, - worker_stats[i].handled_packets); + __atomic_load_n(&worker_stats[i].handled_packets, + __ATOMIC_RELAXED)); if (total_packet_count() != BURST) { -- 2.26.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-11-18 16:33:38.438541184 +0000 +++ 0025-test-distributor-fix-lcores-statistics.patch 2020-11-18 16:33:37.929215062 +0000 @@ -1 +1 @@ -From 2dfdfcb404493a781d152afbc85a2a8a5b90580b Mon Sep 17 00:00:00 2001 +From 4852ea2b3d0cbd694b1515fb3bc58a1cc3320a02 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 2dfdfcb404493a781d152afbc85a2a8a5b90580b ] + @@ -14 +15,0 @@ -Cc: stable@dpdk.org @@ -20 +21 @@ - app/test/test_distributor.c | 39 +++++++++++++++++++++++++------------ + test/test/test_distributor.c | 39 +++++++++++++++++++++++++----------- @@ -23,4 +24,4 @@ -diff --git a/app/test/test_distributor.c b/app/test/test_distributor.c -index ec1fe348ba..4343efed14 100644 ---- a/app/test/test_distributor.c -+++ b/app/test/test_distributor.c +diff --git a/test/test/test_distributor.c b/test/test/test_distributor.c +index d13e38f062..d8e007c47b 100644 +--- a/test/test/test_distributor.c ++++ b/test/test/test_distributor.c @@ -85 +86 @@ -@@ -348,5 +358,6 @@ handle_work_for_shutdown_test(void *arg) +@@ -347,5 +357,6 @@ handle_work_for_shutdown_test(void *arg) @@ -93 +94 @@ -@@ -358,6 +369,7 @@ handle_work_for_shutdown_test(void *arg) +@@ -357,6 +368,7 @@ handle_work_for_shutdown_test(void *arg) @@ -102 +103 @@ -@@ -372,5 +384,6 @@ handle_work_for_shutdown_test(void *arg) +@@ -371,5 +383,6 @@ handle_work_for_shutdown_test(void *arg) @@ -110 +111 @@ -@@ -438,5 +451,6 @@ sanity_test_with_worker_shutdown(struct worker_params *wp, +@@ -437,5 +450,6 @@ sanity_test_with_worker_shutdown(struct worker_params *wp, @@ -118 +119 @@ -@@ -498,5 +512,6 @@ test_flush_with_worker_shutdown(struct worker_params *wp, +@@ -497,5 +511,6 @@ test_flush_with_worker_shutdown(struct worker_params *wp,