DPDK patches and discussions
 help / color / mirror / Atom feed
From: Vladimir Medvedkin <medvedkinv@gmail.com>
To: Tomas Vestelind <Tomas.Vestelind@hiq.se>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] Question regarding concurrency and hash table
Date: Mon, 12 May 2014 13:18:18 +0400	[thread overview]
Message-ID: <CANDrEHkyaAdVp8jXOALV2YtC-xG9RKLKBNC02teSNaoHzi9JMA@mail.gmail.com> (raw)
In-Reply-To: <EA933124232C9B42A1CD6FA8FCA48B4BB77084@hiqqbexc101.sto.hiq.se>

Hi,

Programmer's guide section 22.1:
<quote>
The hash and LPM libraries are, by design, thread unsafe in order to
maintain performance. However, if required the developer can add layers on
top of these libraries to provide thread safety. Locking is not needed in
all situations, and in both the hash and LPM libraries, lookups of values
can be performed in parallel in multiple threads. Adding, removing or
modifying values, however, cannot be done in multiple threads without using
locking when a single hash or LPM table is accessed. Another alternative to
locking would be to create multiple instances of these tables allowing each
thread its own copy.
</quote>

So, rte_hash_add_key() is not multi-thread safe unlike the
rte_hash_lookup() which is multi-thread safe. You can call add and lookup
func simultaneously if you make sure that rte_hash_add_key() call either
from single dedicated thread or protect by lock hash table.


2014-05-12 12:29 GMT+04:00 Tomas Vestelind <Tomas.Vestelind@hiq.se>:

> Hello all!
>
> I have a question regarding the possible concurrency issues in hash table.
> My questions is:
> Is it possible to call rte_hash_add() and rte_hash_lookup() at the same
> time without data inconsistency?
>
> My guess is that I need to use a lock as protection. I see that you have a
> couple of nice ones :)
>
> BR,
> Tomas Vestelind
>

      reply	other threads:[~2014-05-12  9:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-12  8:29 Tomas Vestelind
2014-05-12  9:18 ` Vladimir Medvedkin [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=CANDrEHkyaAdVp8jXOALV2YtC-xG9RKLKBNC02teSNaoHzi9JMA@mail.gmail.com \
    --to=medvedkinv@gmail.com \
    --cc=Tomas.Vestelind@hiq.se \
    --cc=dev@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).