DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] Question regarding concurrency and hash table
@ 2014-05-12  8:29 Tomas Vestelind
  2014-05-12  9:18 ` Vladimir Medvedkin
  0 siblings, 1 reply; 2+ messages in thread
From: Tomas Vestelind @ 2014-05-12  8:29 UTC (permalink / raw)
  To: dev

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-dev] Question regarding concurrency and hash table
  2014-05-12  8:29 [dpdk-dev] Question regarding concurrency and hash table Tomas Vestelind
@ 2014-05-12  9:18 ` Vladimir Medvedkin
  0 siblings, 0 replies; 2+ messages in thread
From: Vladimir Medvedkin @ 2014-05-12  9:18 UTC (permalink / raw)
  To: Tomas Vestelind; +Cc: dev

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
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-05-12  9:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-12  8:29 [dpdk-dev] Question regarding concurrency and hash table Tomas Vestelind
2014-05-12  9:18 ` Vladimir Medvedkin

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).