linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "tip-bot2 for Mark Rutland" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Mark Rutland <mark.rutland@arm.com>,
	"Peter Zijlstra (Intel)" <peterz@infradead.org>,
	Ard Biesheuvel <ardb@kernel.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Frederic Weisbecker <frederic@kernel.org>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: sched/core] arm64: entry: Centralize preemption decision
Date: Sat, 19 Feb 2022 10:21:24 -0000	[thread overview]
Message-ID: <164526608445.16921.6244195610918340088.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20220214165216.2231574-7-mark.rutland@arm.com>

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

Commit-ID:     8e12ab7c0e9f73ebfbcd6d37ece738f1825d58c8
Gitweb:        https://git.kernel.org/tip/8e12ab7c0e9f73ebfbcd6d37ece738f1825d58c8
Author:        Mark Rutland <mark.rutland@arm.com>
AuthorDate:    Mon, 14 Feb 2022 16:52:15 
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Sat, 19 Feb 2022 11:11:08 +01:00

arm64: entry: Centralize preemption decision

For historical reasons, the decision of whether or not to preempt is
spread across arm64_preempt_schedule_irq() and __el1_irq(), and it would
be clearer if this were all in one place.

Also, arm64_preempt_schedule_irq() calls lockdep_assert_irqs_disabled(),
but this is redundant, as we have a subsequent identical assertion in
__exit_to_kernel_mode(), and preempt_schedule_irq() will
BUG_ON(!irqs_disabled()) anyway.

This patch removes the redundant assertion and centralizes the
preemption decision making within arm64_preempt_schedule_irq().

Other than the slight change to assertion behaviour, there should be no
functional change as a result of this patch.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Frederic Weisbecker <frederic@kernel.org>
Link: https://lore.kernel.org/r/20220214165216.2231574-7-mark.rutland@arm.com
---
 arch/arm64/kernel/entry-common.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-common.c
index ef7fcef..2c639b6 100644
--- a/arch/arm64/kernel/entry-common.c
+++ b/arch/arm64/kernel/entry-common.c
@@ -222,7 +222,16 @@ static void noinstr arm64_exit_el1_dbg(struct pt_regs *regs)
 
 static void __sched arm64_preempt_schedule_irq(void)
 {
-	lockdep_assert_irqs_disabled();
+	if (!IS_ENABLED(CONFIG_PREEMPTION))
+		return;
+
+	/*
+	 * Note: thread_info::preempt_count includes both thread_info::count
+	 * and thread_info::need_resched, and is not equivalent to
+	 * preempt_count().
+	 */
+	if (READ_ONCE(current_thread_info()->preempt_count) != 0)
+		return;
 
 	/*
 	 * DAIF.DA are cleared at the start of IRQ/FIQ handling, and when GIC
@@ -438,14 +447,7 @@ static __always_inline void __el1_irq(struct pt_regs *regs,
 	do_interrupt_handler(regs, handler);
 	irq_exit_rcu();
 
-	/*
-	 * Note: thread_info::preempt_count includes both thread_info::count
-	 * and thread_info::need_resched, and is not equivalent to
-	 * preempt_count().
-	 */
-	if (IS_ENABLED(CONFIG_PREEMPTION) &&
-	    READ_ONCE(current_thread_info()->preempt_count) == 0)
-		arm64_preempt_schedule_irq();
+	arm64_preempt_schedule_irq();
 
 	exit_to_kernel_mode(regs);
 }

  reply	other threads:[~2022-02-19 10:21 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-14 16:52 [PATCH v4 0/7] arm64 / sched/preempt: support PREEMPT_DYNAMIC with static keys Mark Rutland
2022-02-14 16:52 ` [PATCH v4 1/7] sched/preempt: move PREEMPT_DYNAMIC logic later Mark Rutland
2022-02-19 10:21   ` [tip: sched/core] sched/preempt: Move " tip-bot2 for Mark Rutland
2022-02-14 16:52 ` [PATCH v4 2/7] sched/preempt: refactor sched_dynamic_update() Mark Rutland
2022-02-19 10:21   ` [tip: sched/core] sched/preempt: Refactor sched_dynamic_update() tip-bot2 for Mark Rutland
2022-02-14 16:52 ` [PATCH v4 3/7] sched/preempt: simplify irqentry_exit_cond_resched() callers Mark Rutland
2022-02-19 10:21   ` [tip: sched/core] sched/preempt: Simplify " tip-bot2 for Mark Rutland
2022-02-14 16:52 ` [PATCH v4 4/7] sched/preempt: decouple HAVE_PREEMPT_DYNAMIC from GENERIC_ENTRY Mark Rutland
2022-02-19 10:21   ` [tip: sched/core] sched/preempt: Decouple " tip-bot2 for Mark Rutland
2022-02-14 16:52 ` [PATCH v4 5/7] sched/preempt: add PREEMPT_DYNAMIC using static keys Mark Rutland
2022-02-19 10:21   ` [tip: sched/core] sched/preempt: Add " tip-bot2 for Mark Rutland
2022-03-18  8:49   ` [PATCH v4 5/7] sched/preempt: add " Sven Schnelle
2022-02-14 16:52 ` [PATCH v4 6/7] arm64: entry: centralize preemption decision Mark Rutland
2022-02-19 10:21   ` tip-bot2 for Mark Rutland [this message]
2022-02-14 16:52 ` [PATCH v4 7/7] arm64: support PREEMPT_DYNAMIC Mark Rutland
2022-02-19 10:21   ` [tip: sched/core] arm64: Support PREEMPT_DYNAMIC tip-bot2 for Mark Rutland
2022-02-17 13:52 ` [PATCH v4 0/7] arm64 / sched/preempt: support PREEMPT_DYNAMIC with static keys Frederic Weisbecker
2022-02-17 18:59   ` Peter Zijlstra

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=164526608445.16921.6244195610918340088.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=ardb@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=frederic@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=peterz@infradead.org \
    --cc=x86@kernel.org \
    /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).