Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1974213ybi; Sat, 13 Jul 2019 04:16:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqx9G1z2dAvPvNhBXJpmynrISRTimrjiTutWb3LKsSHbw80GEDdNIW+/dyt+WQI2EMRydzGr X-Received: by 2002:a17:902:fa2:: with SMTP id 31mr17537891plz.38.1563016615111; Sat, 13 Jul 2019 04:16:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563016615; cv=none; d=google.com; s=arc-20160816; b=sX31WWRaiNuOwl+mzkX/OT47uaIEJXMAjfQzP9DbvreJ6pNSjLOeJIvyVjVaJKwgd1 v48hahFNTW1tNn9qfGs6rnKlrj4WEMpMZoOEvXxbA/BRCOsdNFLtTvpZ89USnTuFkA9j oWPSjRhcL5qhkvt+dHPkrhtlwJxqigfzpn9w0nu+LczIXOBCu20FJWvBMsIZXHGCEMTY yv/Wqc+hmbfkUKzct/cq/afM3tndTYZIo1Yc3t+fVDkVcx9vDDX/plIoazwEoDD+sKpM x7u7hyXV3mQGcA3aj/4Cfr9aV97WKQT04g/OXNx/zSD+asw2EKs1PvA1Kb8YfwGF2qsH hcEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:dkim-signature:dkim-filter; bh=xbLonGcsH9bZ/JLV8M3Qsu8bzQL8cjTdurkGkyehD/k=; b=H2Qf/DICx2QHCZoLCq4VSHnMbIi/3QihShWc3NUxJBtfhN6H/xho4pcWFY2pm4UaEy dUlIHwlDkzu1BVdjcFgMfdK9MsdbKZ8TwPGNycTf2YENNw/6nnObcfNBIlEIWyREFJ43 AR4nQTXvNzOIroqr0fLW9GePHmPzoMuN9DWuVn1aFCFgUCipixgs73ndchnS0pMkkIVY Ry+LXbLwPoNBE24LlMORDRSqXaVhEBJ8GZS7kx4fHkYAVCdWKl4q4fVjOLwa1SphIlZw ByuZgqDNHEsaFGJOAurFs/Fb/YutNt5iuAAoiy/BBG1BHNpm6Z5yI3FOJE3Jj27Omgh5 8/Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2019061801 header.b=RZyeM72T; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l125si11298370pgl.63.2019.07.13.04.16.39; Sat, 13 Jul 2019 04:16:55 -0700 (PDT) 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=@zytor.com header.s=2019061801 header.b=RZyeM72T; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727781AbfGMLOq (ORCPT + 99 others); Sat, 13 Jul 2019 07:14:46 -0400 Received: from terminus.zytor.com ([198.137.202.136]:58939 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726474AbfGMLOq (ORCPT ); Sat, 13 Jul 2019 07:14:46 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x6DBESDv3842162 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sat, 13 Jul 2019 04:14:28 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x6DBESDv3842162 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019061801; t=1563016469; bh=xbLonGcsH9bZ/JLV8M3Qsu8bzQL8cjTdurkGkyehD/k=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=RZyeM72TuraFcimOnvJMiqGYHB97kBKzc+AMSmufrk2PUa3uDrW3Bsw19kP5wdrQd LVHuJeXybmVmOuZVsBMRQwbBHbdbAGamH7eSIKqR/CNSjfyjorW498/RBGvxG3fdQo SSazXeHjpXeWDsKJUwiIZ6tsPBA8rX3sP4Voi0OKDbiJIRzD6DaJs1IadbROZCvMPZ T0XEQjKKrgRZM9ZdmNeRHvc8996Cx0aPJaUXDQoSgzUv6/AwRlaICqFzGv3s4uu9aN AroHXPh9Xh3BoY7veFY2URa0+ZyAoZmecmWAhjEsoJJx0RR46LXYaP7adLYGm1mHwj m5guVlniNhLGw== Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x6DBEQSj3842159; Sat, 13 Jul 2019 04:14:26 -0700 Date: Sat, 13 Jul 2019 04:14:26 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Yuyang Du Message-ID: Cc: peterz@infradead.org, linux-kernel@vger.kernel.org, mingo@kernel.org, torvalds@linux-foundation.org, will.deacon@arm.com, cai@lca.pw, duyuyang@gmail.com, akpm@linux-foundation.org, paulmck@linux.vnet.ibm.com, tglx@linutronix.de, hpa@zytor.com Reply-To: mingo@kernel.org, will.deacon@arm.com, torvalds@linux-foundation.org, cai@lca.pw, akpm@linux-foundation.org, duyuyang@gmail.com, peterz@infradead.org, linux-kernel@vger.kernel.org, paulmck@linux.vnet.ibm.com, tglx@linutronix.de, hpa@zytor.com In-Reply-To: <20190709101522.9117-1-duyuyang@gmail.com> References: <20190709101522.9117-1-duyuyang@gmail.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:locking/urgent] locking/lockdep: Fix lock used or unused stats error Git-Commit-ID: 68d41d8c94a31dfb8233ab90b9baf41a2ed2da68 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=0.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_06_12,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU, DKIM_VALID_EF,FREEMAIL_FORGED_REPLYTO autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 68d41d8c94a31dfb8233ab90b9baf41a2ed2da68 Gitweb: https://git.kernel.org/tip/68d41d8c94a31dfb8233ab90b9baf41a2ed2da68 Author: Yuyang Du AuthorDate: Tue, 9 Jul 2019 18:15:22 +0800 Committer: Ingo Molnar CommitDate: Sat, 13 Jul 2019 11:24:53 +0200 locking/lockdep: Fix lock used or unused stats error The stats variable nr_unused_locks is incremented every time a new lock class is register and decremented when the lock is first used in __lock_acquire(). And after all, it is shown and checked in lockdep_stats. However, under configurations that either CONFIG_TRACE_IRQFLAGS or CONFIG_PROVE_LOCKING is not defined: The commit: 091806515124b20 ("locking/lockdep: Consolidate lock usage bit initialization") missed marking the LOCK_USED flag at IRQ usage initialization because as mark_usage() is not called. And the commit: 886532aee3cd42d ("locking/lockdep: Move mark_lock() inside CONFIG_TRACE_IRQFLAGS && CONFIG_PROVE_LOCKING") further made mark_lock() not defined such that the LOCK_USED cannot be marked at all when the lock is first acquired. As a result, we fix this by not showing and checking the stats under such configurations for lockdep_stats. Reported-by: Qian Cai Signed-off-by: Yuyang Du Signed-off-by: Peter Zijlstra (Intel) Cc: Andrew Morton Cc: Linus Torvalds Cc: Paul E. McKenney Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Will Deacon Cc: arnd@arndb.de Cc: frederic@kernel.org Link: https://lkml.kernel.org/r/20190709101522.9117-1-duyuyang@gmail.com Signed-off-by: Ingo Molnar --- kernel/locking/lockdep_proc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/locking/lockdep_proc.c b/kernel/locking/lockdep_proc.c index 9c49ec645d8b..65b6a1600c8f 100644 --- a/kernel/locking/lockdep_proc.c +++ b/kernel/locking/lockdep_proc.c @@ -210,6 +210,7 @@ static int lockdep_stats_show(struct seq_file *m, void *v) nr_hardirq_read_safe = 0, nr_hardirq_read_unsafe = 0, sum_forward_deps = 0; +#ifdef CONFIG_PROVE_LOCKING list_for_each_entry(class, &all_lock_classes, lock_entry) { if (class->usage_mask == 0) @@ -241,12 +242,12 @@ static int lockdep_stats_show(struct seq_file *m, void *v) if (class->usage_mask & LOCKF_ENABLED_HARDIRQ_READ) nr_hardirq_read_unsafe++; -#ifdef CONFIG_PROVE_LOCKING sum_forward_deps += lockdep_count_forward_deps(class); -#endif } #ifdef CONFIG_DEBUG_LOCKDEP DEBUG_LOCKS_WARN_ON(debug_atomic_read(nr_unused_locks) != nr_unused); +#endif + #endif seq_printf(m, " lock-classes: %11lu [max: %lu]\n", nr_lock_classes, MAX_LOCKDEP_KEYS);