Re: x86: A fast way to check capabilities of the current cpu

From: Tejun Heo
Date: Fri Jan 21 2011 - 12:11:43 EST


Hello, Christoph.

I was trying to forward this to x86 tree but spotted a problem.

On Wed, Dec 15, 2010 at 02:07:39PM -0600, Christoph Lameter wrote:
> +static __always_inline int this_cpu_constant_test_bit(unsigned int nr,
> + const unsigned long __percpu *addr)
> +{
> + unsigned long __percpu *a = (unsigned long *)addr + nr / BITS_PER_LONG;
> +
> + return ((1UL << (nr % BITS_PER_LONG)) & percpu_read_stable(*a)) != 0;
> +}

I don't think percpu_read_stable() can be used here. It's not
guaranteed to be stable across different cpus.

Also, can we just implement what's necessary on top of this_cpu_has()?
this_cpu_has() already has constant handling, so there's no need to
add this_cpu_test_bit() at this point.

Thank you.

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