All of lore.kernel.org
 help / color / mirror / Atom feed
From: Olivier MATZ <olivier.matz-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
To: dvr <jinxiu.1006-9Onoh4P/yGk@public.gmane.org>
Cc: dev-VfR2kkLFssw@public.gmane.org
Subject: Re: Is ”rte_mempool_mp_put_bulk()“ multi-producer safe?
Date: Tue, 13 Aug 2013 13:47:32 +0200	[thread overview]
Message-ID: <520A1CD4.3020601@6wind.com> (raw)
In-Reply-To: <48188b20.1c74c.140765b52ce.Coremail.jinxiu.1006-9Onoh4P/yGk@public.gmane.org>

Hi,

>     My question is :rte_mempool_mp_put_bulk() and
> rte_mempool_sp_put_bulk() call the same function  __mempool_put_bulk()
> with different "is_mp" value. If is_mp=1, that is ,multi-producer, the
> code will add these objects in cache while there is enough room, when
> two thread enqueue objects at the same time, isn't it unsafe?but the
> annotation show this function is "multi-producer safe".

This is not the only difference: rte_mempool_mp_put() will call
rte_ring_mp_enqueue() to add the objects from cache to the common
pool. This function uses a compare_and_set() to update the head/tail
indexes.

And rte_mempool_sp_put() uses rte_ring_mp_enqueue() which is simpler but
not thread safe.

>     Another question: how many thread we can have on a core? just one?

Yes. Both mempool and ring are designed to run with one pthread per
lcore: mempool uses a per-lcore cache, and the ring_mp/mc functions
assume that a pthread is not interrupted by another pthread.

Regards,
Olivier

      parent reply	other threads:[~2013-08-13 11:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-13  6:27 Is ”rte_mempool_mp_put_bulk()“ multi-producer safe? dvr
     [not found] ` <48188b20.1c74c.140765b52ce.Coremail.jinxiu.1006-9Onoh4P/yGk@public.gmane.org>
2013-08-13 11:47   ` Olivier MATZ [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=520A1CD4.3020601@6wind.com \
    --to=olivier.matz-pdr9zngts4eavxtiumwx3w@public.gmane.org \
    --cc=dev-VfR2kkLFssw@public.gmane.org \
    --cc=jinxiu.1006-9Onoh4P/yGk@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.