lkml.org 
[lkml]   [2020]   [Sep]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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.

\
 
 \ /
  Last update: 2020-09-24 14:37    [W:0.150 / U:20.080 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site