linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 3/3] riscv: add PREEMPT_LAZY support
  2024-10-09 13:03   ` Peter Zijlstra
@ 2024-10-10 12:25     ` Sebastian Andrzej Siewior
  2024-12-11 22:32       ` patchwork-bot+linux-riscv
  0 siblings, 1 reply; 14+ messages in thread
From: Sebastian Andrzej Siewior @ 2024-10-10 12:25 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: linux-trace-kernel, linux-kernel, tglx, mingo, juri.lelli,
	vincent.guittot, dietmar.eggemann, rostedt, bsegall, mgorman,
	vschneid, ankur.a.arora, efault, Masami Hiramatsu,
	Mathieu Desnoyers, Jisheng Zhang, Paul Walmsley, Palmer Dabbelt,
	Albert Ou, linux-riscv

From: Jisheng Zhang <jszhang@kernel.org>

riscv has switched to GENERIC_ENTRY, so adding PREEMPT_LAZY is as simple
as adding TIF_NEED_RESCHED_LAZY related definitions and enabling
ARCH_HAS_PREEMPT_LAZY.

[bigeasy: Replace old PREEMPT_AUTO bits with new PREEMPT_LAZY ]

Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: linux-riscv@lists.infradead.org
Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---

v1…v2:
  - shuffle TIF bits around to make RESCHED next to RESCHED_LAZY.
    Compiles & boots.

 arch/riscv/Kconfig                   |  1 +
 arch/riscv/include/asm/thread_info.h | 10 ++++++----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 62545946ecf43..3516c58480612 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -39,6 +39,7 @@ config RISCV
 	select ARCH_HAS_MMIOWB
 	select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
 	select ARCH_HAS_PMEM_API
+	select ARCH_HAS_PREEMPT_LAZY
 	select ARCH_HAS_PREPARE_SYNC_CORE_CMD
 	select ARCH_HAS_PTE_DEVMAP if 64BIT && MMU
 	select ARCH_HAS_PTE_SPECIAL
diff --git a/arch/riscv/include/asm/thread_info.h b/arch/riscv/include/asm/thread_info.h
index 9c10fb180f438..f5916a70879a8 100644
--- a/arch/riscv/include/asm/thread_info.h
+++ b/arch/riscv/include/asm/thread_info.h
@@ -107,9 +107,10 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
  * - pending work-to-be-done flags are in lowest half-word
  * - other flags in upper half-word(s)
  */
-#define TIF_NOTIFY_RESUME	1	/* callback before returning to user */
-#define TIF_SIGPENDING		2	/* signal pending */
-#define TIF_NEED_RESCHED	3	/* rescheduling necessary */
+#define TIF_NEED_RESCHED	0	/* rescheduling necessary */
+#define TIF_NEED_RESCHED_LAZY	1       /* Lazy rescheduling needed */
+#define TIF_NOTIFY_RESUME	2	/* callback before returning to user */
+#define TIF_SIGPENDING		3	/* signal pending */
 #define TIF_RESTORE_SIGMASK	4	/* restore signal mask in do_signal() */
 #define TIF_MEMDIE		5	/* is terminating due to OOM killer */
 #define TIF_NOTIFY_SIGNAL	9	/* signal notifications exist */
@@ -117,9 +118,10 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
 #define TIF_32BIT		11	/* compat-mode 32bit process */
 #define TIF_RISCV_V_DEFER_RESTORE	12 /* restore Vector before returing to user */
 
+#define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
+#define _TIF_NEED_RESCHED_LAZY	(1 << TIF_NEED_RESCHED_LAZY)
 #define _TIF_NOTIFY_RESUME	(1 << TIF_NOTIFY_RESUME)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
-#define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
 #define _TIF_NOTIFY_SIGNAL	(1 << TIF_NOTIFY_SIGNAL)
 #define _TIF_UPROBE		(1 << TIF_UPROBE)
 #define _TIF_RISCV_V_DEFER_RESTORE	(1 << TIF_RISCV_V_DEFER_RESTORE)
-- 
2.45.2


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

* [PATCH v2 0/3] Lazy preemption leftovers
@ 2024-10-21 15:08 Sebastian Andrzej Siewior
  2024-10-21 15:08 ` [PATCH v2 1/3] tracing: Replace TRACE_FLAG_IRQS_NOSUPPORT with its config option Sebastian Andrzej Siewior
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Sebastian Andrzej Siewior @ 2024-10-21 15:08 UTC (permalink / raw)
  To: linux-trace-kernel, linux-kernel
  Cc: Peter Zijlstra, tglx, mingo, juri.lelli, vincent.guittot,
	dietmar.eggemann, rostedt, bsegall, mgorman, vschneid,
	ankur.a.arora, efault, Masami Hiramatsu, Mathieu Desnoyers

This is a followup to PeterZ'
	https://lore.kernel.org/20241007074609.447006177@infradead.org

in PREEMPT_RT we had initially "LAZY preempt" this then morphed into
PREEMPT_AUTO and is becoming "Lazy preemption".
These are the tracing bits from that time that were used up to
PREEMPT_AUTO. With RT's RiscV support, they also contributed
PREEMPT_AUTO support which I just updated to current edition.

I used to have ARM* and POWERPC*, too support for the "LAZY preempt" but
this relied on assembly support and I dropped this during the switch to
PREEMPT_AUTO.

v1…v2 https://lore.kernel.org/all/20241009105709.887510-1-bigeasy@linutronix.de :
  - Added IS_ENABLED(CONFIG_ARCH_HAS_PREEMPT_LAZY) to
    tracing_gen_ctx_irq_test() to only record lazy flags if the
    architecture supports it (Ankur Arora).

  - Added a bit of Documentation for the additional context status
    (Shrikanth Hegde)

