Re: [PATCH 20/30] panic: Add the panic informational notifier list

2022-04-28 Thread Paul E. McKenney
On Wed, Apr 27, 2022 at 07:49:14PM -0300, Guilherme G. Piccoli wrote:
> The goal of this new panic notifier is to allow its users to
> register callbacks to run earlier in the panic path than they
> currently do. This aims at informational mechanisms, like dumping
> kernel offsets and showing device error data (in case it's simple
> registers reading, for example) as well as mechanisms to disable
> log flooding (like hung_task detector / RCU warnings) and the
> tracing dump_on_oops (when enabled).
> 
> Any (non-invasive) information that should be provided before
> kmsg_dump() as well as log flooding preventing code should fit
> here, as long it offers relatively low risk for kdump.
> 
> For now, the patch is almost a no-op, although it changes a bit
> the ordering in which some panic notifiers are executed - specially
> affected by this are the notifiers responsible for disabling the
> hung_task detector / RCU warnings, which now run first. In a
> subsequent patch, the panic path will be refactored, then the
> panic informational notifiers will effectively run earlier,
> before ksmg_dump() (and usually before kdump as well).
> 
> We also defer documenting it all properly in the subsequent
> refactor patch. Finally, while at it, we removed some useless
> header inclusions too.
> 
> Cc: Benjamin Herrenschmidt 
> Cc: Catalin Marinas 
> Cc: Florian Fainelli 
> Cc: Frederic Weisbecker 
> Cc: "H. Peter Anvin" 
> Cc: Hari Bathini 
> Cc: Joel Fernandes 
> Cc: Jonathan Hunter 
> Cc: Josh Triplett 
> Cc: Lai Jiangshan 
> Cc: Leo Yan 
> Cc: Mathieu Desnoyers 
> Cc: Mathieu Poirier 
> Cc: Michael Ellerman 
> Cc: Mike Leach 
> Cc: Mikko Perttunen 
> Cc: Neeraj Upadhyay 
> Cc: Nicholas Piggin 
> Cc: Paul Mackerras 
> Cc: Suzuki K Poulose 
> Cc: Thierry Reding 
> Cc: Thomas Bogendoerfer 
> Signed-off-by: Guilherme G. Piccoli 

>From an RCU perspective:

Acked-by: Paul E. McKenney 

