From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A6769A0543 for ; Sat, 5 Nov 2022 18:12:11 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9F66840151; Sat, 5 Nov 2022 18:12:11 +0100 (CET) Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by mails.dpdk.org (Postfix) with ESMTP id 8579542D1C for ; Sat, 5 Nov 2022 18:12:10 +0100 (CET) Received: by mail-wr1-f42.google.com with SMTP id bs21so10899178wrb.4 for ; Sat, 05 Nov 2022 10:12:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xWeeYNI1tObc+Hrjm96EVVWVxNSUfuKyJ0I52n5iLTA=; b=CEj+wt2QuVxZnAqnbetZXkTjNEBUFrgtuEYADGSD+1vFuDH8GHqaMKpF6cOkOlFeut cabeKIWd61RrWAFxWg7OiyyWnTtdrEXuzNMHuwyxgpUx9HDLO/uKG3kp3EwOTYAXiOez Q/CoCLWnIsMZR+Mn8vg/9FEPlAak6Z2xn3aynZFg4P3OLRZ5fehM3+Cmu0qIASBXsWKB D8G3+vOGeH0PyzMUxXKQo6DmV3p7ankMKqrtvP1ro9IBPY/j1WglWmLxziGoQHSlfay1 c5nx2gNkWK/pLT4kQU78+ja7FipSQPKZ+oeG+Y8r+c26Gi7FrMbC3GY4V/JTH5vp1iqs 93dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xWeeYNI1tObc+Hrjm96EVVWVxNSUfuKyJ0I52n5iLTA=; b=D35VwZgsqTeW3f/eLissUOgpUTFOXVtJaYIv6cGWx0Aq3lkztU6o6Ez8myy9bkTxx8 ZPyGki3jKZXtlmfuD562BpDeAMb2gE2qzGZbYnOEx1k+55o41xUshYLxtL2qSQ9zetEQ t0nf3gseu83WsVdFdDnt+UjX2GGUlFwST1ToF4AnlRjlWJM9rPkl6g8jiBGlvDLTXsjy 2RbS1pmlOejo7TBWuVm4g2wRCbtnDA8t6LsFyVu3IK0493BPaXKUjf2RSMXRbCcHaBql KsoEH0BOd7cMlr8hYN5JjZKIERnn2/bzVF8WoatrFZ9lKJzB2Zrc8XMbFMktQRk/NZPy zK2Q== X-Gm-Message-State: ACrzQf29LYMYJ3+6ZAdr4AkkMe5Zegw8bN5bmjlLN8Js5+qzHvunibMY VDvL5ssGlWZW+ygGUc32cQMYiAioElk= X-Google-Smtp-Source: AMsMyM7fRT8aTMoRQOtXH2eL7bWyANb7ThXAON9ApSAjASXeUd8pQnH843Au7fIWU9fv/gCPLvfq3g== X-Received: by 2002:a5d:548d:0:b0:236:debd:f285 with SMTP id h13-20020a5d548d000000b00236debdf285mr17742633wrv.640.1667668330267; Sat, 05 Nov 2022 10:12:10 -0700 (PDT) Received: from localhost ([2a01:4b00:d307:1000:f1d3:eb5e:11f4:a7d9]) by smtp.gmail.com with ESMTPSA id h18-20020a5d6e12000000b002365730eae8sm2616722wrz.55.2022.11.05.10.12.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Nov 2022 10:12:09 -0700 (PDT) From: luca.boccassi@gmail.com To: Erik Gabriel Carrillo Cc: Harry van Haaren , dpdk stable Subject: patch 'service: fix early move to inactive status' has been queued to stable release 20.11.7 Date: Sat, 5 Nov 2022 17:11:07 +0000 Message-Id: <20221105171146.1520039-8-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221105171146.1520039-1-luca.boccassi@gmail.com> References: <20221103092758.1099402-100-luca.boccassi@gmail.com> <20221105171146.1520039-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 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 Hi, FYI, your patch has been queued to stable release 20.11.7 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/07/22. 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 This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/1cd5de2a59f596d88058f2a46792113308e66bde Thanks. Luca Boccassi --- >From 1cd5de2a59f596d88058f2a46792113308e66bde Mon Sep 17 00:00:00 2001 From: Erik Gabriel Carrillo Date: Thu, 20 Oct 2022 14:00:41 -0500 Subject: [PATCH] service: fix early move to inactive status [ upstream commit 329280c53e6d09002b67e4d052fe27a952bd19cf ] Assume thread T2 is a service lcore that is in the middle of executing a service function. Also, assume thread T1 concurrently calls rte_service_lcore_stop(), which will set the "service_active_on_lcore" state to false. If thread T1 then calls rte_service_may_be_active(), it can return zero even though T2 is still running the service function. If T1 then proceeds to free data being used by T2, a crash can ensue. Move the logic that clears the "service_active_on_lcore" state from the rte_service_lcore_stop() function to the service_runner_func() to ensure that we: - don't let the "service_active_on_lcore" state linger as 1 - don't clear the state early Fixes: 6550113be62d ("service: fix lingering active status") Signed-off-by: Erik Gabriel Carrillo Acked-by: Harry van Haaren --- lib/librte_eal/common/rte_service.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/librte_eal/common/rte_service.c b/lib/librte_eal/common/rte_service.c index d5e3574ec7..e1ff0d2636 100644 --- a/lib/librte_eal/common/rte_service.c +++ b/lib/librte_eal/common/rte_service.c @@ -501,6 +501,12 @@ service_runner_func(void *arg) cs->loops++; } + /* Switch off this core for all services, to ensure that future + * calls to may_be_active() know this core is switched off. + */ + for (i = 0; i < RTE_SERVICE_NUM_MAX; i++) + cs->service_active_on_lcore[i] = 0; + /* Use SEQ CST memory ordering to avoid any re-ordering around * this store, ensuring that once this store is visible, the service * lcore thread really is done in service cores code. @@ -797,11 +803,6 @@ rte_service_lcore_stop(uint32_t lcore) __atomic_load_n(&rte_services[i].num_mapped_cores, __ATOMIC_RELAXED)); - /* Switch off this core for all services, to ensure that future - * calls to may_be_active() know this core is switched off. - */ - cs->service_active_on_lcore[i] = 0; - /* if the core is mapped, and the service is running, and this * is the only core that is mapped, the service would cease to * run if this core stopped, so fail instead. -- 2.34.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2022-11-05 17:11:09.436133306 +0000 +++ 0008-service-fix-early-move-to-inactive-status.patch 2022-11-05 17:11:08.578940581 +0000 @@ -1 +1 @@ -From 329280c53e6d09002b67e4d052fe27a952bd19cf Mon Sep 17 00:00:00 2001 +From 1cd5de2a59f596d88058f2a46792113308e66bde Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 329280c53e6d09002b67e4d052fe27a952bd19cf ] + @@ -20 +21,0 @@ -Cc: stable@dpdk.org @@ -25,2 +26,2 @@ - lib/eal/common/rte_service.c | 13 +++++++------ - 1 file changed, 7 insertions(+), 6 deletions(-) + lib/librte_eal/common/rte_service.c | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) @@ -28,22 +29,6 @@ -diff --git a/lib/eal/common/rte_service.c b/lib/eal/common/rte_service.c -index 81c9514149..bcc2e19077 100644 ---- a/lib/eal/common/rte_service.c -+++ b/lib/eal/common/rte_service.c -@@ -479,6 +479,7 @@ static int32_t - service_runner_func(void *arg) - { - RTE_SET_USED(arg); -+ uint8_t i; - const int lcore = rte_lcore_id(); - struct core_state *cs = &lcore_states[lcore]; - -@@ -494,7 +495,6 @@ service_runner_func(void *arg) - const uint64_t service_mask = cs->service_mask; - uint8_t start_id; - uint8_t end_id; -- uint8_t i; - - if (service_mask == 0) - continue; -@@ -510,6 +510,12 @@ service_runner_func(void *arg) - __atomic_store_n(&cs->loops, cs->loops + 1, __ATOMIC_RELAXED); +diff --git a/lib/librte_eal/common/rte_service.c b/lib/librte_eal/common/rte_service.c +index d5e3574ec7..e1ff0d2636 100644 +--- a/lib/librte_eal/common/rte_service.c ++++ b/lib/librte_eal/common/rte_service.c +@@ -501,6 +501,12 @@ service_runner_func(void *arg) + cs->loops++; @@ -61 +46 @@ -@@ -806,11 +812,6 @@ rte_service_lcore_stop(uint32_t lcore) +@@ -797,11 +803,6 @@ rte_service_lcore_stop(uint32_t lcore)