Sebastian


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

* [PATCH v2 1/3] tracing: Replace TRACE_FLAG_IRQS_NOSUPPORT with its config option.
  2024-10-21 15:08 [PATCH v2 0/3] Lazy preemption leftovers Sebastian Andrzej Siewior
@ 2024-10-21 15:08 ` Sebastian Andrzej Siewior
  2024-10-22  7:14   ` Steven Rostedt
  2024-10-21 15:08 ` [PATCH v2 2/3] tracing: Record task flag NEED_RESCHED_LAZY Sebastian Andrzej Siewior
  2024-10-21 15:08 ` [PATCH v2 3/3] riscv: add PREEMPT_LAZY support Sebastian Andrzej Siewior
  2 siblings, 1 reply; 14+ messages in thread
From: Sebastian Andrzej Siewior @ 2024-10-21 15:08 UTC (permalink / raw)
  To: linux-trace-kernel, linux-kernel
  Cc: Peter Zijlstra, tglx, mingo, juri.lelli, vincent.guittot,
	dietmar.eggemann, rostedt, bsegall, mgorman, vschneid,
	ankur.a.arora, efault, Masami Hiramatsu, Mathieu Desnoyers,
	Sebastian Andrzej Siewior

From: Thomas Gleixner <tglx@linutronix.de>

The TRACE_FLAG_IRQS_NOSUPPORT flag is used by tracing_gen_ctx.*() to
signal that CONFIG_TRACE_IRQFLAGS_SUPPORT is not enabled and tracing IRQ
flags is not supported.

This could be replaced by using the 0 as flags and then deducting that
there is no IRQFLAGS_SUPPORT based on the config option. The downside is
that without CONFIG_TRACE_IRQFLAGS_SUPPORT we can not distinguish
between no-IRQ passed flags and callers which passed 0. On the upside we
have room for one additional flags which could be used for LAZY_PREEMPTION.

Remove TRACE_FLAG_IRQS_NOSUPPORT and set it flags are 0 and
CONFIG_TRACE_IRQFLAGS_SUPPORT is not set.

[bigeasy: Commit descrption.]

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 include/linux/trace_events.h |    7 +++----
 kernel/trace/trace_output.c  |    2 +-
 2 files changed, 4 insertions(+), 5 deletions(-)

