Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1773333ybl; Sat, 11 Jan 2020 02:32:09 -0800 (PST) X-Google-Smtp-Source: APXvYqyPyuJvTGJrKUIhA5J+nD232k5mbos8ri7YfmFnjA+NOxNvGMTNpLWP4A2Vlok4KlUwipD1 X-Received: by 2002:a54:488d:: with SMTP id r13mr5626338oic.115.1578738729531; Sat, 11 Jan 2020 02:32:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578738729; cv=none; d=google.com; s=arc-20160816; b=bK3bGH36/cRrmn2DpfOvSwVu0AOqSrGUv8hChTiGAxzwXlTDj9c5z1z3PQjdtdI046 lMGM+V7wkhIRd1vhye3bZv309pRH66oH/wrJj0OHsaByhPeQ3wfMwFTHHq1Xc/m6J/CP XO3C1KfOnChNqLAGsoQBZwdsxTQHvC1nGcDwdyDzCv4Jz7byNcpRR3TcvN4DhhxJOYAg suKpnV4bt1bO1sdIAgQSPgYZIDhJZC7NT+0yz7lJrMSAKYs7ZDeoYN4MlY9TpbRZ02wG icSj01CTWKejjC9brmTMrZzax6t57pSpixVw+9vFdI/gtXLrCHwojixnR+MpNzKzeNxx Wrig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=crrV9DLxGjEL2bo2lkMEsrdDF431eYnzT63FyCLFlzk=; b=diR2Qmo4dGzDj6Z9OsH3XjBYe5Pk7synRGvqv+HwC1xSH/jhpcTN+nnhZYsXhjqexP UxDYB3MyZveP5y6mb5k917HPDQCJujKUq+Erud65X1nvpecwTc3OQkI4lM49LMNtXC52 ivgluvFhueRgJnJ2u8II3Gu8lnN49DXGPSpX6F6pSjKrZ0IIFFqPSU7VTaKOCdLWV4f1 k70R1qvqFFFTtHqEOGxvX4lQlVg6qvurZIUuFIJKP1n6F0hyFKwwAmcUVb5wpYNBqSEu ROSLUJG8x85bGyeXyp4HN63jh+ve4fDyJen2g+EUi4pAUaMEkiD36dS6+YyM3iUxeDsN uYEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zAr7JYWb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 94si3378521ott.8.2020.01.11.02.31.58; Sat, 11 Jan 2020 02:32:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zAr7JYWb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731297AbgAKKaO (ORCPT + 99 others); Sat, 11 Jan 2020 05:30:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:40274 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728889AbgAKKaN (ORCPT ); Sat, 11 Jan 2020 05:30:13 -0500 Received: from localhost (unknown [62.119.166.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ED4892087F; Sat, 11 Jan 2020 10:30:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578738612; bh=nDGNkb97TAMHMFhdA+qF/xMW2/R1B4L6cCRGHxKUuhI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zAr7JYWbmMrj/qPIEPXxrM5yxPYlvjdZoh45f8OKHYpI71/24kKyvkZFszM+I5uaW LG+JqqPLwyuk8MXcrFZsT5wb4vPhAGkevTZHeZwRp5da18obF1CDQqo1jr9FPO7ji7 4Bib2tcysQCgXe6hLd4wLR2nEbZ4C4BqGu9K2r9U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christoph Hellwig , Ming Lei , Hannes Reinecke , Bart Van Assche , Jens Axboe , Sasha Levin Subject: [PATCH 5.4 125/165] block: Fix a lockdep complaint triggered by request queue flushing Date: Sat, 11 Jan 2020 10:50:44 +0100 Message-Id: <20200111094934.717071949@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200111094921.347491861@linuxfoundation.org> References: <20200111094921.347491861@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bart Van Assche [ Upstream commit b3c6a59975415bde29cfd76ff1ab008edbf614a9 ] Avoid that running test nvme/012 from the blktests suite triggers the following false positive lockdep complaint: ============================================ WARNING: possible recursive locking detected 5.0.0-rc3-xfstests-00015-g1236f7d60242 #841 Not tainted -------------------------------------------- ksoftirqd/1/16 is trying to acquire lock: 000000000282032e (&(&fq->mq_flush_lock)->rlock){..-.}, at: flush_end_io+0x4e/0x1d0 but task is already holding lock: 00000000cbadcbc2 (&(&fq->mq_flush_lock)->rlock){..-.}, at: flush_end_io+0x4e/0x1d0 other info that might help us debug this: Possible unsafe locking scenario: CPU0 ---- lock(&(&fq->mq_flush_lock)->rlock); lock(&(&fq->mq_flush_lock)->rlock); *** DEADLOCK *** May be due to missing lock nesting notation 1 lock held by ksoftirqd/1/16: #0: 00000000cbadcbc2 (&(&fq->mq_flush_lock)->rlock){..-.}, at: flush_end_io+0x4e/0x1d0 stack backtrace: CPU: 1 PID: 16 Comm: ksoftirqd/1 Not tainted 5.0.0-rc3-xfstests-00015-g1236f7d60242 #841 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: dump_stack+0x67/0x90 __lock_acquire.cold.45+0x2b4/0x313 lock_acquire+0x98/0x160 _raw_spin_lock_irqsave+0x3b/0x80 flush_end_io+0x4e/0x1d0 blk_mq_complete_request+0x76/0x110 nvmet_req_complete+0x15/0x110 [nvmet] nvmet_bio_done+0x27/0x50 [nvmet] blk_update_request+0xd7/0x2d0 blk_mq_end_request+0x1a/0x100 blk_flush_complete_seq+0xe5/0x350 flush_end_io+0x12f/0x1d0 blk_done_softirq+0x9f/0xd0 __do_softirq+0xca/0x440 run_ksoftirqd+0x24/0x50 smpboot_thread_fn+0x113/0x1e0 kthread+0x121/0x140 ret_from_fork+0x3a/0x50 Cc: Christoph Hellwig Cc: Ming Lei Cc: Hannes Reinecke Signed-off-by: Bart Van Assche Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/blk-flush.c | 5 +++++ block/blk.h | 1 + 2 files changed, 6 insertions(+) diff --git a/block/blk-flush.c b/block/blk-flush.c index 1eec9cbe5a0a..b1f0a1ac505c 100644 --- a/block/blk-flush.c +++ b/block/blk-flush.c @@ -69,6 +69,7 @@ #include #include #include +#include #include "blk.h" #include "blk-mq.h" @@ -492,6 +493,9 @@ struct blk_flush_queue *blk_alloc_flush_queue(struct request_queue *q, INIT_LIST_HEAD(&fq->flush_queue[1]); INIT_LIST_HEAD(&fq->flush_data_in_flight); + lockdep_register_key(&fq->key); + lockdep_set_class(&fq->mq_flush_lock, &fq->key); + return fq; fail_rq: @@ -506,6 +510,7 @@ void blk_free_flush_queue(struct blk_flush_queue *fq) if (!fq) return; + lockdep_unregister_key(&fq->key); kfree(fq->flush_rq); kfree(fq); } diff --git a/block/blk.h b/block/blk.h index 47fba9362e60..ffea1691470e 100644 --- a/block/blk.h +++ b/block/blk.h @@ -30,6 +30,7 @@ struct blk_flush_queue { * at the same time */ struct request *orig_rq; + struct lock_class_key key; spinlock_t mq_flush_lock; }; -- 2.20.1