linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] init: Initialize jump labels before command line option parsing
@ 2019-04-16 20:54 Dan Williams
  2019-04-16 23:44 ` Andrew Morton
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Williams @ 2019-04-16 20:54 UTC (permalink / raw)
  To: linux-kernel
  Cc: Guenter Roeck, Mathieu Desnoyers, Andrew Morton, Thomas Gleixner,
	Mike Rapoport, linux-mm

When a module option, or core kernel argument, toggles a static-key it
requires jump labels to be initialized early. While x86, PowerPC, and
ARM64 arrange for jump_label_init() to be called before parse_args(),
ARM does not.

  Kernel command line: rdinit=/sbin/init page_alloc.shuffle=1 panic=-1 console=ttyAMA0,115200 page_alloc.shuffle=1
  ------------[ cut here ]------------
  WARNING: CPU: 0 PID: 0 at ./include/linux/jump_label.h:303
  page_alloc_shuffle+0x12c/0x1ac
  static_key_enable(): static key 'page_alloc_shuffle_key+0x0/0x4' used
  before call to jump_label_init()
  Modules linked in:
  CPU: 0 PID: 0 Comm: swapper Not tainted
  5.1.0-rc4-next-20190410-00003-g3367c36ce744 #1
  Hardware name: ARM Integrator/CP (Device Tree)
  [<c0011c68>] (unwind_backtrace) from [<c000ec48>] (show_stack+0x10/0x18)
  [<c000ec48>] (show_stack) from [<c07e9710>] (dump_stack+0x18/0x24)
  [<c07e9710>] (dump_stack) from [<c001bb1c>] (__warn+0xe0/0x108)
  [<c001bb1c>] (__warn) from [<c001bb88>] (warn_slowpath_fmt+0x44/0x6c)
  [<c001bb88>] (warn_slowpath_fmt) from [<c0b0c4a8>]
  (page_alloc_shuffle+0x12c/0x1ac)
  [<c0b0c4a8>] (page_alloc_shuffle) from [<c0b0c550>] (shuffle_store+0x28/0x48)
  [<c0b0c550>] (shuffle_store) from [<c003e6a0>] (parse_args+0x1f4/0x350)
  [<c003e6a0>] (parse_args) from [<c0ac3c00>] (start_kernel+0x1c0/0x488)

Move the fallback call to jump_label_init() to occur before
parse_args(). The redundant calls to jump_label_init() in other archs
are left intact in case they have static key toggling use cases that are
even earlier than option parsing.

Reported-by: Guenter Roeck <groeck@google.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Mike Rapoport <rppt@linux.ibm.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 init/main.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/init/main.c b/init/main.c
index 598e278b46f7..7d4025d665eb 100644
--- a/init/main.c
+++ b/init/main.c
@@ -582,6 +582,8 @@ asmlinkage __visible void __init start_kernel(void)
 	page_alloc_init();
 
 	pr_notice("Kernel command line: %s\n", boot_command_line);
+	/* parameters may set static keys */
+	jump_label_init();
 	parse_early_param();
 	after_dashes = parse_args("Booting kernel",
 				  static_command_line, __start___param,
@@ -591,8 +593,6 @@ asmlinkage __visible void __init start_kernel(void)
 		parse_args("Setting init args", after_dashes, NULL, 0, -1, -1,
 			   NULL, set_init_arg);
 
-	jump_label_init();
-
 	/*
 	 * These use large bootmem allocations and must precede
 	 * kmem_cache_init()


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] init: Initialize jump labels before command line option parsing
  2019-04-16 20:54 [PATCH] init: Initialize jump labels before command line option parsing Dan Williams
@ 2019-04-16 23:44 ` Andrew Morton
  2019-04-17  0:04   ` Dan Williams
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2019-04-16 23:44 UTC (permalink / raw)
  To: Dan Williams
  Cc: linux-kernel, Guenter Roeck, Mathieu Desnoyers, Thomas Gleixner,
	Mike Rapoport, linux-mm

On Tue, 16 Apr 2019 13:54:04 -0700 Dan Williams <dan.j.williams@intel.com> wrote:

> When a module option, or core kernel argument, toggles a static-key it
> requires jump labels to be initialized early. While x86, PowerPC, and
> ARM64 arrange for jump_label_init() to be called before parse_args(),
> ARM does not.
> 
>   Kernel command line: rdinit=/sbin/init page_alloc.shuffle=1 panic=-1 console=ttyAMA0,115200 page_alloc.shuffle=1
>   ------------[ cut here ]------------
>   WARNING: CPU: 0 PID: 0 at ./include/linux/jump_label.h:303
>   page_alloc_shuffle+0x12c/0x1ac
>   static_key_enable(): static key 'page_alloc_shuffle_key+0x0/0x4' used
>   before call to jump_label_init()
>   Modules linked in:
>   CPU: 0 PID: 0 Comm: swapper Not tainted
>   5.1.0-rc4-next-20190410-00003-g3367c36ce744 #1
>   Hardware name: ARM Integrator/CP (Device Tree)
>   [<c0011c68>] (unwind_backtrace) from [<c000ec48>] (show_stack+0x10/0x18)
>   [<c000ec48>] (show_stack) from [<c07e9710>] (dump_stack+0x18/0x24)
>   [<c07e9710>] (dump_stack) from [<c001bb1c>] (__warn+0xe0/0x108)
>   [<c001bb1c>] (__warn) from [<c001bb88>] (warn_slowpath_fmt+0x44/0x6c)
>   [<c001bb88>] (warn_slowpath_fmt) from [<c0b0c4a8>]
>   (page_alloc_shuffle+0x12c/0x1ac)
>   [<c0b0c4a8>] (page_alloc_shuffle) from [<c0b0c550>] (shuffle_store+0x28/0x48)
>   [<c0b0c550>] (shuffle_store) from [<c003e6a0>] (parse_args+0x1f4/0x350)
>   [<c003e6a0>] (parse_args) from [<c0ac3c00>] (start_kernel+0x1c0/0x488)
> 
> Move the fallback call to jump_label_init() to occur before
> parse_args(). The redundant calls to jump_label_init() in other archs
> are left intact in case they have static key toggling use cases that are
> even earlier than option parsing.

Has it been confirmed that this fixes
mm-shuffle-initial-free-memory-to-improve-memory-side-cache-utilization.patch
on beaglebone-black?


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] init: Initialize jump labels before command line option parsing
  2019-04-16 23:44 ` Andrew Morton
@ 2019-04-17  0:04   ` Dan Williams
  2019-04-17  0:39     ` Guenter Roeck
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Williams @ 2019-04-17  0:04 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Linux Kernel Mailing List, Guenter Roeck, Mathieu Desnoyers,
	Thomas Gleixner, Mike Rapoport, Linux MM

On Tue, Apr 16, 2019 at 4:44 PM Andrew Morton <akpm@linux-foundation.org> wrote:
>
> On Tue, 16 Apr 2019 13:54:04 -0700 Dan Williams <dan.j.williams@intel.com> wrote:
>
> > When a module option, or core kernel argument, toggles a static-key it
> > requires jump labels to be initialized early. While x86, PowerPC, and
> > ARM64 arrange for jump_label_init() to be called before parse_args(),
> > ARM does not.
> >
> >   Kernel command line: rdinit=/sbin/init page_alloc.shuffle=1 panic=-1 console=ttyAMA0,115200 page_alloc.shuffle=1
> >   ------------[ cut here ]------------
> >   WARNING: CPU: 0 PID: 0 at ./include/linux/jump_label.h:303
> >   page_alloc_shuffle+0x12c/0x1ac
> >   static_key_enable(): static key 'page_alloc_shuffle_key+0x0/0x4' used
> >   before call to jump_label_init()
> >   Modules linked in:
> >   CPU: 0 PID: 0 Comm: swapper Not tainted
> >   5.1.0-rc4-next-20190410-00003-g3367c36ce744 #1
> >   Hardware name: ARM Integrator/CP (Device Tree)
> >   [<c0011c68>] (unwind_backtrace) from [<c000ec48>] (show_stack+0x10/0x18)
> >   [<c000ec48>] (show_stack) from [<c07e9710>] (dump_stack+0x18/0x24)
> >   [<c07e9710>] (dump_stack) from [<c001bb1c>] (__warn+0xe0/0x108)
> >   [<c001bb1c>] (__warn) from [<c001bb88>] (warn_slowpath_fmt+0x44/0x6c)
> >   [<c001bb88>] (warn_slowpath_fmt) from [<c0b0c4a8>]
> >   (page_alloc_shuffle+0x12c/0x1ac)
> >   [<c0b0c4a8>] (page_alloc_shuffle) from [<c0b0c550>] (shuffle_store+0x28/0x48)
> >   [<c0b0c550>] (shuffle_store) from [<c003e6a0>] (parse_args+0x1f4/0x350)
> >   [<c003e6a0>] (parse_args) from [<c0ac3c00>] (start_kernel+0x1c0/0x488)
> >
> > Move the fallback call to jump_label_init() to occur before
> > parse_args(). The redundant calls to jump_label_init() in other archs
> > are left intact in case they have static key toggling use cases that are
> > even earlier than option parsing.
>
> Has it been confirmed that this fixes
> mm-shuffle-initial-free-memory-to-improve-memory-side-cache-utilization.patch
> on beaglebone-black?

