From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B187BC433F5 for ; Wed, 19 Jan 2022 15:15:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355611AbiASPPZ (ORCPT ); Wed, 19 Jan 2022 10:15:25 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:43190 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355311AbiASPPV (ORCPT ); Wed, 19 Jan 2022 10:15:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642605320; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VhiyyGkhKIQBD9y1CvQ+4U+Kmf7dcrXMU0CgM1XnnpI=; b=U/wPP1qdQMqjjLS+J3Y+X+16vU5Cppbos9k2Z3sRqHMg35Uy2eRHSQSr/7dhKKpHytrSu7 w9f/xuHTn51vEOBRYYq5mjO3qjGsmDrtpTXkKWauilwMdEBTfwuXdbTcM+C1I7BA+c6lRj HlTv2XLDWGwXlPiExAXegxyvvnAmQB4= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-626-6cOSd3k9Nwa0jFnTSbBU_g-1; Wed, 19 Jan 2022 10:15:19 -0500 X-MC-Unique: 6cOSd3k9Nwa0jFnTSbBU_g-1 Received: by mail-ed1-f71.google.com with SMTP id a18-20020aa7d752000000b00403d18712beso2779491eds.17 for ; Wed, 19 Jan 2022 07:15:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=VhiyyGkhKIQBD9y1CvQ+4U+Kmf7dcrXMU0CgM1XnnpI=; b=3cdlPu8FZWICjb74siY3o/GfJbbcluoeo1IhKjgb8E9jXieIAiAcE0naxNbdM74wux 8bAKTtRPMic6hNlycw2JEMt4g7vyOu7qT0+sDkaLnaS0Cgzyc3J0M9AE9vs0kr9diUDe G4XwJgP4QyAr8dUFSId0LMOo2WV3xOpT63YRucz2t2qnLVoU6nPstLWSOp+NPFsyHj6Z xDRbRyaw7CaNgBnL6VbildW/rzOC0QeqjaodAYhyZbW+ZLTTHcW4kwC7Bl2gS96EV84B OSAejfDjEa6dQOR4tF5NpUJTGr4E3iZA0juTb9IcQqrUZ2PLvCekjA8s2NYHgDVhIitt 7zQA== X-Gm-Message-State: AOAM532x/v+aHccGw/5iCbxiS2mU87Wihdyn06SA6lOsQAwRoNDNQSMh dE8QtzbSyX/Y8OOaRVBp2iNorjHfie2uO7WxnBzSgYVP0RBwNrxKbp22g1c3tHf9fSuat1LV6B9 lTh+eK3TkicEnbAVqYzk/ZbVD X-Received: by 2002:a05:6402:22cb:: with SMTP id dm11mr368395edb.375.1642605318273; Wed, 19 Jan 2022 07:15:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJyQZPjexJYBmnBwPzHL0GlxJX389hy6WmeWAsZPKQQv3SHfkBwtwlUfjT/aKiBMYeyF3B3VNw== X-Received: by 2002:a05:6402:22cb:: with SMTP id dm11mr368379edb.375.1642605318104; Wed, 19 Jan 2022 07:15:18 -0800 (PST) Received: from ?IPV6:2003:cb:c705:fb00:c6c0:1fe6:bfa1:e868? (p200300cbc705fb00c6c01fe6bfa1e868.dip0.t-ipconnect.de. [2003:cb:c705:fb00:c6c0:1fe6:bfa1:e868]) by smtp.gmail.com with ESMTPSA id a27sm21089edj.17.2022.01.19.07.15.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 19 Jan 2022 07:15:17 -0800 (PST) Message-ID: Date: Wed, 19 Jan 2022 16:15:16 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH v1] proc/vmcore: fix false positive lockdep warning Content-Language: en-US To: Boqun Feng Cc: linux-kernel@vger.kernel.org, kexec@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Baoquan He , Andrew Morton , Vivek Goyal , Dave Young , "Paul E. McKenney" , Josh Triplett , Peter Zijlstra References: <20220119113702.102567-1-david@redhat.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? -- Thanks, David / dhildenb From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Hildenbrand Date: Wed, 19 Jan 2022 16:15:16 +0100 Subject: [PATCH v1] proc/vmcore: fix false positive lockdep warning In-Reply-To: References: <20220119113702.102567-1-david@redhat.com> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: kexec@lists.infradead.org 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? -- Thanks, David / dhildenb