[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200924123527.GJ2628@hirez.programming.kicks-ass.net>
Date: Thu, 24 Sep 2020 14:35:27 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Valentin Schneider <valentin.schneider@....com>
Cc: tglx@...utronix.de, mingo@...nel.org, linux-kernel@...r.kernel.org,
bigeasy@...utronix.de, qais.yousef@....com, swood@...hat.com,
juri.lelli@...hat.com, vincent.guittot@...aro.org,
dietmar.eggemann@....com, rostedt@...dmis.org, bsegall@...gle.com,
mgorman@...e.de, bristot@...hat.com, vincent.donnefort@....com
Subject: Re: [PATCH 7/9] sched: Add migrate_disable()
On Thu, Sep 24, 2020 at 12:53:25PM +0100, Valentin Schneider wrote:
> > @@ -1830,8 +1892,19 @@ static int migration_cpu_stop(void *data
> > */
> > void set_cpus_allowed_common(struct task_struct *p, const struct cpumask *new_mask, u32 flags)
> > {
> > - cpumask_copy(&p->cpus_mask, new_mask);
> > - p->nr_cpus_allowed = cpumask_weight(new_mask);
> > + if (flags & SCA_MIGRATE_DISABLE) {
> > + p->cpus_ptr = new_mask;
> > + p->nr_cpus_allowed = 1;
> > + return;
> > + }
> > +
> > + if (flags & SCA_MIGRATE_ENABLE)
> > + p->cpus_ptr = &p->cpus_mask;
>
> There's that check in __set_cpus_allowed_ptr() that new_mask *must* be
> p->cpus_mask when SCA_MIGRATE_ENABLE; that means we could mayhaps shuffle
> that to:
>
> ---
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 7cb13df48366..e0e4e42c5e32 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -1892,18 +1892,14 @@ static int migration_cpu_stop(void *data)
> */
> void set_cpus_allowed_common(struct task_struct *p, const struct cpumask *new_mask, u32 flags)
> {
> + if (flags & (SCA_MIGRATE_DISABLE | SCA_MIGRATE_ENABLE))
> p->cpus_ptr = new_mask;
> else
> cpumask_copy(&p->cpus_mask, new_mask);
>
> + if (flags & SCA_MIGRATE_DISABLE)
> + p->nr_cpus_allowed = 1;
> + else if (p->cpus_ptr == &p->cpus_mask)
> p->nr_cpus_allowed = cpumask_weight(p->cpus_ptr);
> }
I'm thinking we should let nr_cpus_allowed reflect ->cpus_mask
unconditionally. See these emails:
https://lkml.kernel.org/r/20200923170809.GY1362448@hirez.programming.kicks-ass.net
https://lkml.kernel.org/r/20200924082717.GA1362448@hirez.programming.kicks-ass.net
Basically we want to keep migrate_disable() tasks elegible for
migration/PULL.
But yes, I think that function can be simplified.
Powered by blists - more mailing lists