linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Valentin Schneider <valentin.schneider@arm.com>
To: linux-kernel@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will.deacon@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Marc Zyngier <marc.zyngier@arm.com>,
	Julien Grall <julien.grall@arm.com>,
	Julien Thierry <julien.thierry@arm.com>,
	Russell King <linux@armlinux.org.uk>,
	Jonathan Corbet <corbet@lwn.net>, Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: [RFC PATCH 0/3] arm/arm64: entry: Remove need_resched() loop
Date: Thu, 31 Jan 2019 18:23:36 +0000	[thread overview]
Message-ID: <20190131182339.9835-1-valentin.schneider@arm.com> (raw)

A while back (before [1]), i386 had this in the tail of its irq
handling code:

  need_resched:
	  movl TI_flags(%ebp), %ecx       # need_resched set ?
	  testb $_TIF_NEED_RESCHED, %cl
	  jz restore_all
	  testl $IF_MASK,EFLAGS(%esp)     # interrupts off (exception path) ?
	  jz restore_all
	  sti
	  call preempt_schedule
	  cli
	  movl $0,TI_preempt_count(%ebp)
	  jmp need_resched

preempt_schedule() already had an inner need_resched() loop introduced by

  commit 4d0b85ea4610 ("[PATCH] kernel preemption bits (2/2)")

and the outer loop was needed since, as the above commit explains, it
was possible to return from preempt_schedule(), get an interrupt and
have need_resched() true.

This was eventually changed when preempt_schedule_irq() was introduced
by [1]:

  commit b268264c6299 ("[PATCH] sched: fix preemption race (Core/i386)")

which moved the enabling & disabling of interrupts inside the then
new preempt_schedule_irq(). From then on, the arch-code loop was no
longer necessary, providing preempt_schedule_irq() was used. This was
talked over on LKML in [2].

It's worth noting that it seems most archs calling
preempt_schedule_irq() have that outer loop, and for most of them it
really looks like they could get rid of it as well.

FWIW the suspects are

$ 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
  s390
  sh
  sparc
  x86
  xtensa


- Patches 1-2 remove the loop for arm & arm64
- Patch 3 adds a bit of documentation to point out the loop isn't needed
  to try and spread the word.

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

Valentin Schneider (3):
  arm64: entry: Remove unneeded need_resched() loop
  ARM: entry: Remove unneeded need_resched() loop
  sched/Documentation: Point out use of preempt_schedule_irq()

 Documentation/scheduler/sched-arch.txt | 10 ++++++++++
 arch/arm/kernel/entry-armv.S           | 12 +-----------
 arch/arm64/kernel/entry.S              | 11 +----------
 3 files changed, 12 insertions(+), 21 deletions(-)

--
2.20.1


             reply	other threads:[~2019-01-31 18:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-31 18:23 Valentin Schneider [this message]
2019-01-31 18:23 ` [RFC PATCH 1/3] arm64: entry: Remove unneeded need_resched() loop Valentin Schneider
2019-02-01  8:46   ` Julien Thierry
2019-02-01 10:21   ` Will Deacon
2019-02-04 16:55   ` Catalin Marinas
2019-01-31 18:23 ` [RFC PATCH 2/3] ARM: " Valentin Schneider
2019-02-01  8:49   ` Julien Thierry
2019-01-31 18:23 ` [RFC PATCH 3/3] sched/Documentation: Point out use of preempt_schedule_irq() Valentin Schneider
2019-02-01  8:45   ` Julien Thierry
2019-02-01 10:27     ` Valentin Schneider

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190131182339.9835-1-valentin.schneider@arm.com \
    --to=valentin.schneider@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=corbet@lwn.net \
    --cc=julien.grall@arm.com \
    --cc=julien.thierry@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=marc.zyngier@arm.com \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).