netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Boqun Feng <boqun.feng@gmail.com>
To: Ryo Takakura <ryotkkr98@gmail.com>
Cc: bp@alien8.de, davem@davemloft.net, edumazet@google.com,
	horms@kernel.org, kuba@kernel.org, kuniyu@amazon.com,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	pabeni@redhat.com, peterz@infradead.org, x86@kernel.org
Subject: Re: request_irq() with local bh disabled
Date: Fri, 7 Mar 2025 07:57:40 -0800	[thread overview]
Message-ID: <Z8sXdDFJTjYbpAcq@tardis> (raw)
In-Reply-To: <20250307133946.64685-1-ryotkkr98@gmail.com>

On Fri, Mar 07, 2025 at 10:39:46PM +0900, Ryo Takakura wrote:
> Hi Boris,
> 
> On Fri, 7 Mar 2025 14:13:19 +0100, Borislav Petkov wrote:
> >On Fri, Mar 07, 2025 at 09:58:51PM +0900, Ryo Takakura wrote:
> >> I'm so sorry that the commit caused this problem...
> >> Please let me know if there is anything that I should do.
> >
> >It is gone from the tip tree so you can take your time and try to do it right.
> >
> >Peter and/or I could help you reproduce the issue and try to figure out what
> >needs to change there.
> >
> >HTH.
> 
> Thank you so much for this. I really appreciate it.
> I'll once again take a look and try to fix the problem.
> 

Looks like we missed cases where

acquire the lock:

	netif_addr_lock_bh():
	  local_bh_disable();
	  spin_lock_nested();

release the lock:

	netif_addr_unlock_bh():
	  spin_unlock_bh(); // <- calling __local_bh_disable_ip() directly

means we should do the following on top of your changes.

Regards,
Boqun

------------------->8
diff --git a/include/linux/bottom_half.h b/include/linux/bottom_half.h
index 0640a147becd..7553309cbed4 100644
--- a/include/linux/bottom_half.h
+++ b/include/linux/bottom_half.h
@@ -22,7 +22,6 @@ extern struct lockdep_map bh_lock_map;
 
 static inline void local_bh_disable(void)
 {
-	lock_map_acquire_read(&bh_lock_map);
 	__local_bh_disable_ip(_THIS_IP_, SOFTIRQ_DISABLE_OFFSET);
 }
 
@@ -31,13 +30,11 @@ extern void __local_bh_enable_ip(unsigned long ip, unsigned int cnt);
 
 static inline void local_bh_enable_ip(unsigned long ip)
 {
-	lock_map_release(&bh_lock_map);
 	__local_bh_enable_ip(ip, SOFTIRQ_DISABLE_OFFSET);
 }
 
 static inline void local_bh_enable(void)
 {
-	lock_map_release(&bh_lock_map);
 	__local_bh_enable_ip(_THIS_IP_, SOFTIRQ_DISABLE_OFFSET);
 }
 
diff --git a/kernel/softirq.c b/kernel/softirq.c
index e864f9ce1dfe..782d5e9753f6 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -175,6 +175,8 @@ void __local_bh_disable_ip(unsigned long ip, unsigned int cnt)
 		lockdep_softirqs_off(ip);
 		raw_local_irq_restore(flags);
 	}
+
+	lock_map_acquire_read(&bh_lock_map);
 }
 EXPORT_SYMBOL(__local_bh_disable_ip);
 
@@ -183,6 +185,8 @@ static void __local_bh_enable(unsigned int cnt, bool unlock)
 	unsigned long flags;
 	int newcnt;
 
+	lock_map_release(&bh_lock_map);
+
 	DEBUG_LOCKS_WARN_ON(current->softirq_disable_cnt !=
 			    this_cpu_read(softirq_ctrl.cnt));
 
@@ -208,6 +212,8 @@ void __local_bh_enable_ip(unsigned long ip, unsigned int cnt)
 	u32 pending;
 	int curcnt;
 
+	lock_map_release(&bh_lock_map);
+
 	WARN_ON_ONCE(in_hardirq());
 	lockdep_assert_irqs_enabled();
 

  reply	other threads:[~2025-03-07 15:57 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-06 12:24 request_irq() with local bh disabled Borislav Petkov
2025-03-06 13:45 ` Eric Dumazet
2025-03-06 16:19   ` Borislav Petkov
2025-03-07 11:55     ` Borislav Petkov
2025-03-07 12:58       ` Ryo Takakura
2025-03-07 13:13         ` Borislav Petkov
2025-03-07 13:39           ` Ryo Takakura
2025-03-07 15:57             ` Boqun Feng [this message]
2025-03-07 18:33               ` Boqun Feng
2025-03-07 19:29                 ` Boqun Feng
2025-03-07 23:08                   ` Boqun Feng
2025-03-08  8:09                     ` Ryo Takakura
2025-03-07 13:59           ` Peter Zijlstra
2025-03-07 15:50             ` Ryo Takakura

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=Z8sXdDFJTjYbpAcq@tardis \
    --to=boqun.feng@gmail.com \
    --cc=bp@alien8.de \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuniyu@amazon.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=peterz@infradead.org \
    --cc=ryotkkr98@gmail.com \
    --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).