]> git.baikalelectronics.ru Git - kernel.git/commit
rcu: Replace list_first_entry_rcu() with list_first_or_null_rcu()
authorMichel Machado <michel@digirati.com.br>
Tue, 10 Apr 2012 18:07:40 +0000 (14:07 -0400)
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Wed, 25 Apr 2012 03:54:49 +0000 (20:54 -0700)
commit1445110bc33f3e978b5b90a8c1a633299c004497
tree650a2185c949330002bb4dce090f3257f2779ee6
parent420c545d91f61a6315d472f0cd141da94d6f13f7
rcu: Replace list_first_entry_rcu() with list_first_or_null_rcu()

The list_first_entry_rcu() macro is inherently unsafe because it cannot
be applied to an empty list.  But because RCU readers do not exclude
updaters, a list might become empty between the time that list_empty()
claimed it was non-empty and the time that list_first_entry_rcu() is
invoked.  Therefore, the list_empty() test cannot be separated from the
list_first_entry_rcu() call.  This commit therefore combines these to
macros to create a new list_first_or_null_rcu() macro that replaces
the old (and unsafe) list_first_entry_rcu() macro.

This patch incorporates Paul's review comments on the previous version of
this patch available here:

https://lkml.org/lkml/2012/4/2/536

This patch cannot break any upstream code because list_first_entry_rcu()
is not being used anywhere in the kernel (tested with grep(1)), and any
external code using it is probably broken as a result of using it.

Signed-off-by: Michel Machado <michel@digirati.com.br>
CC: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
CC: Dipankar Sarma <dipankar@in.ibm.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
include/linux/rculist.h