This only fixes dynamically enabling the shuffling on 32-bit ARM.
Guenter happened to run without the mm-only 'force-enable-always'
patch and when he went to use the command line option to enable it he
hit the jump-label warning.

The original beaglebone-black failure was something different and
avoided this case because the jump-label was never used.

I am otherwise unable to recreate the failure on either the original
failing -next, nor on v5.1-rc5 plus the latest state of the patches. I
need from someone who is actually still seeing the failure so they can
compare with the configuration that is working for me. For reference
that's the Yocto beaglebone-black defconfig:

https://github.com/jumpnow/meta-bbb/blob/thud/recipes-kernel/linux/linux-stable-5.0/beaglebone/defconfig

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] init: Initialize jump labels before command line option parsing
  2019-04-17  0:04   ` Dan Williams
@ 2019-04-17  0:39     ` Guenter Roeck
  2019-04-17  3:24       ` Andrew Morton
  0 siblings, 1 reply; 5+ messages in thread
From: Guenter Roeck @ 2019-04-17  0:39 UTC (permalink / raw)
  To: Dan Williams
  Cc: Andrew Morton, Linux Kernel Mailing List, Guenter Roeck,
	Mathieu Desnoyers, Thomas Gleixner, Mike Rapoport, Linux MM

On Tue, Apr 16, 2019 at 5:04 PM Dan Williams <dan.j.williams@intel.com> wrote:
>
> On Tue, Apr 16, 2019 at 4:44 PM Andrew Morton <akpm@linux-foundation.org> wrote:
> >
> > On Tue, 16 Apr 2019 13:54:04 -0700 Dan Williams <dan.j.williams@intel.com> wrote:
> >
> > > When a module option, or core kernel argument, toggles a static-key it
> > > requires jump labels to be initialized early. While x86, PowerPC, and
> > > ARM64 arrange for jump_label_init() to be called before parse_args(),
> > > ARM does not.
> > >
> > >   Kernel command line: rdinit=/sbin/init page_alloc.shuffle=1 panic=-1 console=ttyAMA0,115200 page_alloc.shuffle=1
> > >   ------------[ cut here ]------------
> > >   WARNING: CPU: 0 PID: 0 at ./include/linux/jump_label.h:303
> > >   page_alloc_shuffle+0x12c/0x1ac
> > >   static_key_enable(): static key 'page_alloc_shuffle_key+0x0/0x4' used
> > >   before call to jump_label_init()
> > >   Modules linked in:
> > >   CPU: 0 PID: 0 Comm: swapper Not tainted
> > >   5.1.0-rc4-next-20190410-00003-g3367c36ce744 #1
> > >   Hardware name: ARM Integrator/CP (Device Tree)
> > >   [<c0011c68>] (unwind_backtrace) from [<c000ec48>] (show_stack+0x10/0x18)
> > >   [<c000ec48>] (show_stack) from [<c07e9710>] (dump_stack+0x18/0x24)
> > >   [<c07e9710>] (dump_stack) from [<c001bb1c>] (__warn+0xe0/0x108)
> > >   [<c001bb1c>] (__warn) from [<c001bb88>] (warn_slowpath_fmt+0x44/0x6c)
> > >   [<c001bb88>] (warn_slowpath_fmt) from [<c0b0c4a8>]
> > >   (page_alloc_shuffle+0x12c/0x1ac)
> > >   [<c0b0c4a8>] (page_alloc_shuffle) from [<c0b0c550>] (shuffle_store+0x28/0x48)
> > >   [<c0b0c550>] (shuffle_store) from [<c003e6a0>] (parse_args+0x1f4/0x350)
> > >   [<c003e6a0>] (parse_args) from [<c0ac3c00>] (start_kernel+0x1c0/0x488)
> > >
> > > Move the fallback call to jump_label_init() to occur before
> > > parse_args(). The redundant calls to jump_label_init() in other archs
> > > are left intact in case they have static key toggling use cases that are
> > > even earlier than option parsing.
> >
> > Has it been confirmed that this fixes
> > mm-shuffle-initial-free-memory-to-improve-memory-side-cache-utilization.patch
> > on beaglebone-black?
>
> This only fixes dynamically enabling the shuffling on 32-bit ARM.
> Guenter happened to run without the mm-only 'force-enable-always'
> patch and when he went to use the command line option to enable it he
> hit the jump-label warning.
>

For my part I have not seen the original failure; it seems that the
kernelci logs are no longer present. As such, I neither know how it
looks like nor how to (try to) reproduce it. I just thought it might
be worthwhile to run the patch through my boot tests to see if
anything pops up. From the feedback I got, though, it sounded like the
failure is/was very omap2 specific, so I would not be able to
reproduce it anyway.

Guenter

> The original beaglebone-black failure was something different and
> avoided this case because the jump-label was never used.
>
> I am otherwise unable to recreate the failure on either the original
> failing -next, nor on v5.1-rc5 plus the latest state of the patches. I
> need from someone who is actually still seeing the failure so they can
> compare with the configuration that is working for me. For reference
> that's the Yocto beaglebone-black defconfig:
>
> https://github.com/jumpnow/meta-bbb/blob/thud/recipes-kernel/linux/linux-stable-5.0/beaglebone/defconfig

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] init: Initialize jump labels before command line option parsing
  2019-04-17  0:39     ` Guenter Roeck
