All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Boqun Feng <boqun.feng@gmail.com>
Cc: linux-kernel@vger.kernel.org, kexec@lists.infradead.org,
	linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
	Baoquan He <bhe@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Vivek Goyal <vgoyal@redhat.com>, Dave Young <dyoung@redhat.com>,
	"Paul E. McKenney" <paulmck@kernel.org>,
	Josh Triplett <josh@joshtriplett.org>,
	Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH v1] proc/vmcore: fix false positive lockdep warning
Date: Wed, 19 Jan 2022 16:19:16 +0100	[thread overview]
Message-ID: <035dc6b1-28cb-0563-c712-bf57ebbc91e8@redhat.com> (raw)
In-Reply-To: <ec19d477-a75c-1e5a-1c02-f62c8565f48d@redhat.com>

On 19.01.22 16:15, David Hildenbrand wrote:
> On 19.01.22 16:08, Boqun Feng wrote:
>> Hi,
>>
>> On Wed, Jan 19, 2022 at 12:37:02PM +0100, David Hildenbrand wrote:
>>> Lockdep complains that we do during mmap of the vmcore:
>>> 	down_write(mmap_lock);
>>> 	down_read(vmcore_cb_rwsem);
>>> And during read of the vmcore:
>>> 	down_read(vmcore_cb_rwsem);
>>> 	down_read(mmap_lock);
>>>
>>> We cannot possibly deadlock when only taking vmcore_cb_rwsem in read
>>> mode, however, it's hard to teach that to lockdep.
>>>
>>
>> Lockdep warned about the above sequences because rw_semaphore is a fair
>> read-write lock, and the following can cause a deadlock:
>>
>> 	TASK 1			TASK 2		TASK 3
>> 	======			======		======
>> 	down_write(mmap_lock);
>> 				down_read(vmcore_cb_rwsem)
>> 						down_write(vmcore_cb_rwsem); // blocked
>> 	down_read(vmcore_cb_rwsem); // cannot get the lock because of the fairness
>> 				down_read(mmap_lock); // blocked
>> 	
>> IOW, a reader can block another read if there is a writer queued by the
>> second reader and the lock is fair.
>>
>> So there is a deadlock possiblity.
> 
> Task 3 will never take the mmap_lock before doing a
> down_write(vmcore_cb_rwsem).
> 
> How would this happen?

Ah, I get it, nevermind. I'll adjust the patch description.

Thanks!

-- 
Thanks,

David / dhildenb


WARNING: multiple messages have this Message-ID (diff)
From: David Hildenbrand <david@redhat.com>
To: kexec@lists.infradead.org
Subject: [PATCH v1] proc/vmcore: fix false positive lockdep warning
Date: Wed, 19 Jan 2022 16:19:16 +0100	[thread overview]
Message-ID: <035dc6b1-28cb-0563-c712-bf57ebbc91e8@redhat.com> (raw)
In-Reply-To: <ec19d477-a75c-1e5a-1c02-f62c8565f48d@redhat.com>

On 19.01.22 16:15, David Hildenbrand wrote:
> On 19.01.22 16:08, Boqun Feng wrote:
>> Hi,
>>
>> On Wed, Jan 19, 2022 at 12:37:02PM +0100, David Hildenbrand wrote:
>>> Lockdep complains that we do during mmap of the vmcore:
>>> 	down_write(mmap_lock);
>>> 	down_read(vmcore_cb_rwsem);
>>> And during read of the vmcore:
>>> 	down_read(vmcore_cb_rwsem);
>>> 	down_read(mmap_lock);
>>>
>>> We cannot possibly deadlock when only taking vmcore_cb_rwsem in read
>>> mode, however, it's hard to teach that to lockdep.
>>>
>>
>> Lockdep warned about the above sequences because rw_semaphore is a fair
>> read-write lock, and the following can cause a deadlock:
>>
>> 	TASK 1			TASK 2		TASK 3
>> 	======			======		======
>> 	down_write(mmap_lock);
>> 				down_read(vmcore_cb_rwsem)
>> 						down_write(vmcore_cb_rwsem); // blocked
>> 	down_read(vmcore_cb_rwsem); // cannot get the lock because of the fairness
>> 				down_read(mmap_lock); // blocked
>> 	
>> IOW, a reader can block another read if there is a writer queued by the
>> second reader and the lock is fair.
>>
>> So there is a deadlock possiblity.
> 
> Task 3 will never take the mmap_lock before doing a
> down_write(vmcore_cb_rwsem).
> 
> How would this happen?

Ah, I get it, nevermind. I'll adjust the patch description.

Thanks!

-- 
Thanks,

David / dhildenb



  reply	other threads:[~2022-01-19 15:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-19 11:37 [PATCH v1] proc/vmcore: fix false positive lockdep warning David Hildenbrand
2022-01-19 11:37 ` David Hildenbrand
2022-01-19 15:08 ` Boqun Feng
2022-01-19 15:08   ` Boqun Feng
2022-01-19 15:15   ` David Hildenbrand
2022-01-19 15:15     ` David Hildenbrand
2022-01-19 15:19     ` David Hildenbrand [this message]
2022-01-19 15:19       ` David Hildenbrand

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=035dc6b1-28cb-0563-c712-bf57ebbc91e8@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=bhe@redhat.com \
    --cc=boqun.feng@gmail.com \
    --cc=dyoung@redhat.com \
    --cc=josh@joshtriplett.org \
    --cc=kexec@lists.infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=vgoyal@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.