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 72E26A04DD for ; Wed, 28 Oct 2020 11:56:12 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3E7E7CAD6; Wed, 28 Oct 2020 11:56:11 +0100 (CET) Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by dpdk.org (Postfix) with ESMTP id 9AAC0CAD6 for ; Wed, 28 Oct 2020 11:56:09 +0100 (CET) Received: by mail-wm1-f44.google.com with SMTP id w23so4106952wmi.4 for ; Wed, 28 Oct 2020 03:56:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=M+b+4WQXcpqzbYlrxRWICtYoduX2sQIfAqX8j6hqGRU=; b=C5RGezpy4YQiKiARPfNReXFD2aQ0UzEl6PhXWD/Xz4i0c66/1z0yQ/4Mtz/Y5xcew4 VxT3ShOIKIEobAiHHUYy6UQb3xwd5CneQanoV/osSQgWyd1KROvOcEQQFgXhjl/uPLsL B6LIU0AZTjCYwrayklhbHIj38zv1zFoWBLKsn9xxb2oVb9Esh/vWxsysG1ABLKvPZMcP oGEYbYnSDJ4xfmHdl2Lh7UvFOvqiA+a8xYW0RWUu/d+ZKtgpm+AMg3ikeTkYrIvr3hcc 0mjrIc4jrNpbud1UQ46H1yJoCST4Nc5smS3DIpQd5gdfCsp6ok9eht5TjzLOqpKVa9O3 PGCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=M+b+4WQXcpqzbYlrxRWICtYoduX2sQIfAqX8j6hqGRU=; b=rmd+robnU0lXSwHMoSuLhBV+c4WOgKHrqsNTZLGz6LWR9t3Z0NHdmHqlIZ6TYSSbLq kV2YXaLZ5etIG/f6XhU51BkN0PvIxD0fwv/e9rsxrDILhTETOnTRYA/EbANEkZyC32Tu z4nx5OG97kVxs1UKqU4rU5TMavE6QpUBRW/U/MphwPJctx83vyqHuQBhe9PmgwnDkKZd BZkmuZtAjCgAVIURGNtm0pzmHg3dcbaO7k1vALOn62s6yW0NlIMVX4tBpvL51UNHelnX ez6t2S/NkunQpJbK5Ed2nsVQsHicbQnpQHnYhyt8krUPL+11UeekYj0OLfKl2yVgJ34Q GWHg== X-Gm-Message-State: AOAM532E9I4j3LhxvjHVCnQeKwfGu/y1II1A8NHnshxl/AUWh4plQsqb adxW+oDdSjQQ+5mua/S34HQ= X-Google-Smtp-Source: ABdhPJwsJNfHarWxa8o5VJlEivJyK9b8PlxeiOJxEfvpX1kLJaFkGzlrGcdSNS/XVvvMKnLH87KRkQ== X-Received: by 2002:a1c:3882:: with SMTP id f124mr7216995wma.184.1603882568382; Wed, 28 Oct 2020 03:56:08 -0700 (PDT) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id g4sm5622801wmh.13.2020.10.28.03.56.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 03:56:07 -0700 (PDT) From: luca.boccassi@gmail.com To: Lukasz Wojciechowski Cc: David Hunt , Honnappa Nagarahalli , dpdk stable Date: Wed, 28 Oct 2020 10:45:48 +0000 Message-Id: <20201028104606.3504127-189-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201028104606.3504127-1-luca.boccassi@gmail.com> References: <20201028104606.3504127-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'test/distributor: fix lcores statistics' has been queued to stable release 19.11.6 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 stable release 19.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 10/30/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. Thanks. Luca Boccassi --- >From 2ceaaa8d33c635f5f9d56e5b4f20387d7a53b932 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 --- app/test/test_distributor.c | 39 +++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/app/test/test_distributor.c b/app/test/test_distributor.c index 62495a8c67..6e5bdc3f60 100644 --- a/app/test/test_distributor.c +++ b/app/test/test_distributor.c @@ -43,7 +43,8 @@ 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; } @@ -51,7 +52,10 @@ total_packet_count(void) 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); } /* this is the basic worker function for sanity test @@ -129,7 +133,8 @@ 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"); /* pick two flows and check they go correctly */ @@ -154,7 +159,9 @@ 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"); } @@ -180,7 +187,8 @@ 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"); rte_mempool_put_bulk(p, (void *)bufs, BURST); @@ -272,12 +280,14 @@ 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,7 +357,8 @@ handle_work_for_shutdown_test(void *arg) /* wait for quit single globally, or for worker zero, wait * 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); if (num > 0) { @@ -357,8 +368,9 @@ 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,7 +383,8 @@ handle_work_for_shutdown_test(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); num = rte_distributor_get_pkt(d, id, buf, NULL, 0); } } @@ -437,7 +450,8 @@ 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) { printf("Line %d: Error, not all packets flushed. " @@ -497,7 +511,8 @@ test_flush_with_worker_shutdown(struct worker_params *wp, zero_quit = 0; 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) { printf("Line %d: Error, not all packets flushed. " -- 2.20.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-10-28 10:35:17.568182056 +0000 +++ 0189-test-distributor-fix-lcores-statistics.patch 2020-10-28 10:35:11.800834381 +0000 @@ -1,8 +1,10 @@ -From 2dfdfcb404493a781d152afbc85a2a8a5b90580b Mon Sep 17 00:00:00 2001 +From 2ceaaa8d33c635f5f9d56e5b4f20387d7a53b932 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. @@ -11,7 +13,6 @@ Relaxed memory model is used. Fixes: c3eabff124e6 ("distributor: add unit tests") -Cc: stable@dpdk.org Signed-off-by: Lukasz Wojciechowski Acked-by: David Hunt @@ -21,7 +22,7 @@ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/app/test/test_distributor.c b/app/test/test_distributor.c -index ec1fe348ba..4343efed14 100644 +index 62495a8c67..6e5bdc3f60 100644 --- a/app/test/test_distributor.c +++ b/app/test/test_distributor.c @@ -43,7 +43,8 @@ total_packet_count(void)