lkml.org 
[lkml]   [2011]   [Jan]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: x86: A fast way to check capabilities of the current cpu
On Fri, 21 Jan 2011, H. Peter Anvin wrote:

> On 01/21/2011 09:46 AM, Christoph Lameter wrote:
> >> Oh, you're right. Sorry about that. Can you please then add a
> >> comment noting that the operation is x86 only? Maybe prefix it with
> >> x86_?
> >
> > For a function defined in an specific include file and only used in arch
> > specific code?
>
> Yes, x86_ prefix to indicate it's an x86-specific interface, as opposed
> to arch_ which is a architecture-specific component of the
> implementation of a generic interface.

Subject: x86,percpu: Add x86_ prefix to this_cpu_test_bit and do not use percpu_read_stable

Add a prefix to this_cpu_test_bit and friends and do not use percpu_read_stable for
checking per cpu features.

Signed-off-by: Christoph Lameter <cl@linux.com>


---
arch/x86/include/asm/cpufeature.h | 2 +-
arch/x86/include/asm/percpu.h | 12 ++++++------
2 files changed, 7 insertions(+), 7 deletions(-)
Index: linux-2.6/arch/x86/include/asm/cpufeature.h
===================================================================
--- linux-2.6.orig/arch/x86/include/asm/cpufeature.h 2011-01-24 09:18:53.000000000 -0600
+++ linux-2.6/arch/x86/include/asm/cpufeature.h 2011-01-24 09:19:02.000000000 -0600
@@ -224,7 +224,7 @@ extern const char * const x86_power_flag

#define this_cpu_has(bit) \
(__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 : \
- this_cpu_test_bit(bit, (unsigned long *)&cpu_info.x86_capability))
+ x86_this_cpu_test_bit(bit, (unsigned long *)&cpu_info.x86_capability))

#define boot_cpu_has(bit) cpu_has(&boot_cpu_data, bit)

Index: linux-2.6/arch/x86/include/asm/percpu.h
===================================================================
--- linux-2.6.orig/arch/x86/include/asm/percpu.h 2011-01-24 09:18:53.000000000 -0600
+++ linux-2.6/arch/x86/include/asm/percpu.h 2011-01-24 09:24:21.000000000 -0600
@@ -492,15 +492,15 @@ do { \
old__; \
})

-static __always_inline int this_cpu_constant_test_bit(unsigned int nr,
+static __always_inline int x86_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;
+ return ((1UL << (nr % BITS_PER_LONG)) & percpu_read(*a)) != 0;
}

-static inline int this_cpu_variable_test_bit(int nr,
+static inline int x86_this_cpu_variable_test_bit(int nr,
const unsigned long __percpu *addr)
{
int oldbit;
@@ -513,10 +513,10 @@ static inline int this_cpu_variable_test
return oldbit;
}

-#define this_cpu_test_bit(nr, addr) \
+#define x86_this_cpu_test_bit(nr, addr) \
(__builtin_constant_p((nr)) \
- ? this_cpu_constant_test_bit((nr), (addr)) \
- : this_cpu_variable_test_bit((nr), (addr)))
+ ? x86_this_cpu_constant_test_bit((nr), (addr)) \
+ : x86_this_cpu_variable_test_bit((nr), (addr)))


#include <asm-generic/percpu.h>

\
 
 \ /
  Last update: 2011-01-24 18:09    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site