Re: [PATCH] Code clean up for percpu_xxx() functions

From: Christoph Lameter
Date: Tue Oct 11 2011 - 10:13:20 EST


On Tue, 11 Oct 2011, Alex,Shi wrote:

> percpu_read() used in asm/percpu.h yet. Anyway, I removed definitions
> here and do a work around for the function as following:
>
> @@ -551,7 +544,11 @@ static __always_inline int x86_this_cpu_constant_test_bit(unsigned int nr,
> {
> unsigned long __percpu *a = (unsigned long *)addr + nr / BITS_PER_LONG;
>
> - return ((1UL << (nr % BITS_PER_LONG)) & percpu_read(*a)) != 0;
> +#ifdef CONFIG_X86_64
> + return ((1UL << (nr % BITS_PER_LONG)) & this_cpu_read_8(*a)) != 0;
> +#else
> + return ((1UL << (nr % BITS_PER_LONG)) & this_cpu_read_4(*a)) != 0;
> +#endif

OK that looks okay.

> Signed-off-by: Alex Shi <alex.shi@xxxxxxxxx>

Is this a revised patch? I do not see a use of the __this_cpu_xx ops.

> -#define percpu_write(var, val) percpu_to_op("mov", var, val)
> -#define percpu_add(var, val) percpu_add_op(var, val)
> -#define percpu_sub(var, val) percpu_add_op(var, -(val))
> -#define percpu_and(var, val) percpu_to_op("and", var, val)
> -#define percpu_or(var, val) percpu_to_op("or", var, val)
> -#define percpu_xor(var, val) percpu_to_op("xor", var, val)
> -#define percpu_inc(var) percpu_unary_op("inc", var)
> +#define this_cpu_read_stable(var) percpu_from_op("mov", var, "p" (&(var)))
> +#define this_cpu_inc(var) percpu_unary_op("inc", var)

Why redefine this_cpu_inc? include/linux/percpu.h already defines it.

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