DPDK usage discussions
 help / color / Atom feed
* [dpdk-users] Sharing Data structure between logical cores in DPDK- regarding
@ 2019-12-05 10:16 Perugu Hemasai Chandra Prasad
  2019-12-05 10:42 ` [dpdk-users] [dpdk-dev] " Tom Barbette
  0 siblings, 1 reply; 7+ messages in thread
From: Perugu Hemasai Chandra Prasad @ 2019-12-05 10:16 UTC (permalink / raw)
  To: users, dev

Hi All,
          I have a small doubt, can we share a data structure between
multiple logical cores in DPDK without locking? I have tested it by sharing
a small structure with two variable and incrementing them in all logical
cores. It ran smooth I didn't get any issue. But I doubt if we can run it
for long time with some huge data structure having many elements getting
accessed by multiple logical cores.
     Can anyone please clarify this.

Thanks and regards,
Hemasai.

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

* Re: [dpdk-users] [dpdk-dev] Sharing Data structure between logical cores in DPDK- regarding
  2019-12-05 10:16 [dpdk-users] Sharing Data structure between logical cores in DPDK- regarding Perugu Hemasai Chandra Prasad
@ 2019-12-05 10:42 ` " Tom Barbette
  2019-12-05 10:54   ` Van Haaren, Harry
  2019-12-10  5:56   ` Honnappa Nagarahalli
  0 siblings, 2 replies; 7+ messages in thread
From: Tom Barbette @ 2019-12-05 10:42 UTC (permalink / raw)
  To: Perugu Hemasai Chandra Prasad, users, dev

It depends on the datastructure.

If you use rte_hash, with the thread safety flags, it's safe.

In any case having a lot of cores accessing the same DS will lead to bad performance. You should try to have per-core data structures whenever possible.

Tom

________________________________________
De : dev <dev-bounces@dpdk.org> de la part de Perugu Hemasai Chandra Prasad <hemasaiperugu@5g.iith.ac.in>
Envoyé : jeudi 5 décembre 2019 11:16
À : users@dpdk.org; dev@dpdk.org
Objet : [dpdk-dev] Sharing Data structure between logical cores in DPDK-        regarding

Hi All,
          I have a small doubt, can we share a data structure between
multiple logical cores in DPDK without locking? I have tested it by sharing
a small structure with two variable and incrementing them in all logical
cores. It ran smooth I didn't get any issue. But I doubt if we can run it
for long time with some huge data structure having many elements getting
accessed by multiple logical cores.
     Can anyone please clarify this.

Thanks and regards,
Hemasai.

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

* Re: [dpdk-users] [dpdk-dev] Sharing Data structure between logical cores in DPDK- regarding
  2019-12-05 10:42 ` [dpdk-users] [dpdk-dev] " Tom Barbette
@ 2019-12-05 10:54   ` Van Haaren, Harry
  2019-12-06 16:30     ` Stephen Hemminger
  2019-12-10  5:56   ` Honnappa Nagarahalli
  1 sibling, 1 reply; 7+ messages in thread
From: Van Haaren, Harry @ 2019-12-05 10:54 UTC (permalink / raw)
  To: Tom Barbette, Perugu Hemasai Chandra Prasad, users, dev

> -----Original Message-----
> From: users <users-bounces@dpdk.org> On Behalf Of Tom Barbette
> Sent: Thursday, December 5, 2019 10:42 AM
> To: Perugu Hemasai Chandra Prasad <hemasaiperugu@5g.iith.ac.in>;
> users@dpdk.org; dev@dpdk.org
> Subject: Re: [dpdk-users] [dpdk-dev] Sharing Data structure between logical
> cores in DPDK- regarding
> 
> It depends on the datastructure.
> 
> If you use rte_hash, with the thread safety flags, it's safe.
> 
> In any case having a lot of cores accessing the same DS will lead to bad
> performance. You should try to have per-core data structures whenever
> possible.
> 
> Tom
> 
> ________________________________________
> De : dev <dev-bounces@dpdk.org> de la part de Perugu Hemasai Chandra Prasad
> <hemasaiperugu@5g.iith.ac.in>
> Envoyé : jeudi 5 décembre 2019 11:16
> À : users@dpdk.org; dev@dpdk.org
> Objet : [dpdk-dev] Sharing Data structure between logical cores in DPDK-
> regarding
> 
> Hi All,

Hi!

>           I have a small doubt, can we share a data structure between
> multiple logical cores in DPDK without locking?

Note that "locking" and "atomic instructions" are not the same. So locking a mutex is only one way of ensuring multiple cores have a coherent view on the datastructure.

The other method of doing "lock free" but multi-core safe data-structures is by using Atomic instructions, which ensure that results are observed correctly on all cores accessing that data-structure. A good example is the Multi-producer or Multi-consumer versions of the DPDK rte_ring ringbuffer.

Regards, -Harry

> I have tested it by sharing
> a small structure with two variable and incrementing them in all logical
> cores. It ran smooth I didn't get any issue. But I doubt if we can run it
> for long time with some huge data structure having many elements getting
> accessed by multiple logical cores.
>      Can anyone please clarify this.
> 
> Thanks and regards,
> Hemasai.

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

* Re: [dpdk-users] [dpdk-dev] Sharing Data structure between logical cores in DPDK- regarding
  2019-12-05 10:54   ` Van Haaren, Harry
@ 2019-12-06 16:30     ` Stephen Hemminger
  2019-12-06 16:51       ` Van Haaren, Harry
  0 siblings, 1 reply; 7+ messages in thread
From: Stephen Hemminger @ 2019-12-06 16:30 UTC (permalink / raw)
  To: Van Haaren, Harry; +Cc: Tom Barbette, Perugu Hemasai Chandra Prasad, users, dev

On Thu, 5 Dec 2019 10:54:59 +0000
"Van Haaren, Harry" <harry.van.haaren@intel.com> wrote:

>          I have a small doubt, can we share a data structure between
> > multiple logical cores in DPDK without locking?  

Sure, learn to use RCU!!

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

* Re: [dpdk-users] [dpdk-dev] Sharing Data structure between logical cores in DPDK- regarding
  2019-12-06 16:30     ` Stephen Hemminger
@ 2019-12-06 16:51       ` Van Haaren, Harry
  2019-12-06 17:01         ` Stephen Hemminger
  0 siblings, 1 reply; 7+ messages in thread
From: Van Haaren, Harry @ 2019-12-06 16:51 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Tom Barbette, Perugu Hemasai Chandra Prasad, users, dev

> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Friday, December 6, 2019 4:31 PM
> To: Van Haaren, Harry <harry.van.haaren@intel.com>
> Cc: Tom Barbette <barbette@kth.se>; Perugu Hemasai Chandra Prasad
> <hemasaiperugu@5g.iith.ac.in>; users@dpdk.org; dev@dpdk.org
> Subject: Re: [dpdk-users] [dpdk-dev] Sharing Data structure between logical
> cores in DPDK- regarding

Hey Stephen,

[OT] Please watch your snipping of > characters and Wrote: strings, I'm not the original author of the question, but from snipping it looks like that below.


> On Thu, 5 Dec 2019 10:54:59 +0000
> "Van Haaren, Harry" <harry.van.haaren@intel.com> wrote:
> 
> >          I have a small doubt, can we share a data structure between
> > > multiple logical cores in DPDK without locking?
> 
> Sure, learn to use RCU!!

Good suggestion, apart from Atomics or Mutex based locking schemes, RCU (Read Copy Update) is another method of (semi) synchronizing/sharing data-structures across threads.

DPDK has some RCU mechanics in lib/librte_rcu/ library, perhaps they are of interest. The implementation here is particularly for reclaiming memory after a Quiescent State point has been reached by all threads.

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

* Re: [dpdk-users] [dpdk-dev] Sharing Data structure between logical cores in DPDK- regarding
  2019-12-06 16:51       ` Van Haaren, Harry
@ 2019-12-06 17:01         ` Stephen Hemminger
  0 siblings, 0 replies; 7+ messages in thread
From: Stephen Hemminger @ 2019-12-06 17:01 UTC (permalink / raw)
  To: Van Haaren, Harry; +Cc: Tom Barbette, Perugu Hemasai Chandra Prasad, users, dev

On Fri, 6 Dec 2019 16:51:40 +0000
"Van Haaren, Harry" <harry.van.haaren@intel.com> wrote:

> > -----Original Message-----
> > From: Stephen Hemminger <stephen@networkplumber.org>
> > Sent: Friday, December 6, 2019 4:31 PM
> > To: Van Haaren, Harry <harry.van.haaren@intel.com>
> > Cc: Tom Barbette <barbette@kth.se>; Perugu Hemasai Chandra Prasad
> > <hemasaiperugu@5g.iith.ac.in>; users@dpdk.org; dev@dpdk.org
> > Subject: Re: [dpdk-users] [dpdk-dev] Sharing Data structure between logical
> > cores in DPDK- regarding  
> 
> Hey Stephen,
> 
> [OT] Please watch your snipping of > characters and Wrote: strings, I'm not the original author of the question, but from snipping it looks like that below.

Harry, I just use bottom posting as is commonly done in open source mailing lists.
So if your comments are mixed in with earlier text it will get confusing

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

* Re: [dpdk-users] [dpdk-dev] Sharing Data structure between logical cores in DPDK- regarding
  2019-12-05 10:42 ` [dpdk-users] [dpdk-dev] " Tom Barbette
  2019-12-05 10:54   ` Van Haaren, Harry
@ 2019-12-10  5:56   ` Honnappa Nagarahalli
  1 sibling, 0 replies; 7+ messages in thread
From: Honnappa Nagarahalli @ 2019-12-10  5:56 UTC (permalink / raw)
  To: Tom Barbette, Perugu Hemasai Chandra Prasad, users, dev; +Cc: nd, nd

<snip>

> 
> It depends on the datastructure.
> 
> If you use rte_hash, with the thread safety flags, it's safe.
> 
> In any case having a lot of cores accessing the same DS will lead to bad
> performance. You should try to have per-core data structures whenever
> possible.
Even better if you can create a lock free data structure and combine it with RCU. You can look at lock-free version of rte_hash implementation. There was a presentation done on this topic in the previous DPDK summit[1].

[1] https://dpdkuserspace2018.sched.com/event/G44w/lock-free-read-write-concurrency-in-rtehash
> 
> Tom
> 
> ________________________________________
> De : dev <dev-bounces@dpdk.org> de la part de Perugu Hemasai Chandra
> Prasad <hemasaiperugu@5g.iith.ac.in> Envoyé : jeudi 5 décembre 2019
> 11:16 À : users@dpdk.org; dev@dpdk.org
> Objet : [dpdk-dev] Sharing Data structure between logical cores in DPDK-
> regarding
> 
> Hi All,
>           I have a small doubt, can we share a data structure between multiple
> logical cores in DPDK without locking? I have tested it by sharing a small
> structure with two variable and incrementing them in all logical cores. It ran
> smooth I didn't get any issue. But I doubt if we can run it for long time with
> some huge data structure having many elements getting accessed by multiple
> logical cores.
>      Can anyone please clarify this.
> 
> Thanks and regards,
> Hemasai.

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

end of thread, back to index

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-05 10:16 [dpdk-users] Sharing Data structure between logical cores in DPDK- regarding Perugu Hemasai Chandra Prasad
2019-12-05 10:42 ` [dpdk-users] [dpdk-dev] " Tom Barbette
2019-12-05 10:54   ` Van Haaren, Harry
2019-12-06 16:30     ` Stephen Hemminger
2019-12-06 16:51       ` Van Haaren, Harry
2019-12-06 17:01         ` Stephen Hemminger
2019-12-10  5:56   ` Honnappa Nagarahalli

DPDK usage discussions

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/users/0 users/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 users users/ http://inbox.dpdk.org/users \
		users@dpdk.org
	public-inbox-index users


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.users


AGPL code for this site: git clone https://public-inbox.org/ public-inbox