Skip to content

RFC Introduce checks for preemptable code for this_cpu_read/write()

Steven Rostedt lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest5 patches 67 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5x86: Remove const_udelay() caring about which cpu var it usesarch/x86/lib/delay.c+1 -12 replies
2/5mm: Switch mod_state() to __this_cpu_read()mm/vmstat.c+2 -218 replies
3/5memcg: Disable preemption in memcg_check_events()mm/memcontrol.c+2 -04 replies
4/5printk: Have wake_up_klogd() use __this_cpu_write()kernel/printk.c+1 -14 replies
5/5percpu: Add preempt checks back into this_cpu_read/write()include/linux/percpu.h+15 -20 replies

Reviews trailers per patch

2 of 5 patches have a Reviewed-by or Acked-by.

PatchKAMEZAWA HiroyukiBalbir SinghChristoph Lameter
1/5
2/5
3/5A-b A-b
4/5R-b
5/5

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v1 thread

Cover letter [RFC][PATCH 0/5] Introduce checks for preemptable code for this_cpu_read/write()

I just found out that the this_cpu_*() functions do not perform the test to see if the usage is in atomic or not. Thus, the blind conversion of the per_cpu(*, smp_processor_id()) and the get_cpu_var() code to this_cpu_*() introduce the regression to detect the hard to find case where a per cpu variable is used in preempt code that migrates and causes bugs.

I'm adding back a simple call to smp_processor_id() to this_cpu_read() and this_cpu_write() to see what errors I find. I found 4 places that required touch up. 3 were areas that the race is known and we don't care, but the memcg looks very buggy.

Anyway, if I had known that the this_cpu_*() code removed this smp_processor_id() check, I would have NAK'd all the changes to the tracing code.

I only modified this_cpu_read and *_write() I may decide other this_cpu_* code should be updated too. Especially the ones that return a value.

-- Steve

Steven Rostedt (5):
x86: Remove const_udelay() caring about which cpu var it uses
mm: Switch mod_state() to __this_cpu_read()
memcg: Disable preemption in memcg_check_events()
printk: Have wake_up_klogd() use __this_cpu_write()
percpu: Add preempt checks back into this_cpu_read/write()

----

 arch/x86/lib/delay.c   |    2 +-
 include/linux/percpu.h |   17 +++++++++++++++--
 kernel/printk.c        |    2 +-
 mm/memcontrol.c        |    2 ++
 mm/vmstat.c            |    4 ++--
 5 files changed, 21 insertions(+), 6 deletions(-)