Re: [PATCH 10/16] sched: optimize __set_cpus_allowed_ptr_locked()

Peter Zijlstra
2022-07-18T21:34:55Z

On Mon, Jul 18, 2022 at 12:28:38PM -0700, Yury Norov wrote:
> ---
> kernel/sched/core.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index da0bf6fe9ecd..d6424336ef2d 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -2874,7 +2874,8 @@ static int __set_cpus_allowed_ptr_locked(struct task_struct *p,
> cpu_valid_mask = cpu_online_mask;
> }
>
> - if (!kthread && !cpumask_subset(new_mask, cpu_allowed_mask)) {
> + if (!kthread && new_mask != cpu_allowed_mask &&
> + !cpumask_subset(new_mask, cpu_allowed_mask)) {

Optimize cpumask_subset() for src1p == src2p instead?

> ret = -EINVAL;
> goto out;
> }
> --
> 2.34.1
>