Re: [PATCH] printk: use this_cpu_{read|write} api onprintk_pending

From: Christoph Lameter
Date: Fri Nov 26 2010 - 11:41:03 EST


On Fri, 26 Nov 2010, Eric Dumazet wrote:

> --- a/kernel/printk.c
> +++ b/kernel/printk.c
> @@ -1074,17 +1074,17 @@ static DEFINE_PER_CPU(int, printk_pending);
>
> void printk_tick(void)
> {
> - if (__get_cpu_var(printk_pending)) {
> - __get_cpu_var(printk_pending) = 0;
> + if (__this_cpu_read(printk_pending)) {
> + __this_cpu_write(printk_pending, 0);
> wake_up_interruptible(&log_wait);
> }
> }

The above looks ok.

> int printk_needs_cpu(int cpu)
> {
> - if (unlikely(cpu_is_offline(cpu)))
> + if (cpu_is_offline(cpu))
> printk_tick();
> - return per_cpu(printk_pending, cpu);
> + return __this_cpu_read(printk_pending);
> }

This only works if printk_needs_cpu is always passed the current cpu. The
check for cpu_is_offline suggests that the function is also used for other
cpus. The __this_cpu_read() will then get the printk_pending stat for the
current cpu and not for the specified cpu.


--
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/