[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <035dc6b1-28cb-0563-c712-bf57ebbc91e8@redhat.com>
Date: Wed, 19 Jan 2022 16:19:16 +0100
From: David Hildenbrand <david@...hat.com>
To: Boqun Feng <boqun.feng@...il.com>
Cc: linux-kernel@...r.kernel.org, kexec@...ts.infradead.org,
linux-fsdevel@...r.kernel.org, linux-mm@...ck.org,
Baoquan He <bhe@...hat.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Vivek Goyal <vgoyal@...hat.com>,
Dave Young <dyoung@...hat.com>,
"Paul E. McKenney" <paulmck@...nel.org>,
Josh Triplett <josh@...htriplett.org>,
Peter Zijlstra <peterz@...radead.org>
Subject: Re: [PATCH v1] proc/vmcore: fix false positive lockdep warning
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
Powered by blists - more mailing lists