@ 2019-04-17  3:24       ` Andrew Morton
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew Morton @ 2019-04-17  3:24 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Dan Williams, Linux Kernel Mailing List, Mathieu Desnoyers,
	Thomas Gleixner, Mike Rapoport, Linux MM

On Tue, 16 Apr 2019 17:39:03 -0700 Guenter Roeck <groeck@google.com> wrote:

> > > Has it been confirmed that this fixes
> > > mm-shuffle-initial-free-memory-to-improve-memory-side-cache-utilization.patch
> > > on beaglebone-black?
> >
> > This only fixes dynamically enabling the shuffling on 32-bit ARM.
> > Guenter happened to run without the mm-only 'force-enable-always'
> > patch and when he went to use the command line option to enable it he
> > hit the jump-label warning.
> >
> 
> For my part I have not seen the original failure; it seems that the
> kernelci logs are no longer present. As such, I neither know how it
> looks like nor how to (try to) reproduce it. I just thought it might
> be worthwhile to run the patch through my boot tests to see if
> anything pops up. From the feedback I got, though, it sounded like the
> failure is/was very omap2 specific, so I would not be able to
> reproduce it anyway.

hm.  Maybe we forge ahead and see if someone hits the issue who
can work with us on resolving it.  It sounds like the affected population
will be quite small.  But still, ugh :(

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-04-17  3:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-16 20:54 [PATCH] init: Initialize jump labels before command line option parsing Dan Williams
2019-04-16 23:44 ` Andrew Morton
2019-04-17  0:04   ` Dan Williams
2019-04-17  0:39     ` Guenter Roeck
2019-04-17  3:24       ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).