linux-rt-devel.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/9] preempt: Add a generic function to return the preemption string.
@ 2025-02-12 13:41 Sebastian Andrzej Siewior
  2025-02-12 13:41 ` [PATCH v3 1/9] sched: " Sebastian Andrzej Siewior
                   ` (8 more replies)
  0 siblings, 9 replies; 12+ messages in thread
From: Sebastian Andrzej Siewior @ 2025-02-12 13:41 UTC (permalink / raw)
  To: linux-kernel, linux-rt-devel
  Cc: Ben Segall, Catalin Marinas, Dietmar Eggemann, Ingo Molnar,
	Juri Lelli, Mel Gorman, Peter Zijlstra, Shrikanth Hegde,
	Steven Rostedt, Thomas Gleixner, Valentin Schneider,
	Vincent Guittot, Will Deacon, Sebastian Andrzej Siewior

The individual architectures often add the preemption model to the begin
of the backtrace. This is the case on X86 or ARM64 for the "die" case
but not for regular warning. With the addition of DYNAMIC_PREEMPT for
PREEMPT_RT we end up with CONFIG_PREEMPT and CONFIG_PREEMPT_RT set
simultaneously. That means that everyone who tried to add that piece of
information gets it wrong for PREEMPT_RT because PREEMPT is checked
first.

This series adds a generic helper which is used by
dump_stack_print_info() and other architectures which don't use the
function and provide this information on their own.

I collected ACKs for all architectures but x86.

v2…v3 https://lore.kernel.org/all/20250203141632.440554-1-bigeasy@linutronix.de/
  - powerpc/ s390 and xtensa had the preemption string twice. Removed
    from the arch code.
  - Keeping the same printk() invocation, avoiding adding any level.
  - #1 has now a table showing which strings are possible.

RFC…v2 https://lore.kernel.org/all/20241206113431.Q-VXMlru@linutronix.de/
  - Split into individual patches.
  - Implement preempt_model_str() based on feedback by Peter Zijlstra
    and Steven Rostedt.

Sebastian Andrzej Siewior (9):
  sched: Add a generic function to return the preemption string.
  lib/dump_stack: Use preempt_model_str().
  arm: Rely on generic printing of preemption model.
  arm64: Rely on generic printing of preemption model.
  powerpc: Rely on generic printing of preemption model.
  s390: Rely on generic printing of preemption model.
  x86: Rely on generic printing of preemption model.
  xtensa: Rely on generic printing of preemption model.
  tracing: Use preempt_model_str().

 arch/arm/kernel/traps.c      | 11 ++-------
 arch/arm64/kernel/traps.c    | 10 +-------
 arch/powerpc/kernel/traps.c  |  3 +--
 arch/s390/kernel/dumpstack.c |  7 +-----
 arch/x86/kernel/dumpstack.c  |  9 ++-----
 arch/xtensa/kernel/traps.c   |  6 +----
 include/linux/preempt.h      |  2 ++
 kernel/sched/core.c          | 47 ++++++++++++++++++++++++++++++++++++
 kernel/sched/debug.c         | 10 +++++---
 kernel/sched/sched.h         |  1 +
 kernel/trace/trace.c         |  7 +-----
 lib/dump_stack.c             |  4 +--
 12 files changed, 67 insertions(+), 50 deletions(-)

Sebastian

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

* [PATCH v3 1/9] sched: Add a generic function to return the preemption string.
  2025-02-12 13:41 [PATCH v3 0/9] preempt: Add a generic function to return the preemption string Sebastian Andrzej Siewior
@ 2025-02-12 13:41 ` Sebastian Andrzej Siewior
  2025-02-12 13:41 ` [PATCH v3 2/9] lib/dump_stack: Use preempt_model_str() Sebastian Andrzej Siewior
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Sebastian Andrzej Siewior @ 2025-02-12 13:41 UTC (permalink / raw)
  To: linux-kernel, linux-rt-devel
  Cc: Ben Segall, Catalin Marinas, Dietmar Eggemann, Ingo Molnar,
	Juri Lelli, Mel Gorman, Peter Zijlstra, Shrikanth Hegde,
	Steven Rostedt, Thomas Gleixner, Valentin Schneider,
	Vincent Guittot, Will Deacon, Sebastian Andrzej Siewior

The individual architectures often add the preemption model to the begin
of the backtrace. This is the case on X86 or ARM64 for the "die" case
but not for regular warning. With the addition of DYNAMIC_PREEMPT for
PREEMPT_RT we end up with CONFIG_PREEMPT and CONFIG_PREEMPT_RT set
simultaneously. That means that everyone who tried to add that piece of
information gets it wrong for PREEMPT_RT because PREEMPT is checked
first.

