mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ryo Takakura <ryotkkr98@gmail.com>
To: llong@redhat.com
Cc: bigeasy@linutronix.de, boqun.feng@gmail.com,
	clrkwllms@kernel.org, linux-kernel@vger.kernel.org,
	linux-rt-devel@lists.linux.dev, mingo@redhat.com,
	peterz@infradead.org, rostedt@goodmis.org, tglx@linutronix.de,
	will@kernel.org
Subject: Re: [PATCH v2] lockdep: Fix wait context check on softirq for PREEMPT_RT
Date: Tue,  7 Jan 2025 20:11:50 +0900	[thread overview]
Message-ID: <20250107111150.27315-1-ryotkkr98@gmail.com> (raw)
In-Reply-To: <f3ca9b15-6365-4639-b93c-33f540448b66@redhat.com>

Hi Long, and happy new year to everyone!

On Mon, 6 Jan 2025 14:13:57 -0500, Waiman Long wrote:
>On 12/26/24 11:08 PM, Ryo Takakura wrote:
>>   include/linux/bottom_half.h |  8 ++++++++
>>   kernel/softirq.c            | 12 ++++++++++++
>>   2 files changed, 20 insertions(+)
>>
>> diff --git a/include/linux/bottom_half.h b/include/linux/bottom_half.h
>> index fc53e0ad5..f77dc746c 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,8 +16,13 @@ static __always_inline void __local_bh_disable_ip(unsigned long ip, unsigned int
>>   }
>>   #endif
>>   
>> +#ifdef CONFIG_LOCKDEP
>> +extern struct lockdep_map bh_lock_map;
>> +#endif
>> +
>>   static inline void local_bh_disable(void)
>>   {
>> +	lock_map_acquire_read(&bh_lock_map);
>>   	__local_bh_disable_ip(_THIS_IP_, SOFTIRQ_DISABLE_OFFSET);
>>   }
>>   
>> @@ -25,11 +31,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 4dae6ac2e..a8211ba9a 100644
>> --- a/kernel/softirq.c
>> +++ b/kernel/softirq.c
>> @@ -1073,3 +1073,15 @@ unsigned int __weak arch_dynirq_lower_bound(unsigned int from)
>>   {
>>   	return from;
>>   }
>> +
>> +#ifdef CONFIG_LOCKDEP
>> +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);
>> +#endif
>
>All the locking code use CONFIG_DEBUG_LOCK_ALLOC to determine if 
>lockdep_map should be used. Should you also use CONFIG_DEBUG_LOCK_ALLOC 
>instead of CONFIG_LOCKDEP to be consistent with the others?

I see, I wasn't sure which CONFIG should be use here. Thanks for
pointing it out! 
I'll use CONFIG_DEBUG_LOCK_ALLOC for the next version.

>Cheers,
>Longman

Sincerely,
Ryo Takakura

      reply	other threads:[~2025-01-07 11:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-27  4:08 Ryo Takakura
2025-01-06 19:13 ` Waiman Long
2025-01-07 11:11   ` Ryo Takakura [this message]

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=20250107111150.27315-1-ryotkkr98@gmail.com \
    --to=ryotkkr98@gmail.com \
    --cc=bigeasy@linutronix.de \
    --cc=boqun.feng@gmail.com \
    --cc=clrkwllms@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --cc=llong@redhat.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=will@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

all inboxes | Powered by JetHome®