lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20241221051732.218496-1-ryotkkr98@gmail.com>
Date: Sat, 21 Dec 2024 14:17:32 +0900
From: Ryo Takakura <ryotkkr98@...il.com>
To: boqun.feng@...il.com,
	bigeasy@...utronix.de
Cc: clrkwllms@...nel.org,
	linux-kernel@...r.kernel.org,
	linux-rt-devel@...ts.linux.dev,
	longman@...hat.com,
	mingo@...hat.com,
	peterz@...radead.org,
	rostedt@...dmis.org,
	tglx@...utronix.de,
	will@...nel.org
Subject: Re: [PATCH] lockdep: Fix wait context check on softirq for PREEMPT_RT

On Fri, 20 Dec 2024 11:00:13 -0800, Boqun Feng wrote:
>On Sat, Dec 21, 2024 at 01:10:16AM +0900, Ryo Takakura wrote:
>> On Thu, 19 Dec 2024 14:27:11 -0800, Boqun Feng wrote:
>> >The following is the rough idea:
>> >
>> >Regards,
>> >Boqun
>> >
>> >----->8
>> >diff --git a/include/linux/bottom_half.h b/include/linux/bottom_half.h
>> >index fc53e0ad56d9..7191a753e983 100644
>> >--- a/include/linux/bottom_half.h
>> >+++ b/include/linux/bottom_half.h
>> >@@ -4,6 +4,7 @@
>> > 
>> > #include <linux/instruction_pointer.h>
>> > #include <linux/preempt.h>
>> >+#include <linux/lockdep.h>
>> > 
>> > #if defined(CONFIG_PREEMPT_RT) || defined(CONFIG_TRACE_IRQFLAGS)
>> > extern void __local_bh_disable_ip(unsigned long ip, unsigned int cnt);
>> >@@ -15,9 +16,12 @@ static __always_inline void __local_bh_disable_ip(unsigned long ip, unsigned int
>> > }
>> > #endif
>> > 
>> >+extern struct lockdep_map bh_lock_map;
>> >+
>> > static inline void local_bh_disable(void)
>> > {
>> > 	__local_bh_disable_ip(_THIS_IP_, SOFTIRQ_DISABLE_OFFSET);
>> >+	lock_map_acquire_read(&bh_lock_map);
>> > }
>> > 
>> > extern void _local_bh_enable(void);
>> >@@ -25,11 +29,13 @@ 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 8b41bd13cc3d..17d9bf6e0caf 100644
>> >--- a/kernel/softirq.c
>> >+++ b/kernel/softirq.c
>> >@@ -1066,3 +1066,13 @@ unsigned int __weak arch_dynirq_lower_bound(unsigned int from)
>> > {
>> > 	return from;
>> > }
>> >+
>> >+static struct lock_class_key bh_lock_key;
>> >+struct lockdep_map bh_lock_map = {
>> >+	.name = "local_bh",
>> >+	.key = &bh_lock_key,
>> >+	.wait_type_outer = LD_WAIT_FREE,
>> >+	.wait_type_inner = LD_WAIT_CONFIG, /* PREEMPT_RT makes BH preemptible. */
>> >+	.lock_type = LD_LOCK_PERCPU,
>> >+};
>> >+EXPORT_SYMBOL_GPL(bh_lock_map);
>> 
>> Self-tests are now all passing. Thanks!
>> It looks good to me.
>
>Good! Do you want to continue working on this based on the above
>changes? If so, feel free.

Oh yes, for sure!!
I'll send the next version based on it with the Sebastian's earlier
suggestion included [0].

>Regards,
>Boqun

Sincerely,
Ryo Takakura

[0] https://lore.kernel.org/lkml/20241220071554.YAD157bS@linutronix.de/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