From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 698C6C388F7 for ; Sat, 31 Oct 2020 11:30:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1887820825 for ; Sat, 31 Oct 2020 11:30:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="kYs4tsOf"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="dpm4Z9jY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726923AbgJaLaj (ORCPT ); Sat, 31 Oct 2020 07:30:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726813AbgJaLaf (ORCPT ); Sat, 31 Oct 2020 07:30:35 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9E78C0613D5; Sat, 31 Oct 2020 04:30:34 -0700 (PDT) Date: Sat, 31 Oct 2020 11:30:31 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1604143832; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tsB98iqrU+rxw9xA0DzPumvB4zFOqFjdq5X8x1qmzcI=; b=kYs4tsOfxqOJAKQBL4SWSanhu1q11ig47I9zQdYLNK9gSad19mOTd6sQEnr2Wjd73NPK59 A/j1ZgTolXTFXOemS75AUzktF+NzDJc+CfrI/vk4IHO3pgsmGyWnP705tDpbdxAonNNKu7 JvwKZE+l7GMUU7QGvbusm4kiYT7oNkLsWNnURlTbzBkjaWl/I0vuYCOWyo69NiTkXWWO10 hdrncZJvIjWYKmBBwCj3/SZY/9L1N/6vwJUumKC6GhcvWL9nEbRo+5gDRz4ZUoZFiIrj1R cPEyV46+b0mbksL/xxnquMlVou1bMGi+BvIP1EgQpa0f2U8GgofdIz0OclNTTg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1604143832; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tsB98iqrU+rxw9xA0DzPumvB4zFOqFjdq5X8x1qmzcI=; b=dpm4Z9jYFbpZXg7WTVtqCVQX72tcyLU8w71q8KSuP9rvLoArcyPyjAsST9Rd7UX6PqLOfh F5QS5KO24fV2ExBw== From: "tip-bot2 for Peter Zijlstra" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: locking/urgent] lockdep: Fix nr_unused_locks accounting Cc: Chris Wilson , "Peter Zijlstra (Intel)" , x86 , LKML In-Reply-To: <20201027124834.GL2628@hirez.programming.kicks-ass.net> References: <20201027124834.GL2628@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Message-ID: <160414383158.397.3025016969633820018.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the locking/urgent branch of tip: Commit-ID: 1a39340865ce505a029b37aeb47a3e4c8db5f6c6 Gitweb: https://git.kernel.org/tip/1a39340865ce505a029b37aeb47a3e4c8db5f6c6 Author: Peter Zijlstra AuthorDate: Tue, 27 Oct 2020 13:48:34 +01:00 Committer: Peter Zijlstra CommitterDate: Fri, 30 Oct 2020 17:07:18 +01:00 lockdep: Fix nr_unused_locks accounting Chris reported that commit 24d5a3bffef1 ("lockdep: Fix usage_traceoverflow") breaks the nr_unused_locks validation code triggered by /proc/lockdep_stats. By fully splitting LOCK_USED and LOCK_USED_READ it becomes a bad indicator for accounting nr_unused_locks; simplyfy by using any first bit. Fixes: 24d5a3bffef1 ("lockdep: Fix usage_traceoverflow") Reported-by: Chris Wilson Signed-off-by: Peter Zijlstra (Intel) Tested-by: Chris Wilson Link: https://lkml.kernel.org/r/20201027124834.GL2628@hirez.programming.kicks-ass.net --- kernel/locking/lockdep.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 1102849..b71ad8d 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -4396,6 +4396,9 @@ static int mark_lock(struct task_struct *curr, struct held_lock *this, if (unlikely(hlock_class(this)->usage_mask & new_mask)) goto unlock; + if (!hlock_class(this)->usage_mask) + debug_atomic_dec(nr_unused_locks); + hlock_class(this)->usage_mask |= new_mask; if (new_bit < LOCK_TRACE_STATES) { @@ -4403,19 +4406,10 @@ static int mark_lock(struct task_struct *curr, struct held_lock *this, return 0; } - switch (new_bit) { - case 0 ... LOCK_USED-1: + if (new_bit < LOCK_USED) { ret = mark_lock_irq(curr, this, new_bit); if (!ret) return 0; - break; - - case LOCK_USED: - debug_atomic_dec(nr_unused_locks); - break; - - default: - break; } unlock: