linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/14] entry: preempt_schedule_irq() callers scrub
@ 2019-03-11 22:47 Valentin Schneider
  2019-03-11 22:47 ` [PATCH 10/14] sh: entry: Remove unneeded need_resched() loop Valentin Schneider
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Valentin Schneider @ 2019-03-11 22:47 UTC (permalink / raw)
  To: linux-kernel
  Cc: Julien Thierry, Ingo Molnar, Peter Zijlstra, Thomas Gleixner,
	linux-xtensa, x86, sparclinux, linux-sh, linux-riscv,
	linuxppc-dev, linux-mips, uclinux-h8-devel, linux-c6x-dev,
	linux-ia64, linux-s390, linux-snps-arc, linux-m68k, nios2-dev

Hi,

This is the continuation of [1] where I'm hunting down
preempt_schedule_irq() callers because of [2].

I told myself the best way to get this moving forward wouldn't be to write
doc about it, but to go write some fixes and get some discussions going,
which is what this patch-set is about.

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) and C) EXCEPT for ia64 and s390 because I
haven't been able to tell if it's actually fine to kill that "long jump"
(and maybe I'm wrong on sparc). Hopefully folks who understand what goes on
in there might be able to shed some light.

Also, since I sent patches for arm & arm64 in [1] I'm not including them
here.

Boot-tested on:
- x86

Build-tested on:
- h8300
- c6x
- powerpc
- mips
- nds32
- microblaze
- sparc
- xtensa

Thanks,
Valentin

[1]: https://lore.kernel.org/lkml/20190131182339.9835-1-valentin.schneider@arm.com/
[2]: https://lore.kernel.org/lkml/cc989920-a13b-d53b-db83-1584a7f53edc@arm.com/

Valentin Schneider (14):
  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
  MIPS: entry: Remove unneeded need_resched() loop
  nds32: ex-exit: Remove unneeded need_resched() loop
  powerpc: 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
  sparc64: rtrap: Remove unneeded need_resched() loop
  x86/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/mips/kernel/entry.S       | 3 +--
 arch/nds32/kernel/ex-exit.S    | 4 ++--
 arch/powerpc/kernel/entry_32.S | 6 +-----
 arch/powerpc/kernel/entry_64.S | 8 +-------
 arch/riscv/kernel/entry.S      | 3 +--
 arch/sh/kernel/cpu/sh5/entry.S | 5 +----
 arch/sh/kernel/entry-common.S  | 4 +---
 arch/sparc/kernel/rtrap_64.S   | 1 -
 arch/x86/entry/entry_32.S      | 3 +--
 arch/x86/entry/entry_64.S      | 3 +--
 arch/xtensa/kernel/entry.S     | 2 +-
 kernel/sched/core.c            | 7 +++----
 16 files changed, 16 insertions(+), 48 deletions(-)

--
2.20.1

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

* [PATCH 10/14] sh: entry: Remove unneeded need_resched() loop
  2019-03-11 22:47 [PATCH 00/14] entry: preempt_schedule_irq() callers scrub Valentin Schneider
@ 2019-03-11 22:47 ` Valentin Schneider
  2019-03-11 22:47 ` [PATCH 11/14] sh64: " Valentin Schneider
  2019-03-12 18:03 ` [PATCH 00/14] entry: preempt_schedule_irq() callers scrub Vineet Gupta
  2 siblings, 0 replies; 5+ messages in thread
From: Valentin Schneider @ 2019-03-11 22:47 UTC (permalink / raw)
  To: linux-kernel; +Cc: Yoshinori Sato, Rich Felker, linux-sh

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

Signed-off-by: Valentin Schneider <valentin.schneider@arm.com>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Rich Felker <dalias@libc.org>
Cc: linux-sh@vger.kernel.org
---
 arch/sh/kernel/entry-common.S | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/sh/kernel/entry-common.S b/arch/sh/kernel/entry-common.S
index d31f66e82ce5..65a105de52a0 100644
--- a/arch/sh/kernel/entry-common.S
+++ b/arch/sh/kernel/entry-common.S
@@ -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
-- 
2.20.1

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

