patches for DPDK stable branches
 help / color / mirror / Atom feed
From: "Van Haaren, Harry" <harry.van.haaren@intel.com>
To: Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>,
	Phil Yang <Phil.Yang@arm.com>,
	"thomas@monjalon.net" <thomas@monjalon.net>,
	"Ananyev, Konstantin" <konstantin.ananyev@intel.com>,
	"stephen@networkplumber.org" <stephen@networkplumber.org>,
	"maxime.coquelin@redhat.com" <maxime.coquelin@redhat.com>,
	"dev@dpdk.org" <dev@dpdk.org>
Cc: "david.marchand@redhat.com" <david.marchand@redhat.com>,
	"jerinj@marvell.com" <jerinj@marvell.com>,
	"hemant.agrawal@nxp.com" <hemant.agrawal@nxp.com>,
	Gavin Hu <Gavin.Hu@arm.com>, Ruifeng Wang <Ruifeng.Wang@arm.com>,
	Joyce Kong <Joyce.Kong@arm.com>, nd <nd@arm.com>,
	"stable@dpdk.org" <stable@dpdk.org>, nd <nd@arm.com>,
	nd <nd@arm.com>
Subject: Re: [dpdk-stable] [PATCH v3 09/12] service: avoid race condition for MT unsafe service
Date: Tue, 21 Apr 2020 17:43:40 +0000	[thread overview]
Message-ID: <BYAPR11MB31432F1B283E75E2D9525C17D7D50@BYAPR11MB3143.namprd11.prod.outlook.com> (raw)
In-Reply-To: <DBBPR08MB464683996C2AFF93FB7D149298D60@DBBPR08MB4646.eurprd08.prod.outlook.com>

> -----Original Message-----
> From: Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>
> Sent: Saturday, April 18, 2020 7:22 AM
> To: Van Haaren, Harry <harry.van.haaren@intel.com>; Phil Yang
> <Phil.Yang@arm.com>; thomas@monjalon.net; Ananyev, Konstantin
> <konstantin.ananyev@intel.com>; stephen@networkplumber.org;
> maxime.coquelin@redhat.com; dev@dpdk.org
> Cc: david.marchand@redhat.com; jerinj@marvell.com;
> hemant.agrawal@nxp.com; Gavin Hu <Gavin.Hu@arm.com>; Ruifeng Wang
> <Ruifeng.Wang@arm.com>; Joyce Kong <Joyce.Kong@arm.com>; nd
> <nd@arm.com>; stable@dpdk.org; nd <nd@arm.com>; Honnappa Nagarahalli
> <Honnappa.Nagarahalli@arm.com>; nd <nd@arm.com>
> Subject: RE: [PATCH v3 09/12] service: avoid race condition for MT unsafe service
> 
> <snip>
<snip snip>
> > > > To achieve our desired goal;
> > > >  - control thread doing mapping performs the following operations
> > > >     -- write service->num_mapped_lcores++ (atomic not required, only
> > > > single- writer allowed by APIs)
> > > This has to be atomic because of rte_service_run_iter_on_app_lcore API.
> > > Performance should be fine as this API is not called frequently. But
> > > need to consider the implications of more than one thread updating
> > num_mapped_cores.
> > >
> > > >     -- MFENCE (full st-ld barrier) to flush write, and force later
> > > > loads to
> > > issue
> > > > after
> > > I am not exactly sure what MFENCE on x86 does. On Arm platforms, the
> > > full barrier (DMB ISH) just makes sure that memory operations are not
> > > re-ordered around it. It does not say anything about when that store
> > > is visible to other cores. It will be visible at some point in time to cores.
> > > But, I do not think we need to be worried about flushing to memory.
> > >
> > > >     -- read the "calls_per_service" counter for each lcores, add them up.
> > > This can be trimmed down to the single core the service is mapped to
> > > currently, no need to add all the counters.
> >
> > Correct - however that requires figuring out which lcore is running the service.
> > Anyway, agree - it's an implementation detail as to exactly how we detect it.
> >
> > >
> > > >     ---- Wait :)
> > > >     -- re-read the "calls_per_service", and ensure the count has changed.
> Here, there is an assumption that the service core function is running on the
> service core. If the service core is not running, the code will be stuck in this
> polling loop.

