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 E972DA04DD for ; Wed, 18 Nov 2020 17:37:53 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2DE56C94E; Wed, 18 Nov 2020 17:37:32 +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 A9690C93E for ; Wed, 18 Nov 2020 17:37:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605717448; 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=ySoX4rBjQ5SVqK8jN9C+BApI2bRP8CSQq5YcrOMIo00=; b=VgzNZIF+C7DlWFn1qqkYX3jrvnq7eofY87fTI+AWmONHXVJP5vhxbc8Nr8w9UIdr67b+fo rP2TCjXI1mVOZyocOrRGbGocstMXvr7HCtM6HLuapkjhL1DEpONDEAcsDsGBLPC7sn51ai 236A/6OtV8Av8LCwV7jC4VHAbMZ2naU= 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-198-FsDyFA5ZNeWmskQ6riDbVw-1; Wed, 18 Nov 2020 11:37:24 -0500 X-MC-Unique: FsDyFA5ZNeWmskQ6riDbVw-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 1E242A0CD8; Wed, 18 Nov 2020 16:37:04 +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 139005C1A3; Wed, 18 Nov 2020 16:37:02 +0000 (UTC) From: Kevin Traynor To: Lukasz Wojciechowski Cc: David Hunt , dpdk stable Date: Wed, 18 Nov 2020 16:35:14 +0000 Message-Id: <20201118163558.1101823-28-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 race conditions on shutdown' 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/f7b94e1e83274916f3ed163fcf5ebe02d93bb17c Thanks. Kevin. --- >From f7b94e1e83274916f3ed163fcf5ebe02d93bb17c Mon Sep 17 00:00:00 2001 From: Lukasz Wojciechowski Date: Sat, 17 Oct 2020 05:06:55 +0200 Subject: [PATCH] test/distributor: fix race conditions on shutdown [ upstream commit 92e69743ed18692a1470396c4e7e47246c2191a5 ] Instead of making delays in test code and waiting for worker hopefully to reach proper states, synchronize worker shutdown test cases with spin lock on atomic variable. Fixes: c0de0eb82e40 ("distributor: switch over to new API") Signed-off-by: Lukasz Wojciechowski Acked-by: David Hunt --- test/test/test_distributor.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/test/test/test_distributor.c b/test/test/test_distributor.c index 43fd231904..459f75b96a 100644 --- a/test/test/test_distributor.c +++ b/test/test/test_distributor.c @@ -28,4 +28,5 @@ struct worker_params worker_params; 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 int zero_sleep; /**< thr0 has quit basic loop and is sleeping*/ static volatile unsigned worker_idx; static volatile unsigned zero_idx; @@ -377,6 +378,8 @@ handle_work_for_shutdown_test(void *arg) * when all workers are shutting down. */ + __atomic_store_n(&zero_sleep, 1, __ATOMIC_RELEASE); while (zero_quit) usleep(100); + __atomic_store_n(&zero_sleep, 0, __ATOMIC_RELEASE); num = rte_distributor_get_pkt(d, id, buf, NULL, 0); @@ -446,5 +449,10 @@ sanity_test_with_worker_shutdown(struct worker_params *wp, /* flush the distributor */ rte_distributor_flush(d); - rte_delay_us(10000); + while (!__atomic_load_n(&zero_sleep, __ATOMIC_ACQUIRE)) + rte_distributor_flush(d); + + zero_quit = 0; + while (__atomic_load_n(&zero_sleep, __ATOMIC_ACQUIRE)) + rte_delay_us(100); for (i = 0; i < rte_lcore_count() - 1; i++) @@ -506,7 +514,12 @@ test_flush_with_worker_shutdown(struct worker_params *wp, rte_distributor_flush(d); - rte_delay_us(10000); + while (!__atomic_load_n(&zero_sleep, __ATOMIC_ACQUIRE)) + rte_distributor_flush(d); zero_quit = 0; + + while (__atomic_load_n(&zero_sleep, __ATOMIC_ACQUIRE)) + rte_delay_us(100); + for (i = 0; i < rte_lcore_count() - 1; i++) printf("Worker %u handled %u packets\n", i, @@ -616,4 +629,6 @@ quit_workers(struct worker_params *wp, struct rte_mempool *p) worker_idx = 0; zero_idx = RTE_MAX_LCORE; + zero_quit = 0; + zero_sleep = 0; } -- 2.26.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-11-18 16:33:38.489536518 +0000 +++ 0028-test-distributor-fix-race-conditions-on-shutdown.patch 2020-11-18 16:33:37.931215063 +0000 @@ -1 +1 @@ -From 92e69743ed18692a1470396c4e7e47246c2191a5 Mon Sep 17 00:00:00 2001 +From f7b94e1e83274916f3ed163fcf5ebe02d93bb17c Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 92e69743ed18692a1470396c4e7e47246c2191a5 ] + @@ -12 +13,0 @@ -Cc: stable@dpdk.org @@ -17 +18 @@ - app/test/test_distributor.c | 19 +++++++++++++++++-- + test/test/test_distributor.c | 19 +++++++++++++++++-- @@ -20,4 +21,4 @@ -diff --git a/app/test/test_distributor.c b/app/test/test_distributor.c -index 3f0aeb7b90..fdb6ea9ceb 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 43fd231904..459f75b96a 100644 +--- a/test/test/test_distributor.c ++++ b/test/test/test_distributor.c @@ -30 +31 @@ -@@ -378,6 +379,8 @@ handle_work_for_shutdown_test(void *arg) +@@ -377,6 +378,8 @@ handle_work_for_shutdown_test(void *arg) @@ -39 +40 @@ -@@ -447,5 +450,10 @@ sanity_test_with_worker_shutdown(struct worker_params *wp, +@@ -446,5 +449,10 @@ sanity_test_with_worker_shutdown(struct worker_params *wp, @@ -51 +52 @@ -@@ -507,7 +515,12 @@ test_flush_with_worker_shutdown(struct worker_params *wp, +@@ -506,7 +514,12 @@ test_flush_with_worker_shutdown(struct worker_params *wp, @@ -65 +66 @@ -@@ -617,4 +630,6 @@ quit_workers(struct worker_params *wp, struct rte_mempool *p) +@@ -616,4 +629,6 @@ quit_workers(struct worker_params *wp, struct rte_mempool *p)