Skip to contentSkip to conversation

LoongArch: Add PREEMPT_LAZY support

PATCH In review Xi Ruoyao 2 participants 2 messages Nov 21, 2024 LoongArch

lore
Share & tools
lore

Xi Ruoyao

author
#0 lore raw

PATCH 1/1 LoongArch: Add PREEMPT_LAZY support

Like x86 and RISC-V, we are using GENERIC_ENTRY so supporting PREEMPT_LAZY just needs to allocate a bit in thread flags.

---
 arch/loongarch/Kconfig                   | 1 +
 arch/loongarch/include/asm/thread_info.h | 8 +++++---
 2 files changed, 6 insertions(+), 3 deletions(-)
arch/loongarch/Kconfig +1 -0
index d9fce0fd475a..b8cc5997d595 100644
@@ -25,6 +25,7 @@ config LOONGARCH
 	select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
 	select ARCH_HAS_PTE_DEVMAP
 	select ARCH_HAS_PTE_SPECIAL
+	select ARCH_HAS_PREEMPT_LAZY
 	select ARCH_HAS_SET_MEMORY
 	select ARCH_HAS_SET_DIRECT_MAP
 	select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
arch/loongarch/include/asm/thread_info.h +5 -3
index 8bf0e6f51546..fd68a6d81b8e 100644
@@ -66,8 +66,9 @@ register unsigned long current_stack_pointer __asm__("$sp");
  * - pending work-to-be-done flags are in LSW
  * - other flags in MSW
  */
-#define TIF_SIGPENDING		1	/* signal pending */
-#define TIF_NEED_RESCHED	2	/* rescheduling necessary */
+#define TIF_NEED_RESCHED	0	/* rescheduling necessary */
+#define TIF_NEED_RESCHED_LAZY	1	/* Lazy rescheduling needed */
+#define TIF_SIGPENDING		2	/* signal pending */
 #define TIF_NOTIFY_RESUME	3	/* callback before returning to user */
 #define TIF_NOTIFY_SIGNAL	4	/* signal notifications exist */
 #define TIF_RESTORE_SIGMASK	5	/* restore signal mask in do_signal() */
@@ -88,8 +89,9 @@ register unsigned long current_stack_pointer __asm__("$sp");
 #define TIF_LBT_CTX_LIVE	20	/* LBT context must be preserved */
 #define TIF_PATCH_PENDING	21	/* pending live patching update */
 
-#define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
+#define _TIF_NEED_RESCHED_LAZY	(1<<TIF_NEED_RESCHED_LAZY)
+#define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 #define _TIF_NOTIFY_SIGNAL	(1<<TIF_NOTIFY_SIGNAL)
 #define _TIF_NOHZ		(1<<TIF_NOHZ)

base-commit: 43fb83c17ba2d63dfb798f0be7453ed55ca3f9c2

Signature · 1 line
2.47.0
maintainer
#1 lore raw

Hmmm, I have just written the same patch...
https://github.com/chenhuacai/linux/commit/d908e12e493173df4a3edf23c4a265385f475621

Huacai

Quoted 55 lines · Xi Ruoyao

Like x86 and RISC-V, we are using GENERIC_ENTRY so supporting PREEMPT_LAZY just needs to allocate a bit in thread flags.

---
 arch/loongarch/Kconfig                   | 1 +
 arch/loongarch/include/asm/thread_info.h | 8 +++++---
 2 files changed, 6 insertions(+), 3 deletions(-)
arch/loongarch/Kconfig +1 -0
index d9fce0fd475a..b8cc5997d595 100644
@@ -25,6 +25,7 @@ config LOONGARCH
        select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
        select ARCH_HAS_PTE_DEVMAP
        select ARCH_HAS_PTE_SPECIAL
+       select ARCH_HAS_PREEMPT_LAZY
        select ARCH_HAS_SET_MEMORY
        select ARCH_HAS_SET_DIRECT_MAP
        select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
arch/loongarch/include/asm/thread_info.h +5 -3
index 8bf0e6f51546..fd68a6d81b8e 100644
@@ -66,8 +66,9 @@ register unsigned long current_stack_pointer __asm__("$sp");
  * - pending work-to-be-done flags are in LSW
  * - other flags in MSW
  */
-#define TIF_SIGPENDING         1       /* signal pending */
-#define TIF_NEED_RESCHED       2       /* rescheduling necessary */
+#define TIF_NEED_RESCHED       0       /* rescheduling necessary */
+#define TIF_NEED_RESCHED_LAZY  1       /* Lazy rescheduling needed */
+#define TIF_SIGPENDING         2       /* signal pending */
 #define TIF_NOTIFY_RESUME      3       /* callback before returning to user */
 #define TIF_NOTIFY_SIGNAL      4       /* signal notifications exist */
 #define TIF_RESTORE_SIGMASK    5       /* restore signal mask in do_signal() */
@@ -88,8 +89,9 @@ register unsigned long current_stack_pointer __asm__("$sp");
 #define TIF_LBT_CTX_LIVE       20      /* LBT context must be preserved */
 #define TIF_PATCH_PENDING      21      /* pending live patching update */
 
-#define _TIF_SIGPENDING                (1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED      (1<<TIF_NEED_RESCHED)
+#define _TIF_NEED_RESCHED_LAZY (1<<TIF_NEED_RESCHED_LAZY)
+#define _TIF_SIGPENDING                (1<<TIF_SIGPENDING)
 #define _TIF_NOTIFY_RESUME     (1<<TIF_NOTIFY_RESUME)
 #define _TIF_NOTIFY_SIGNAL     (1<<TIF_NOTIFY_SIGNAL)
 #define _TIF_NOHZ              (1<<TIF_NOHZ)

base-commit: 43fb83c17ba2d63dfb798f0be7453ed55ca3f9c2 --
2.47.0