2020-08-30 18:06:20

by Thomas Gleixner

[permalink] [raw]
Subject: [GIT pull] sched/urgent for v5.9-rc2

Linus,

please pull the latest sched/urgent branch from:

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git sched-urgent-2020-08-30

up to: c94a88f341c9: sched: Use __always_inline on is_idle_task()


A single fix for the scheduler:

- Make is_idle_task() __always_inline to prevent the compiler from putting
it out of line into the wrong section because it's used inside noinstr
sections.

Thanks,

tglx

------------------>
Marco Elver (1):
sched: Use __always_inline on is_idle_task()


include/linux/sched.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 93ecd930efd3..afe01e232935 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1666,7 +1666,7 @@ extern struct task_struct *idle_task(int cpu);
*
* Return: 1 if @p is an idle task. 0 otherwise.
*/
-static inline bool is_idle_task(const struct task_struct *p)
+static __always_inline bool is_idle_task(const struct task_struct *p)
{
return !!(p->flags & PF_IDLE);
}


2020-08-30 18:56:22

by Linus Torvalds

[permalink] [raw]
Subject: Re: [GIT pull] sched/urgent for v5.9-rc2

On Sun, Aug 30, 2020 at 11:04 AM Thomas Gleixner <[email protected]> wrote:
>
> - Make is_idle_task() __always_inline to prevent the compiler from putting
> it out of line into the wrong section because it's used inside noinstr
> sections.

What completely broken compiler uninlined that single-instruction function?

I've obviously pulled this, but it sounds like there should be a
compiler bug-report for this insane behavior.

Or is Marco building the kernel without optimizations or something
like that? That has not been a supported model, for various good
reasons..

Linus

2020-08-30 19:18:47

by pr-tracker-bot

[permalink] [raw]
Subject: Re: [GIT pull] sched/urgent for v5.9-rc2

The pull request you sent on Sun, 30 Aug 2020 18:03:38 -0000:

> git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git sched-urgent-2020-08-30

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/0063a82de937433ccfffe123e12b4503b9155c96

Thank you!

--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html

2020-08-31 06:43:15

by Marco Elver

[permalink] [raw]
Subject: Re: [GIT pull] sched/urgent for v5.9-rc2

On Sun, 30 Aug 2020 at 20:54, Linus Torvalds
<[email protected]> wrote:
> On Sun, Aug 30, 2020 at 11:04 AM Thomas Gleixner <[email protected]> wrote:
> >
> > - Make is_idle_task() __always_inline to prevent the compiler from putting
> > it out of line into the wrong section because it's used inside noinstr
> > sections.
>
> What completely broken compiler uninlined that single-instruction function?
>
> I've obviously pulled this, but it sounds like there should be a
> compiler bug-report for this insane behavior.
>
> Or is Marco building the kernel without optimizations or something
> like that? That has not been a supported model, for various good
> reasons..

Certainly with optimizations, but also with various debug options and
sanitizer instrumentation. (FTR, the config used:
https://lore.kernel.org/lkml/[email protected]/3-a.txt
on GCC 10.1 with GCC 11's KCSAN patches backported.)

Checking GCC's sources, the inlining policy here is that the compiler
tries to sanitize as many functions as possible, and if only 'inline'
is used, it'll avoid inlining such a function into a 'no_sanitize'
function in favor of instrumenting it.

With a normal non-debug config this should therefore never happen.

Thanks,
-- Marco

2020-08-31 07:27:48

by Peter Zijlstra

[permalink] [raw]
Subject: Re: [GIT pull] sched/urgent for v5.9-rc2

On Sun, Aug 30, 2020 at 11:54:19AM -0700, Linus Torvalds wrote:
> On Sun, Aug 30, 2020 at 11:04 AM Thomas Gleixner <[email protected]> wrote:
> >
> > - Make is_idle_task() __always_inline to prevent the compiler from putting
> > it out of line into the wrong section because it's used inside noinstr
> > sections.
>
> What completely broken compiler uninlined that single-instruction function?
>
> I've obviously pulled this, but it sounds like there should be a
> compiler bug-report for this insane behavior.
>
> Or is Marco building the kernel without optimizations or something
> like that? That has not been a supported model, for various good
> reasons..

I think that was Clang with KCSAN on, KCSAN obviously makes this
function a little bigger with the instrumentation for the load(s). But
yes...

2020-08-31 07:39:47

by Marco Elver

[permalink] [raw]
Subject: Re: [GIT pull] sched/urgent for v5.9-rc2

On Mon, 31 Aug 2020 at 09:24, <[email protected]> wrote:
>
> On Sun, Aug 30, 2020 at 11:54:19AM -0700, Linus Torvalds wrote:
> > On Sun, Aug 30, 2020 at 11:04 AM Thomas Gleixner <[email protected]> wrote:
> > >
> > > - Make is_idle_task() __always_inline to prevent the compiler from putting
> > > it out of line into the wrong section because it's used inside noinstr
> > > sections.
> >
> > What completely broken compiler uninlined that single-instruction function?
> >
> > I've obviously pulled this, but it sounds like there should be a
> > compiler bug-report for this insane behavior.
> >
> > Or is Marco building the kernel without optimizations or something
> > like that? That has not been a supported model, for various good
> > reasons..
>
> I think that was Clang with KCSAN on, KCSAN obviously makes this
> function a little bigger with the instrumentation for the load(s). But
> yes...

I wasn't quite sure myself if it was Clang or GCC, so I re-tested with
the linked config (which says GCC), and it reproduces on both.