Skip to content

rculist: Fix list_entry_rcu to read ptr with, rcu_dereference_raw

Patrick Marlier lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 8 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3rculist: Fix list_entry_rcu to read ptr with rcu_dereference_rawinclude/linux/rculist.h+0 -06 replies
2/3netfilter: fix list_entry_rcu usage.net/netfilter/core.c+1 -12 replies
3/3md/bitmap: fix list_entry_rcu usage.drivers/md/bitmap.c+1 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/3] rculist: Fix list_entry_rcu to read ptr with, rcu_dereference_raw

Hi Paul and Josh,

While running some benchmarks with rcu, I noticed that rculist had a performance issue compared to the non-rcu list. Having a closer look at the rlulist, I found that there is a bad usage of rcu_dereference_raw in list_entry_rcu(). Indeed, "typeof (*ptr) *__ptr = ptr;" reads ptr and "rcu_dereference_raw(__ptr)" forces read on the stack variable __ptr. However, ptr should be read with rcu_dereference_raw not the __ptr.

This was introduced some years ago with commit 67bdbffd (2010-02-25).
I am proposing to revert this part of the patch but probably this can be fixed differently.

Fixing this showed 2 problems in the usage of list_entry_rcu.
Since it touches other parts of kernel, I guess it requires ack from other maintainers.

Thanks.

PS: I will Cc the others maintainers when somebody confirms the problem.

Cc "Paul E. McKenney" <[email protected]>
Cc Josh Triplett <[email protected]>
Cc Arnd Bergmann <[email protected]>