2022-05-27 11:33:23

by Peter Zijlstra

[permalink] [raw]
Subject: [PATCH 7/7] context_tracking: Always inline empty stubs

Because GCC is seriously challenged..

vmlinux.o: warning: objtool: enter_from_user_mode+0x85: call to context_tracking_enabled() leaves .noinstr.text section
vmlinux.o: warning: objtool: syscall_enter_from_user_mode+0x8f: call to context_tracking_enabled() leaves .noinstr.text section
vmlinux.o: warning: objtool: syscall_enter_from_user_mode_prepare+0x85: call to context_tracking_enabled() leaves .noinstr.text section
vmlinux.o: warning: objtool: irqentry_enter_from_user_mode+0x85: call to context_tracking_enabled() leaves .noinstr.text section

Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
---
include/linux/context_tracking_state.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

--- a/include/linux/context_tracking_state.h
+++ b/include/linux/context_tracking_state.h
@@ -46,10 +46,10 @@ static __always_inline bool context_trac
return __this_cpu_read(context_tracking.state) == CONTEXT_USER;
}
#else
-static inline bool context_tracking_in_user(void) { return false; }
-static inline bool context_tracking_enabled(void) { return false; }
-static inline bool context_tracking_enabled_cpu(int cpu) { return false; }
-static inline bool context_tracking_enabled_this_cpu(void) { return false; }
+static __always_inline bool context_tracking_in_user(void) { return false; }
+static __always_inline bool context_tracking_enabled(void) { return false; }
+static __always_inline bool context_tracking_enabled_cpu(int cpu) { return false; }
+static __always_inline bool context_tracking_enabled_this_cpu(void) { return false; }
#endif /* CONFIG_CONTEXT_TRACKING */

#endif




2022-05-27 11:52:15

by Mark Rutland

[permalink] [raw]
Subject: Re: [PATCH 7/7] context_tracking: Always inline empty stubs

On Thu, May 26, 2022 at 08:16:54AM -0700, Josh Poimboeuf wrote:
> On Thu, May 26, 2022 at 04:10:52PM +0100, Mark Rutland wrote:
> > On Thu, May 26, 2022 at 08:02:06AM -0700, Josh Poimboeuf wrote:
> > > On Thu, May 26, 2022 at 12:52:59PM +0200, Peter Zijlstra wrote:
> > > > Because GCC is seriously challenged..
> > >
> > > Or are these CONFIG_DEBUG_SECTION_MISMATCH?
> >
> > Does it matter?
>
> Yes, because I believe the only thing this option is good for is
> creating a bunch of useless '__always_inline' patches:
>
> https://lore.kernel.org/all/7fad83ecde03540e65677959034315f8fbb3755e.1649434832.git.jpoimboe@redhat.com/

Sure, but as I said, there are other reasons why the compiler can generate code
in this way, even if that's unlikely. Without `__always_inline` we don't
actually have a guarantee of inlining, so those warning *is* legitimate, even
if 99.99% of the time the compiler doesn't decide to generate code in a silly
way.

Thanks,
Mark.

2022-05-27 17:55:03

by Josh Poimboeuf

[permalink] [raw]
Subject: Re: [PATCH 7/7] context_tracking: Always inline empty stubs

On Thu, May 26, 2022 at 12:52:59PM +0200, Peter Zijlstra wrote:
> Because GCC is seriously challenged..

Or are these CONFIG_DEBUG_SECTION_MISMATCH?

--
Josh

2022-05-28 19:26:40

by Josh Poimboeuf

[permalink] [raw]
Subject: Re: [PATCH 7/7] context_tracking: Always inline empty stubs

On Thu, May 26, 2022 at 04:10:52PM +0100, Mark Rutland wrote:
> On Thu, May 26, 2022 at 08:02:06AM -0700, Josh Poimboeuf wrote:
> > On Thu, May 26, 2022 at 12:52:59PM +0200, Peter Zijlstra wrote:
> > > Because GCC is seriously challenged..
> >
> > Or are these CONFIG_DEBUG_SECTION_MISMATCH?
>
> Does it matter?

Yes, because I believe the only thing this option is good for is
creating a bunch of useless '__always_inline' patches:

https://lore.kernel.org/all/7fad83ecde03540e65677959034315f8fbb3755e.1649434832.git.jpoimboe@redhat.com/

--
Josh

2022-05-28 20:07:20

by Mark Rutland

[permalink] [raw]
Subject: Re: [PATCH 7/7] context_tracking: Always inline empty stubs

On Thu, May 26, 2022 at 08:02:06AM -0700, Josh Poimboeuf wrote:
> On Thu, May 26, 2022 at 12:52:59PM +0200, Peter Zijlstra wrote:
> > Because GCC is seriously challenged..
>
> Or are these CONFIG_DEBUG_SECTION_MISMATCH?

Does it matter?

The fact that CONFIG_DEBUG_SECTION_MISMATCH=y forces GCC to place these
out-of-line is really a debugging aid, since it shows us what it could
potentially leave out-of-line. It's not the *only* reason GCC might do this
(e.g. I see sanitizers and other debug options often have similar effects on
arm64).

So FWIW, for the patch:

Acked-by: Mark Rutland <[email protected]>

... as I'd like this for arm64, even if you don't beleive that's necessary for
x86.

Thanks,
Mark.

Subject: [tip: objtool/urgent] context_tracking: Always inline empty stubs

The following commit has been merged into the objtool/urgent branch of tip:

Commit-ID: 620f8d3bd3d5e82dff8cc591c831827d4beeae2e
Gitweb: https://git.kernel.org/tip/620f8d3bd3d5e82dff8cc591c831827d4beeae2e
Author: Peter Zijlstra <[email protected]>
AuthorDate: Sat, 07 May 2022 13:35:37 +02:00
Committer: Peter Zijlstra <[email protected]>
CommitterDate: Fri, 27 May 2022 12:34:44 +02:00

context_tracking: Always inline empty stubs

Because GCC is seriously challenged..

vmlinux.o: warning: objtool: enter_from_user_mode+0x85: call to context_tracking_enabled() leaves .noinstr.text section
vmlinux.o: warning: objtool: syscall_enter_from_user_mode+0x8f: call to context_tracking_enabled() leaves .noinstr.text section
vmlinux.o: warning: objtool: syscall_enter_from_user_mode_prepare+0x85: call to context_tracking_enabled() leaves .noinstr.text section
vmlinux.o: warning: objtool: irqentry_enter_from_user_mode+0x85: call to context_tracking_enabled() leaves .noinstr.text section

Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Acked-by: Mark Rutland <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
---
include/linux/context_tracking_state.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/linux/context_tracking_state.h b/include/linux/context_tracking_state.h
index 65a60d3..ae1e63e 100644
--- a/include/linux/context_tracking_state.h
+++ b/include/linux/context_tracking_state.h
@@ -46,10 +46,10 @@ static __always_inline bool context_tracking_in_user(void)
return __this_cpu_read(context_tracking.state) == CONTEXT_USER;
}
#else
-static inline bool context_tracking_in_user(void) { return false; }
-static inline bool context_tracking_enabled(void) { return false; }
-static inline bool context_tracking_enabled_cpu(int cpu) { return false; }
-static inline bool context_tracking_enabled_this_cpu(void) { return false; }
+static __always_inline bool context_tracking_in_user(void) { return false; }
+static __always_inline bool context_tracking_enabled(void) { return false; }
+static __always_inline bool context_tracking_enabled_cpu(int cpu) { return false; }
+static __always_inline bool context_tracking_enabled_this_cpu(void) { return false; }
#endif /* CONFIG_CONTEXT_TRACKING */

#endif