From patchwork Wed Aug 23 03:49:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boqun Feng X-Patchwork-Id: 9916515 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 21709603FA for ; Wed, 23 Aug 2017 03:50:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E604288BD for ; Wed, 23 Aug 2017 03:50:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0311528948; Wed, 23 Aug 2017 03:50:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A251E288BD for ; Wed, 23 Aug 2017 03:50:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753170AbdHWDtc (ORCPT ); Tue, 22 Aug 2017 23:49:32 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:34821 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753152AbdHWDtb (ORCPT ); Tue, 22 Aug 2017 23:49:31 -0400 Received: by mail-pf0-f195.google.com with SMTP id k3so519168pfc.2; Tue, 22 Aug 2017 20:49:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=hGS6X8f2IccTFzxXqK0qu4hUyrkk3+rRn9YeRXxcyGI=; b=d3WItvIAYgRu59CdmMKa4X5FaOyfJbe/xLYJlbxGvDk0fMTEvRUGBwUwiXRYYu6+Ec RUedBkLbVQP9/Z0JIS55rZwiJEXBzqEA9eWRNzGT+mxWOaODyfypVAymmYoKE6Zxzz6d 1NyDBmhHWjuJoxG9ZJWDUsp6QdFTNHJ23BKCzgodNF5qG7EY4oSr9mYgqLXF7RdVY8DI 97EdELFm2iuy8p44XnreL0G3MbEn1yPA4gnoatmkAl6LwiD25DSAl+MHWdGk4fmhczH0 FRFcTj14KwNO6nCL/CsyX/44HgKg9xqHHruQd2LKkJqKS1x4BY2cX9nkFt8qik4e1OKn yMPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=hGS6X8f2IccTFzxXqK0qu4hUyrkk3+rRn9YeRXxcyGI=; b=f4+GgF0YCNR7+DL5JEKMhZQfjB169D13w4x5z3iQmsLJWCS1tAWawvsaGusgVSGoFW +qAuLwf/t/D2SBxchrBHV1lS+XcOPvTnkQ4x78M+4e/d+wsfsN/HFOKBRzkgXdYF58Wq 9UA+NSQWoqWgmp4aV0+svnuhNLjX/MR0RTKkiHukhdjKqihXoPh6UQJDXPY2HIXjUH8T nV+uuIy+SnG6ygse5+jAji1i0xjvfTz39OnE2RaPre2JYBZPPUAyHHMteHfRAYiTEAKB FEdpiSrnE9yyg46N0R21fy3onzFALdCyLcfRSqCgnhvaEmaAim8zs8CUlexksKq+75Qa 24Ew== X-Gm-Message-State: AHYfb5i6kY+Hch0kExTp4lb55oPxJA+ddpjVKhk8MRuzvtAVMZZEcLmb AlTCmw8YOdBTew== X-Received: by 10.99.106.65 with SMTP id f62mr1374994pgc.32.1503460170623; Tue, 22 Aug 2017 20:49:30 -0700 (PDT) Received: from localhost ([45.32.52.191]) by smtp.gmail.com with ESMTPSA id k186sm568864pga.78.2017.08.22.20.49.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 22 Aug 2017 20:49:29 -0700 (PDT) Date: Wed, 23 Aug 2017 11:49:51 +0800 From: Boqun Feng To: Byungchul Park Cc: Bart Van Assche , peterz@infradead.org, "linux-kernel@vger.kernel.org" , "linux-block@vger.kernel.org" , "sergey.senozhatsky.work@gmail.com" , "martin.petersen@oracle.com" , "axboe@kernel.dk" , "linux-scsi@vger.kernel.org" , "sfr@canb.auug.org.au" , "linux-next@vger.kernel.org" , kernel-team@lge.com Subject: Re: possible circular locking dependency detected [was: linux-next: Tree for Aug 22] Message-ID: <20170823034951.GG11771@tardis> References: <20170822183816.7925e0f8@canb.auug.org.au> <20170822104708.GA491@jagdpanzerIV.localdomain> <1503438234.2508.27.camel@wdc.com> <20170823000304.GK20323@X58A-UD3R> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170823000304.GK20323@X58A-UD3R> User-Agent: Mutt/1.8.3 (2017-05-23) Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Byungchul, On Wed, Aug 23, 2017 at 09:03:04AM +0900, Byungchul Park wrote: > On Tue, Aug 22, 2017 at 09:43:56PM +0000, Bart Van Assche wrote: > > On Tue, 2017-08-22 at 19:47 +0900, Sergey Senozhatsky wrote: > > > ====================================================== > > > WARNING: possible circular locking dependency detected > > > 4.13.0-rc6-next-20170822-dbg-00020-g39758ed8aae0-dirty #1746 Not tainted > > > ------------------------------------------------------ > > > fsck.ext4/148 is trying to acquire lock: > > > (&bdev->bd_mutex){+.+.}, at: [] __blkdev_put+0x33/0x190 > > > > > > but now in release context of a crosslock acquired at the following: > > > ((complete)&wait#2){+.+.}, at: [] blk_execute_rq+0xbb/0xda > > > > > > which lock already depends on the new lock. > > > I felt this message really misleading, because the deadlock is detected at the commit time of "((complete)&wait#2)" rather than the acquisition time of "(&bdev->bd_mutex)", so I made the following improvement. Thoughts? Regards, Boqun ----------------------->8 From: Boqun Feng Date: Wed, 23 Aug 2017 10:18:30 +0800 Subject: [PATCH] lockdep: Improve the readibility of crossrelease related splats When a crossrelease related deadlock is detected in a commit, the current implemention makes splats like: > fsck.ext4/148 is trying to acquire lock: > (&bdev->bd_mutex){+.+.}, at: [] __blkdev_put+0x33/0x190 > > but now in release context of a crosslock acquired at the following: > ((complete)&wait#2){+.+.}, at: [] blk_execute_rq+0xbb/0xda > > which lock already depends on the new lock. > ... However, it could be misleading because the current task has got the lock already, and in fact the deadlock is detected when it is doing the commit of the crossrelease lock. So make the splats more accurate to describe the deadlock case. Signed-off-by: Boqun Feng --- kernel/locking/lockdep.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 66011c9f5df3..642fb5362507 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -1195,17 +1195,23 @@ print_circular_bug_header(struct lock_list *entry, unsigned int depth, pr_warn("WARNING: possible circular locking dependency detected\n"); print_kernel_ident(); pr_warn("------------------------------------------------------\n"); - pr_warn("%s/%d is trying to acquire lock:\n", - curr->comm, task_pid_nr(curr)); - print_lock(check_src); - if (cross_lock(check_tgt->instance)) - pr_warn("\nbut now in release context of a crosslock acquired at the following:\n"); - else + if (cross_lock(check_tgt->instance)) { + pr_warn("%s/%d is committing a crossrelease lock:\n", + curr->comm, task_pid_nr(curr)); + print_lock(check_tgt); + pr_warn("\n, with the following lock held:\n"); + print_lock(check_src); + pr_warn("\non which lock the crossrelease lock already depends.\n\n"); + } else { + pr_warn("%s/%d is trying to acquire lock:\n", + curr->comm, task_pid_nr(curr)); + print_lock(check_src); pr_warn("\nbut task is already holding lock:\n"); + print_lock(check_tgt); + pr_warn("\nwhich lock already depends on the new lock.\n\n"); + } - print_lock(check_tgt); - pr_warn("\nwhich lock already depends on the new lock.\n\n"); pr_warn("\nthe existing dependency chain (in reverse order) is:\n"); print_circular_bug_entry(entry, depth);