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 66FFFA00C2 for ; Thu, 17 Nov 2022 08:40:45 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 631EF40DDC; Thu, 17 Nov 2022 08:40:45 +0100 (CET) Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by mails.dpdk.org (Postfix) with ESMTP id E982740DDA for ; Thu, 17 Nov 2022 08:40:44 +0100 (CET) Received: from mail-oo1-f71.google.com (mail-oo1-f71.google.com [209.85.161.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 854753F199 for ; Thu, 17 Nov 2022 07:40:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1668670844; bh=cUOG5MyAJM5X1K3QsTMlC03oSO9oSP6F9TAVqYaHgog=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Q9uhcL+V5wctu/1+ZQ1o8bbqhaEPmmTkPV806HJxislFyLmhOfL4s3PlyUyWndunt lT76B7GzxrRowCPsmuCQRru35XQGT+83qD5eqg6qEWzdfA1JhODCm33WUzrQVZeVLt QMDAQ3n9DeXXaikQvDgHULmbDFHLbYLSFU5ePopa/NvTk8BzCvV3Baqfs7czqgUw7f hAH4CV/npvOxouNl6npMynohtlMvoxvcmjZjQZFYZUacrF62C2aT02RLUUTgAyGN9Q s5A1TVlyNQvGYYWvikYx0g1IAoBA0a2A6EHRuWOQem+50SDfiB4oxFlA1piG26//1b jUHUayykHGcUA== Received: by mail-oo1-f71.google.com with SMTP id k3-20020a4a3103000000b0049eef7e70caso555229ooa.18 for ; Wed, 16 Nov 2022 23:40:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=cUOG5MyAJM5X1K3QsTMlC03oSO9oSP6F9TAVqYaHgog=; b=6fm1TeILIGbhOk1B9vddZ57n35qMDesEj50U5idZHWRQZ8fy4M+/0TbtnegjMoqMZt BOCZ41HZm54Fab/OMOBdRgcs/kd61f0eAqtr8g6KmIQQ86cJcKkQH9dO6XntpZ/RSWsl SUOHYK4oCSf1/PabWcwTXbTkuK9a8NehhYbw5SVn6FgoBZNJerp7/u/DGNK1PBxdikpZ 2oTYZyb65q4APw17lReyNu3EeQGtKauReR4BNZyzH3ORCqYslX6AIjxuK3c3j6NdMypu rExqGGb67wswttfR1odGijZgy/OuCJIV7odTXhgv6jCLkFIqWq+FzNKj3t2Qwx9+2qYk lRvw== X-Gm-Message-State: ANoB5plL3KX6lXCQN01UuI5dEJ7sxV44FtCODaFbBhhYMDuQTJ1iMMYW 8w2QwPyBSZYr8qRk/Mh9TgwgziU8lVz08noYBwkseui+O4F+KdECjmeWQ2O/5WRs0ZUxkqGnZem FVKrQD4K08gVUepJkxPegE6f+GfYKoUZNwOKAF7D8 X-Received: by 2002:a05:6808:f8e:b0:35a:6005:3d90 with SMTP id o14-20020a0568080f8e00b0035a60053d90mr542412oiw.127.1668670843250; Wed, 16 Nov 2022 23:40:43 -0800 (PST) X-Google-Smtp-Source: AA0mqf5F1TGL06sFXuldtoVV/dwX7zarisCq7lWeWpB0AJhotwtlMrP/FjhLKrGJ6r8ftX5lReosCd+80wjzCc9rt7A= X-Received: by 2002:a05:6808:f8e:b0:35a:6005:3d90 with SMTP id o14-20020a0568080f8e00b0035a60053d90mr542407oiw.127.1668670843027; Wed, 16 Nov 2022 23:40:43 -0800 (PST) MIME-Version: 1.0 References: <20221116183430.1926243-1-erik.g.carrillo@intel.com> In-Reply-To: <20221116183430.1926243-1-erik.g.carrillo@intel.com> From: Christian Ehrhardt Date: Thu, 17 Nov 2022 08:40:17 +0100 Message-ID: Subject: Re: [PATCH 19.11] service: fix early move to inactive status To: Erik Gabriel Carrillo Cc: harry.van.haaren@intel.com, stable@dpdk.org Content-Type: text/plain; charset="UTF-8" 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 On Wed, Nov 16, 2022 at 7:34 PM Erik Gabriel Carrillo wrote: > > [ upstream commit 329280c53e6d09002b67e4d052fe27a952bd19cf ] Applied, thanks! > 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: 3d3bcdcee4 ("service: fix lingering active status") > > Signed-off-by: Erik Gabriel Carrillo > --- > 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 d11027fcb..11cd5a538 100644 > --- a/lib/librte_eal/common/rte_service.c > +++ b/lib/librte_eal/common/rte_service.c > @@ -447,6 +447,12 @@ service_runner_func(void *arg) > rte_smp_rmb(); > } > > + /* 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; > + > return 0; > } > > @@ -717,11 +723,6 @@ rte_service_lcore_stop(uint32_t lcore) > int32_t only_core = (1 == > rte_atomic32_read(&rte_services[i].num_mapped_cores)); > > - /* 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.23.0 > -- Christian Ehrhardt Senior Staff Engineer, Ubuntu Server Canonical Ltd