Re: [RFC][PATCH 2/5] mm: Switch mod_state() to __this_cpu_read()

Steven Rostedt
2011-09-20T17:08:39Z

On Tue, 2011-09-20 at 18:51 +0200, Thomas Gleixner wrote:

> this_cpu_*() is patently wrong. It should be: random_cpu_*() or
> any_cpu_*(). This way you could have avoided confusion in the first
> place and made it entirely clear what the interfaces are about.

Thinking about this, my vote is for "any_cpu_*()". I initially liked my
own snapshot_cpu_*(), and even random_cpu_*() is humorous. But truly,
the "any_cpu_*()" has the best meaning. As you really don't seem to care
about which CPU you access. Sure you can document something like:

/*
* Will modify the per cpu data on the current CPU, but there is no
* guarantee which CPU you may be on, as you can migrate just before
* or after calling this function. Only the scope of this function
* will be atomic to the CPU the task is currently on, but no guarantee
* before or after the function. If you care about that, disable
* preemption and use the this_cpu_*() variants.
*/

-- Steve