entry: preempt_schedule_irq() callers scrub
Subsystems (6)
v2 cover entry: preempt_schedule_irq() callers scrub
I've left this to ~rot~ age out in the sun for a while, apologies for that. One early new-year resolution for me is to maintain a shorter resend timeout on this.
This is the continuation of [1] where I'm hunting down preempt_schedule_irq() callers because of [2]. I've looked at users of preempt_schedule_irq(), and made sure they didn't have one of those useless loops. The list of offenders is:
$ grep -r -I "preempt_schedule_irq" arch/ | cut -d/ -f2 | sort | uniq
arc
arm
arm64
c6x
csky
h8300
ia64
m68k
microblaze
mips
nds32
nios2
parisc
powerpc
riscv
s390
sh
sparc
x86
xtensa
Regarding that loop, archs seem to fall in 3 categories:
A) Those that don't have the loop
B) Those that have a small need_resched() loop around the preempt_schedule_irq() callsite
C) Those that branch to some more generic code further up the entry code and eventually branch back to preempt_schedule_irq()
arc, m68k, nios2 fall in A)
sparc, ia64, s390 fall in C)
all the others fall in B)
I've written patches for B). As of 5.3 mainline contains those for:
- arm64
- mips
- x86
- powerpc
- nds32
I've also got acks/reviews but haven't seen in any tree yet for:
- c6x
- csky
- riscv
- xtensa
The remaining ones for which I haven't had any reply at all are
- h8300
- microblaze
- sh
- sh64
Build-tested:
- h8300
- c6x
- microblaze
- riscv
No major change since v1 other than rebasing on top of 5.4 and collecting Reviewed-By / Acked-By.
Thanks,
Valentin
[1]: https://lore.kernel.org/lkml/[email protected]/
[2]: https://lore.kernel.org/lkml/[email protected]/
Valentin Schneider (9):
sched/core: Fix preempt_schedule() interrupt return comment
c6x: entry: Remove unneeded need_resched() loop
csky: entry: Remove unneeded need_resched() loop
h8300: entry: Remove unneeded need_resched() loop
microblaze: entry: Remove unneeded need_resched() loop
RISC-V: entry: Remove unneeded need_resched() loop
sh: entry: Remove unneeded need_resched() loop
sh64: entry: Remove unneeded need_resched() loop
xtensa: entry: Remove unneeded need_resched() loop
arch/c6x/kernel/entry.S | 3 +-- arch/csky/kernel/entry.S | 4 ---- arch/h8300/kernel/entry.S | 3 +-- arch/microblaze/kernel/entry.S | 5 ----- arch/riscv/kernel/entry.S | 3 +-- arch/sh/kernel/cpu/sh5/entry.S | 5 +---- arch/sh/kernel/entry-common.S | 4 +--- arch/xtensa/kernel/entry.S | 2 +- kernel/sched/core.c | 7 +++---- 9 files changed, 9 insertions(+), 27 deletions(-)
--
2.22.0
PATCH v2 1/9 sched/core: Fix preempt_schedule() interrupt return comment
preempt_schedule_irq() is the one that should be called on return from interrupt, clean up the comment to avoid any ambiguity.
--- kernel/sched/core.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
kernel/sched/core.c +3 -4
@@ -4223,9 +4223,8 @@ static void __sched notrace preempt_schedule_common(void)#ifdef CONFIG_PREEMPTION /* -* this is the entry point to schedule() from in-kernel preemption -* off of preempt_enable. Kernel preemptions off return from interrupt -* occur there and call schedule directly. +* This is the entry point to schedule() from in-kernel preemption +* off of preempt_enable. */ asmlinkage __visible void __sched notrace preempt_schedule(void) {
@@ -4296,7 +4295,7 @@ EXPORT_SYMBOL_GPL(preempt_schedule_notrace);#endif /* CONFIG_PREEMPTION */ /* -* this is the entry point to schedule() from kernel preemption +* This is the entry point to schedule() from kernel preemption * off of irq context. * Note, that this is called and return with irqs disabled. This will * protect us against recursive calling from irq.
--
2.22.0
[tip: sched/urgent] sched/core: Fix preempt_schedule() interrupt return comment
The following commit has been merged into the sched/urgent branch of tip:
The following commit has been merged into the sched/urgent branch of tip:
Commit-ID: a49b4f4012ef233143c5f7ce44f97851e54d5ef9 Gitweb: https://git.kernel.org/tip/a49b4f4012ef233143c5f7ce44f97851e54d5ef9 Author: Valentin Schneider <[email protected]> AuthorDate: Mon, 23 Sep 2019 15:36:12 +01:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Wed, 25 Sep 2019 17:42:32 +02:00
sched/core: Fix preempt_schedule() interrupt return comment
preempt_schedule_irq() is the one that should be called on return from interrupt, clean up the comment to avoid any ambiguity.
--- kernel/sched/core.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
kernel/sched/core.c +3 -4
@@ -4218,9 +4218,8 @@ static void __sched notrace preempt_schedule_common(void)#ifdef CONFIG_PREEMPTION /* -* this is the entry point to schedule() from in-kernel preemption -* off of preempt_enable. Kernel preemptions off return from interrupt -* occur there and call schedule directly. +* This is the entry point to schedule() from in-kernel preemption +* off of preempt_enable. */ asmlinkage __visible void __sched notrace preempt_schedule(void) {
@@ -4291,7 +4290,7 @@ EXPORT_SYMBOL_GPL(preempt_schedule_notrace);#endif /* CONFIG_PREEMPTION */ /* -* this is the entry point to schedule() from kernel preemption +* This is the entry point to schedule() from kernel preemption * off of irq context. * Note, that this is called and return with irqs disabled. This will * protect us against recursive calling from irq.
PATCH v2 2/9 c6x: entry: Remove unneeded need_resched() loop
In reply to Valentin SchneiderSince the enabling and disabling of IRQs within preempt_schedule_irq() is contained in a need_resched() loop, we don't need the outer arch code loop.
--- arch/c6x/kernel/entry.S | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/c6x/kernel/entry.S +1 -2
@@ -564,7 +564,6 @@ resume_kernel: NOP 4 [A1] BNOP .S2 restore_all,5 -preempt_schedule: GET_THREAD_INFO A2 LDW .D1T1 *+A2(THREAD_INFO_FLAGS),A1 #ifdef CONFIG_C6X_BIG_KERNEL
@@ -581,7 +580,7 @@ preempt_schedule: #else B .S2 preempt_schedule_irq #endif - ADDKPC .S2 preempt_schedule,B3,4 + ADDKPC .S2 restore_all,B3,4 #endif /* CONFIG_PREEMPT */ ENTRY(enable_exception)
Signature · 1 line
2.22.0
PATCH v2 3/9 csky: entry: Remove unneeded need_resched() loop
In reply to Valentin SchneiderSince the enabling and disabling of IRQs within preempt_schedule_irq() is contained in a need_resched() loop, we don't need the outer arch code loop.
--- arch/csky/kernel/entry.S | 4 ---- 1 file changed, 4 deletions(-)
arch/csky/kernel/entry.S +0 -4
@@ -292,11 +292,7 @@ ENTRY(csky_irq) ldw r8, (r9, TINFO_FLAGS) btsti r8, TIF_NEED_RESCHED bf 2f -1: jbsr preempt_schedule_irq /* irq en/disable is done inside */ - ldw r7, (r9, TINFO_FLAGS) /* get new tasks TI_FLAGS */ - btsti r7, TIF_NEED_RESCHED - bt 1b /* go again */ #endif 2: jmpi ret_from_exception
Signature · 1 line
2.22.0
Guo Ren
maintainerRe: [PATCH v2 3/9] csky: entry: Remove unneeded need_resched() loop
Ok, I'll put in my tree :)
Quoted 30 lines · Valentin Schneider
Since the enabling and disabling of IRQs within
preempt_schedule_irq()is contained in aneed_resched()loop, we don't need the outer arch code loop.Acked-by Guo Ren <[email protected]>Signed-off-by Valentin Schneider <[email protected]>--- arch/csky/kernel/entry.S | 4 ---- 1 file changed, 4 deletions(-)arch/csky/kernel/entry.S +0
-5@@ -292,11 +292,7 @@ ENTRY(csky_irq) ldw r8, (r9, TINFO_FLAGS) btsti r8, TIF_NEED_RESCHED bf 2f -1: jbsr preempt_schedule_irq /* irq en/disable is done inside */ - ldw r7, (r9, TINFO_FLAGS) /* get new tasks TI_FLAGS */ - btsti r7, TIF_NEED_RESCHED - bt 1b /* go again */ #endif 2: jmpi ret_from_exception --2.22.0
Signature · 4 lines
Best Regards Guo Ren ML: https://lore.kernel.org/linux-csky/
PATCH v2 4/9 h8300: entry: Remove unneeded need_resched() loop
In reply to Valentin SchneiderSince the enabling and disabling of IRQs within preempt_schedule_irq() is contained in a need_resched() loop, we don't need the outer arch code loop.
--- arch/h8300/kernel/entry.S | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/h8300/kernel/entry.S +1 -2
@@ -323,7 +323,6 @@ restore_all: resume_kernel: mov.l @(TI_PRE_COUNT:16,er4),er0 bne restore_all:8 -need_resched: mov.l @(TI_FLAGS:16,er4),er0 btst #TIF_NEED_RESCHED,r0l beq restore_all:8
@@ -332,7 +331,7 @@ need_resched: mov.l sp,er0 jsr @set_esp0 jsr @preempt_schedule_irq - bra need_resched:8 + bra restore_all:8 #endif ret_from_fork:
Signature · 1 line
2.22.0
PATCH v2 5/9 microblaze: entry: Remove unneeded need_resched() loop
In reply to Valentin SchneiderSince the enabling and disabling of IRQs within preempt_schedule_irq() is contained in a need_resched() loop, we don't need the outer arch code loop.
--- arch/microblaze/kernel/entry.S | 5 ----- 1 file changed, 5 deletions(-)
arch/microblaze/kernel/entry.S +0 -5
@@ -738,14 +738,9 @@ no_intr_resched: andi r5, r5, _TIF_NEED_RESCHED; beqi r5, restore /* if zero jump over */ -preempt: /* interrupts are off that's why I am calling preempt_chedule_irq */ bralid r15, preempt_schedule_irq nop - lwi r11, CURRENT_TASK, TS_THREAD_INFO; /* get thread info */ - lwi r5, r11, TI_FLAGS; /* get flags in thread info */ - andi r5, r5, _TIF_NEED_RESCHED; - bnei r5, preempt /* if non zero jump to resched */ restore: #endif VM_OFF /* MS: turn off MMU */
Signature · 1 line
2.22.0
Michal Simek
maintainerRe: [PATCH v2 5/9] microblaze: entry: Remove unneeded need_resched() loop
Quoted 20 lines · Valentin Schneider
Since the enabling and disabling of IRQs within
preempt_schedule_irq()is contained in aneed_resched()loop, we don't need the outer arch code loop.Signed-off-by Valentin Schneider <[email protected]>Cc Michal Simek <[email protected]>--- arch/microblaze/kernel/entry.S | 5 ----- 1 file changed, 5 deletions(-)arch/microblaze/kernel/entry.S +0
-1@@ -738,14 +738,9 @@ no_intr_resched: andi r5, r5, _TIF_NEED_RESCHED; beqi r5, restore /* if zero jump over */ -preempt:
arch/microblaze/kernel/entry.S no_intr_resched: · line 746
Quoted 10 lines
arch/microblaze/kernel/entry.S +0
-4/* interrupts are off that's why I am calling preempt_chedule_irq */ bralid r15, preempt_schedule_irq nop - lwi r11, CURRENT_TASK, TS_THREAD_INFO; /* get thread info */ - lwi r5, r11, TI_FLAGS; /* get flags in thread info */ - andi r5, r5, _TIF_NEED_RESCHED; - bnei r5, preempt /* if non zero jump to resched */ restore: #endif VM_OFF /* MS: turn off MMU */
Looks reasonable and also tested on HW. I expect you want me to take it via microblaze tree that's why applied.
Thanks,
Michal
Signature · 5 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91 w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel - Xilinx Microblaze Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs
Re: [PATCH v2 5/9] microblaze: entry: Remove unneeded need_resched() loop
Quoted 19 lines · Michal Simek
Quoted 18 lines · Valentin Schneider
Since the enabling and disabling of IRQs within
preempt_schedule_irq()is contained in aneed_resched()loop, we don't need the outer arch code loop.Signed-off-by Valentin Schneider <[email protected]>Cc Michal Simek <[email protected]>--- arch/microblaze/kernel/entry.S | 5 ----- 1 file changed, 5 deletions(-)arch/microblaze/kernel/entry.S +0
-0@@ -738,14 +738,9 @@ no_intr_resched: andi r5, r5, _TIF_NEED_RESCHED; beqi r5, restore /* if zero jump over */
Quoted 16 lines
arch/microblaze/kernel/entry.S no_intr_resched: · line 746
Quoted 12 lines
arch/microblaze/kernel/entry.S +0
-5-preempt: /* interrupts are off that's why I am calling preempt_chedule_irq */ bralid r15, preempt_schedule_irq nop - lwi r11, CURRENT_TASK, TS_THREAD_INFO; /* get thread info */ - lwi r5, r11, TI_FLAGS; /* get flags in thread info */ - andi r5, r5, _TIF_NEED_RESCHED; - bnei r5, preempt /* if non zero jump to resched */ restore: #endif VM_OFF /* MS: turn off MMU */Looks reasonable and also tested on HW. I expect you want me to take it via microblaze tree that's why applied.
Yes, please. Thanks!
Quoted 3 lines
Thanks,
Michal
PATCH v2 6/9 RISC-V: entry: Remove unneeded need_resched() loop
In reply to Valentin SchneiderSince the enabling and disabling of IRQs within preempt_schedule_irq() is contained in a need_resched() loop, we don't need the outer arch code loop.
--- arch/riscv/kernel/entry.S | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/riscv/kernel/entry.S +1 -2
@@ -250,12 +250,11 @@ restore_all: resume_kernel: REG_L s0, TASK_TI_PREEMPT_COUNT(tp) bnez s0, restore_all -need_resched: REG_L s0, TASK_TI_FLAGS(tp) andi s0, s0, _TIF_NEED_RESCHED beqz s0, restore_all call preempt_schedule_irq - j need_resched + j restore_all #endif work_pending:
Signature · 1 line
2.22.0
Re: [PATCH v2 6/9] RISC-V: entry: Remove unneeded need_resched() loop
Quoted 8 lines · Valentin Schneider
Since the enabling and disabling of IRQs within
preempt_schedule_irq()is contained in aneed_resched()loop, we don't need the outer arch code loop.Reviewed-by Palmer Dabbelt <[email protected]>Signed-off-by Valentin Schneider <[email protected]>Cc Albert Ou <[email protected]>
Thanks, queued for v5.4-rc.
- Paul
PATCH v2 7/9 sh: entry: Remove unneeded need_resched() loop
In reply to Valentin SchneiderSince the enabling and disabling of IRQs within preempt_schedule_irq() is contained in a need_resched() loop, we don't need the outer arch code loop.
--- arch/sh/kernel/entry-common.S | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
arch/sh/kernel/entry-common.S +1 -3
@@ -93,7 +93,7 @@ ENTRY(resume_kernel) mov.l @(TI_PRE_COUNT,r8), r0 ! current_thread_info->preempt_count tst r0, r0 bf noresched -need_resched: + mov.l @(TI_FLAGS,r8), r0 ! current_thread_info->flags tst #_TIF_NEED_RESCHED, r0 ! need_resched set? bt noresched
@@ -107,8 +107,6 @@ need_resched: mov.l 1f, r0 jsr @r0 ! call preempt_schedule_irq nop - bra need_resched - nop noresched: bra __restore_all
Signature · 1 line
2.22.0
PATCH v2 8/9 sh64: entry: Remove unneeded need_resched() loop
In reply to Valentin SchneiderSince the enabling and disabling of IRQs within preempt_schedule_irq() is contained in a need_resched() loop, we don't need the outer arch code loop.
--- arch/sh/kernel/cpu/sh5/entry.S | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
arch/sh/kernel/cpu/sh5/entry.S +1 -4
@@ -897,7 +897,6 @@ resume_kernel: ld.l r6, TI_PRE_COUNT, r7 beq/u r7, ZERO, tr0 -need_resched: ld.l r6, TI_FLAGS, r7 movi (1 << TIF_NEED_RESCHED), r8 and r8, r7, r8
@@ -911,9 +910,7 @@ need_resched: ori r7, 1, r7 ptabs r7, tr1 blink tr1, LINK - - pta need_resched, tr1 - blink tr1, ZERO + blink tr0, ZERO #endif .global ret_from_syscall
Signature · 1 line
2.22.0
PATCH v2 9/9 xtensa: entry: Remove unneeded need_resched() loop
In reply to Valentin SchneiderSince the enabling and disabling of IRQs within preempt_schedule_irq() is contained in a need_resched() loop, we don't need the outer arch code loop.
--- arch/xtensa/kernel/entry.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/xtensa/kernel/entry.S +1 -1
@@ -529,7 +529,7 @@ common_exception_return: l32i a4, a2, TI_PRE_COUNT bnez a4, 4f call4 preempt_schedule_irq - j 1b + j 4f #endif #if XTENSA_FAKE_NMI
Signature · 1 line
2.22.0
Re: [PATCH v2 9/9] xtensa: entry: Remove unneeded need_resched() loop
Quoted 5 lines · Valentin Schneider
Since the enabling and disabling of IRQs within
preempt_schedule_irq()is contained in aneed_resched()loop, we don't need the outer arch code loop.
Quoted 7 lines
Acked-by Max Filippov <[email protected]>Signed-off-by Valentin Schneider <[email protected]>Cc Chris Zankel <[email protected]>--- arch/xtensa/kernel/entry.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
I've applied this patch to the xtensa tree as it doesn't seem to be taken anywhere else.
Signature · 2 lines
Thanks. -- Max