mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-09-22 12:42:50 +00:00
x86: Remove cpumask games in x86/kernel/cpu/intel_cacheinfo.c
Impact: remove cpumask_t from stack. We should not try to save and restore cpus_allowed on current. We can't use work_on_cpu() here, since it's in the hotplug cpu path (if anyone else tries to get the hotplug lock from a workqueue we could deadlock against them). Fortunately, we can just use smp_call_function_single() since the function can run from an interrupt. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Mike Travis <travis@sgi.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Oleg Nesterov <oleg@tv-sign.ru>
This commit is contained in:
parent
1de88cd4a3
commit
b2bb855491
1 changed files with 21 additions and 24 deletions
|
@ -534,12 +534,29 @@ static void __cpuinit free_cache_attributes(unsigned int cpu)
|
||||||
per_cpu(cpuid4_info, cpu) = NULL;
|
per_cpu(cpuid4_info, cpu) = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void get_cpu_leaves(void *_retval)
|
||||||
|
{
|
||||||
|
int j, *retval = _retval, cpu = smp_processor_id();
|
||||||
|
|
||||||
|
/* Do cpuid and store the results */
|
||||||
|
for (j = 0; j < num_cache_leaves; j++) {
|
||||||
|
struct _cpuid4_info *this_leaf;
|
||||||
|
this_leaf = CPUID4_INFO_IDX(cpu, j);
|
||||||
|
*retval = cpuid4_cache_lookup(j, this_leaf);
|
||||||
|
if (unlikely(*retval < 0)) {
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < j; i++)
|
||||||
|
cache_remove_shared_cpu_map(cpu, i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
cache_shared_cpu_map_setup(cpu, j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int __cpuinit detect_cache_attributes(unsigned int cpu)
|
static int __cpuinit detect_cache_attributes(unsigned int cpu)
|
||||||
{
|
{
|
||||||
struct _cpuid4_info *this_leaf;
|
|
||||||
unsigned long j;
|
|
||||||
int retval;
|
int retval;
|
||||||
cpumask_t oldmask;
|
|
||||||
|
|
||||||
if (num_cache_leaves == 0)
|
if (num_cache_leaves == 0)
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
@ -549,27 +566,7 @@ static int __cpuinit detect_cache_attributes(unsigned int cpu)
|
||||||
if (per_cpu(cpuid4_info, cpu) == NULL)
|
if (per_cpu(cpuid4_info, cpu) == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
oldmask = current->cpus_allowed;
|
smp_call_function_single(cpu, get_cpu_leaves, &retval, true);
|
||||||
retval = set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
|
|
||||||
if (retval)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
/* Do cpuid and store the results */
|
|
||||||
for (j = 0; j < num_cache_leaves; j++) {
|
|
||||||
this_leaf = CPUID4_INFO_IDX(cpu, j);
|
|
||||||
retval = cpuid4_cache_lookup(j, this_leaf);
|
|
||||||
if (unlikely(retval < 0)) {
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < j; i++)
|
|
||||||
cache_remove_shared_cpu_map(cpu, i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
cache_shared_cpu_map_setup(cpu, j);
|
|
||||||
}
|
|
||||||
set_cpus_allowed_ptr(current, &oldmask);
|
|
||||||
|
|
||||||
out:
|
|
||||||
if (retval) {
|
if (retval) {
|
||||||
kfree(per_cpu(cpuid4_info, cpu));
|
kfree(per_cpu(cpuid4_info, cpu));
|
||||||
per_cpu(cpuid4_info, cpu) = NULL;
|
per_cpu(cpuid4_info, cpu) = NULL;
|
||||||
|
|
Loading…
Reference in a new issue