Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp536372pxj; Thu, 17 Jun 2021 08:14:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3bjzyohFqaZdAkPkT1YV2XJQzY8DBTCAHYwwcZAcx6YHtB7dx8CLStJqMofQjniLka1oX X-Received: by 2002:a92:660f:: with SMTP id a15mr4284518ilc.182.1623942872700; Thu, 17 Jun 2021 08:14:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623942872; cv=none; d=google.com; s=arc-20160816; b=V52eu937JHpV7d+wNDMffE+4XSGfyPP0yL4uSRjPA70ROcY+X6oT6u2CKLEvwjDKXp MeQBwFl6K3wVQCTan+YsRo+M8/+eJRtnYhUKsxlDEvXYHSumo0lNF+I71Ihp5VnGgV+5 QEngULzifIaotby7DKMIDqnN6hKLSVJj4yeDP+TW+51u10MNQFsdywEkDmncMRNRNHIP +N28HoM9Bh4SzDn+cjFO50mM8GTPNrHNABNB5yVXfXtN3+tP9TUKA1Yvy3WDt+NklEjU hWGO5leyZbhztFXl8fOIeS/kLw/MLQWIQVxEsCd6W3P5/ExDfngBnlViZO8sR2UWGC3F iTkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=R6IjdE1Ab1c2r5GwqgV+dlCerZLtvAuLnafRfT9ALeI=; b=RR8rpvx16kxc3qbQGP8ExDVV4qg1uNPOh3ZVGPW2xdZlJUo8u/9ul1AgS1AVQiHp+C LrSrnHASB8a5jg8n5vfYahleL9IVz9/cD8SZ0IYWxz7TZJk2GHkzbzY0LqyxzPKcYbaN EMRKKSXUjwMvJydoqyL14kwtTaWBCXghvkXwy2w58OBQcMlPoq5VMUlfaMyFikOqVVVB lwrQzv6APIxqAL0GZsiSA5it9rzTk37z56aBmTLPcaR5nOSTqvwdMW3GoIzSEjo0lS10 XysGgRslOEKSFE77TIACkzT/je1nguNDoqKH2Gm95OmhSHQklW30gBbGeI3ZurzqPy9i J9mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nl7kh8mT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l16si6082542jam.101.2021.06.17.08.14.18; Thu, 17 Jun 2021 08:14:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nl7kh8mT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233149AbhFQPPX (ORCPT + 99 others); Thu, 17 Jun 2021 11:15:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230442AbhFQPPW (ORCPT ); Thu, 17 Jun 2021 11:15:22 -0400 Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C247DC061574 for ; Thu, 17 Jun 2021 08:13:13 -0700 (PDT) Received: by mail-io1-xd36.google.com with SMTP id k5so3497065iow.12 for ; Thu, 17 Jun 2021 08:13:13 -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:in-reply-to; bh=R6IjdE1Ab1c2r5GwqgV+dlCerZLtvAuLnafRfT9ALeI=; b=nl7kh8mTFxsEnrvy3uxWmeHdlgAwdDUBxobn/V+RwZr8AMgFHO4ca227CVwWr7sqe5 g/bMVkljqXrEglmAfcmsHcYrO8bQX+ED/ca9WgTANuCj7on/KMwFt8r7n7k5SzNzs4Uh U9dzh0EgHfUUE9BhwGwA+gn2WV7Ft7hbRSFfHieiq1Re6wqLKlP3WDy22ReM5+GE0VrP kQSqdpIWhSFBoEmIoERYF8ODAXIlbMMsjCIA6rAO4/j1iNl7KWr85EKPt7gRIWABksgt 9PZdk7hxVuGrbIA6BiTyMKWJxvOG47F0JrBiCcBIhuwftgCne91VH6fXT/Xhjg0SYaqY HPAw== 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:in-reply-to; bh=R6IjdE1Ab1c2r5GwqgV+dlCerZLtvAuLnafRfT9ALeI=; b=C4GoYpcdbIrTk2D5Yl+0cjnzCPWnTh5v12/oizDiGtswXq80dJndiMYv3bOEUQaReb QPOkvQp0rTh4FnngBxEX86ax/Qu3L8hrumzXkIFmJvWw70iNs2I2qfggrtWkYRIH4gL5 /RE6xOsWtkWssKUzd6O2qnHzgvMJhpqYmn4qUGKs8ZTePsjbcqD+/bweZcK7m7P0O1fM QbcOY6VcLk36rV9/+1fpYkPvMDtPXyUnARAC31JkTZAAf+d/H74zGFaNir4CXqsA8VvC nJvpigx6SwU4I//Ubz2t8yVWLdtRTWDrCcIq1SztKqfub33aJmsOMxEM//2rGztBwAaJ 6P2Q== X-Gm-Message-State: AOAM532+ZLfXU5Vb8BX2UfFpLgxq9upLu9ufCwpGubUxTiFpgS4AH6Pq FyuVnP0NK7VrCWk+xX0YN34MH2Rz3cU= X-Received: by 2002:a02:cc3b:: with SMTP id o27mr6409jap.84.1623942793219; Thu, 17 Jun 2021 08:13:13 -0700 (PDT) Received: from auth1-smtp.messagingengine.com (auth1-smtp.messagingengine.com. [66.111.4.227]) by smtp.gmail.com with ESMTPSA id n2sm3078950iod.54.2021.06.17.08.13.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Jun 2021 08:13:12 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailauth.nyi.internal (Postfix) with ESMTP id 1B41327C0054; Thu, 17 Jun 2021 11:13:11 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Thu, 17 Jun 2021 11:13:12 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfeefuddgkeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkfhggtggujgesthdtre dttddtvdenucfhrhhomhepuehoqhhunhcuhfgvnhhguceosghoqhhunhdrfhgvnhhgsehg mhgrihhlrdgtohhmqeenucggtffrrghtthgvrhhnpedvleeigedugfegveejhfejveeuve eiteejieekvdfgjeefudehfefhgfegvdegjeenucevlhhushhtvghrufhiiigvpedtnecu rfgrrhgrmhepmhgrihhlfhhrohhmpegsohhquhhnodhmvghsmhhtphgruhhthhhpvghrsh honhgrlhhithihqdeiledvgeehtdeigedqudejjeekheehhedvqdgsohhquhhnrdhfvghn gheppehgmhgrihhlrdgtohhmsehfihigmhgvrdhnrghmvg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 17 Jun 2021 11:13:11 -0400 (EDT) Date: Thu, 17 Jun 2021 23:12:46 +0800 From: Boqun Feng To: Xiongwei Song Cc: peterz@infradead.org, mingo@redhat.com, will@kernel.org, longman@redhat.com, linux-kernel@vger.kernel.org, Xiongwei Song Subject: Re: [PATCH 3/3] locking/lockdep: print possible warning after counting deps Message-ID: References: <20210617142828.346111-1-sxwjean@me.com> <20210617142828.346111-4-sxwjean@me.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210617142828.346111-4-sxwjean@me.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Thu, Jun 17, 2021 at 10:28:28PM +0800, Xiongwei Song wrote: > From: Xiongwei Song > > The graph walk might hit error when counting dependencies. Once the > return value is negative, print a warning to reminder users. > Thanks for the improvement, but please see below: > Suggested-by: Waiman Long > Signed-off-by: Xiongwei Song > --- > kernel/locking/lockdep.c | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c > index cb94097014d8..cfe0f4374594 100644 > --- a/kernel/locking/lockdep.c > +++ b/kernel/locking/lockdep.c > @@ -2028,8 +2028,12 @@ static unsigned long __lockdep_count_forward_deps(struct lock_list *this) > { > unsigned long count = 0; > struct lock_list *target_entry; > + enum bfs_result ret; > + > + ret = __bfs_forwards(this, (void *)&count, noop_count, NULL, &target_entry); > > - __bfs_forwards(this, (void *)&count, noop_count, NULL, &target_entry); > + if (bfs_error(ret)) > + print_bfs_bug(ret); Here print_bfs_bug() will eventually call debug_locks_off_graph_unlock() to release the graph lock, and the caller (lockdep_count_fowards_deps()) will also call graph_unlock() afterwards, and that means we unlock *twice* if a BFS error happens... although in that case, lockdep should stop working so messing up with the graph lock may not hurt anything, but still, I don't think we want to do that. So probably you can open-code __lockdep_count_forward_deps() into lockdep_count_forwards_deps(), and call print_bfs_bug() or graph_unlock() accordingly. The body of __lockdep_count_forward_deps() is really small, so I think it's OK to open-code it into its caller. Regards, Boqun > > return count; > } > @@ -2053,8 +2057,12 @@ static unsigned long __lockdep_count_backward_deps(struct lock_list *this) > { > unsigned long count = 0; > struct lock_list *target_entry; > + enum bfs_result ret; > + > + ret = __bfs_backwards(this, (void *)&count, noop_count, NULL, &target_entry); > > - __bfs_backwards(this, (void *)&count, noop_count, NULL, &target_entry); > + if (bfs_error(ret)) > + print_bfs_bug(ret); > > return count; > } > -- > 2.30.2 >