powerpc: Make sysfs code use smp_call_function_single
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@rustcorp.com.au> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
This commit is contained in:
parent
c5785f9e1c
commit
9a3719341a
1 changed files with 6 additions and 25 deletions
|
@ -134,36 +134,16 @@ void ppc_enable_pmcs(void)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(ppc_enable_pmcs);
|
EXPORT_SYMBOL(ppc_enable_pmcs);
|
||||||
|
|
||||||
#if defined(CONFIG_6xx) || defined(CONFIG_PPC64)
|
|
||||||
/* XXX convert to rusty's on_one_cpu */
|
|
||||||
static unsigned long run_on_cpu(unsigned long cpu,
|
|
||||||
unsigned long (*func)(unsigned long),
|
|
||||||
unsigned long arg)
|
|
||||||
{
|
|
||||||
cpumask_t old_affinity = current->cpus_allowed;
|
|
||||||
unsigned long ret;
|
|
||||||
|
|
||||||
/* should return -EINVAL to userspace */
|
|
||||||
if (set_cpus_allowed(current, cpumask_of_cpu(cpu)))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
ret = func(arg);
|
|
||||||
|
|
||||||
set_cpus_allowed(current, old_affinity);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define SYSFS_PMCSETUP(NAME, ADDRESS) \
|
#define SYSFS_PMCSETUP(NAME, ADDRESS) \
|
||||||
static unsigned long read_##NAME(unsigned long junk) \
|
static void read_##NAME(void *val) \
|
||||||
{ \
|
{ \
|
||||||
return mfspr(ADDRESS); \
|
mtspr(ADDRESS, *(unsigned long *)val); \
|
||||||
} \
|
} \
|
||||||
static unsigned long write_##NAME(unsigned long val) \
|
static unsigned long write_##NAME(unsigned long val) \
|
||||||
{ \
|
{ \
|
||||||
ppc_enable_pmcs(); \
|
ppc_enable_pmcs(); \
|
||||||
mtspr(ADDRESS, val); \
|
mtspr(ADDRESS, *(unsigned long *)val); \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
static ssize_t show_##NAME(struct sys_device *dev, \
|
static ssize_t show_##NAME(struct sys_device *dev, \
|
||||||
|
@ -171,7 +151,8 @@ static ssize_t show_##NAME(struct sys_device *dev, \
|
||||||
char *buf) \
|
char *buf) \
|
||||||
{ \
|
{ \
|
||||||
struct cpu *cpu = container_of(dev, struct cpu, sysdev); \
|
struct cpu *cpu = container_of(dev, struct cpu, sysdev); \
|
||||||
unsigned long val = run_on_cpu(cpu->sysdev.id, read_##NAME, 0); \
|
unsigned long val; \
|
||||||
|
smp_call_function_single(cpu->sysdev.id, read_##NAME, &val, 1); \
|
||||||
return sprintf(buf, "%lx\n", val); \
|
return sprintf(buf, "%lx\n", val); \
|
||||||
} \
|
} \
|
||||||
static ssize_t __used \
|
static ssize_t __used \
|
||||||
|
@ -183,7 +164,7 @@ static ssize_t __used \
|
||||||
int ret = sscanf(buf, "%lx", &val); \
|
int ret = sscanf(buf, "%lx", &val); \
|
||||||
if (ret != 1) \
|
if (ret != 1) \
|
||||||
return -EINVAL; \
|
return -EINVAL; \
|
||||||
run_on_cpu(cpu->sysdev.id, write_##NAME, val); \
|
smp_call_function_single(cpu->sysdev.id, write_##NAME, &val, 1); \
|
||||||
return count; \
|
return count; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue