Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4081987ybi; Mon, 29 Jul 2019 18:52:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqyWSI2OviCw9sYkLAw2hG6ocy5HUZ2uk/E1qK7grWAhZOks710JhNVLafrjYSESCEFZZn6u X-Received: by 2002:a17:90a:8d0d:: with SMTP id c13mr110876802pjo.137.1564451527950; Mon, 29 Jul 2019 18:52:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564451527; cv=none; d=google.com; s=arc-20160816; b=JrpFkBeSBRuEdYA6ISI1eTXuZLghEk3guH0XwfIKRJArSgP51pl+6bYLwMwMdCabYK VNIhTOPu3hnN4lJsxgVTwgqVzkl+7DM5Q4uAXH098ZvgfMlQKVyii3k1eP/0A1dXMV1s ILdUXT1F3uyCirE6zfTz2FzWzrrI7DmEvAWLp5+M/cJmX3SMoZHL9Ak7VGF3ppo1QUXr WqRVMpwGP47igJ4s8l7xsciZaOvOKUyUE28eCIVjrTUqDMJ9Kl1ZYKnRpFMu795fZg7Y vHmgodMOLulP/b+GunaSjaaDQs055S5ncvMK3FpO+hoIMESW/TQY53mj65zjbzRLNs1q juog== 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=pvId5wuS3JQjDkcLQ/gExjLZOxBGMmv5UP+rRzY4t2g=; b=cYVeYiwcT+z0YerYCDP6mkekncgYTKs05tuHu8kugLjv4MhT8Gl8WsrArP1f9H3Eko gde4Op2VKLNyiP1ErdrBb1yMeP3zIeK9WQaYKqT72TzdtHaRXbbtnIqWgZA2EDRffgIb WqEPazdvdWR/Z8vVrC9VHiWBZaJgjmqM8w2NmR2vIv9XdyHQ8+1DWY5kvf0zJnBjXA8/ yiBvFcJkQ8vQsG+lHDrZomdpZtyTC3g/TDQIdK/KDRM2cxmUruozmbqIO2XtO6JUxRYg W7BhuXlwPPyFL6BCVFXYaj8hogGMBYnzcr/WkQb7zpmeUC+a/e7l1s3nDtfLlxaCUNM+ NgDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ctfJOvop; 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 s23si27275240pgq.516.2019.07.29.18.51.53; Mon, 29 Jul 2019 18:52:07 -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=ctfJOvop; 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 S2389718AbfG2Tnz (ORCPT + 99 others); Mon, 29 Jul 2019 15:43:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:60434 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389713AbfG2Tnw (ORCPT ); Mon, 29 Jul 2019 15:43:52 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 90913205F4; Mon, 29 Jul 2019 19:43:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429431; bh=REbwc4i22Y9r8hbpNcBt/TcR5wSYBdiN8ktOy5yWdpc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ctfJOvop1DmHL1O9N7TXHizvhlZ57iv8822WcnaMJoy2Zp2ynN8ZLiph7yxELAnse 0UDuQ4haVPVLRVONv82VGmS79HODxmRH/DHPSLxFVxcC+mCRGuyHv8m16V2/VsCG9a 2X7XGj0O3raZ6DIOr2PE1Cnh/mr9nETGWvVVndXs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qian Cai , Yuyang Du , "Peter Zijlstra (Intel)" , Andrew Morton , Linus Torvalds , "Paul E. McKenney" , Thomas Gleixner , Will Deacon , arnd@arndb.de, frederic@kernel.org, Ingo Molnar , Sasha Levin Subject: [PATCH 4.19 095/113] locking/lockdep: Fix lock used or unused stats error Date: Mon, 29 Jul 2019 21:23:02 +0200 Message-Id: <20190729190718.271983481@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190655.455345569@linuxfoundation.org> References: <20190729190655.455345569@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 [ 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 3dd980dfba2d..6cf288eef670 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