> ---
>  arch/arm64/kernel/setup.c | 2 +-
>  arch/mips/kernel/relocate.c   | 2 +-
>  arch/powerpc/kernel/setup-common.c| 2 +-
>  arch/x86/kernel/setup.c   | 2 +-
>  drivers/bus/brcmstb_gisb.c| 2 +-
>  drivers/hwtracing/coresight/coresight-cpu-debug.c | 4 ++--
>  drivers/soc/tegra/ari-tegra186.c  | 3 ++-
>  include/linux/panic_notifier.h| 1 +
>  kernel/hung_task.c| 3 ++-
>  kernel/panic.c| 4 
>  kernel/rcu/tree.c | 1 -
>  kernel/rcu/tree_stall.h   | 3 ++-
>  kernel/trace/trace.c  | 2 +-
>  13 files changed, 19 insertions(+), 12 deletions(-)
> 
> diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
> index 3505789cf4bd..ac2c7e8c9c6a 100644
> --- a/arch/arm64/kernel/setup.c
> +++ b/arch/arm64/kernel/setup.c
> @@ -444,7 +444,7 @@ static struct notifier_block arm64_panic_block = {
>  
>  static int __init register_arm64_panic_block(void)
>  {
> - atomic_notifier_chain_register(_notifier_list,
> + atomic_notifier_chain_register(_info_list,
>  _panic_block);
>   return 0;
>  }
> diff --git a/arch/mips/kernel/relocate.c b/arch/mips/kernel/relocate.c
> index 56b51de2dc51..650811f2436a 100644
> --- a/arch/mips/kernel/relocate.c
> +++ b/arch/mips/kernel/relocate.c
> @@ -459,7 +459,7 @@ static struct notifier_block kernel_location_notifier = {
>  
>  static int __init register_kernel_offset_dumper(void)
>  {
> - atomic_notifier_chain_register(_notifier_list,
> + atomic_notifier_chain_register(_info_list,
>  _location_notifier);
>   return 0;
>  }
> diff --git a/arch/powerpc/kernel/setup-common.c 
> b/arch/powerpc/kernel/setup-common.c
> index 1468c3937bf4..d04b8bf8dbc7 100644
> --- a/arch/powerpc/kernel/setup-common.c
> +++ b/arch/powerpc/kernel/setup-common.c
> @@ -757,7 +757,7 @@ void __init setup_panic(void)
>  _fadump_block);
>  
>   if (IS_ENABLED(CONFIG_RANDOMIZE_BASE) && kaslr_offset() > 0)
> - atomic_notifier_chain_register(_notifier_list,
> + atomic_notifier_chain_register(_info_list,
>  _offset_notifier);
>  
>   /* Low-level platform-specific routines that should run on panic */
> diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
> index c95b9ac5a457..599b25346964 100644
> --- a/arch/x86/kernel/setup.c
> +++ b/arch/x86/kernel/setup.c
> @@ -1266,7 +1266,7 @@ static struct not

Re: [PATCH v3 2/3] printk: add lockless ringbuffer

2020-06-30 Thread Paul E. McKenney
On Thu, Jun 18, 2020 at 04:55:18PM +0206, John Ogness wrote:
> Introduce a multi-reader multi-writer lockless ringbuffer for storing
> the kernel log messages. Readers and writers may use their API from
> any context (including scheduler and NMI). This ringbuffer will make
> it possible to decouple printk() callers from any context, locking,
> or console constraints. It also makes it possible for readers to have
> full access to the ringbuffer contents at any time and context (for
> example from any panic situation).
> 
> The printk_ringbuffer is made up of 3 internal ringbuffers:
> 
> desc_ring:
> A ring of descriptors. A descriptor contains all record meta data
> (sequence number, timestamp, loglevel, etc.) as well as internal state
> information about the record and logical positions specifying where in
> the other ringbuffers the text and dictionary strings are located.
> 
> text_data_ring:
> A ring of data blocks. A data block consists of an unsigned long
> integer (ID) that maps to a desc_ring index followed by the text
> string of the record.
> 
> dict_data_ring:
> A ring of data blocks. A data block consists of an unsigned long
> integer (ID) that maps to a desc_ring index followed by the dictionary
> string of the record.
> 
> The internal state information of a descriptor is the key element to
> allow readers and writers to locklessly synchronize access to the data.
> 
> Co-developed-by: Petr Mladek 
> Signed-off-by: John Ogness 

The orderings match the comments, although a number could (later!)
be weakened to the easier-to-read smp_load_acquire() and/or
smp_store_release().  So, from a memory-ordering perspective:

Reviewed-by: Paul E. McKenney 

> ---
>  kernel/printk/Makefile|1 +
>  kernel/printk/printk_ringbuffer.c | 1674 +
>  kernel/printk/printk_ringbuffer.h |  352 ++
>  3 files changed, 2027 insertions(+)
>  create mode 100644 kernel/printk/printk_ringbuffer.c
>  create mode 100644 kernel/printk/printk_ringbuffer.h
> 
> diff --git a/kernel/printk/Makefile b/kernel/printk/Makefile
> index 4d052fc6bcde..eee3dc9b60a9 100644
> --- a/kernel/printk/Makefile
> +++ b/kernel/printk/Makefile
> @@ -2,3 +2,4 @@
>  obj-y= printk.o
>  obj-$(CONFIG_PRINTK) += printk_safe.o
>  obj-$(CONFIG_A11Y_BRAILLE_CONSOLE)   += braille.o
> +obj-$(CONFIG_PRINTK) += printk_ringbuffer.o
> diff --git a/kernel/printk/printk_ringbuffer.c 
> b/kernel/printk/printk_ringbuffer.c
> new file mode 100644
> index ..75d056436cc5
> --- /dev/null
> +++ b/kernel/printk/printk_ringbuffer.c
> @@ -0,0 +1,1674 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include "printk_ringbuffer.h"
> +
> +/**
> + * DOC: printk_ringbuffer overview
> + *
> + * Data Structure
> + * --
> + * The printk_ringbuffer is made up of 3 internal ringbuffers:
> + *
> + *   desc_ring
> + * A ring of descriptors. A descriptor contains all record meta data
> + * (sequence number, timestamp, loglevel, etc.) as well as internal state
> + * information about the record and logical positions specifying where in
> + * the other ringbuffers the text and dictionary strings are located.
> + *
> + *   text_data_ring
> + * A ring of data blocks. A data block consists of an unsigned long
> + * integer (ID) that maps to a desc_ring index followed by the text
> + * string of the record.
> + *
> + *   dict_data_ring
> + * A ring of data blocks. A data block consists of an unsigned long
> + * integer (ID) that maps to a desc_ring index followed by the dictionary
> + * string of the record.
> + *
> + * The internal state information of a descriptor is the key element to allow
> + * readers and writers to locklessly synchronize access to the data.
> + *
> + * Implementation
> + * --
> + *
> + * Descriptor Ring
> + * ~~~
> + * The descriptor ring is an array of descriptors. A descriptor contains all
> + * the meta data of a printk record as well as blk_lpos structs pointing to
> + * associated text and dictionary data blocks (see "Data Rings" below). Each
> + * descriptor is assigned an ID that maps directly to index values of the
> + * descriptor array and has a state. The ID and the state are bitwise 
> combined
> + * into a single descriptor field named @state_var, allowing ID and state to
> + * be synchronously and atomically updated.
> + *
> + * Descriptors have three states:
> + *
> + *   reserved
> + * A writer is modifying the record.
> + *
> + *   committed
> + * The record and all its data are complete and av

[PATCH] powerpc: Fix kexec-related UP build error

2011-04-15 Thread Paul E. McKenney
Hello!

The following patch fixes a UP build problem for kexec() on powerpc.
When the crash_kexec_wait_realmode() function was added, it was
placed in only two of the three required locations.

Thoughts?

Thanx, Paul



The function crash_kexec_wait_realmode() is defined only if SMP, but is
called in UP builds.  Create an empty function to keep the compiler happy
in UP builds.

Signed-off-by: Paul E. McKenney paul.mcken...@linaro.org
Signed-off-by: Paul E. McKenney paul...@linux.vnet.ibm.com

diff --git a/arch/powerpc/kernel/crash.c b/arch/powerpc/kernel/crash.c
index 3d3d416..6f964ef 100644
--- a/arch/powerpc/kernel/crash.c
+++ b/arch/powerpc/kernel/crash.c
@@ -251,6 +251,10 @@ static void crash_kexec_prepare_cpus(int cpu)
 #endif
 }
 
+static void crash_kexec_wait_realmode(int cpu)
+{
+}
+
 void crash_kexec_secondary(struct pt_regs *regs)
 {
cpus_in_sr = CPU_MASK_NONE;

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH] powerpc: Fix kexec-related UP build error

2011-04-15 Thread Paul E. McKenney
On Fri, Apr 15, 2011 at 02:00:51PM -0700, Nishanth Aravamudan wrote:
 Hi Paul,
 
 On 15.04.2011 [13:29:16 -0700], Paul E. McKenney wrote:
  Hello!
  
  The following patch fixes a UP build problem for kexec() on powerpc.
  When the crash_kexec_wait_realmode() function was added, it was
  placed in only two of the three required locations.
 
 I believe the fix has already been posted as
 
 http://lists.ozlabs.org/pipermail/linuxppc-dev/2011-April/089559.html

So it has!  Thank you for the pointer.

Thanx, Paul

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec