patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Christian Ehrhardt <christian.ehrhardt@canonical.com>
To: Erik Gabriel Carrillo <erik.g.carrillo@intel.com>
Cc: harry.van.haaren@intel.com, stable@dpdk.org
Subject: Re: [PATCH 19.11] service: fix early move to inactive status
Date: Thu, 17 Nov 2022 08:40:17 +0100	[thread overview]
Message-ID: <CAATJJ0KmJG_q-4rbP+SJ8BycviPRLxDpM+Nsj8PjtU-=fHoimw@mail.gmail.com> (raw)
In-Reply-To: <20221116183430.1926243-1-erik.g.carrillo@intel.com>

On Wed, Nov 16, 2022 at 7:34 PM Erik Gabriel Carrillo
<erik.g.carrillo@intel.com> 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 <erik.g.carrillo@intel.com>
> ---
>  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

      reply	other threads:[~2022-11-17  7:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-16 18:34 Erik Gabriel Carrillo
2022-11-17  7:40 ` Christian Ehrhardt [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAATJJ0KmJG_q-4rbP+SJ8BycviPRLxDpM+Nsj8PjtU-=fHoimw@mail.gmail.com' \
    --to=christian.ehrhardt@canonical.com \
    --cc=erik.g.carrillo@intel.com \
    --cc=harry.van.haaren@intel.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).