Re: [PATCH] sched, cpuidle: Do not access cpuidle_devices when !CONFIG_CPU_IDLE

From: Catalin Marinas
Date: Wed Jun 01 2016 - 17:48:56 EST


On Wed, Jun 01, 2016 at 10:20:03PM +0200, Rafael J. Wysocki wrote:
> On Wednesday, June 01, 2016 06:52:16 PM Catalin Marinas wrote:
> > The cpuidle_devices per-CPU variable is only defined when CPU_IDLE is
> > enabled. Commit c8cc7d4de7a4 ("sched/idle: Reorganize the idle loop")
> > removed the #ifdef CONFIG_CPU_IDLE around cpuidle_idle_call() with the
> > compiler optimising away __this_cpu_read(cpuidle_devices). However, with
> > CONFIG_UBSAN && !CONFIG_CPU_IDLE, this optimisation no longer happens
> > and the kernel fails to link since cpuidle_devices is not defined.
> >
> > This patch introduces an accessor function for the current CPU cpuidle
> > device (returning NULL when !CONFIG_CPU_IDLE) and uses it in
> > cpuidle_idle_call().
> >
> > Cc: Rafael J. Wysocki <rjw@xxxxxxxxxxxxx>
> > Cc: Daniel Lezcano <daniel.lezcano@xxxxxxxxxx>
> > Cc: Ingo Molnar <mingo@xxxxxxxxxx>
> > Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> > Cc: Andrey Ryabinin <aryabinin@xxxxxxxxxxxxx>
> > Signed-off-by: Catalin Marinas <catalin.marinas@xxxxxxx>
>
> OK
>
> Is this needed in -stable?

Not sure how common this config combination is (I was just testing
different options and came across it). Even though it's not a fix for
UBSAN, we could add it up to 4.5 since that's when UBSAN was merged:

Cc: <stable@xxxxxxxxxxxxxxx> # 4.5+

--
Catalin