Skip to contentSkip to conversation

Lazy preemption leftovers

PATCH Applied Sebastian Andrzej Siewior 4 participants 13 messages Oct 21, 2024 – Dec 11, 2024

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover Lazy preemption leftovers

This is a followup to PeterZ'

	https://lore.kernel.org/[email protected]

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/[email protected] :
- 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

#1 lore raw

PATCH v2 1/3 tracing: Replace TRACE_FLAG_IRQS_NOSUPPORT with its config option.

From: Thomas Gleixner <[email protected]>

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

---
 include/linux/trace_events.h |    7 +++----
 kernel/trace/trace_output.c  |    2 +-
 2 files changed, 4 insertions(+), 5 deletions(-)
include/linux/trace_events.h +3 -4
@@ -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
 
kernel/trace/trace_output.c +1 -1
@@ -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 |
maintainer
#2 lore raw

Re: [PATCH v2 1/3] tracing: Replace TRACE_FLAG_IRQS_NOSUPPORT with its config option.

Quoted 6 lines · On Mon, 21 Oct 2024 17:08:40 +0200 Sebastian Andrzej Siewior…

From: Thomas Gleixner <[email protected]>

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.

Quoted 8 lines

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!

Quoted 13 lines

[bigeasy: Commit descrption.]

---
 include/linux/trace_events.h |    7 +++----
 kernel/trace/trace_output.c  |    2 +-
 2 files changed, 4 insertions(+), 5 deletions(-)

