Re: [PATCH 78/89] sched/core: Remove the tsk_cpus_allowed() wrapper

Peter Zijlstra
2017-02-06T14:59:14Z

On Mon, Feb 06, 2017 at 02:29:21PM +0100, Ingo Molnar wrote:
> diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
> index 54903862cf57..f40e2a5cf044 100644
> --- a/arch/powerpc/kernel/smp.c
> +++ b/arch/powerpc/kernel/smp.c
> @@ -796,7 +796,7 @@ void __init smp_cpus_done(unsigned int max_cpus)
> * se we pin us down to CPU 0 for a short while
> */
> alloc_cpumask_var(&old_mask, GFP_NOWAIT);
> - cpumask_copy(old_mask, tsk_cpus_allowed(current));
> + cpumask_copy(old_mask, &current->cpus_allowed);
> set_cpus_allowed_ptr(current, cpumask_of(boot_cpuid));
>
> if (smp_ops && smp_ops->setup_cpu)

> diff --git a/arch/sparc/kernel/sysfs.c b/arch/sparc/kernel/sysfs.c
> index 4808b6d23455..d63fc613e7a9 100644
> --- a/arch/sparc/kernel/sysfs.c
> +++ b/arch/sparc/kernel/sysfs.c
> @@ -106,7 +106,7 @@ static unsigned long run_on_cpu(unsigned long cpu,
> cpumask_t old_affinity;
> unsigned long ret;
>
> - cpumask_copy(&old_affinity, tsk_cpus_allowed(current));
> + cpumask_copy(&old_affinity, &current->cpus_allowed);
> /* should return -EINVAL to userspace */
> if (set_cpus_allowed_ptr(current, cpumask_of(cpu)))
> return 0;
> diff --git a/drivers/cpufreq/sparc-us2e-cpufreq.c b/drivers/cpufreq/sparc-us2e-cpufreq.c
> index b73feeb666f9..35ddb6da93aa 100644
> --- a/drivers/cpufreq/sparc-us2e-cpufreq.c
> +++ b/drivers/cpufreq/sparc-us2e-cpufreq.c
> @@ -234,7 +234,7 @@ static unsigned int us2e_freq_get(unsigned int cpu)
> cpumask_t cpus_allowed;
> unsigned long clock_tick, estar;
>
> - cpumask_copy(&cpus_allowed, tsk_cpus_allowed(current));
> + cpumask_copy(&cpus_allowed, &current->cpus_allowed);
> set_cpus_allowed_ptr(current, cpumask_of(cpu));
>
> clock_tick = sparc64_get_clock_tick(cpu) / 1000;
> @@ -252,7 +252,7 @@ static int us2e_freq_target(struct cpufreq_policy *policy, unsigned int index)
> unsigned long clock_tick, divisor, old_divisor, estar;
> cpumask_t cpus_allowed;
>
> - cpumask_copy(&cpus_allowed, tsk_cpus_allowed(current));
> + cpumask_copy(&cpus_allowed, &current->cpus_allowed);
> set_cpus_allowed_ptr(current, cpumask_of(cpu));
>
> new_freq = clock_tick = sparc64_get_clock_tick(cpu) / 1000;
> diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
> index 9bb42ba50efa..a8d86a449ca1 100644
> --- a/drivers/cpufreq/sparc-us3-cpufreq.c
> +++ b/drivers/cpufreq/sparc-us3-cpufreq.c
> @@ -82,7 +82,7 @@ static unsigned int us3_freq_get(unsigned int cpu)
> unsigned long reg;
> unsigned int ret;
>
> - cpumask_copy(&cpus_allowed, tsk_cpus_allowed(current));
> + cpumask_copy(&cpus_allowed, &current->cpus_allowed);
> set_cpus_allowed_ptr(current, cpumask_of(cpu));
>
> reg = read_safari_cfg();
> @@ -99,7 +99,7 @@ static int us3_freq_target(struct cpufreq_policy *policy, unsigned int index)
> unsigned long new_bits, new_freq, reg;
> cpumask_t cpus_allowed;
>
> - cpumask_copy(&cpus_allowed, tsk_cpus_allowed(current));
> + cpumask_copy(&cpus_allowed, &current->cpus_allowed);
> set_cpus_allowed_ptr(current, cpumask_of(cpu));
>
> new_freq = sparc64_get_clock_tick(cpu) / 1000;

Note that all those, and this is where I stopped looking, appear broken
vs userspace changing the mask right after.