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 A7CFAA04DD for ; Wed, 28 Oct 2020 11:56:25 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A1706CAD0; Wed, 28 Oct 2020 11:56:24 +0100 (CET) Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) by dpdk.org (Postfix) with ESMTP id 68CDCCAD0 for ; Wed, 28 Oct 2020 11:56:22 +0100 (CET) Received: by mail-wm1-f48.google.com with SMTP id c16so4323551wmd.2 for ; Wed, 28 Oct 2020 03:56:22 -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=8NKXIACTfRU+0NwIFv1atCQtkIEqmL8eTxuyTdKFKdI=; b=f+A1ocdLVtcF+AVRleLdWqsko4YRUjOhw9BlGUeBLP9jH4Gns/Z+iiFYOT6Sqs/mIr +1p6pD2NwevEYnmw+09/kdwbYua2QohBcprs/efJg8yga/jyiQEwoobn2j4ue27Wh3ky Muu0j7fdmzOEQxviaYjOViAj1OfzpDxQTBUf5nfxZHCN/8ji3TDriqKu3cQLZxV3FwWa m3770Hz8bnhKA+Up/LVk+YjVqprEqdgwIuedn9lnJtMv/K0EIASLW/+r9XSyU3W+7Xa/ D03ETTSiNTtjeD33r6tx81IloNuUfuY4S69cB3hqugpN8KTtNake+mi4lUXjFu08/SR0 bV/Q== 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=8NKXIACTfRU+0NwIFv1atCQtkIEqmL8eTxuyTdKFKdI=; b=YKcpyJEeFzQO9In+xnlOd8XYziZTgocpffTxbYEouUcFPITi6b9dyW0P5rgn4HGApV X8JXhPzaj0DCu9jPO3+CLgEyfexlWfbtrceoR8fTAlgNU+ltBrpHhOmlrDnpjCIlvp+i gJs0/zmANw/zAUUkjZoFhwURbEM2/ccB6qAIzUol1qsWNNdLR+M5kajONQ2OJOHuigoR jtHVZWUiChquTopVTbL2N8R2zkA51Iu8G1yyY69bBfQ0n8Tm4crrWM0Z84se5EPVmrfm NtJyM+XvHkitwUbsww7YdeODGfyW+FRrHs1pwNP4hdN1UuliM9dI6nMvh79EWqWTHL0M kcBQ== X-Gm-Message-State: AOAM532Y4oic2RUrdyYFyl3JXkHUwRPyI8+/j61kclRObd/cKQB/pY0y QWSMI7RJ9LnGk/ZbQhU/SSo= X-Google-Smtp-Source: ABdhPJwrTfumEXL7IGd3BwK41ZQv07QWLqlvruBMpxeZHMn/SjJd8pgcAg4C4FYyqbxz0izvK7ERlg== X-Received: by 2002:a1c:7409:: with SMTP id p9mr7159481wmc.167.1603882582122; Wed, 28 Oct 2020 03:56:22 -0700 (PDT) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id u3sm6485222wrq.19.2020.10.28.03.56.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 03:56:21 -0700 (PDT) From: luca.boccassi@gmail.com To: Lukasz Wojciechowski Cc: David Hunt , dpdk stable Date: Wed, 28 Oct 2020 10:45:51 +0000 Message-Id: <20201028104606.3504127-192-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 race conditions on shutdown' 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 c26c6e434ba2fe8863f8a6fce27b030703742243 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 --- app/test/test_distributor.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/test/test_distributor.c b/app/test/test_distributor.c index 7219925521..e9e8e2c7af 100644 --- a/app/test/test_distributor.c +++ b/app/test/test_distributor.c @@ -27,6 +27,7 @@ struct worker_params worker_params; /* statics - all zero-initialized by default */ 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,8 +378,10 @@ handle_work_for_shutdown_test(void *arg) /* for worker zero, allow it to restart to pick up last packet * 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,7 +449,12 @@ 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++) printf("Worker %u handled %u packets\n", i, @@ -506,9 +514,14 @@ test_flush_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++) printf("Worker %u handled %u packets\n", i, __atomic_load_n(&worker_stats[i].handled_packets, @@ -616,6 +629,8 @@ quit_workers(struct worker_params *wp, struct rte_mempool *p) quit = 0; worker_idx = 0; zero_idx = RTE_MAX_LCORE; + zero_quit = 0; + zero_sleep = 0; } static int -- 2.20.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-10-28 10:35:17.654469274 +0000 +++ 0192-test-distributor-fix-race-conditions-on-shutdown.patch 2020-10-28 10:35:11.800834381 +0000 @@ -1,15 +1,16 @@ -From 92e69743ed18692a1470396c4e7e47246c2191a5 Mon Sep 17 00:00:00 2001 +From c26c6e434ba2fe8863f8a6fce27b030703742243 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") -Cc: stable@dpdk.org Signed-off-by: Lukasz Wojciechowski Acked-by: David Hunt @@ -18,7 +19,7 @@ 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/test/test_distributor.c b/app/test/test_distributor.c -index 3f0aeb7b90..fdb6ea9ceb 100644 +index 7219925521..e9e8e2c7af 100644 --- a/app/test/test_distributor.c +++ b/app/test/test_distributor.c @@ -27,6 +27,7 @@ struct worker_params worker_params;