Provide a generic function which returns the current scheduling model
considering LAZY preempt and the current state of PREEMPT_DYNAMIC.

The resulting strings are:
┏━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━┓
┃   Model   ┃  -RT -DYN    ┃     +RT -DYN      ┃     -RT +DYN       ┃     +RT +DYN      ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━┩
│NONE       │ NONE         │ n/a               │ PREEMPT(none)      │ n/a               │
├───────────┼──────────────┼───────────────────┼────────────────────┼───────────────────┤
│VOLUNTARY  │ VOLUNTARY    │ n/a               │ PREEMPT(voluntary) │ n/a               │
├───────────┼──────────────┼───────────────────┼────────────────────┼───────────────────┤
│FULL       │ PREEMPT      │ PREEMPT_RT        │ PREEMPT(full)      │ PREEMPT_{RT,full} │
├───────────┼──────────────┼───────────────────┼────────────────────┼───────────────────┤
│LAZY       │ PREEMPT_LAZY │ PREEMPT_{RT,LAZY} │ PREEMPT(lazy)      │ PREEMPT_{RT,lazy} │
└───────────┴──────────────┴───────────────────┴────────────────────┴───────────────────┘

[ The dynamic building of the string can lead to an empty string if the
  function is invoked simultaneously on two CPUs. ]

Co-developed-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Co-developed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Reviewed-by: Shrikanth Hegde <sshegde@linux.ibm.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 include/linux/preempt.h |  2 ++
 kernel/sched/core.c     | 47 +++++++++++++++++++++++++++++++++++++++++
 kernel/sched/debug.c    | 10 +++++----
 kernel/sched/sched.h    |  1 +
 4 files changed, 56 insertions(+), 4 deletions(-)

diff --git a/include/linux/preempt.h b/include/linux/preempt.h
index ca86235ac15c0..3e9808f2b5491 100644
--- a/include/linux/preempt.h
+++ b/include/linux/preempt.h
@@ -515,6 +515,8 @@ static inline bool preempt_model_rt(void)
 	return IS_ENABLED(CONFIG_PREEMPT_RT);
 }
 
+extern const char *preempt_model_str(void);
+
 /*
  * Does the preemption model allow non-cooperative preemption?
  *
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 165c90ba64ea9..c3d5f38dd0574 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -7646,10 +7646,57 @@ PREEMPT_MODEL_ACCESSOR(lazy);
 
 #else /* !CONFIG_PREEMPT_DYNAMIC: */
 
+#define preempt_dynamic_mode -1
+
 static inline void preempt_dynamic_init(void) { }
 
 #endif /* CONFIG_PREEMPT_DYNAMIC */
 
