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

From: Steven Rostedt
Date: Tue Sep 20 2011 - 13:08:46 EST


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


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/