Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp402961img; Tue, 26 Feb 2019 02:04:47 -0800 (PST) X-Google-Smtp-Source: AHgI3IZYr0ILPpjEHzehdf5xE/x+3LKrr1ppusWwjk2iD74rhcAUDFklJBkQtaDETcpWnbeLv9Su X-Received: by 2002:a62:6dc7:: with SMTP id i190mr25167324pfc.166.1551175487271; Tue, 26 Feb 2019 02:04:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551175487; cv=none; d=google.com; s=arc-20160816; b=udQT5DAr+tWO7bUAWnDLzIlRWRoPZ9iH1OFgdztp+RyvBLCiimrx89j0QEnoCfk/BD VpKQSbcEEfrvZMv0GyV0HdEV/WarcWw40lOHP+3F3WurvCIWFUMHjNNQKS4s2UXnAiv0 SYMpR2nYdoJ9YdUKuQ6F7yaz/Y53xGD4pnNvD3ZDiKce2dfNQjOBGCtERUdMrlTNlR0z rmd6qSk6EW8Ra3yOTfdZbj4wHBPHiyb6Crc/WVSKS8XFZIC9PSqZxT1oRXBTBGzRAhzX XFoldGGi9fU7dzvR1FmeWZcpRbY7aslJvge51IE55vmSPO5yvHflfLrctNCxMZCV9EDD /F3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=G+RoZDxlii0BAcLmyBvk41Q9KarsmkZs6L5a3xycMNU=; b=CFjDOkWKRsxA/w7JlgDbM2UAErxJk5AYsDOAp8tYRnYNbZCphtn2iTolWOga9FlK3F q31/oRPsjkoCXs4JYgUyPhhpY8Mjc13b/O4YEaTy/0fB0aSQY3xIiBzLyvQ64srM8sFf S4tlBEoAL4kLQHLJL4YKJ4M34ZNigzzpN1Jg0d92l54qeTjUwhKuaO0YbHgNxO89xnSc zv1t8kbeYJVkDycXNTooWPgQnYoi3+6rcZTKvzM+OUj1+OO+pNGAYlNDXdELJhY7w0rT JbMNPbRKi53g+tMR1nWGzTVKD4YNXDd6KYHWI/lCSZZLz5RMVRejgO94UbvRQRBz/Qcw 9tOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LjsdSHs+; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k185si11804409pge.2.2019.02.26.02.04.32; Tue, 26 Feb 2019 02:04:47 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=LjsdSHs+; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728267AbfBZKEB (ORCPT + 99 others); Tue, 26 Feb 2019 05:04:01 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:44174 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728151AbfBZKD4 (ORCPT ); Tue, 26 Feb 2019 05:03:56 -0500 Received: by mail-pl1-f196.google.com with SMTP id c4so5986530pls.11 for ; Tue, 26 Feb 2019 02:03:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=G+RoZDxlii0BAcLmyBvk41Q9KarsmkZs6L5a3xycMNU=; b=LjsdSHs+75hR4YMRpX5dlkFy/quBDym0yZiCOoiOsShEiZjCuajCXAzkAwBIOeJsqK APZ149PKFm2w0uN0AautxjQtRdRXQrLXqqGF4WuP9N10diBTcK1Tb76WIJ4p1pJwuRUI o439+lueTx8x/kGftsHqOlAbErOn8hkS2TrtN/Kouz03/waYvFgC3dOO2usHkr1ItmV1 KuUY6MraZSOqOcs39I7TsvLPT1L5q7PaZRNCDRcA64LlZqxuXzp80UkYVjUQcTUZZdy9 l6KUQcY5kVpebUlqUYmQyCgg21wWzfHSrnbwwKXQtbO6grbLlKA6vySuNHxCI08ZUczF Pwrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=G+RoZDxlii0BAcLmyBvk41Q9KarsmkZs6L5a3xycMNU=; b=XsiCFQMDG9WLvyR70yT4FJ9XEVgu/qC9057D7qj/GaMNuBVLTmMJIpm9VoZ/Tyr/ZA XnwtSfPEq6UcjCyQTW1f+KeNngj4/GXl7qwoWhoNMYnHlho6pvcSjLMCpsvqwSykElOY +qO3gZQMTYOTm2DGuOW1uReuCkeeQEcNxKPkTVi8hjPzNDmHumcUR0DJp3Uylpo3z6Ab Tb5r7mPF/L0T0+cAAZ1gEOCsLeDMYx7iuIaDNzuXnYou119nQ4euKn9Vo8IYvZhBgs8F n3NWWyhP910d5U8PHSss3lpSUGU1fGvM5f5yNkaolyr0RPHICEbzfPwKY8jH4G7sTiLd TQKQ== X-Gm-Message-State: AHQUAub52LelnvCGKJ19nuo0KYg/vt/HHQiBMpn13tU8qo3bFmLL5JJI aHi+0eaWOmpbm7l9xMA7pL/u++zn8As= X-Received: by 2002:a17:902:9b90:: with SMTP id y16mr25622839plp.0.1551175435694; Tue, 26 Feb 2019 02:03:55 -0800 (PST) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id y6sm12045520pfy.87.2019.02.26.02.03.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Feb 2019 02:03:55 -0800 (PST) From: Yuyang Du To: peterz@infradead.org, mingo@kernel.org Cc: linux-kernel@vger.kernel.org, Yuyang Du Subject: [PATCH 8/8] locking/lockdep: Consider zapped locks when printing lock chains in /proc Date: Tue, 26 Feb 2019 18:03:27 +0800 Message-Id: <20190226100327.19340-9-duyuyang@gmail.com> X-Mailer: git-send-email 2.17.2 (Apple Git-113) In-Reply-To: <20190226100327.19340-1-duyuyang@gmail.com> References: <20190226100327.19340-1-duyuyang@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It is not rare to spot empty lock chains in /proc/lockdep_chains, where only shows irq_context but not the locks, which is useless and makes people confused. This happens because the chained lock classes are freeed, so consider this when printing the lock chains. Signed-off-by: Yuyang Du --- kernel/locking/lockdep_proc.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/kernel/locking/lockdep_proc.c b/kernel/locking/lockdep_proc.c index 3d31f9b..47a6f4f 100644 --- a/kernel/locking/lockdep_proc.c +++ b/kernel/locking/lockdep_proc.c @@ -127,7 +127,7 @@ static int lc_show(struct seq_file *m, void *v) { struct lock_chain *chain = v; struct lock_class *class; - int i; + int i, nr_locks = 0; if (v == SEQ_START_TOKEN) { if (nr_chain_hlocks > MAX_LOCKDEP_CHAIN_HLOCKS) @@ -136,18 +136,28 @@ static int lc_show(struct seq_file *m, void *v) return 0; } - seq_printf(m, "irq_context: %d\n", chain->irq_context); - for (i = 0; i < chain->depth; i++) { class = lock_chain_get_class(chain, i); + /* + * Is this lock class zapped? + */ if (!class->key) continue; + if (!nr_locks++) + seq_printf(m, "irq_context: %d\n", chain->irq_context); + seq_printf(m, "[%p] ", class->key); print_name(m, class); seq_puts(m, "\n"); } - seq_puts(m, "\n"); + + if (nr_locks) { + if (nr_locks != chain->depth) + seq_printf(m, "(chain has %d zapped classes)\n", + chain->depth - nr_locks); + seq_puts(m, "\n"); + } return 0; } -- 1.8.3.1