Skip to contentSkip to conversation

Use get_online_cpus to avoid races involving for_each_online_cpu

PATCH Superseded Silas Boyd-Wickizer 1 participant 1 message Aug 3, 2012

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Use get_online_cpus to avoid races involving for_each_online_cpu

Hello,

I've found 4 races involving for_each_online_cpu that could have ill effects. All 4 occur in code that can be compiled as modules, but which is probably usually linked statically. All 4 occur during module init and/or exit. I've written patches for 3 of the 4, and will describe the 4th race in separate e-mail.

I've been checking the usages of for_each_online_cpu for the possibility of races with offlining and onlining CPUs. I used libsparse and kernel source annotations to check that code uses for_each_online_cpu in contexts with hotplug disabled (e.g. get_online_cpus(), preempt_disable, ..). I compiled with an x86 64-bit allyesconfig and weeded out false positives (e.g. careful use of CPU notifiers) by hand.

I've identified about 40 races, but only 4 that seem to have unintentional and potentially harmful effects.

Here is a link to my checker code, which isn't fit for inclusion in anything:

http://pdos.csail.mit.edu/~sbw/online-checker/

Silas