[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <4CFFC6F2.5040304@kernel.org>
Date: Wed, 08 Dec 2010 18:57:06 +0100
From: Tejun Heo <tj@...nel.org>
To: Christoph Lameter <cl@...ux.com>
CC: Eric Dumazet <eric.dumazet@...il.com>, akpm@...ux-foundation.org,
Yinghai Lu <yinghai@...nel.org>, Ingo Molnar <mingo@...e.hu>,
Pekka Enberg <penberg@...helsinki.fi>,
linux-kernel@...r.kernel.org,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
Subject: Re: [PATCH] x86: Replace uses of current_cpu_data with this_cpu ops
Hello, Christoph.
On 12/08/2010 06:33 PM, Christoph Lameter wrote:
> Beginnings of a patch to avoid bitops. If you think this is the right way
> then I will complete it for all uses of cpu_has.
>
> ---
> arch/x86/include/asm/cpufeature.h | 15 +++++++++++++++
> arch/x86/kernel/apic/apic.c | 2 +-
> 2 files changed, 16 insertions(+), 1 deletion(-)
>
> Index: linux-2.6/arch/x86/include/asm/cpufeature.h
> ===================================================================
> --- linux-2.6.orig/arch/x86/include/asm/cpufeature.h 2010-12-08 09:39:31.000000000 -0600
> +++ linux-2.6/arch/x86/include/asm/cpufeature.h 2010-12-08 09:40:02.000000000 -0600
> @@ -221,6 +221,21 @@ extern const char * const x86_power_flag
> ? 1 : \
> test_cpu_cap(c, bit))
>
> +#define this_cpu_has(bit) \
> + (__builtin_constant_p(bit) && \
> + ( (((bit)>>5)==0 && (1UL<<((bit)&31) & REQUIRED_MASK0)) || \
> + (((bit)>>5)==1 && (1UL<<((bit)&31) & REQUIRED_MASK1)) || \
> + (((bit)>>5)==2 && (1UL<<((bit)&31) & REQUIRED_MASK2)) || \
> + (((bit)>>5)==3 && (1UL<<((bit)&31) & REQUIRED_MASK3)) || \
> + (((bit)>>5)==4 && (1UL<<((bit)&31) & REQUIRED_MASK4)) || \
> + (((bit)>>5)==5 && (1UL<<((bit)&31) & REQUIRED_MASK5)) || \
> + (((bit)>>5)==6 && (1UL<<((bit)&31) & REQUIRED_MASK6)) || \
> + (((bit)>>5)==7 && (1UL<<((bit)&31) & REQUIRED_MASK7)) || \
> + (((bit)>>5)==8 && (1UL<<((bit)&31) & REQUIRED_MASK8)) || \
> + (((bit)>>5)==9 && (1UL<<((bit)&31) & REQUIRED_MASK9)) ) \
> + ? 1 : \
It would be nice to factor out the above so that it's not repated for
cpu_has() and this_cpu_has().
> + (this_cpu_read(cpu_info.x86_capabilty) & (1 << bit)))
bit can go beyond unsigned, so 1 << bit doesn't work. Why not just
start with a simple wrapper? ie. sth like
#define this_cpu_has(bit) cpu_has(__this_cpu_ptr(&cpu_info), bit)
We can later optimize in a separate patch along the line of...
#define this_cpu_has(bit) ({ \
__builtin_constant_p(bit) ? \
(cpu_required_bit_test(bit) || \
this_cpu_read(cpu_info.x86_capability + ((bit) >> 5)) & \
(1 << ((bit) & 31))) : \
cpu_has(__this_cpu_ptr(&cpu_info), bit); \
})
Thanks.
--
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists