DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: Harry van Haaren <harry.van.haaren@intel.com>
Cc: dev@dpdk.org, thomas@monjalon.net, pbhagavatula@caviumnetworks.com
Subject: Re: [dpdk-dev] [PATCH v2] service: fix race in service on app lcore function
Date: Thu, 2 Nov 2017 09:41:05 +0000	[thread overview]
Message-ID: <20171102094105.GB19712@bricha3-MOBL3.ger.corp.intel.com> (raw)
In-Reply-To: <1509562081-52763-1-git-send-email-harry.van.haaren@intel.com>

On Wed, Nov 01, 2017 at 06:48:01PM +0000, Harry van Haaren wrote:
> This commit fixes a possible race condition if an application
> uses the service-cores infrastructure and the function to run
> a service on an application lcore at the same time.
> 
> The fix is to change the num_mapped_cores variable to be an
> atomic variable. This causes concurrent accesses by multiple
> threads to a service using rte_service_run_iter_on_app_lcore()
> to detect if another core is currently mapped to the service,
> and refuses to run if it is not multi-thread safe.
> 
> The run iteration on app lcore function has two arguments, the
> service id to run, and if atomics should be used to serialize access
> to multi-thread unsafe services. This allows applications to choose
> if they wish to use use the service-cores feature, or if they
> take responsibility themselves for serializing invoking a service.
> See doxygen documentation for more details.
> 
> Two unit tests were added to verify the behaviour of the
> function to run a service on an application core, testing both
> a multi-thread safe service, and a multi-thread unsafe service.
> 
> The doxygen API documentation for the function has been updated
> to reflect the current and correct behaviour.
> 
> Fixes: e9139a32f6e8 ("service: add function to run on app lcore")
> 
> Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
> 
> ---
> 
> v2:
> - Rework function to have parameter that allows the application
>   to select if it requires atomics to be used of it the application
>   wishes to take responsibility for serializing instead.
> 
This approach seems better to me. I think the function itself might be
better if you just duplicated a bit more code to reduce the number of
checks on the serialization variable, but it's readable enough as it is
now, so

Acked-by: Bruce Richardson <bruce.richardson@intel.com>

  reply	other threads:[~2017-11-02  9:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-31 11:49 [dpdk-dev] [PATCH] " Harry van Haaren
2017-11-01 17:09 ` Bruce Richardson
2017-11-01 17:59   ` Van Haaren, Harry
2017-11-02  9:10     ` Bruce Richardson
2017-11-01 18:48 ` [dpdk-dev] [PATCH v2] " Harry van Haaren
2017-11-02  9:41   ` Bruce Richardson [this message]
2017-11-07  0:26     ` Thomas Monjalon

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=20171102094105.GB19712@bricha3-MOBL3.ger.corp.intel.com \
    --to=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=harry.van.haaren@intel.com \
    --cc=pbhagavatula@caviumnetworks.com \
    --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).