include/linux/trace_events.h unsigned int tracing_gen_ctx_irq_test(un · line 187

Quoted 6 lines
include/linux/trace_events.h +1 -2
@@ -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.

Quoted 20 lines
include/linux/trace_events.h +2 -2
 	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
 

kernel/trace/trace_output.c int trace_print_lat_fmt(struct trace_seq · line 463

Quoted 5 lines
kernel/trace/trace_output.c +1 -1
@@ -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

Quoted 3 lines
kernel/trace/trace_output.c +0 -0
 		'.';
 
 	switch (entry->flags & (TRACE_FLAG_NEED_RESCHED |
#3 lore raw

Re: [PATCH v2 1/3] tracing: Replace TRACE_FLAG_IRQS_NOSUPPORT with its config option.

Quoted 30 lines · Steven Rostedt
Quoted 6 lines · On Mon, 21 Oct 2024 17:08:40 +0200 Sebastian Andrzej Siewior…

From: Thomas Gleixner <[email protected]>

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.

Quoted 8 lines

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
Quoted 1 line

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

Quoted 12 lines

include/linux/trace_events.h unsigned int tracing_gen_ctx_irq_test(un · line 187

Quoted 8 lines

+++ b/include/linux/trace_events.h

include/linux/trace_events.h +1 -2
@@ -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.

Quoted 1 line

Please just remove NOSUPPORT and do not touch NEED_RESCHED.

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

Quoted 5 lines
Quoted 5 lines
include/linux/trace_events.h +0 -0
 	TRACE_FLAG_HARDIRQ		= 0x08,
 	TRACE_FLAG_SOFTIRQ		= 0x10,
 	TRACE_FLAG_PREEMPT_RESCHED	= 0x20,
kernel/trace/trace_output.c +0 -0
Quoted 8 lines

kernel/trace/trace_output.c int trace_print_lat_fmt(struct trace_seq · line 463

Quoted 6 lines
kernel/trace/trace_output.c +1 -1
@@ -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.

Quoted 1 line

-- Steve

Sebastian

maintainer
#4 lore raw

Re: [PATCH v2 1/3] tracing: Replace TRACE_FLAG_IRQS_NOSUPPORT with its config option.

Quoted 4 lines · On Tue, 22 Oct 2024 11:52:41 +0200 Sebastian Andrzej Siewior…
Quoted 2 lines

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

#5 lore raw

Re: [PATCH v2 1/3] tracing: Replace TRACE_FLAG_IRQS_NOSUPPORT with its config option.

Quoted 9 lines · Steven Rostedt
Quoted 4 lines · On Tue, 22 Oct 2024 11:52:41 +0200 Sebastian Andrzej Siewior…
Quoted 2 lines

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?

Quoted 1 line

-- Steve

Sebastian

#6 lore raw

PATCH 1/1 tracing: Remove TRACE_FLAG_IRQS_NOSUPPORT

In reply to Steven Rostedt

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.

---

Quoted 1 line · Steven Rostedt

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(-)
Documentation/trace/ftrace.rst +0 -3
index 4073ca48af4ad..74d5bd801b1a8 100644
@@ -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,
include/linux/trace_events.h +0 -13
index 42bedcddd5113..467dadb990cbe 100644
@@ -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)
 {
kernel/trace/trace_output.c +0 -1
index 868f2f912f280..2ee6613dce6dc 100644
@@ -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 |
Signature · 1 line
2.45.2
#7 lore raw

PATCH v2 2/3 tracing: Record task flag NEED_RESCHED_LAZY.

In reply to Sebastian Andrzej Siewior

From: Thomas Gleixner <[email protected]>

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

---
 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(-)
Documentation/trace/ftrace.rst +4 -0
@@ -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:
include/linux/trace_events.h +1 -0
@@ -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,
kernel/trace/trace.c +2 -0
@@ -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;
 }
kernel/trace/trace_output.c +13 -1
@@ -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;
maintainer
#8 lore raw

Re: [PATCH v2 2/3] tracing: Record task flag NEED_RESCHED_LAZY.

include/linux/trace_events.h unsigned int tracing_gen_ctx_irq_test(un · line 191

Quoted 7 lines · On Mon, 21 Oct 2024 17:08:41 +0200 Sebastian Andrzej Siewior…

enum trace_flag_type {

include/linux/trace_events.h +1 -0
 	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

#9 lore raw

Re: [PATCH v2 2/3] tracing: Record task flag NEED_RESCHED_LAZY.

Quoted 13 lines · Steven Rostedt

include/linux/trace_events.h unsigned int tracing_gen_ctx_irq_test(un · line 191

Quoted 7 lines · On Mon, 21 Oct 2024 17:08:41 +0200 Sebastian Andrzej Siewior…

enum trace_flag_type {

include/linux/trace_events.h +1 -0
 	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().

Quoted 2 lines

-- Steve

Sebastian

#10 lore raw

PATCH v2 3/3 riscv: add PREEMPT_LAZY support

In reply to Sebastian Andrzej Siewior

From: Jisheng Zhang <[email protected]>

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 ]

---
 arch/riscv/Kconfig                   |    1 +
 arch/riscv/include/asm/thread_info.h |   10 ++++++----
 2 files changed, 7 insertions(+), 4 deletions(-)
arch/riscv/Kconfig +1 -0
@@ -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
arch/riscv/include/asm/thread_info.h +6 -4
@@ -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)
merge bot Applied
#11 lore raw

[tip: sched/core] riscv: add PREEMPT_LAZY support

The following commit has been merged into the sched/core branch of tip:

The following commit has been merged into the sched/core branch of tip:

Commit-ID:     22aaec357c1ff85b72c105c90503e3b4187384b8
Gitweb:        https://git.kernel.org/tip/22aaec357c1ff85b72c105c90503e3b4187384b8
Author:        Jisheng Zhang <[email protected]>
AuthorDate:    Mon, 21 Oct 2024 17:08:42 +02:00
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Tue, 05 Nov 2024 12:55:39 +01:00

riscv: add PREEMPT_LAZY support

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 ]

---
 arch/riscv/Kconfig                   |  1 +
 arch/riscv/include/asm/thread_info.h | 10 ++++++----
 2 files changed, 7 insertions(+), 4 deletions(-)
arch/riscv/Kconfig +1 -0
index 6254594..3516c58 100644
@@ -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
arch/riscv/include/asm/thread_info.h +6 -4
index 9c10fb1..f5916a7 100644
@@ -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)
#12 lore raw

Re: [PATCH v2 3/3] riscv: add PREEMPT_LAZY support

In reply to Sebastian Andrzej Siewior
This patch was applied to riscv/linux.git (fixes) by Peter Zijlstra <[email protected]>:

Hello:

This patch was applied to riscv/linux.git (fixes)
by Peter Zijlstra <[email protected]>:

Quoted 9 lines · On Mon, 21 Oct 2024 17:08:42 +0200 you wrote:

From: Jisheng Zhang <[email protected]>

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!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html