public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <frederic@kernel.org>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Frederic Weisbecker <frederic@kernel.org>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	"Paul E . McKenney" <paulmck@kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Anna-Maria Behnsen <anna-maria@linutronix.de>,
	Eric Dumazet <edumazet@google.com>
Subject: [RFC PATCH 2/6] softirq: Make softirq handling entry/exit generally available
Date: Tue,  1 Aug 2023 15:24:37 +0200	[thread overview]
Message-ID: <20230801132441.559222-3-frederic@kernel.org> (raw)
In-Reply-To: <20230801132441.559222-1-frederic@kernel.org>

In order to prepare for re-enabling softirqs from vector callbacks that
are known safe, make the code incrementing the preempt count while
servicing softirqs more generally available.

No intended behaviour change.

Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
---
 include/linux/bottom_half.h |  7 +++++++
 kernel/softirq.c            | 22 ++++++++++++++++------
 2 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/include/linux/bottom_half.h b/include/linux/bottom_half.h
index fc53e0ad56d9..2243c7de4917 100644
--- a/include/linux/bottom_half.h
+++ b/include/linux/bottom_half.h
@@ -33,6 +33,13 @@ static inline void local_bh_enable(void)
 	__local_bh_enable_ip(_THIS_IP_, SOFTIRQ_DISABLE_OFFSET);
 }
 
+static inline void local_bh_enter(void)
+{
+	__local_bh_disable_ip(_RET_IP_, SOFTIRQ_OFFSET);
+}
+
+extern void local_bh_exit(void);
+
 #ifdef CONFIG_PREEMPT_RT
 extern bool local_bh_blocked(void);
 #else
diff --git a/kernel/softirq.c b/kernel/softirq.c
index 1a3c3fe341ea..ba998d572ef4 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -247,21 +247,26 @@ void __local_bh_enable_ip(unsigned long ip, unsigned int cnt)
 }
 EXPORT_SYMBOL(__local_bh_enable_ip);
 
+inline void local_bh_exit(void)
+{
+	__local_bh_enable(SOFTIRQ_OFFSET, true);
+	WARN_ON_ONCE(in_interrupt());
+}
+
 /*
  * Invoked from ksoftirqd_run() outside of the interrupt disabled section
  * to acquire the per CPU local lock for reentrancy protection.
  */
 static inline void ksoftirqd_run_begin(void)
 {
-	__local_bh_disable_ip(_RET_IP_, SOFTIRQ_OFFSET);
+	local_bh_enter();
 	local_irq_disable();
 }
 
 /* Counterpart to ksoftirqd_run_begin() */
 static inline void ksoftirqd_run_end(void)
 {
-	__local_bh_enable(SOFTIRQ_OFFSET, true);
-	WARN_ON_ONCE(in_interrupt());
+	local_bh_exit();
 	local_irq_enable();
 }
 
@@ -389,15 +394,20 @@ void __local_bh_enable_ip(unsigned long ip, unsigned int cnt)
 }
 EXPORT_SYMBOL(__local_bh_enable_ip);
 
+inline void local_bh_exit(void)
+{
+	__local_bh_enable(SOFTIRQ_OFFSET);
+	WARN_ON_ONCE(in_interrupt());
+}
+
 static inline void softirq_handle_begin(void)
 {
-	__local_bh_disable_ip(_RET_IP_, SOFTIRQ_OFFSET);
+	local_bh_enter();
 }
 
 static inline void softirq_handle_end(void)
 {
-	__local_bh_enable(SOFTIRQ_OFFSET);
-	WARN_ON_ONCE(in_interrupt());
+	local_bh_exit();
 }
 
 static inline void ksoftirqd_run_begin(void)
-- 
2.34.1


  parent reply	other threads:[~2023-08-01 13:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-01 13:24 [RFC PATCH 0/6] softirq: Start pushing down the big softirq lock Frederic Weisbecker
2023-08-01 13:24 ` [RFC PATCH 1/6] softirq: Turn set_softirq_pending() to reset_softirq_pending() Frederic Weisbecker
2023-08-01 13:24 ` Frederic Weisbecker [this message]
2023-08-01 13:24 ` [RFC PATCH 3/6] softirq: Introduce softirq disabled mask Frederic Weisbecker
2023-08-01 13:24 ` [RFC PATCH 4/6] x86/softirq: Support " Frederic Weisbecker
2023-08-01 13:24 ` [RFC PATCH 5/6] timers: Introduce soft-interruptible timers Frederic Weisbecker
2023-08-01 13:24 ` [RFC PATCH 6/6] timers: Make process_timeout() soft-interruptible Frederic Weisbecker
2023-08-07 12:50 ` [RFC PATCH 0/6] softirq: Start pushing down the big softirq lock Sebastian Andrzej Siewior
2023-08-07 15:22   ` Frederic Weisbecker
2023-08-08  7:15     ` Sebastian Andrzej Siewior

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=20230801132441.559222-3-frederic@kernel.org \
    --to=frederic@kernel.org \
    --cc=anna-maria@linutronix.de \
    --cc=bigeasy@linutronix.de \
    --cc=edumazet@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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