Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3615957pxv; Mon, 28 Jun 2021 08:39:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYgDys9lto8/irEFFcnhhl0qNLIMwATJ9k2VArKoJ3fbf+UAInM+mE1ck2g3MGKvsB92OI X-Received: by 2002:a17:906:69cc:: with SMTP id g12mr25004096ejs.550.1624894792133; Mon, 28 Jun 2021 08:39:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624894792; cv=none; d=google.com; s=arc-20160816; b=DW2dliqd95UAb8R8/9qi5xlSgxei7NlJmqoysrEt9F5QHgwjFDVB3HSPxQmvjOEahl VYkgNIvEYP6nbE0715R++klZ1tODK/I1frLRanms71loUCRzDsW5roII4E9N4jxec0NZ TPhVrfpHKZHT4aMZT0R5+YWfZynyIl4PLq72F6hfid6gfOcduFgG1PjYWsZOnxWmh9dl 9Rtg9Ft2OqV66TLXJFYEDLhmo9lZPYDBOX4zWRZVI8bZvd4uX482aOoEU39X9w/mg008 ijlpHFAFX+R9MGFVkn9Q2PZjwJYmLn0DHKaYq3KR7TM7/igpapaXjK2+GWUP0HEynJSu mBGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=giHbjBf++rogiLGAOt9HJUmkwkKfSi+Vn7w9ZvDIEbs=; b=la+T6cAdEkg9wxajj7qeYO9FA59ek7DEO6IzcNCWqlgBklTAxfc2vqhX4gY7hmWP9g vs0swSufXJMcjV+metxo98odJ1Bv2faFoTUJ9q7ZMKsswe+8oSRZf/Quxuxp5/LImX2l 7yaq+cveaxUxOmwqbmwP0P1+k8C1KvPo+JWmVqkLOeNMmcpDDEPOdxcLqYdOv40QWhOH o5eLu/GMn5drfBwCCIjrYV2E9GlwFFYS86AuQcEoVfAvKRCY4kQ8/6flqp4cVDLQDnRM YXQPjQfXQ9rXmP5EW9HXDvDtRm6az2jvozebR4r/bz86hqvn52/rabGIsK10hu5qoFaK Mckg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@me.com header.s=1a1hai header.b=aOLuUBqQ; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=me.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ar27si13871248ejc.694.2021.06.28.08.39.27; Mon, 28 Jun 2021 08:39:52 -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=@me.com header.s=1a1hai header.b=aOLuUBqQ; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=me.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239091AbhF1Pe7 (ORCPT + 99 others); Mon, 28 Jun 2021 11:34:59 -0400 Received: from pv50p00im-ztbu10021601.me.com ([17.58.6.57]:40640 "EHLO pv50p00im-ztbu10021601.me.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237768AbhF1PUV (ORCPT ); Mon, 28 Jun 2021 11:20:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=1a1hai; t=1624893472; bh=giHbjBf++rogiLGAOt9HJUmkwkKfSi+Vn7w9ZvDIEbs=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=aOLuUBqQPLCC+7v8dTC5dnj9RauiQqR52DoXxQT1W6ZmR4zDs139xL/weFC2VHLRM uBVC7F2Kzf2zQfcMY21RKU6LCZqr7fIGCfCPEmTGvVo5WjHas8rpv1jMNpuq8MgTDM Kvk7LkieRdZeMjYrf3arxNA2kZ7BlP5d3mC9S8tjYAAmDpGDU9Tg3esmjq9WbHdnM+ MjaV0PSunvhXf/yf4kxSEKCuzBSRaaQbipstsU7C9Jq3RZfBrgQnU9sP8N8t1Us/2/ CDYoAKd7xhLKx9FNIQJDv47gvb/H8AikyKRnr32GyohsFuVUqIco/on0JSS0mOFnyw iXQhw49r8JOtA== Received: from xiongwei.. (unknown [120.245.2.115]) by pv50p00im-ztbu10021601.me.com (Postfix) with ESMTPSA id 663A56E05A7; Mon, 28 Jun 2021 15:17:49 +0000 (UTC) From: Xiongwei Song To: peterz@infradead.org, mingo@redhat.com, will@kernel.org, longman@redhat.com, boqun.feng@gmail.com Cc: linux-kernel@vger.kernel.org, Xiongwei Song Subject: [PATCH v2] locking/lockdep: Fix meaningless usages output of lock classes Date: Mon, 28 Jun 2021 23:17:08 +0800 Message-Id: <20210628151708.138524-1-sxwjean@me.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.790 definitions=2021-06-28_12:2021-06-25,2021-06-28 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-2009150000 definitions=main-2106280104 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiongwei Song When enabling CONFIG_LOCK_STAT, then CONFIG_LOCKDEP is forcedly enabled. We can get output from /proc/lockdep, which currently includes usages of lock classes. But the usages are meaningless, see the output below: / # cat /proc/lockdep all lock classes: ffffffff9af63350 ....: cgroup_mutex ffffffff9af54eb8 ....: (console_sem).lock ffffffff9af54e60 ....: console_lock ffffffff9ae74c38 ....: console_owner_lock ffffffff9ae74c80 ....: console_owner ffffffff9ae66e60 ....: cpu_hotplug_lock Only one usage context for each lock, this is because each usage is only changed in mark_lock() that is in CONFIG_PROVE_LOCKING defined section, however in the test situation, it's not. The fix is to move the usages reading and seq_print from CONFIG_PROVE_LOCKING undefined setcion to its defined section. Also, locks_after list of lock_class is empty when CONFIG_PROVE_LOCKING undefined, so do the same thing as what have done for usages of lock classes. Signed-off-by: Xiongwei Song --- kernel/locking/lockdep_proc.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/kernel/locking/lockdep_proc.c b/kernel/locking/lockdep_proc.c index 806978314496..a1ec2652d492 100644 --- a/kernel/locking/lockdep_proc.c +++ b/kernel/locking/lockdep_proc.c @@ -70,23 +70,25 @@ static int l_show(struct seq_file *m, void *v) #ifdef CONFIG_DEBUG_LOCKDEP seq_printf(m, " OPS:%8ld", debug_class_ops_read(class)); #endif -#ifdef CONFIG_PROVE_LOCKING - seq_printf(m, " FD:%5ld", lockdep_count_forward_deps(class)); - seq_printf(m, " BD:%5ld", lockdep_count_backward_deps(class)); -#endif + if (IS_ENABLED(CONFIG_PROVE_LOCKING)) { + seq_printf(m, " FD:%5ld", lockdep_count_forward_deps(class)); + seq_printf(m, " BD:%5ld", lockdep_count_backward_deps(class)); - get_usage_chars(class, usage); - seq_printf(m, " %s", usage); + get_usage_chars(class, usage); + seq_printf(m, " %s", usage); + } seq_printf(m, ": "); print_name(m, class); seq_puts(m, "\n"); - list_for_each_entry(entry, &class->locks_after, entry) { - if (entry->distance == 1) { - seq_printf(m, " -> [%p] ", entry->class->key); - print_name(m, entry->class); - seq_puts(m, "\n"); + if (IS_ENABLED(CONFIG_PROVE_LOCKING)) { + list_for_each_entry(entry, &class->locks_after, entry) { + if (entry->distance == 1) { + seq_printf(m, " -> [%p] ", entry->class->key); + print_name(m, entry->class); + seq_puts(m, "\n"); + } } } seq_puts(m, "\n"); -- 2.30.2