--- a/include/linux/trace_events.h
+++ b/include/linux/trace_events.h
@@ -184,8 +184,7 @@ unsigned int tracing_gen_ctx_irq_test(un
 
 enum trace_flag_type {
 	TRACE_FLAG_IRQS_OFF		= 0x01,
-	TRACE_FLAG_IRQS_NOSUPPORT	= 0x02,
-	TRACE_FLAG_NEED_RESCHED		= 0x04,
+	TRACE_FLAG_NEED_RESCHED		= 0x02,
 	TRACE_FLAG_HARDIRQ		= 0x08,
 	TRACE_FLAG_SOFTIRQ		= 0x10,
 	TRACE_FLAG_PREEMPT_RESCHED	= 0x20,
@@ -211,11 +210,11 @@ static inline unsigned int tracing_gen_c
 
 static inline unsigned int tracing_gen_ctx_flags(unsigned long irqflags)
 {
-	return tracing_gen_ctx_irq_test(TRACE_FLAG_IRQS_NOSUPPORT);
+	return tracing_gen_ctx_irq_test(0);
 }
 static inline unsigned int tracing_gen_ctx(void)
 {
-	return tracing_gen_ctx_irq_test(TRACE_FLAG_IRQS_NOSUPPORT);
+	return tracing_gen_ctx_irq_test(0);
 }
 #endif
 
--- a/kernel/trace/trace_output.c
+++ b/kernel/trace/trace_output.c
@@ -460,7 +460,7 @@ int trace_print_lat_fmt(struct trace_seq
 		(entry->flags & TRACE_FLAG_IRQS_OFF && bh_off) ? 'D' :
 		(entry->flags & TRACE_FLAG_IRQS_OFF) ? 'd' :
 		bh_off ? 'b' :
-		(entry->flags & TRACE_FLAG_IRQS_NOSUPPORT) ? 'X' :
+		!IS_ENABLED(CONFIG_TRACE_IRQFLAGS_SUPPORT) ? 'X' :
 		'.';
 
 	switch (entry->flags & (TRACE_FLAG_NEED_RESCHED |

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

* [PATCH v2 2/3] tracing: Record task flag NEED_RESCHED_LAZY.
  2024-10-21 15:08 [PATCH v2 0/3] Lazy preemption leftovers Sebastian Andrzej Siewior
  2024-10-21 15:08 ` [PATCH v2 1/3] tracing: Replace TRACE_FLAG_IRQS_NOSUPPORT with its config option Sebastian Andrzej Siewior
@ 2024-10-21 15:08 ` Sebastian Andrzej Siewior
  2024-10-22  7:18   ` Steven Rostedt
  2024-10-21 15:08 ` [PATCH v2 3/3] riscv: add PREEMPT_LAZY support Sebastian Andrzej Siewior
  2 siblings, 1 reply; 14+ messages in thread
From: Sebastian Andrzej Siewior @ 2024-10-21 15:08 UTC (permalink / raw)
  To: linux-trace-kernel, linux-kernel
  Cc: Peter Zijlstra, tglx, mingo, juri.lelli, vincent.guittot,
	dietmar.eggemann, rostedt, bsegall, mgorman, vschneid,
	ankur.a.arora, efault, Masami Hiramatsu, Mathieu Desnoyers,
	Sebastian Andrzej Siewior

From: Thomas Gleixner <tglx@linutronix.de>

The scheduler added NEED_RESCHED_LAZY scheduling. Record this state as
part of trace flags and expose it in the need_resched field.

Record and expose NEED_RESCHED_LAZY.

[bigeasy: Commit description, documentation bits.]

Reviewed-by: Ankur Arora <ankur.a.arora@oracle.com>
Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 Documentation/trace/ftrace.rst |    4 ++++
 include/linux/trace_events.h   |    1 +
 kernel/trace/trace.c           |    2 ++
 kernel/trace/trace_output.c    |   14 +++++++++++++-
 4 files changed, 20 insertions(+), 1 deletion(-)

--- a/Documentation/trace/ftrace.rst
+++ b/Documentation/trace/ftrace.rst
@@ -1036,9 +1036,13 @@ explains which is which.
 		be printed here.
 
   need-resched:
+	- 'B' all, TIF_NEED_RESCHED, PREEMPT_NEED_RESCHED and TIF_RESCHED_LAZY is set,
 	- 'N' both TIF_NEED_RESCHED and PREEMPT_NEED_RESCHED is set,
 	- 'n' only TIF_NEED_RESCHED is set,
 	- 'p' only PREEMPT_NEED_RESCHED is set,
+	- 'L' borg PREEMPT_NEED_RESCHED and TIF_RESCHED_LAZY is set,
+	- 'b' borg TIF_NEED_RESCHED and TIF_RESCHED_LAZY is set,
+	- 'l' only TIF_RESCHED_LAZY is set
 	- '.' otherwise.
 
   hardirq/softirq:
--- a/include/linux/trace_events.h
+++ b/include/linux/trace_events.h
@@ -185,6 +185,7 @@ unsigned int tracing_gen_ctx_irq_test(un
 enum trace_flag_type {
 	TRACE_FLAG_IRQS_OFF		= 0x01,
 	TRACE_FLAG_NEED_RESCHED		= 0x02,
+	TRACE_FLAG_NEED_RESCHED_LAZY	= 0x04,
 	TRACE_FLAG_HARDIRQ		= 0x08,
 	TRACE_FLAG_SOFTIRQ		= 0x10,
 	TRACE_FLAG_PREEMPT_RESCHED	= 0x20,
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -2544,6 +2544,8 @@ unsigned int tracing_gen_ctx_irq_test(un
 		trace_flags |= TRACE_FLAG_NEED_RESCHED;
 	if (test_preempt_need_resched())
 		trace_flags |= TRACE_FLAG_PREEMPT_RESCHED;
+	if (IS_ENABLED(CONFIG_ARCH_HAS_PREEMPT_LAZY) && tif_test_bit(TIF_NEED_RESCHED_LAZY))
+		trace_flags |= TRACE_FLAG_NEED_RESCHED_LAZY;
 	return (trace_flags << 16) | (min_t(unsigned int, pc & 0xff, 0xf)) |
 		(min_t(unsigned int, migration_disable_value(), 0xf)) << 4;
 }
--- a/kernel/trace/trace_output.c
+++ b/kernel/trace/trace_output.c
@@ -463,17 +463,29 @@ int trace_print_lat_fmt(struct trace_seq
 		!IS_ENABLED(CONFIG_TRACE_IRQFLAGS_SUPPORT) ? 'X' :
 		'.';
 
-	switch (entry->flags & (TRACE_FLAG_NEED_RESCHED |
+	switch (entry->flags & (TRACE_FLAG_NEED_RESCHED | TRACE_FLAG_NEED_RESCHED_LAZY |
 				TRACE_FLAG_PREEMPT_RESCHED)) {
+	case TRACE_FLAG_NEED_RESCHED | TRACE_FLAG_NEED_RESCHED_LAZY | TRACE_FLAG_PREEMPT_RESCHED:
+		need_resched = 'B';
+		break;
 	case TRACE_FLAG_NEED_RESCHED | TRACE_FLAG_PREEMPT_RESCHED:
 		need_resched = 'N';
 		break;
+	case TRACE_FLAG_NEED_RESCHED_LAZY | TRACE_FLAG_PREEMPT_RESCHED:
+		need_resched = 'L';
+		break;
+	case TRACE_FLAG_NEED_RESCHED | TRACE_FLAG_NEED_RESCHED_LAZY:
+		need_resched = 'b';
+		break;
 	case TRACE_FLAG_NEED_RESCHED:
 		need_resched = 'n';
 		break;
 	case TRACE_FLAG_PREEMPT_RESCHED:
 		need_resched = 'p';
 		break;
+	case TRACE_FLAG_NEED_RESCHED_LAZY:
+		need_resched = 'l';
+		break;
 	default:
 		need_resched = '.';
 		break;

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

* [PATCH v2 3/3] riscv: add PREEMPT_LAZY support
  2024-10-21 15:08 [PATCH v2 0/3] Lazy preemption leftovers Sebastian Andrzej Siewior
  2024-10-21 15:08 ` [PATCH v2 1/3] tracing: Replace TRACE_FLAG_IRQS_NOSUPPORT with its config option Sebastian Andrzej Siewior
  2024-10-21 15:08 ` [PATCH v2 2/3] tracing: Record task flag NEED_RESCHED_LAZY Sebastian Andrzej Siewior
@ 2024-10-21 15:08 ` Sebastian Andrzej Siewior
  2024-12-11 22:32   ` patchwork-bot+linux-riscv
  2 siblings, 1 reply; 14+ messages in thread
From: Sebastian Andrzej Siewior @ 2024-10-21 15:08 UTC (permalink / raw)
  To: linux-trace-kernel, linux-kernel
  Cc: Peter Zijlstra, tglx, mingo, juri.lelli, vincent.guittot,
	dietmar.eggemann, rostedt, bsegall, mgorman, vschneid,
	ankur.a.arora, efault, Masami Hiramatsu, Mathieu Desnoyers,
	Jisheng Zhang, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	linux-riscv, Palmer Dabbelt, Sebastian Andrzej Siewior

From: Jisheng Zhang <jszhang@kernel.org>

riscv has switched to GENERIC_ENTRY, so adding PREEMPT_LAZY is as simple
as adding TIF_NEED_RESCHED_LAZY related definitions and enabling
ARCH_HAS_PREEMPT_LAZY.

[bigeasy: Replace old PREEMPT_AUTO bits with new PREEMPT_LAZY ]

Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: linux-riscv@lists.infradead.org
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 arch/riscv/Kconfig                   |    1 +
 arch/riscv/include/asm/thread_info.h |   10 ++++++----
 2 files changed, 7 insertions(+), 4 deletions(-)

--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -39,6 +39,7 @@ config RISCV
 	select ARCH_HAS_MMIOWB
 	select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
 	select ARCH_HAS_PMEM_API
+	select ARCH_HAS_PREEMPT_LAZY
 	select ARCH_HAS_PREPARE_SYNC_CORE_CMD
 	select ARCH_HAS_PTE_DEVMAP if 64BIT && MMU
 	select ARCH_HAS_PTE_SPECIAL
--- a/arch/riscv/include/asm/thread_info.h
+++ b/arch/riscv/include/asm/thread_info.h
@@ -107,9 +107,10 @@ int arch_dup_task_struct(struct task_str
  * - pending work-to-be-done flags are in lowest half-word
  * - other flags in upper half-word(s)
  */
-#define TIF_NOTIFY_RESUME	1	/* callback before returning to user */
-#define TIF_SIGPENDING		2	/* signal pending */
-#define TIF_NEED_RESCHED	3	/* rescheduling necessary */
+#define TIF_NEED_RESCHED	0	/* rescheduling necessary */
+#define TIF_NEED_RESCHED_LAZY	1       /* Lazy rescheduling needed */
+#define TIF_NOTIFY_RESUME	2	/* callback before returning to user */
+#define TIF_SIGPENDING		3	/* signal pending */
 #define TIF_RESTORE_SIGMASK	4	/* restore signal mask in do_signal() */
 #define TIF_MEMDIE		5	/* is terminating due to OOM killer */
 #define TIF_NOTIFY_SIGNAL	9	/* signal notifications exist */
@@ -117,9 +118,10 @@ int arch_dup_task_struct(struct task_str
 #define TIF_32BIT		11	/* compat-mode 32bit process */
 #define TIF_RISCV_V_DEFER_RESTORE	12 /* restore Vector before returing to user */
 
+#define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
+#define _TIF_NEED_RESCHED_LAZY	(1 << TIF_NEED_RESCHED_LAZY)
 #define _TIF_NOTIFY_RESUME	(1 << TIF_NOTIFY_RESUME)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
-#define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
 #define _TIF_NOTIFY_SIGNAL	(1 << TIF_NOTIFY_SIGNAL)
 #define _TIF_UPROBE		(1 << TIF_UPROBE)
 #define _TIF_RISCV_V_DEFER_RESTORE	(1 << TIF_RISCV_V_DEFER_RESTORE)

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

* Re: [PATCH v2 1/3] tracing: Replace TRACE_FLAG_IRQS_NOSUPPORT with its config option.
  2024-10-21 15:08 ` [PATCH v2 1/3] tracing: Replace TRACE_FLAG_IRQS_NOSUPPORT with its config option Sebastian Andrzej Siewior
@ 2024-10-22  7:14   ` Steven Rostedt
  2024-10-22  9:52     ` Sebastian Andrzej Siewior
  2024-10-22 11:01     ` [PATCH] tracing: Remove TRACE_FLAG_IRQS_NOSUPPORT Sebastian Andrzej Siewior
  0 siblings, 2 replies; 14+ messages in thread
From: Steven Rostedt @ 2024-10-22  7:14 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: linux-trace-kernel, linux-kernel, Peter Zijlstra, tglx, mingo,
	juri.lelli, vincent.guittot, dietmar.eggemann, bsegall, mgorman,
	vschneid, ankur.a.arora, efault, Masami Hiramatsu,
	Mathieu Desnoyers

On Mon, 21 Oct 2024 17:08:40 +0200
Sebastian Andrzej Siewior <bigeasy@linutronix.de> wrote:

> From: Thomas Gleixner <tglx@linutronix.de>
> 
> The TRACE_FLAG_IRQS_NOSUPPORT flag is used by tracing_gen_ctx.*() to
> signal that CONFIG_TRACE_IRQFLAGS_SUPPORT is not enabled and tracing IRQ
> flags is not supported.
> 
> This could be replaced by using the 0 as flags and then deducting that
> there is no IRQFLAGS_SUPPORT based on the config option. The downside is
> that without CONFIG_TRACE_IRQFLAGS_SUPPORT we can not distinguish
> between no-IRQ passed flags and callers which passed 0. On the upside we
> have room for one additional flags which could be used for LAZY_PREEMPTION.
> 
> Remove TRACE_FLAG_IRQS_NOSUPPORT and set it flags are 0 and
> CONFIG_TRACE_IRQFLAGS_SUPPORT is not set.

We could also add that we have:

#
# Minimum requirements an architecture has to meet for us to
# be able to offer generic tracing facilities:
#
config TRACING_SUPPORT
        bool
        depends on TRACE_IRQFLAGS_SUPPORT
        depends on STACKTRACE_SUPPORT
        default y

So this can't even be built without TRACE_IRQFLAGS_SUPPORT!

> 
> [bigeasy: Commit descrption.]
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>  include/linux/trace_events.h |    7 +++----
>  kernel/trace/trace_output.c  |    2 +-
>  2 files changed, 4 insertions(+), 5 deletions(-)
> 
> --- a/include/linux/trace_events.h
> +++ b/include/linux/trace_events.h
> @@ -184,8 +184,7 @@ unsigned int tracing_gen_ctx_irq_test(un
>  
>  enum trace_flag_type {
>  	TRACE_FLAG_IRQS_OFF		= 0x01,
> -	TRACE_FLAG_IRQS_NOSUPPORT	= 0x02,
> -	TRACE_FLAG_NEED_RESCHED		= 0x04,
> +	TRACE_FLAG_NEED_RESCHED		= 0x02,

These flags are user visible (I probably should move them into uapi).
They are parsed by libtraceevent.

Please just remove NOSUPPORT and do not touch NEED_RESCHED.


>  	TRACE_FLAG_HARDIRQ		= 0x08,
>  	TRACE_FLAG_SOFTIRQ		= 0x10,
>  	TRACE_FLAG_PREEMPT_RESCHED	= 0x20,
> @@ -211,11 +210,11 @@ static inline unsigned int tracing_gen_c
>  
>  static inline unsigned int tracing_gen_ctx_flags(unsigned long irqflags)
>  {
> -	return tracing_gen_ctx_irq_test(TRACE_FLAG_IRQS_NOSUPPORT);
> +	return tracing_gen_ctx_irq_test(0);
>  }
>  static inline unsigned int tracing_gen_ctx(void)
>  {
> -	return tracing_gen_ctx_irq_test(TRACE_FLAG_IRQS_NOSUPPORT);
> +	return tracing_gen_ctx_irq_test(0);
>  }
>  #endif
>  
> --- a/kernel/trace/trace_output.c
> +++ b/kernel/trace/trace_output.c
> @@ -460,7 +460,7 @@ int trace_print_lat_fmt(struct trace_seq
>  		(entry->flags & TRACE_FLAG_IRQS_OFF && bh_off) ? 'D' :
>  		(entry->flags & TRACE_FLAG_IRQS_OFF) ? 'd' :
>  		bh_off ? 'b' :
> -		(entry->flags & TRACE_FLAG_IRQS_NOSUPPORT) ? 'X' :
> +		!IS_ENABLED(CONFIG_TRACE_IRQFLAGS_SUPPORT) ? 'X' :

Probably can even remove this check.

-- Steve

>  		'.';
>  
>  	switch (entry->flags & (TRACE_FLAG_NEED_RESCHED |


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

* Re: [PATCH v2 2/3] tracing: Record task flag NEED_RESCHED_LAZY.
  2024-10-21 15:08 ` [PATCH v2 2/3] tracing: Record task flag NEED_RESCHED_LAZY Sebastian Andrzej Siewior
@ 2024-10-22  7:18   ` Steven Rostedt
  2024-10-22  7:26     ` Sebastian Andrzej Siewior
  0 siblings, 1 reply; 14+ messages in thread
From: Steven Rostedt @ 2024-10-22  7:18 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: linux-trace-kernel, linux-kernel, Peter Zijlstra, tglx, mingo,
	juri.lelli, vincent.guittot, dietmar.eggemann, bsegall, mgorman,
	vschneid, ankur.a.arora, efault, Masami Hiramatsu,
	Mathieu Desnoyers

On Mon, 21 Oct 2024 17:08:41 +0200
Sebastian Andrzej Siewior <bigeasy@linutronix.de> wrote:

>  enum trace_flag_type {
>  	TRACE_FLAG_IRQS_OFF		= 0x01,
>  	TRACE_FLAG_NEED_RESCHED		= 0x02,
> +	TRACE_FLAG_NEED_RESCHED_LAZY	= 0x04,
>  	TRACE_FLAG_HARDIRQ		= 0x08,
>  	TRACE_FLAG_SOFTIRQ		= 0x10,
>  	TRACE_FLAG_PREEMPT_RESCHED	= 0x20,

As I stated in the other email, these are user visible. Should probably
make the LAZY flag 0x100, as the trace_flags are 16 bits worth.

-- Steve

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

* Re: [PATCH v2 2/3] tracing: Record task flag NEED_RESCHED_LAZY.
  2024-10-22  7:18   ` Steven Rostedt
@ 2024-10-22  7:26     ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 14+ messages in thread
From: Sebastian Andrzej Siewior @ 2024-10-22  7:26 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-trace-kernel, linux-kernel, Peter Zijlstra, tglx, mingo,
	juri.lelli, vincent.guittot, dietmar.eggemann, bsegall, mgorman,
	vschneid, ankur.a.arora, efault, Masami Hiramatsu,
	Mathieu Desnoyers

On 2024-10-22 03:18:27 [-0400], Steven Rostedt wrote:
> On Mon, 21 Oct 2024 17:08:41 +0200
> Sebastian Andrzej Siewior <bigeasy@linutronix.de> wrote:
> 
> >  enum trace_flag_type {
> >  	TRACE_FLAG_IRQS_OFF		= 0x01,
> >  	TRACE_FLAG_NEED_RESCHED		= 0x02,
> > +	TRACE_FLAG_NEED_RESCHED_LAZY	= 0x04,
> >  	TRACE_FLAG_HARDIRQ		= 0x08,
> >  	TRACE_FLAG_SOFTIRQ		= 0x10,
> >  	TRACE_FLAG_PREEMPT_RESCHED	= 0x20,
> 
> As I stated in the other email, these are user visible. Should probably
> make the LAZY flag 0x100, as the trace_flags are 16 bits worth.

What about struct trace_entry? That flags is stored as 8bit in
tracing_generic_entry_update().

> 
> -- Steve

Sebastian

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

* Re: [PATCH v2 1/3] tracing: Replace TRACE_FLAG_IRQS_NOSUPPORT with its config option.
  2024-10-22  7:14   ` Steven Rostedt
@ 2024-10-22  9:52     ` Sebastian Andrzej Siewior
  2024-10-22 10:19       ` Steven Rostedt
  2024-10-22 11:01     ` [PATCH] tracing: Remove TRACE_FLAG_IRQS_NOSUPPORT Sebastian Andrzej Siewior
  1 sibling, 1 reply; 14+ messages in thread
From: Sebastian Andrzej Siewior @ 2024-10-22  9:52 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-trace-kernel, linux-kernel, Peter Zijlstra, tglx, mingo,
	juri.lelli, vincent.guittot, dietmar.eggemann, bsegall, mgorman,
	vschneid, ankur.a.arora, efault, Masami Hiramatsu,
	Mathieu Desnoyers

On 2024-10-22 03:14:18 [-0400], Steven Rostedt wrote:
> On Mon, 21 Oct 2024 17:08:40 +0200
> Sebastian Andrzej Siewior <bigeasy@linutronix.de> wrote:
> 
> > From: Thomas Gleixner <tglx@linutronix.de>
> > 
> > The TRACE_FLAG_IRQS_NOSUPPORT flag is used by tracing_gen_ctx.*() to
> > signal that CONFIG_TRACE_IRQFLAGS_SUPPORT is not enabled and tracing IRQ
> > flags is not supported.
> > 
> > This could be replaced by using the 0 as flags and then deducting that
> > there is no IRQFLAGS_SUPPORT based on the config option. The downside is
> > that without CONFIG_TRACE_IRQFLAGS_SUPPORT we can not distinguish
> > between no-IRQ passed flags and callers which passed 0. On the upside we
> > have room for one additional flags which could be used for LAZY_PREEMPTION.
> > 
> > Remove TRACE_FLAG_IRQS_NOSUPPORT and set it flags are 0 and
> > CONFIG_TRACE_IRQFLAGS_SUPPORT is not set.
> 
> We could also add that we have:
> 
> #
> # Minimum requirements an architecture has to meet for us to
> # be able to offer generic tracing facilities:
> #
> config TRACING_SUPPORT
>         bool
>         depends on TRACE_IRQFLAGS_SUPPORT
>         depends on STACKTRACE_SUPPORT
>         default y
> 
> So this can't even be built without TRACE_IRQFLAGS_SUPPORT!

Good point. So we could TRACE_FLAG_IRQS_NOSUPPORT since it can't be
used. This is since commit 0ea5ee035133a ("tracing: Remove PPC32 wart
from config TRACING_SUPPORT").

> > +++ b/include/linux/trace_events.h
> > @@ -184,8 +184,7 @@ unsigned int tracing_gen_ctx_irq_test(un
> >  
> >  enum trace_flag_type {
> >  	TRACE_FLAG_IRQS_OFF		= 0x01,
> > -	TRACE_FLAG_IRQS_NOSUPPORT	= 0x02,
> > -	TRACE_FLAG_NEED_RESCHED		= 0x04,
> > +	TRACE_FLAG_NEED_RESCHED		= 0x02,
> 
> These flags are user visible (I probably should move them into uapi).
> They are parsed by libtraceevent.
> 
> Please just remove NOSUPPORT and do not touch NEED_RESCHED.

Then I put the lazy bit where we have not NOSUPPORT.

> >  	TRACE_FLAG_HARDIRQ		= 0x08,
> >  	TRACE_FLAG_SOFTIRQ		= 0x10,
> >  	TRACE_FLAG_PREEMPT_RESCHED	= 0x20,
> > --- a/kernel/trace/trace_output.c
> > +++ b/kernel/trace/trace_output.c
> > @@ -460,7 +460,7 @@ int trace_print_lat_fmt(struct trace_seq
> >  		(entry->flags & TRACE_FLAG_IRQS_OFF && bh_off) ? 'D' :
> >  		(entry->flags & TRACE_FLAG_IRQS_OFF) ? 'd' :
> >  		bh_off ? 'b' :
> > -		(entry->flags & TRACE_FLAG_IRQS_NOSUPPORT) ? 'X' :
> > +		!IS_ENABLED(CONFIG_TRACE_IRQFLAGS_SUPPORT) ? 'X' :
> 
> Probably can even remove this check.

Yes.

> -- Steve

Sebastian

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

* Re: [PATCH v2 1/3] tracing: Replace TRACE_FLAG_IRQS_NOSUPPORT with its config option.
  2024-10-22  9:52     ` Sebastian Andrzej Siewior
@ 2024-10-22 10:19       ` Steven Rostedt
  2024-10-22 10:29         ` Sebastian Andrzej Siewior
  0 siblings, 1 reply; 14+ messages in thread
From: Steven Rostedt @ 2024-10-22 10:19 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: linux-trace-kernel, linux-kernel, Peter Zijlstra, tglx, mingo,
	juri.lelli, vincent.guittot, dietmar.eggemann, bsegall, mgorman,
	vschneid, ankur.a.arora, efault, Masami Hiramatsu,
	Mathieu Desnoyers

On Tue, 22 Oct 2024 11:52:41 +0200
Sebastian Andrzej Siewior <bigeasy@linutronix.de> wrote:

> > 
> > Please just remove NOSUPPORT and do not touch NEED_RESCHED.  
> 
> Then I put the lazy bit where we have not NOSUPPORT.

I'm afraid user space will confuse this with the NOSUPPORT.

-- Steve

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

* Re: [PATCH v2 1/3] tracing: Replace TRACE_FLAG_IRQS_NOSUPPORT with its config option.
  2024-10-22 10:19       ` Steven Rostedt
@ 2024-10-22 10:29         ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 14+ messages in thread
From: Sebastian Andrzej Siewior @ 2024-10-22 10:29 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-trace-kernel, linux-kernel, Peter Zijlstra, tglx, mingo,
	juri.lelli, vincent.guittot, dietmar.eggemann, bsegall, mgorman,
	vschneid, ankur.a.arora, efault, Masami Hiramatsu,
	Mathieu Desnoyers

On 2024-10-22 06:19:59 [-0400], Steven Rostedt wrote:
> On Tue, 22 Oct 2024 11:52:41 +0200
> Sebastian Andrzej Siewior <bigeasy@linutronix.de> wrote:
> 
> > > 
> > > Please just remove NOSUPPORT and do not touch NEED_RESCHED.  
> > 
> > Then I put the lazy bit where we have not NOSUPPORT.
> 
> I'm afraid user space will confuse this with the NOSUPPORT.

So? We don't ignore this for now and recycle that bit? If I got it
right, only PPC32 was using that NOSUPPORT bit.
What are the options given that it has to be an 8 bit field?

> -- Steve

Sebastian

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

* [PATCH] tracing: Remove TRACE_FLAG_IRQS_NOSUPPORT
  2024-10-22  7:14   ` Steven Rostedt
  2024-10-22  9:52     ` Sebastian Andrzej Siewior
@ 2024-10-22 11:01     ` Sebastian Andrzej Siewior
  1 sibling, 0 replies; 14+ messages in thread
From: Sebastian Andrzej Siewior @ 2024-10-22 11:01 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-trace-kernel, linux-kernel, Peter Zijlstra, tglx, mingo,
	juri.lelli, vincent.guittot, dietmar.eggemann, bsegall, mgorman,
	vschneid, ankur.a.arora, efault, Masami Hiramatsu,
	Mathieu Desnoyers

It was possible to enable tracing with no IRQ tracing support. The
tracing infrastructure would then record TRACE_FLAG_IRQS_NOSUPPORT as
the only tracing flag and show an 'X' in the output.

The last user of this feature was PPC32 which managed to implement it
during PowerPC merge in 2009. Since then, it was unused and the PPC32
dependency was finally removed in commit 0ea5ee035133a ("tracing: Remove
PPC32 wart from config TRACING_SUPPORT").
Since the PowerPC merge the code behind !CONFIG_TRACE_IRQFLAGS_SUPPORT
with TRACING enabled can no longer be selected used and the 'X' is not
displayed or recorded.

Remove the CONFIG_TRACE_IRQFLAGS_SUPPORT from the tracing code. Remove
TRACE_FLAG_IRQS_NOSUPPORT.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
On 2024-10-22 03:14:18 [-0400], Steven Rostedt wrote:
> So this can't even be built without TRACE_IRQFLAGS_SUPPORT!

What about this as a first step? This bit was not used since 2009.

 Documentation/trace/ftrace.rst |  3 ---
 include/linux/trace_events.h   | 13 -------------
 kernel/trace/trace_output.c    |  1 -
 3 files changed, 17 deletions(-)

diff --git a/Documentation/trace/ftrace.rst b/Documentation/trace/ftrace.rst
index 4073ca48af4ad..74d5bd801b1a8 100644
--- a/Documentation/trace/ftrace.rst
+++ b/Documentation/trace/ftrace.rst
@@ -1031,9 +1031,6 @@ explains which is which.
   CPU#: The CPU which the process was running on.
 
   irqs-off: 'd' interrupts are disabled. '.' otherwise.
-	.. caution:: If the architecture does not support a way to
-		read the irq flags variable, an 'X' will always
-		be printed here.
 
   need-resched:
 	- 'N' both TIF_NEED_RESCHED and PREEMPT_NEED_RESCHED is set,
diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h
index 42bedcddd5113..467dadb990cbe 100644
--- a/include/linux/trace_events.h
+++ b/include/linux/trace_events.h
@@ -184,7 +184,6 @@ unsigned int tracing_gen_ctx_irq_test(unsigned int irqs_status);
 
 enum trace_flag_type {
 	TRACE_FLAG_IRQS_OFF		= 0x01,
-	TRACE_FLAG_IRQS_NOSUPPORT	= 0x02,
 	TRACE_FLAG_NEED_RESCHED		= 0x04,
 	TRACE_FLAG_HARDIRQ		= 0x08,
 	TRACE_FLAG_SOFTIRQ		= 0x10,
@@ -193,7 +192,6 @@ enum trace_flag_type {
 	TRACE_FLAG_BH_OFF		= 0x80,
 };
 
-#ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT
 static inline unsigned int tracing_gen_ctx_flags(unsigned long irqflags)
 {
 	unsigned int irq_status = irqs_disabled_flags(irqflags) ?
@@ -207,17 +205,6 @@ static inline unsigned int tracing_gen_ctx(void)
 	local_save_flags(irqflags);
 	return tracing_gen_ctx_flags(irqflags);
 }
-#else
-
-static inline unsigned int tracing_gen_ctx_flags(unsigned long irqflags)
-{
-	return tracing_gen_ctx_irq_test(TRACE_FLAG_IRQS_NOSUPPORT);
-}
-static inline unsigned int tracing_gen_ctx(void)
-{
-	return tracing_gen_ctx_irq_test(TRACE_FLAG_IRQS_NOSUPPORT);
-}
-#endif
 
 static inline unsigned int tracing_gen_ctx_dec(void)
 {
diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
index 868f2f912f280..2ee6613dce6dc 100644
--- a/kernel/trace/trace_output.c
+++ b/kernel/trace/trace_output.c
@@ -460,7 +460,6 @@ int trace_print_lat_fmt(struct trace_seq *s, struct trace_entry *entry)
 		(entry->flags & TRACE_FLAG_IRQS_OFF && bh_off) ? 'D' :
 		(entry->flags & TRACE_FLAG_IRQS_OFF) ? 'd' :
 		bh_off ? 'b' :
-		(entry->flags & TRACE_FLAG_IRQS_NOSUPPORT) ? 'X' :
 		'.';
 
 	switch (entry->flags & (TRACE_FLAG_NEED_RESCHED |
-- 
2.45.2


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

* Re: [PATCH v2 3/3] riscv: add PREEMPT_LAZY support
  2024-10-10 12:25     ` [PATCH v2 " Sebastian Andrzej Siewior
@ 2024-12-11 22:32       ` patchwork-bot+linux-riscv
  0 siblings, 0 replies; 14+ messages in thread
From: patchwork-bot+linux-riscv @ 2024-12-11 22:32 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: linux-riscv, peterz, linux-trace-kernel, linux-kernel, tglx,
	mingo, juri.lelli, vincent.guittot, dietmar.eggemann, rostedt,
	bsegall, mgorman, vschneid, ankur.a.arora, efault, mhiramat,
	mathieu.desnoyers, jszhang, paul.walmsley, palmer, aou

Hello:

This patch was applied to riscv/linux.git (fixes)
by Peter Zijlstra <peterz@infradead.org>:

On Thu, 10 Oct 2024 14:25:45 +0200 you wrote:
> From: Jisheng Zhang <jszhang@kernel.org>
> 
> riscv has switched to GENERIC_ENTRY, so adding PREEMPT_LAZY is as simple
> as adding TIF_NEED_RESCHED_LAZY related definitions and enabling
> ARCH_HAS_PREEMPT_LAZY.
> 
> [bigeasy: Replace old PREEMPT_AUTO bits with new PREEMPT_LAZY ]
> 
> [...]

Here is the summary with links:
  - [v2,3/3] riscv: add PREEMPT_LAZY support
    https://git.kernel.org/riscv/c/22aaec357c1f

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

* Re: [PATCH v2 3/3] riscv: add PREEMPT_LAZY support
  2024-10-21 15:08 ` [PATCH v2 3/3] riscv: add PREEMPT_LAZY support Sebastian Andrzej Siewior
@ 2024-12-11 22:32   ` patchwork-bot+linux-riscv
  0 siblings, 0 replies; 14+ messages in thread
From: patchwork-bot+linux-riscv @ 2024-12-11 22:32 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: linux-riscv, linux-trace-kernel, linux-kernel, peterz, tglx,
	mingo, juri.lelli, vincent.guittot, dietmar.eggemann, rostedt,
	bsegall, mgorman, vschneid, ankur.a.arora, efault, mhiramat,
	mathieu.desnoyers, jszhang, paul.walmsley, palmer, aou, palmer

Hello:

This patch was applied to riscv/linux.git (fixes)
by Peter Zijlstra <peterz@infradead.org>:

On Mon, 21 Oct 2024 17:08:42 +0200 you wrote:
> From: Jisheng Zhang <jszhang@kernel.org>
> 
> riscv has switched to GENERIC_ENTRY, so adding PREEMPT_LAZY is as simple
> as adding TIF_NEED_RESCHED_LAZY related definitions and enabling
> ARCH_HAS_PREEMPT_LAZY.
> 
> [bigeasy: Replace old PREEMPT_AUTO bits with new PREEMPT_LAZY ]
> 
> [...]

Here is the summary with links:
  - [v2,3/3] riscv: add PREEMPT_LAZY support
    https://git.kernel.org/riscv/c/22aaec357c1f

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2024-12-11 22:32 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-21 15:08 [PATCH v2 0/3] Lazy preemption leftovers Sebastian Andrzej Siewior
2024-10-21 15:08 ` [PATCH v2 1/3] tracing: Replace TRACE_FLAG_IRQS_NOSUPPORT with its config option Sebastian Andrzej Siewior
2024-10-22  7:14   ` Steven Rostedt
2024-10-22  9:52     ` Sebastian Andrzej Siewior
2024-10-22 10:19       ` Steven Rostedt
2024-10-22 10:29         ` Sebastian Andrzej Siewior
2024-10-22 11:01     ` [PATCH] tracing: Remove TRACE_FLAG_IRQS_NOSUPPORT Sebastian Andrzej Siewior
2024-10-21 15:08 ` [PATCH v2 2/3] tracing: Record task flag NEED_RESCHED_LAZY Sebastian Andrzej Siewior
2024-10-22  7:18   ` Steven Rostedt
2024-10-22  7:26     ` Sebastian Andrzej Siewior
2024-10-21 15:08 ` [PATCH v2 3/3] riscv: add PREEMPT_LAZY support Sebastian Andrzej Siewior
2024-12-11 22:32   ` patchwork-bot+linux-riscv
  -- strict thread matches above, loose matches on Subject: below --
2024-10-09 10:50 [PATCH 0/3] Lazy preemption leftovers Sebastian Andrzej Siewior
2024-10-09 10:50 ` [PATCH 3/3] riscv: add PREEMPT_LAZY support Sebastian Andrzej Siewior
2024-10-09 13:03   ` Peter Zijlstra
2024-10-10 12:25     ` [PATCH v2 " Sebastian Andrzej Siewior
2024-12-11 22:32       ` patchwork-bot+linux-riscv

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