[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191001134410.GL4536@hirez.programming.kicks-ass.net>
Date: Tue, 1 Oct 2019 15:44:10 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Srikar Dronamraju <srikar@...ux.vnet.ibm.com>
Cc: Qian Cai <cai@....pw>, akpm@...ux-foundation.org,
bigeasy@...utronix.de, tglx@...utronix.de, thgarnie@...gle.com,
tytso@....edu, cl@...ux.com, penberg@...nel.org,
rientjes@...gle.com, mingo@...hat.com, will@...nel.org,
linux-mm@...ck.org, linux-kernel@...r.kernel.org,
keescook@...omium.org
Subject: Re: [PATCH] sched: Avoid spurious lock dependencies
On Tue, Oct 01, 2019 at 05:06:56PM +0530, Srikar Dronamraju wrote:
> > Subject: sched: Avoid spurious lock dependencies
> >
> > While seemingly harmless, __sched_fork() does hrtimer_init(), which,
> > when DEBUG_OBJETS, can end up doing allocations.
> >
>
> NIT: s/DEBUG_OBJETS/DEBUG_OBJECTS
>
> > diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> > index 7880f4f64d0e..1832fc0fbec5 100644
> > --- a/kernel/sched/core.c
> > +++ b/kernel/sched/core.c
> > @@ -6039,10 +6039,11 @@ void init_idle(struct task_struct *idle, int cpu)
> > struct rq *rq = cpu_rq(cpu);
> > unsigned long flags;
> >
> > + __sched_fork(0, idle);
> > +
> > raw_spin_lock_irqsave(&idle->pi_lock, flags);
> > raw_spin_lock(&rq->lock);
> >
> > - __sched_fork(0, idle);
> > idle->state = TASK_RUNNING;
> > idle->se.exec_start = sched_clock();
> > idle->flags |= PF_IDLE;
> >
>
> Given that there is a comment just after this which says
> "init_task() gets called multiple times on a task",
> should we add a check if rq->idle is present and bail out?
>
> if (rq->idle) {
> raw_spin_unlock(&rq->lock);
> raw_spin_unlock_irqrestore(&idle->pi_lock, flags);
> return;
> }
Not really worth it; the best solution is to fix the callchains leading
up to it. It's all hotplug related IIRC and so it's slow anyway.
> Also can we also move the above 3 statements before the lock?
Probably, but to what effect?
Powered by blists - more mailing lists