+const char *preempt_modes[] = {
+	"none", "voluntary", "full", "lazy", NULL,
+};
+
+const char *preempt_model_str(void)
+{
+	bool brace = IS_ENABLED(CONFIG_PREEMPT_RT) &&
+		(IS_ENABLED(CONFIG_PREEMPT_DYNAMIC) ||
+		 IS_ENABLED(CONFIG_PREEMPT_LAZY));
+	static char buf[128];
+
+	if (IS_ENABLED(CONFIG_PREEMPT_BUILD)) {
+		struct seq_buf s;
+
+		seq_buf_init(&s, buf, sizeof(buf));
+		seq_buf_puts(&s, "PREEMPT");
+
+		if (IS_ENABLED(CONFIG_PREEMPT_RT))
+			seq_buf_printf(&s, "%sRT%s",
+				       brace ? "_{" : "_",
+				       brace ? "," : "");
+
+		if (IS_ENABLED(CONFIG_PREEMPT_DYNAMIC)) {
+			seq_buf_printf(&s, "(%s)%s",
+				       preempt_dynamic_mode > 0 ?
+				       preempt_modes[preempt_dynamic_mode] : "undef",
+				       brace ? "}" : "");
+			return seq_buf_str(&s);
+		}
+
+		if (IS_ENABLED(CONFIG_PREEMPT_LAZY)) {
+			seq_buf_printf(&s, "LAZY%s",
+				       brace ? "}" : "");
+			return seq_buf_str(&s);
+		}
+
+		return seq_buf_str(&s);
+	}
+
+	if (IS_ENABLED(CONFIG_PREEMPT_VOLUNTARY_BUILD))
+		return "VOLUNTARY";
+
+	return "NONE";
+}
+
 int io_schedule_prepare(void)
 {
 	int old_iowait = current->in_iowait;
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index ef047add7f9e6..39be73969d284 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -244,11 +244,13 @@ static ssize_t sched_dynamic_write(struct file *filp, const char __user *ubuf,
 
 static int sched_dynamic_show(struct seq_file *m, void *v)
 {
-	static const char * preempt_modes[] = {
-		"none", "voluntary", "full", "lazy",
-	};
-	int j = ARRAY_SIZE(preempt_modes) - !IS_ENABLED(CONFIG_ARCH_HAS_PREEMPT_LAZY);
 	int i = IS_ENABLED(CONFIG_PREEMPT_RT) * 2;
+	int j;
+
+	/* Count entries in NULL terminated preempt_modes */
+	for (j = 0; preempt_modes[j]; j++)
+		;
+	j -= !IS_ENABLED(CONFIG_ARCH_HAS_PREEMPT_LAZY);
 
 	for (; i < j; i++) {
 		if (preempt_dynamic_mode == i)
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 38e0e323dda26..fb4486ceb978a 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -3619,6 +3619,7 @@ extern int preempt_dynamic_mode;
 extern int sched_dynamic_mode(const char *str);
 extern void sched_dynamic_update(int mode);
 #endif
+extern const char *preempt_modes[];
 
 #ifdef CONFIG_SCHED_MM_CID
 
-- 
2.47.2


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

* [PATCH v3 2/9] lib/dump_stack: Use preempt_model_str().
  2025-02-12 13:41 [PATCH v3 0/9] preempt: Add a generic function to return the preemption string Sebastian Andrzej Siewior
  2025-02-12 13:41 ` [PATCH v3 1/9] sched: " Sebastian Andrzej Siewior
@ 2025-02-12 13:41 ` Sebastian Andrzej Siewior
  2025-02-12 13:41 ` [PATCH v3 3/9] arm: Rely on generic printing of preemption model Sebastian Andrzej Siewior
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Sebastian Andrzej Siewior @ 2025-02-12 13:41 UTC (permalink / raw)
  To: linux-kernel, linux-rt-devel
  Cc: Ben Segall, Catalin Marinas, Dietmar Eggemann, Ingo Molnar,
	Juri Lelli, Mel Gorman, Peter Zijlstra, Shrikanth Hegde,
	Steven Rostedt, Thomas Gleixner, Valentin Schneider,
	Vincent Guittot, Will Deacon, Sebastian Andrzej Siewior,
	Andrew Morton

Use preempt_model_str() to print the current preemption model. Use
pr_warn() instead of printk() to pass a loglevel. This makes it part of
generic WARN/ BUG traces.

Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 lib/dump_stack.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/dump_stack.c b/lib/dump_stack.c
index 388da1aea14a5..b3a85fe8b673e 100644
--- a/lib/dump_stack.c
+++ b/lib/dump_stack.c
@@ -54,7 +54,7 @@ void __init dump_stack_set_arch_desc(const char *fmt, ...)
  */
 void dump_stack_print_info(const char *log_lvl)
 {
-	printk("%sCPU: %d UID: %u PID: %d Comm: %.20s %s%s %s %.*s" BUILD_ID_FMT "\n",
+	printk("%sCPU: %d UID: %u PID: %d Comm: %.20s %s%s %s %.*s %s " BUILD_ID_FMT "\n",
 	       log_lvl, raw_smp_processor_id(),
 	       __kuid_val(current_real_cred()->euid),
 	       current->pid, current->comm,
@@ -62,7 +62,7 @@ void dump_stack_print_info(const char *log_lvl)
 	       print_tainted(),
 	       init_utsname()->release,
 	       (int)strcspn(init_utsname()->version, " "),
-	       init_utsname()->version, BUILD_ID_VAL);
+	       init_utsname()->version, preempt_model_str(), BUILD_ID_VAL);
 
 	if (get_taint())
 		printk("%s%s\n", log_lvl, print_tainted_verbose());
-- 
2.47.2


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

* [PATCH v3 3/9] arm: Rely on generic printing of preemption model.
  2025-02-12 13:41 [PATCH v3 0/9] preempt: Add a generic function to return the preemption string Sebastian Andrzej Siewior
  2025-02-12 13:41 ` [PATCH v3 1/9] sched: " Sebastian Andrzej Siewior
  2025-02-12 13:41 ` [PATCH v3 2/9] lib/dump_stack: Use preempt_model_str() Sebastian Andrzej Siewior
@ 2025-02-12 13:41 ` Sebastian Andrzej Siewior
  2025-02-12 15:58   ` Russell King (Oracle)
  2025-02-12 13:41 ` [PATCH v3 4/9] arm64: " Sebastian Andrzej Siewior
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 12+ messages in thread
From: Sebastian Andrzej Siewior @ 2025-02-12 13:41 UTC (permalink / raw)
  To: linux-kernel, linux-rt-devel
  Cc: Ben Segall, Catalin Marinas, Dietmar Eggemann, Ingo Molnar,
	Juri Lelli, Mel Gorman, Peter Zijlstra, Shrikanth Hegde,
	Steven Rostedt, Thomas Gleixner, Valentin Schneider,
	Vincent Guittot, Will Deacon, Sebastian Andrzej Siewior,
	Russell King, linux-arm-kernel, Russell King (Oracle)

__die() invokes later __show_regs() -> show_regs_print_info() which
prints the current preemption model.
Remove it from the initial line.

Cc: Russell King <linux@armlinux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 arch/arm/kernel/traps.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index 6ea645939573f..afbd2ebe5c39d 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -258,13 +258,6 @@ void show_stack(struct task_struct *tsk, unsigned long *sp, const char *loglvl)
 	barrier();
 }
 
-#ifdef CONFIG_PREEMPT
-#define S_PREEMPT " PREEMPT"
-#elif defined(CONFIG_PREEMPT_RT)
-#define S_PREEMPT " PREEMPT_RT"
-#else
-#define S_PREEMPT ""
-#endif
 #ifdef CONFIG_SMP
 #define S_SMP " SMP"
 #else
@@ -282,8 +275,8 @@ static int __die(const char *str, int err, struct pt_regs *regs)
 	static int die_counter;
 	int ret;
 
-	pr_emerg("Internal error: %s: %x [#%d]" S_PREEMPT S_SMP S_ISA "\n",
-	         str, err, ++die_counter);
+	pr_emerg("Internal error: %s: %x [#%d]" S_SMP S_ISA "\n",
+		 str, err, ++die_counter);
 
 	/* trap and error numbers are mostly meaningless on ARM */
 	ret = notify_die(DIE_OOPS, str, regs, err, tsk->thread.trap_no, SIGSEGV);
-- 
2.47.2


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

* [PATCH v3 4/9] arm64: Rely on generic printing of preemption model.
  2025-02-12 13:41 [PATCH v3 0/9] preempt: Add a generic function to return the preemption string Sebastian Andrzej Siewior
                   ` (2 preceding siblings ...)
  2025-02-12 13:41 ` [PATCH v3 3/9] arm: Rely on generic printing of preemption model Sebastian Andrzej Siewior
@ 2025-02-12 13:41 ` Sebastian Andrzej Siewior
  2025-02-12 18:41   ` Catalin Marinas
  2025-02-12 13:41 ` [PATCH v3 5/9] powerpc: " Sebastian Andrzej Siewior
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 12+ messages in thread
From: Sebastian Andrzej Siewior @ 2025-02-12 13:41 UTC (permalink / raw)
  To: linux-kernel, linux-rt-devel
  Cc: Ben Segall, Catalin Marinas, Dietmar Eggemann, Ingo Molnar,
	Juri Lelli, Mel Gorman, Peter Zijlstra, Shrikanth Hegde,
	Steven Rostedt, Thomas Gleixner, Valentin Schneider,
	Vincent Guittot, Will Deacon, Sebastian Andrzej Siewior,
	linux-arm-kernel

__die() invokes later show_regs() -> show_regs_print_info() which prints
the current preemption model.
Remove it from the initial line.

Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Acked-by: Will Deacon <will@kernel.org>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 arch/arm64/kernel/traps.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
index 4e26bd356a482..529cff825531c 100644
--- a/arch/arm64/kernel/traps.c
+++ b/arch/arm64/kernel/traps.c
@@ -172,14 +172,6 @@ static void dump_kernel_instr(const char *lvl, struct pt_regs *regs)
 	printk("%sCode: %s\n", lvl, str);
 }
 
-#ifdef CONFIG_PREEMPT
-#define S_PREEMPT " PREEMPT"
-#elif defined(CONFIG_PREEMPT_RT)
-#define S_PREEMPT " PREEMPT_RT"
-#else
-#define S_PREEMPT ""
-#endif
-
 #define S_SMP " SMP"
 
 static int __die(const char *str, long err, struct pt_regs *regs)
@@ -187,7 +179,7 @@ static int __die(const char *str, long err, struct pt_regs *regs)
 	static int die_counter;
 	int ret;
 
-	pr_emerg("Internal error: %s: %016lx [#%d]" S_PREEMPT S_SMP "\n",
+	pr_emerg("Internal error: %s: %016lx [#%d] " S_SMP "\n",
 		 str, err, ++die_counter);
 
 	/* trap and error numbers are mostly meaningless on ARM */
-- 
2.47.2


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

* [PATCH v3 5/9] powerpc: Rely on generic printing of preemption model.
  2025-02-12 13:41 [PATCH v3 0/9] preempt: Add a generic function to return the preemption string Sebastian Andrzej Siewior
                   ` (3 preceding siblings ...)
  2025-02-12 13:41 ` [PATCH v3 4/9] arm64: " Sebastian Andrzej Siewior
@ 2025-02-12 13:41 ` Sebastian Andrzej Siewior
  2025-02-12 13:41 ` [PATCH v3 6/9] s390: " Sebastian Andrzej Siewior
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Sebastian Andrzej Siewior @ 2025-02-12 13:41 UTC (permalink / raw)
  To: linux-kernel, linux-rt-devel
  Cc: Ben Segall, Catalin Marinas, Dietmar Eggemann, Ingo Molnar,
	Juri Lelli, Mel Gorman, Peter Zijlstra, Shrikanth Hegde,
	Steven Rostedt, Thomas Gleixner, Valentin Schneider,
	Vincent Guittot, Will Deacon, Sebastian Andrzej Siewior,
	Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, Naveen N Rao, linuxppc-dev

After the first printk in __die() there is show_regs() ->
show_regs_print_info() which prints the current
preemption model.

Remove the preempion model from the arch code.

Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Naveen N Rao <naveen@kernel.org>
Cc: linuxppc-dev@lists.ozlabs.org
Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Reviewed-by: Shrikanth Hegde <sshegde@linux.ibm.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 arch/powerpc/kernel/traps.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index edf5cabe5dfdb..cb8e9357383e9 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -263,10 +263,9 @@ static int __die(const char *str, struct pt_regs *regs, long err)
 {
 	printk("Oops: %s, sig: %ld [#%d]\n", str, err, ++die_counter);
 
-	printk("%s PAGE_SIZE=%luK%s%s%s%s%s%s %s\n",
+	printk("%s PAGE_SIZE=%luK%s %s%s%s%s %s\n",
 	       IS_ENABLED(CONFIG_CPU_LITTLE_ENDIAN) ? "LE" : "BE",
 	       PAGE_SIZE / 1024, get_mmu_str(),
-	       IS_ENABLED(CONFIG_PREEMPT) ? " PREEMPT" : "",
 	       IS_ENABLED(CONFIG_SMP) ? " SMP" : "",
 	       IS_ENABLED(CONFIG_SMP) ? (" NR_CPUS=" __stringify(NR_CPUS)) : "",
 	       debug_pagealloc_enabled() ? " DEBUG_PAGEALLOC" : "",
-- 
2.47.2


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

* [PATCH v3 6/9] s390: Rely on generic printing of preemption model.
  2025-02-12 13:41 [PATCH v3 0/9] preempt: Add a generic function to return the preemption string Sebastian Andrzej Siewior
                   ` (4 preceding siblings ...)
  2025-02-12 13:41 ` [PATCH v3 5/9] powerpc: " Sebastian Andrzej Siewior
@ 2025-02-12 13:41 ` Sebastian Andrzej Siewior
  2025-02-12 13:41 ` [PATCH v3 7/9] x86: " Sebastian Andrzej Siewior
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Sebastian Andrzej Siewior @ 2025-02-12 13:41 UTC (permalink / raw)
  To: linux-kernel, linux-rt-devel
  Cc: Ben Segall, Catalin Marinas, Dietmar Eggemann, Ingo Molnar,
	Juri Lelli, Mel Gorman, Peter Zijlstra, Shrikanth Hegde,
	Steven Rostedt, Thomas Gleixner, Valentin Schneider,
	Vincent Guittot, Will Deacon, Sebastian Andrzej Siewior,
	Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, linux-s390

die() invokes later show_regs() -> show_regs_print_info() which prints
the current preemption model.
Remove it from the initial line.

Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: linux-s390@vger.kernel.org
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 arch/s390/kernel/dumpstack.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/arch/s390/kernel/dumpstack.c b/arch/s390/kernel/dumpstack.c
index 1ecd0580561f6..911b95cd57e58 100644
--- a/arch/s390/kernel/dumpstack.c
+++ b/arch/s390/kernel/dumpstack.c
@@ -198,13 +198,8 @@ void __noreturn die(struct pt_regs *regs, const char *str)
 	console_verbose();
 	spin_lock_irq(&die_lock);
 	bust_spinlocks(1);
-	printk("%s: %04x ilc:%d [#%d] ", str, regs->int_code & 0xffff,
+	printk("%s: %04x ilc:%d [#%d]", str, regs->int_code & 0xffff,
 	       regs->int_code >> 17, ++die_counter);
-#ifdef CONFIG_PREEMPT
-	pr_cont("PREEMPT ");
-#elif defined(CONFIG_PREEMPT_RT)
-	pr_cont("PREEMPT_RT ");
-#endif
 	pr_cont("SMP ");
 	if (debug_pagealloc_enabled())
 		pr_cont("DEBUG_PAGEALLOC");
-- 
2.47.2


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

* [PATCH v3 7/9] x86: Rely on generic printing of preemption model.
  2025-02-12 13:41 [PATCH v3 0/9] preempt: Add a generic function to return the preemption string Sebastian Andrzej Siewior
                   ` (5 preceding siblings ...)
  2025-02-12 13:41 ` [PATCH v3 6/9] s390: " Sebastian Andrzej Siewior
@ 2025-02-12 13:41 ` Sebastian Andrzej Siewior
  2025-02-12 13:41 ` [PATCH v3 8/9] xtensa: " Sebastian Andrzej Siewior
  2025-02-12 13:41 ` [PATCH v3 9/9] tracing: Use preempt_model_str() Sebastian Andrzej Siewior
  8 siblings, 0 replies; 12+ messages in thread
From: Sebastian Andrzej Siewior @ 2025-02-12 13:41 UTC (permalink / raw)
  To: linux-kernel, linux-rt-devel
  Cc: Ben Segall, Catalin Marinas, Dietmar Eggemann, Ingo Molnar,
	Juri Lelli, Mel Gorman, Peter Zijlstra, Shrikanth Hegde,
	Steven Rostedt, Thomas Gleixner, Valentin Schneider,
	Vincent Guittot, Will Deacon, Sebastian Andrzej Siewior,
	Josh Poimboeuf, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin

After __die_header(), __die_body() is always invoked. There we have
show_regs() -> show_regs_print_info() which prints the current
preemption model.
Remove it from the initial line.

Cc: Josh Poimboeuf <jpoimboe@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: x86@kernel.org
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 arch/x86/kernel/dumpstack.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
index a7d562697e50e..91639d1e4ec2c 100644
--- a/arch/x86/kernel/dumpstack.c
+++ b/arch/x86/kernel/dumpstack.c
@@ -395,18 +395,13 @@ NOKPROBE_SYMBOL(oops_end);
 
 static void __die_header(const char *str, struct pt_regs *regs, long err)
 {
-	const char *pr = "";
-
 	/* Save the regs of the first oops for the executive summary later. */
 	if (!die_counter)
 		exec_summary_regs = *regs;
 
-	if (IS_ENABLED(CONFIG_PREEMPTION))
-		pr = IS_ENABLED(CONFIG_PREEMPT_RT) ? " PREEMPT_RT" : " PREEMPT";
-
 	printk(KERN_DEFAULT
-	       "Oops: %s: %04lx [#%d]%s%s%s%s%s\n", str, err & 0xffff,
-	       ++die_counter, pr,
+	       "Oops: %s: %04lx [#%d]%s%s%s%s\n", str, err & 0xffff,
+	       ++die_counter,
 	       IS_ENABLED(CONFIG_SMP)     ? " SMP"             : "",
 	       debug_pagealloc_enabled()  ? " DEBUG_PAGEALLOC" : "",
 	       IS_ENABLED(CONFIG_KASAN)   ? " KASAN"           : "",
-- 
2.47.2


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

* [PATCH v3 8/9] xtensa: Rely on generic printing of preemption model.
  2025-02-12 13:41 [PATCH v3 0/9] preempt: Add a generic function to return the preemption string Sebastian Andrzej Siewior
                   ` (6 preceding siblings ...)
  2025-02-12 13:41 ` [PATCH v3 7/9] x86: " Sebastian Andrzej Siewior
@ 2025-02-12 13:41 ` Sebastian Andrzej Siewior
  2025-02-12 13:41 ` [PATCH v3 9/9] tracing: Use preempt_model_str() Sebastian Andrzej Siewior
  8 siblings, 0 replies; 12+ messages in thread
From: Sebastian Andrzej Siewior @ 2025-02-12 13:41 UTC (permalink / raw)
  To: linux-kernel, linux-rt-devel
  Cc: Ben Segall, Catalin Marinas, Dietmar Eggemann, Ingo Molnar,
	Juri Lelli, Mel Gorman, Peter Zijlstra, Shrikanth Hegde,
	Steven Rostedt, Thomas Gleixner, Valentin Schneider,
	Vincent Guittot, Will Deacon, Sebastian Andrzej Siewior,
	Chris Zankel, Max Filippov

die() invokes later show_regs() -> show_regs_print_info() which prints
the current preemption model.

Remove it from the initial line.

Cc: Chris Zankel <chris@zankel.net>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Acked-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 arch/xtensa/kernel/traps.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/arch/xtensa/kernel/traps.c b/arch/xtensa/kernel/traps.c
index 38092d21acf8e..44c07c4e0833a 100644
--- a/arch/xtensa/kernel/traps.c
+++ b/arch/xtensa/kernel/traps.c
@@ -629,15 +629,11 @@ DEFINE_SPINLOCK(die_lock);
 void __noreturn die(const char * str, struct pt_regs * regs, long err)
 {
 	static int die_counter;
-	const char *pr = "";
-
-	if (IS_ENABLED(CONFIG_PREEMPTION))
-		pr = IS_ENABLED(CONFIG_PREEMPT_RT) ? " PREEMPT_RT" : " PREEMPT";
 
 	console_verbose();
 	spin_lock_irq(&die_lock);
 
-	pr_info("%s: sig: %ld [#%d]%s\n", str, err, ++die_counter, pr);
+	pr_info("%s: sig: %ld [#%d]\n", str, err, ++die_counter);
 	show_regs(regs);
 	if (!user_mode(regs))
 		show_stack(NULL, (unsigned long *)regs->areg[1], KERN_INFO);
-- 
2.47.2


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

* [PATCH v3 9/9] tracing: Use preempt_model_str().
  2025-02-12 13:41 [PATCH v3 0/9] preempt: Add a generic function to return the preemption string Sebastian Andrzej Siewior
                   ` (7 preceding siblings ...)
  2025-02-12 13:41 ` [PATCH v3 8/9] xtensa: " Sebastian Andrzej Siewior
@ 2025-02-12 13:41 ` Sebastian Andrzej Siewior
  8 siblings, 0 replies; 12+ messages in thread
From: Sebastian Andrzej Siewior @ 2025-02-12 13:41 UTC (permalink / raw)
  To: linux-kernel, linux-rt-devel
  Cc: Ben Segall, Catalin Marinas, Dietmar Eggemann, Ingo Molnar,
	Juri Lelli, Mel Gorman, Peter Zijlstra, Shrikanth Hegde,
	Steven Rostedt, Thomas Gleixner, Valentin Schneider,
	Vincent Guittot, Will Deacon, Sebastian Andrzej Siewior,
	Masami Hiramatsu, Mathieu Desnoyers, linux-trace-kernel

Use preempt_model_str() instead of manually conducting the preemption
model.

Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: linux-trace-kernel@vger.kernel.org
Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 kernel/trace/trace.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 1496a5ac33ae1..77271faab20e9 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -4100,12 +4100,7 @@ print_trace_header(struct seq_file *m, struct trace_iterator *iter)
 		   entries,
 		   total,
 		   buf->cpu,
-		   preempt_model_none()      ? "server" :
-		   preempt_model_voluntary() ? "desktop" :
-		   preempt_model_full()      ? "preempt" :
-		   preempt_model_lazy()	     ? "lazy"    :
-		   preempt_model_rt()        ? "preempt_rt" :
-		   "unknown",
+		   preempt_model_str(),
 		   /* These are reserved for later use */
 		   0, 0, 0, 0);
 #ifdef CONFIG_SMP
-- 
2.47.2


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

* Re: [PATCH v3 3/9] arm: Rely on generic printing of preemption model.
  2025-02-12 13:41 ` [PATCH v3 3/9] arm: Rely on generic printing of preemption model Sebastian Andrzej Siewior
@ 2025-02-12 15:58   ` Russell King (Oracle)
  0 siblings, 0 replies; 12+ messages in thread
From: Russell King (Oracle) @ 2025-02-12 15:58 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: linux-kernel, linux-rt-devel, Ben Segall, Catalin Marinas,
	Dietmar Eggemann, Ingo Molnar, Juri Lelli, Mel Gorman,
	Peter Zijlstra, Shrikanth Hegde, Steven Rostedt, Thomas Gleixner,
	Valentin Schneider, Vincent Guittot, Will Deacon,
	linux-arm-kernel

On Wed, Feb 12, 2025 at 02:41:09PM +0100, Sebastian Andrzej Siewior wrote:
> __die() invokes later __show_regs() -> show_regs_print_info() which
> prints the current preemption model.
> Remove it from the initial line.
> 
> Cc: Russell King <linux@armlinux.org.uk>

Please either drop this - or correct it as per my r-b below. Thanks.

> Cc: linux-arm-kernel@lists.infradead.org
> Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>  arch/arm/kernel/traps.c | 11 ++---------
>  1 file changed, 2 insertions(+), 9 deletions(-)
> 
> diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
> index 6ea645939573f..afbd2ebe5c39d 100644
> --- a/arch/arm/kernel/traps.c
> +++ b/arch/arm/kernel/traps.c
> @@ -258,13 +258,6 @@ void show_stack(struct task_struct *tsk, unsigned long *sp, const char *loglvl)
>  	barrier();
>  }
>  
> -#ifdef CONFIG_PREEMPT
> -#define S_PREEMPT " PREEMPT"
> -#elif defined(CONFIG_PREEMPT_RT)
> -#define S_PREEMPT " PREEMPT_RT"
> -#else
> -#define S_PREEMPT ""
> -#endif
>  #ifdef CONFIG_SMP
>  #define S_SMP " SMP"
>  #else
> @@ -282,8 +275,8 @@ static int __die(const char *str, int err, struct pt_regs *regs)
>  	static int die_counter;
>  	int ret;
>  
> -	pr_emerg("Internal error: %s: %x [#%d]" S_PREEMPT S_SMP S_ISA "\n",
> -	         str, err, ++die_counter);
> +	pr_emerg("Internal error: %s: %x [#%d]" S_SMP S_ISA "\n",
> +		 str, err, ++die_counter);
>  
>  	/* trap and error numbers are mostly meaningless on ARM */
>  	ret = notify_die(DIE_OOPS, str, regs, err, tsk->thread.trap_no, SIGSEGV);
> -- 
> 2.47.2
> 
> 

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

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

* Re: [PATCH v3 4/9] arm64: Rely on generic printing of preemption model.
  2025-02-12 13:41 ` [PATCH v3 4/9] arm64: " Sebastian Andrzej Siewior
@ 2025-02-12 18:41   ` Catalin Marinas
  0 siblings, 0 replies; 12+ messages in thread
From: Catalin Marinas @ 2025-02-12 18:41 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: linux-kernel, linux-rt-devel, Ben Segall, Dietmar Eggemann,
	Ingo Molnar, Juri Lelli, Mel Gorman, Peter Zijlstra,
	Shrikanth Hegde, Steven Rostedt, Thomas Gleixner,
	Valentin Schneider, Vincent Guittot, Will Deacon,
	linux-arm-kernel

On Wed, Feb 12, 2025 at 02:41:10PM +0100, Sebastian Andrzej Siewior wrote:
> __die() invokes later show_regs() -> show_regs_print_info() which prints
> the current preemption model.
> Remove it from the initial line.
> 
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will@kernel.org>
> Cc: linux-arm-kernel@lists.infradead.org
> Acked-by: Will Deacon <will@kernel.org>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

Acked-by: Catalin Marinas <catalin.marinas@arm.com>

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

end of thread, other threads:[~2025-02-12 18:41 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-12 13:41 [PATCH v3 0/9] preempt: Add a generic function to return the preemption string Sebastian Andrzej Siewior
2025-02-12 13:41 ` [PATCH v3 1/9] sched: " Sebastian Andrzej Siewior
2025-02-12 13:41 ` [PATCH v3 2/9] lib/dump_stack: Use preempt_model_str() Sebastian Andrzej Siewior
2025-02-12 13:41 ` [PATCH v3 3/9] arm: Rely on generic printing of preemption model Sebastian Andrzej Siewior
2025-02-12 15:58   ` Russell King (Oracle)
2025-02-12 13:41 ` [PATCH v3 4/9] arm64: " Sebastian Andrzej Siewior
2025-02-12 18:41   ` Catalin Marinas
2025-02-12 13:41 ` [PATCH v3 5/9] powerpc: " Sebastian Andrzej Siewior
2025-02-12 13:41 ` [PATCH v3 6/9] s390: " Sebastian Andrzej Siewior
2025-02-12 13:41 ` [PATCH v3 7/9] x86: " Sebastian Andrzej Siewior
2025-02-12 13:41 ` [PATCH v3 8/9] xtensa: " Sebastian Andrzej Siewior
2025-02-12 13:41 ` [PATCH v3 9/9] tracing: Use preempt_model_str() Sebastian Andrzej Siewior

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).