rcu.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Should list_entry_rcu use rcu_dereference ?
@ 2019-05-04 18:59 Joel Fernandes
  2019-05-06 23:54 ` Paul E. McKenney
  0 siblings, 1 reply; 7+ messages in thread
From: Joel Fernandes @ 2019-05-04 18:59 UTC (permalink / raw)
  To: rcu, paulmck

Hi,
Sorry if this is a silly question.

Looking at the list_entry_rcu primitive, I see it does direct READ_ONCE
on ptr. That's Ok, but rcu_dereference also does additional lockdep and
sparse checking.  Why not call rcu_dereference instead of READ_ONCE? The
pointer may be dereference by the caller so IMO makes sense to check.

Here is the definition of list_entry_rcu:
/**
 * list_entry_rcu - get the struct for this entry
 [snip]
* This primitive may safely run concurrently with the _rcu list-mutation
 * primitives such as list_add_rcu() as long as it's guarded by rcu_read_lock().
 */
#define list_entry_rcu(ptr, type, member) \
	container_of(READ_ONCE(ptr), type, member)

Also, I was curious why hlist_for_each_entry_rcu() uses rcu_dereference_raw()
while __hlist_for_each_rcu)_ uses rcu_dereference(). I feel both should use
rcu_dereference to have the lockdep checking. Is this not done due to
performance reasons?

thanks!

  - Joel

https://cdn-images-1.medium.com/max/1600/0*XTYvSNj_rT2UZwfm.png

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

end of thread, other threads:[~2019-05-24 17:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-04 18:59 Should list_entry_rcu use rcu_dereference ? Joel Fernandes
2019-05-06 23:54 ` Paul E. McKenney
2019-05-13  3:30   ` Joel Fernandes
2019-05-14 22:20     ` Paul E. McKenney
2019-05-24  8:07       ` Joel Fernandes
2019-05-24 16:50         ` Joel Fernandes
2019-05-24 17:33           ` Paul E. McKenney

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