Re: [PATCH] sched: Do not bug in __sched_setscheduler() when pi is not used
From: Greg KH
Date: Mon Nov 19 2018 - 10:13:17 EST
On Wed, Nov 14, 2018 at 12:55:20PM -0800, Florian Fainelli wrote:
> On 3/9/17 7:18 AM, Steven Rostedt wrote:
> > From: "Steven Rostedt (VMware)" <rostedt@xxxxxxxxxxx>
> >
> >
> > When priority inheritance was added back in 2.6.18 to sched_setscheduler, it
> > added a path to taking an rt-mutex wait_lock, which is not IRQ safe. As PI
> > is not a common occurrence, lockdep will likely never trigger if
> > sched_setscheduler was called from interrupt context. A BUG_ON() was added
> > to trigger if __sched_setscheduler() was ever called from interrupt context
> > because there was a possibility to take the wait_lock.
> >
> > Today the wait_lock is irq safe, but the path to taking it in
> > sched_setscheduler() is the same as the path to taking it from normal
> > context. The wait_lock is taken with raw_spin_lock_irq() and released with
> > raw_spin_unlock_irq() which will indiscriminately enable interrupts,
> > which would be bad in interrupt context.
> >
> > The problem is that normalize_rt_tasks, which is called by triggering the
> > sysrq nice-all-RT-tasks was changed to call __sched_setscheduler(), and this
> > is done from interrupt context!
> >
> > Now __sched_setscheduler() takes a "pi" parameter that is used to know if
> > the priority inheritance should be called or not. As the BUG_ON() only cares
> > about calling the PI code, it should only bug if called from interrupt
> > context with the "pi" parameter set to true.
> >
> > Link: http://lkml.kernel.org/r/20170308124654.10e598f2@xxxxxxxxxxxxxxxxxx
> >
> > Reported-by: Laurent Dufour <ldufour@xxxxxxxxxxxxxxxxxx>
> > Tested-by: Laurent Dufour <ldufour@xxxxxxxxxxxxxxxxxx>
> > Fixes: dbc7f069b93a ("sched: Use replace normalize_task() with __sched_setscheduler()")
> > Cc: Andrew Morton <akpm@xxxxxxxx>
> > Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> > Cc: Ingo Molnar <mingo@xxxxxxx>
> > Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> > Cc: stable@xxxxxxxxxxxxxxx
> > Signed-off-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx>
>
> Can this patch also be applied to the stable trees? The offending commit
> was first introduced in 4.2.
What is the git commit id of this patch in Linus's tree?
thanks,
greg k-h