* [PATCH 11/14] sh64: entry: Remove unneeded need_resched() loop
  2019-03-11 22:47 [PATCH 00/14] entry: preempt_schedule_irq() callers scrub Valentin Schneider
  2019-03-11 22:47 ` [PATCH 10/14] sh: entry: Remove unneeded need_resched() loop Valentin Schneider
@ 2019-03-11 22:47 ` Valentin Schneider
  2019-03-12 18:03 ` [PATCH 00/14] entry: preempt_schedule_irq() callers scrub Vineet Gupta
  2 siblings, 0 replies; 5+ messages in thread
From: Valentin Schneider @ 2019-03-11 22:47 UTC (permalink / raw)
  To: linux-kernel; +Cc: Yoshinori Sato, Rich Felker, linux-sh

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

Signed-off-by: Valentin Schneider <valentin.schneider@arm.com>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Rich Felker <dalias@libc.org>
Cc: linux-sh@vger.kernel.org
---
 arch/sh/kernel/cpu/sh5/entry.S | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/sh/kernel/cpu/sh5/entry.S b/arch/sh/kernel/cpu/sh5/entry.S
index de68ffdfffbf..40e6d9a7a6a2 100644
--- a/arch/sh/kernel/cpu/sh5/entry.S
+++ b/arch/sh/kernel/cpu/sh5/entry.S
@@ -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
-- 
2.20.1

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

* Re: [PATCH 00/14] entry: preempt_schedule_irq() callers scrub
  2019-03-11 22:47 [PATCH 00/14] entry: preempt_schedule_irq() callers scrub Valentin Schneider
  2019-03-11 22:47 ` [PATCH 10/14] sh: entry: Remove unneeded need_resched() loop Valentin Schneider
  2019-03-11 22:47 ` [PATCH 11/14] sh64: " Valentin Schneider
@ 2019-03-12 18:03 ` Vineet Gupta
  2019-03-12 18:18   ` Valentin Schneider
  2 siblings, 1 reply; 5+ messages in thread
From: Vineet Gupta @ 2019-03-12 18:03 UTC (permalink / raw)
  To: Valentin Schneider, linux-kernel
  Cc: Julien Thierry, Ingo Molnar, Peter Zijlstra, Thomas Gleixner,
	linux-xtensa, x86, sparclinux, linux-sh, linux-riscv,
	linuxppc-dev, linux-mips, uclinux-h8-devel, linux-c6x-dev,
	linux-ia64, linux-s390, linux-snps-arc, linux-m68k, nios2-dev

On 3/11/19 3:47 PM, Valentin Schneider wrote:
> Hi,
> 
> This is the continuation of [1] where I'm hunting down
> preempt_schedule_irq() callers because of [2].
> 
> I told myself the best way to get this moving forward wouldn't be to write
> doc about it, but to go write some fixes and get some discussions going,
> which is what this patch-set is about.
> 
> 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
> 
...

> 
> Regarding that loop, archs seem to fall in 3 categories:
> A) Those that don't have the loop

Please clarify that this is the right thing to do (since core code already has the
loop) hence no fixing is required for this "category"

> 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) and C) EXCEPT for ia64 and s390 because I
> haven't been able to tell if it's actually fine to kill that "long jump"
> (and maybe I'm wrong on sparc). Hopefully folks who understand what goes on
> in there might be able to shed some light.

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

* Re: [PATCH 00/14] entry: preempt_schedule_irq() callers scrub
  2019-03-12 18:03 ` [PATCH 00/14] entry: preempt_schedule_irq() callers scrub Vineet Gupta
@ 2019-03-12 18:18   ` Valentin Schneider
  0 siblings, 0 replies; 5+ messages in thread
From: Valentin Schneider @ 2019-03-12 18:18 UTC (permalink / raw)
  To: Vineet Gupta, linux-kernel
  Cc: Julien Thierry, Ingo Molnar, Peter Zijlstra, Thomas Gleixner,
	linux-xtensa, x86, sparclinux, linux-sh, linux-riscv,
	linuxppc-dev, linux-mips, uclinux-h8-devel, linux-c6x-dev,
	linux-ia64, linux-s390, linux-snps-arc, linux-m68k, nios2-dev

On 12/03/2019 18:03, Vineet Gupta wrote:
[...]
>> Regarding that loop, archs seem to fall in 3 categories:
>> A) Those that don't have the loop
> 
> Please clarify that this is the right thing to do (since core code already has the
> loop) hence no fixing is required for this "category"
> 

Right, those don't need any change. I had a brief look at them to double
check they had the proper need_resched() gate before calling
preempt_schedule_irq() (with no loop) and they all seem fine. Also...

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

I forgot to include parisc in here.

[...]

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

end of thread, other threads:[~2019-03-12 18:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-11 22:47 [PATCH 00/14] entry: preempt_schedule_irq() callers scrub Valentin Schneider
2019-03-11 22:47 ` [PATCH 10/14] sh: entry: Remove unneeded need_resched() loop Valentin Schneider
2019-03-11 22:47 ` [PATCH 11/14] sh64: " Valentin Schneider
2019-03-12 18:03 ` [PATCH 00/14] entry: preempt_schedule_irq() callers scrub Vineet Gupta
2019-03-12 18:18   ` Valentin Schneider

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