On Wed, Aug 28, 2013 at 07:48:14PM +0000, Christoph Lameter wrote:
> Transformations done to __get_cpu_var()
> 
> 
> 1. Determine the address of the percpu instance of the current processor.
> 
>       DEFINE_PER_CPU(int, y);
>       int *x = &__get_cpu_var(y);
> 
>     Converts to
> 
>       int *x = this_cpu_ptr(&y);
> 
> 
> 2. Same as #1 but this time an array structure is involved.
> 
>       DEFINE_PER_CPU(int, y[20]);
>       int *x = __get_cpu_var(y);
> 
>     Converts to
> 
>       int *x = this_cpu_ptr(y);
> 
> 
> 3. Retrieve the content of the current processors instance of a per cpu 
> variable.
> 
>       DEFINE_PER_CPU(int, u);
>       int x = __get_cpu_var(y)
> 
>    Converts to
> 
>       int x = __this_cpu_read(y);
> 

This looses a preemption debug check, so NAK

> 4. Retrieve the content of a percpu struct
> 
>       DEFINE_PER_CPU(struct mystruct, y);
>       struct mystruct x = __get_cpu_var(y);
> 
>    Converts to
> 
>       memcpy(this_cpu_ptr(&x), y, sizeof(x));
> 
> 5. Assignment to a per cpu variable
> 
>       DEFINE_PER_CPU(int, y)
>       __get_cpu_var(y) = x;
> 
>    Converts to
> 
>       this_cpu_write(y, x);
> 

This too looses a preemption debug check, NAK

> 6. Increment/Decrement etc of a per cpu variable
> 
>       DEFINE_PER_CPU(int, y);
>       __get_cpu_var(y)++
> 
>    Converts to
> 
>       this_cpu_inc(y)
> 

Lo and behold.. no preemption checks again.


Seriously first fix the debug and validation bits of the *this_cpu*
stuff.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to