Re: Poll about irqsafe_cpu_add and others

From: Christoph Lameter
Date: Thu Mar 17 2011 - 14:42:18 EST


On Thu, 17 Mar 2011, Eric Dumazet wrote:

> By the way, I noticed :
>
> DECLARE_PER_CPU(u64, xt_u64);
> __this_cpu_add(xt_u64, 2) translates to following x86_32 code :
>
> mov $xt_u64,%eax
> add %fs:0x0,%eax
> addl $0x2,(%eax)
> adcl $0x0,0x4(%eax)
>
>
> I wonder why we dont use :
>
> addl $0x2,%fs:xt_u64
> addcl $0x0,%fs:xt_u64+4

The compiler is fed the following

*__this_cpu_ptr(xt_u64) += 2

__this_cpu_ptr makes it:

*(xt_u64 + __my_cpu_offset) += 2

So the compiler calculates the address first and then increments it.

The compiler could optimize this I think. Wonder why that does not happen.




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