Right - we could add a timeout ehre, but that just moves the problem somewhere
else (the application) which now needs to handle error rets, and possibly retries.
It could be a possible solution.. I'm not in favour of it at the moment, but it
needs some more time to think.

> I could not come up with a good way to check if the service core is running.
> Checking the app_runstate and comp_runstate is not enough as they just
> indicate that the service is ready to run. Using the counter 'calls_per_service'
> introduces race conditions.
> 
> Only way I can think of is asking the user to follow a specific sequence of APIs to
> ensure the service core is running before calling rte_service_map_lcore_set.

Good point - I'm thinking about this - but haven't come to an obvious conclusion yet.
I'm considering other ways to detect the core is/isn't running, and also considering
just "high-jacking" the service function pointer temporarily with a CAS, which gives
some new options on avoiding threads entering the critical section.

As above, I don't have a good solution yet.

<snip irrelevant to above discussion stuff>

  reply	other threads:[~2020-04-21 17:43 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1583862551-2049-1-git-send-email-phil.yang@arm.com>
2020-03-10 17:49 ` [dpdk-stable] [PATCH 05/10] service: remove rte prefix from static functions Phil Yang
2020-03-10 17:49 ` [dpdk-stable] [PATCH 06/10] service: remove redundant code Phil Yang
2020-03-10 17:49 ` [dpdk-stable] [PATCH 07/10] service: avoid race condition for MT unsafe service Phil Yang
2020-03-10 17:49 ` [dpdk-stable] [PATCH 08/10] service: identify service running on another core correctly Phil Yang
     [not found] ` <1583993624-20446-1-git-send-email-phil.yang@arm.com>
2020-03-12  6:13   ` [dpdk-stable] [PATCH v2 05/10] service: remove rte prefix from static functions Phil Yang
2020-03-12  6:13   ` [dpdk-stable] [PATCH v2 06/10] service: remove redundant code Phil Yang
2020-03-12  6:13   ` [dpdk-stable] [PATCH v2 07/10] service: avoid race condition for MT unsafe service Phil Yang
2020-03-12  6:13   ` [dpdk-stable] [PATCH v2 08/10] service: identify service running on another core correctly Phil Yang
     [not found] ` <1583999071-22872-1-git-send-email-phil.yang@arm.com>
2020-03-12  7:44   ` [dpdk-stable] [PATCH v2 05/10] service: remove rte prefix from static functions Phil Yang
2020-03-12  7:44   ` [dpdk-stable] [PATCH v2 06/10] service: remove redundant code Phil Yang
2020-03-12  7:44   ` [dpdk-stable] [PATCH v2 07/10] service: avoid race condition for MT unsafe service Phil Yang
2020-03-12  7:44   ` [dpdk-stable] [PATCH v2 08/10] service: identify service running on another core correctly Phil Yang
     [not found]   ` <1584407863-774-1-git-send-email-phil.yang@arm.com>
2020-03-17  1:17     ` [dpdk-stable] [PATCH v3 07/12] service: remove rte prefix from static functions Phil Yang
2020-04-03 11:57       ` Van Haaren, Harry
2020-04-08 10:14         ` Phil Yang
2020-04-08 10:36           ` Van Haaren, Harry
2020-04-08 10:49             ` Phil Yang
2020-04-05 21:35       ` Honnappa Nagarahalli
2020-04-08 10:14         ` Phil Yang
     [not found]       ` <1587659482-27133-1-git-send-email-phil.yang@arm.com>
2020-04-23 16:31         ` [dpdk-stable] [PATCH v2 1/6] service: fix race condition for MT unsafe service Phil Yang
2020-04-29 16:51           ` Van Haaren, Harry
2020-04-29 22:48             ` Honnappa Nagarahalli
2020-05-01 14:21               ` Van Haaren, Harry
2020-05-01 14:56                 ` Honnappa Nagarahalli
2020-05-01 17:51                   ` Van Haaren, Harry
2020-04-23 16:31         ` [dpdk-stable] [PATCH v2 2/6] service: identify service running on another core correctly Phil Yang
     [not found]         ` <20200502000245.11071-1-honnappa.nagarahalli@arm.com>
2020-05-02  0:02           ` [dpdk-stable] [PATCH v3 1/6] service: fix race condition for MT unsafe service Honnappa Nagarahalli
2020-05-05 14:48             ` Van Haaren, Harry
2020-05-02  0:02           ` [dpdk-stable] [PATCH v3 2/6] service: identify service running on another core correctly Honnappa Nagarahalli
2020-05-05 14:48             ` Van Haaren, Harry
     [not found]         ` <20200505211732.25291-1-honnappa.nagarahalli@arm.com>
2020-05-05 21:17           ` [dpdk-stable] [PATCH v4 1/6] service: fix race condition for MT unsafe service Honnappa Nagarahalli
2020-05-05 21:17           ` [dpdk-stable] [PATCH v4 2/6] service: fix identification of service running on other lcore Honnappa Nagarahalli
     [not found]           ` <1588760683-11027-1-git-send-email-phil.yang@arm.com>
2020-05-06 10:24             ` [dpdk-stable] [PATCH v5 1/6] service: fix race condition for MT unsafe service Phil Yang
2020-05-06 10:24             ` [dpdk-stable] [PATCH v5 2/6] service: fix identification of service running on other lcore Phil Yang
     [not found]             ` <1588778884-13047-1-git-send-email-phil.yang@arm.com>
2020-05-06 15:27               ` [dpdk-stable] [PATCH v6 1/6] service: fix race condition for MT unsafe service Phil Yang
2020-05-06 15:28               ` [dpdk-stable] [PATCH v6 2/6] service: fix identification of service running on other lcore Phil Yang
2020-03-17  1:17     ` [dpdk-stable] [PATCH v3 08/12] service: remove redundant code Phil Yang
2020-04-03 11:58       ` Van Haaren, Harry
2020-04-05 18:35         ` Honnappa Nagarahalli
2020-04-08 10:15           ` Phil Yang
2020-03-17  1:17     ` [dpdk-stable] [PATCH v3 09/12] service: avoid race condition for MT unsafe service Phil Yang
2020-04-03 11:58       ` Van Haaren, Harry
2020-04-04 18:03         ` Honnappa Nagarahalli
2020-04-08 18:05           ` Van Haaren, Harry
2020-04-09  1:31             ` Honnappa Nagarahalli
2020-04-09 16:46               ` Van Haaren, Harry
2020-04-18  6:21                 ` Honnappa Nagarahalli
2020-04-21 17:43                   ` Van Haaren, Harry [this message]
2020-03-17  1:17     ` [dpdk-stable] [PATCH v3 10/12] service: identify service running on another core correctly Phil Yang
2020-04-03 11:58       ` Van Haaren, Harry
2020-04-05  2:43         ` Honnappa Nagarahalli

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=BYAPR11MB31432F1B283E75E2D9525C17D7D50@BYAPR11MB3143.namprd11.prod.outlook.com \
    --to=harry.van.haaren@intel.com \
    --cc=Gavin.Hu@arm.com \
    --cc=Honnappa.Nagarahalli@arm.com \
    --cc=Joyce.Kong@arm.com \
    --cc=Phil.Yang@arm.com \
    --cc=Ruifeng.Wang@arm.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=hemant.agrawal@nxp.com \
    --cc=jerinj@marvell.com \
    --cc=konstantin.ananyev@intel.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=nd@arm.com \
    --cc=stable@dpdk.org \
    --cc=stephen@networkplumber.org \
    --cc=thomas@monjalon.net \
    /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).