Should list_entry_rcu use rcu_dereference ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux