[PATCH] powerpc: make sysfs code use smp_call_function_single
Rusty Russell
rusty at rustcorp.com.au
Thu Mar 12 09:20:05 EST 2009
Impact: performance improvement
This fixes 'powerpc: avoid cpumask games in arch/powerpc/kernel/sysfs.c'
which talked about using smp_call_function_single, but actually used
work_on_cpu (an older version of the patch).
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
---
arch/powerpc/kernel/sysfs.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
--- a/arch/powerpc/kernel/sysfs.c
+++ b/arch/powerpc/kernel/sysfs.c
@@ -135,14 +135,14 @@ EXPORT_SYMBOL(ppc_enable_pmcs);
EXPORT_SYMBOL(ppc_enable_pmcs);
#define SYSFS_PMCSETUP(NAME, ADDRESS) \
-static long read_##NAME(void *junk) \
+static void read_##NAME(void *val) \
{ \
- return mfspr(ADDRESS); \
+ *(unsigned long *)val = mfspr(ADDRESS); \
} \
static long write_##NAME(void *val) \
{ \
ppc_enable_pmcs(); \
- mtspr(ADDRESS, (unsigned long)val); \
+ mtspr(ADDRESS, *(unsigned long *)val); \
return 0; \
} \
static ssize_t show_##NAME(struct sys_device *dev, \
@@ -150,7 +150,8 @@ static ssize_t show_##NAME(struct sys_de
char *buf) \
{ \
struct cpu *cpu = container_of(dev, struct cpu, sysdev); \
- unsigned long val = work_on_cpu(cpu->sysdev.id, read_##NAME, NULL); \
+ unsigned long val; \
+ smp_call_function_single(cpu->sysdev.id, read_##NAME, &val, 1); \
return sprintf(buf, "%lx\n", val); \
} \
static ssize_t __used \
@@ -162,7 +163,7 @@ static ssize_t __used \
int ret = sscanf(buf, "%lx", &val); \
if (ret != 1) \
return -EINVAL; \
- work_on_cpu(cpu->sysdev.id, write_##NAME, (void *)val); \
+ smp_call_function_single(cpu->sysdev.id, write_##NAME, &val, 1); \
return count; \
}
More information about the Linuxppc-dev
mailing list