Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3101631ybi; Thu, 18 Jul 2019 21:03:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqxpJZjy4J52mA7xiZOXwgbwrPw98aszKC0/PSKi1z7Tdh009IengFJfFouDv3TdQX0weycI X-Received: by 2002:a17:902:8f81:: with SMTP id z1mr53133071plo.290.1563509031088; Thu, 18 Jul 2019 21:03:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563509031; cv=none; d=google.com; s=arc-20160816; b=P05NEx5WOUjnxwC8oOav1q4YMnb4UGjINwF8/t+0aK7MPlEUKxQtTXaua6o8sSLZ9x b/wf8vn+vn6Lbj5BYn/hvGKaBxPH044Mhh81+q5AiTv7H4lJmaEOh91k8tmXIZYRRLyh QK08i50CXwY8XDZQFp6hxXeJ4Urq8ACsaeKYFaizeBbQQBtaVitw25x1XQbHKLJ5ti11 rTspBsaX/G/cppeu6hyDWQfe/SRn1gAm9m+2sMrnCe+nXfbNvz/Rsrq8AT5mm2DdqDEv 8t60yluG1GB6mHx/WyGLixw1pRtKn9PCzkMUbN/nGsjLUy8E18bCc7mnZWykZocmMTOY SaFw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Paw1wwdsw7Fvrs6YVpkOW5mhtzPDdOtWOMibDXoWaIw=; b=RiuxAA2mLdAZlVODLJH+3PxnnWWu3o3jtySI2XSupo1szg1pG2pKi65hUHpXrKQjLx 5272kiXrC8J8C4u+w2a6pXI8EalihmYkQP2qjOlJwep6ntOZaFPUDpV+3Diz+5fY6ALG JwVJcWMHL2uiiXRcqvsQ/9bPyX2YXR7cJoqWwlvRi6nlMSm6+SmXBsDt33NIGIhANlWl M8iB7QF5Q+3pFWkloCcs0TglDTnTmUOnmtKkEbow0PKWSdI9YOHfxOlWk5qCio8IaTas hJ8skWsUsXHDtk0byJ1M3JF2ntTy94cgkxqQse7NvuifMwAFnkba5gz6hnC/qIz65qz5 mwzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=d5833rXm; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 7si4272232pfh.38.2019.07.18.21.03.36; Thu, 18 Jul 2019 21:03:51 -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=@kernel.org header.s=default header.b=d5833rXm; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730067AbfGSECc (ORCPT + 99 others); Fri, 19 Jul 2019 00:02:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:34408 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730042AbfGSEC3 (ORCPT ); Fri, 19 Jul 2019 00:02:29 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2B7AD21882; Fri, 19 Jul 2019 04:02:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563508948; bh=wDsaDCVLsx1YodnVdzLeuj7AnHp11gBq8Ad75vyQdkA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d5833rXm+5mpGkHd1LopBp5DAaLmfhLdUjq62DjVX5yBqx0EEa5z8bT0R9YwBWtYB b77zsKZKqlIe69ijV5bTnGAYSea1a1joLYxplhphOx9xl3787eXabVsdi/CyLBmPEB lkKGEomxh6hIU9OF5eY6iJZhVhIXAjWKePWLo0Xk= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Yuyang Du , Qian Cai , Peter Zijlstra , Andrew Morton , Linus Torvalds , "Paul E . McKenney" , Thomas Gleixner , Will Deacon , arnd@arndb.de, frederic@kernel.org, Ingo Molnar , Sasha Levin Subject: [PATCH AUTOSEL 5.2 169/171] locking/lockdep: Fix lock used or unused stats error Date: Thu, 18 Jul 2019 23:56:40 -0400 Message-Id: <20190719035643.14300-169-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719035643.14300-1-sashal@kernel.org> References: <20190719035643.14300-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yuyang Du [ Upstream commit 68d41d8c94a31dfb8233ab90b9baf41a2ed2da68 ] 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 Signed-off-by: Sasha Levin --- 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); -- 2.20.1