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 50BF7A04DD for ; Wed, 18 Nov 2020 17:37:31 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DFAF03B5; Wed, 18 Nov 2020 17:37:25 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by dpdk.org (Postfix) with ESMTP id 748885947 for ; Wed, 18 Nov 2020 17:37:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605717440; 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=LLPDafxoGmqVKhWCmp6xtZSBGZiMtIx0enOewBatrc8=; b=dqf4wtpMdKJqsqHAv689khPG6Aif/TU/qLq6n0jRYz9YuohMYmrodXxk3nWHqk5SnvzMNm pAfd8aCvlNfnTKZyh7GawlIvX3riAPpGnCgosYkevijkGqWxxRJjbvSrcSYsxhfEWwpkSa XYFRVSnDYF2GWZtZFqMSdO3Y8ahdXZQ= 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-487-vkGeprKnOnOJZSgp9I-fpA-1; Wed, 18 Nov 2020 11:37:16 -0500 X-MC-Unique: vkGeprKnOnOJZSgp9I-fpA-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 F2D86100C616; Wed, 18 Nov 2020 16:36:54 +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 CF02A5C1A3; Wed, 18 Nov 2020 16:36:53 +0000 (UTC) From: Kevin Traynor To: Lukasz Wojciechowski Cc: David Hunt , dpdk stable Date: Wed, 18 Nov 2020 16:35:08 +0000 Message-Id: <20201118163558.1101823-22-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 shutdown of busy worker' 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/9759e36e4f000ff9b16a3681b3806b6c3efaf507 Thanks. Kevin. --- >From 9759e36e4f000ff9b16a3681b3806b6c3efaf507 Mon Sep 17 00:00:00 2001 From: Lukasz Wojciechowski Date: Sat, 17 Oct 2020 05:06:49 +0200 Subject: [PATCH] test/distributor: fix shutdown of busy worker [ upstream commit cf669d6930116b80493d67cdc5d7a1a568eed8e9 ] The sanity test with worker shutdown delegates all bufs to be processed by a single lcore worker, then it freezes one of the lcore workers and continues to send more bufs. The freezed core shuts down first by calling rte_distributor_return_pkt(). The test intention is to verify if packets assigned to the shut down lcore will be reassigned to another worker. However the shutdown core was not always the one, that was processing packets. The lcore processing mbufs might be different every time test is launched. This is caused by keeping the value of wkr static variable in rte_distributor_process() function between running test cases. Test freezed always lcore with 0 id. The patch stores the id of worker that is processing the data in zero_idx global atomic variable. This way the freezed lcore is always the proper one. Fixes: c3eabff124e6 ("distributor: add unit tests") Signed-off-by: Lukasz Wojciechowski Tested-by: David Hunt --- test/test/test_distributor.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/test/test/test_distributor.c b/test/test/test_distributor.c index ae7eff5a91..45b4b22b43 100644 --- a/test/test/test_distributor.c +++ b/test/test/test_distributor.c @@ -29,4 +29,5 @@ static volatile int quit; /**< general quit variable for all threads */ static volatile int zero_quit; /**< var for when we just want thr0 to quit*/ static volatile unsigned worker_idx; +static volatile unsigned zero_idx; struct worker_stats { @@ -341,11 +342,20 @@ handle_work_for_shutdown_test(void *arg) unsigned int i; unsigned int returned = 0; + unsigned int zero_id = 0; + unsigned int zero_unset; const unsigned int id = __sync_fetch_and_add(&worker_idx, 1); num = rte_distributor_get_pkt(d, id, buf, NULL, 0); + if (num > 0) { + zero_unset = RTE_MAX_LCORE; + __atomic_compare_exchange_n(&zero_idx, &zero_unset, id, + 0, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE); + } + zero_id = __atomic_load_n(&zero_idx, __ATOMIC_ACQUIRE); + /* wait for quit single globally, or for worker zero, wait * for zero_quit */ - while (!quit && !(id == 0 && zero_quit)) { + while (!quit && !(id == zero_id && zero_quit)) { worker_stats[id].handled_packets += num; count += num; @@ -353,4 +363,12 @@ handle_work_for_shutdown_test(void *arg) rte_pktmbuf_free(buf[i]); num = rte_distributor_get_pkt(d, id, buf, NULL, 0); + + if (num > 0) { + zero_unset = RTE_MAX_LCORE; + __atomic_compare_exchange_n(&zero_idx, &zero_unset, id, + 0, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE); + } + zero_id = __atomic_load_n(&zero_idx, __ATOMIC_ACQUIRE); + total += num; } @@ -359,5 +377,5 @@ handle_work_for_shutdown_test(void *arg) returned = rte_distributor_return_pkt(d, id, buf, num); - if (id == 0) { + if (id == zero_id) { /* for worker zero, allow it to restart to pick up last packet * when all workers are shutting down. @@ -578,4 +596,5 @@ quit_workers(struct worker_params *wp, struct rte_mempool *p) quit = 0; worker_idx = 0; + zero_idx = RTE_MAX_LCORE; } -- 2.26.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-11-18 16:33:38.387612492 +0000 +++ 0022-test-distributor-fix-shutdown-of-busy-worker.patch 2020-11-18 16:33:37.927215061 +0000 @@ -1 +1 @@ -From cf669d6930116b80493d67cdc5d7a1a568eed8e9 Mon Sep 17 00:00:00 2001 +From 9759e36e4f000ff9b16a3681b3806b6c3efaf507 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit cf669d6930116b80493d67cdc5d7a1a568eed8e9 ] + @@ -26 +27,0 @@ -Cc: stable@dpdk.org @@ -31 +32 @@ - app/test/test_distributor.c | 23 +++++++++++++++++++++-- + test/test/test_distributor.c | 23 +++++++++++++++++++++-- @@ -34,4 +35,4 @@ -diff --git a/app/test/test_distributor.c b/app/test/test_distributor.c -index 52230d2504..6cd7a2edda 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 ae7eff5a91..45b4b22b43 100644 +--- a/test/test/test_distributor.c ++++ b/test/test/test_distributor.c @@ -44 +45 @@ -@@ -341,4 +342,6 @@ handle_work_for_shutdown_test(void *arg) +@@ -341,11 +342,20 @@ handle_work_for_shutdown_test(void *arg) @@ -49,3 +50,2 @@ - const unsigned int id = __atomic_fetch_add(&worker_idx, 1, - __ATOMIC_RELAXED); -@@ -346,7 +349,14 @@ handle_work_for_shutdown_test(void *arg) + const unsigned int id = __sync_fetch_and_add(&worker_idx, 1); + @@ -57 +57 @@ -+ false, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE); ++ 0, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE); @@ -67 +67 @@ -@@ -354,4 +364,12 @@ handle_work_for_shutdown_test(void *arg) +@@ -353,4 +363,12 @@ handle_work_for_shutdown_test(void *arg) @@ -74 +74 @@ -+ false, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE); ++ 0, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE); @@ -80 +80 @@ -@@ -360,5 +378,5 @@ handle_work_for_shutdown_test(void *arg) +@@ -359,5 +377,5 @@ handle_work_for_shutdown_test(void *arg) @@ -87 +87 @@ -@@ -579,4 +597,5 @@ quit_workers(struct worker_params *wp, struct rte_mempool *p) +@@ -578,4 +596,5 @@ quit_workers(struct worker_params *wp, struct rte_mempool *p)