Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp3068493ybd; Fri, 28 Jun 2019 02:16:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqxXD7is+0UEJ1+M2PLF2T2R/26VElvKCgxPpqmFGFQ86GNAgPjryelshv95CYPimL1Jd94s X-Received: by 2002:a17:90a:b011:: with SMTP id x17mr11933011pjq.113.1561713386487; Fri, 28 Jun 2019 02:16:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561713386; cv=none; d=google.com; s=arc-20160816; b=doyIBSglkV39AgL8OXDsdWBxhgiKHNp4jXUJiwOIOGlYHhA4SiPuZNWQ8Q/FcejSoZ 0/6rCapKuBn7ndcqfns5zvxNyn+7z/7AFaDGl7BFDaEkOKYzVcvXUxXEN9ZWJtmGXmre HOmHSPjKk7NadutyJjZPpo8Z4rJIlQxZWDzkCfcZ6qYHW/e49GsncgotrMOp5yka06AD U4OitYgBkVIkZ5ObJ3raTjks83AQ0BWSlXe6VQl3OazA49OhObJuQCXgId2H2amY8bQW lY6RibqrzUvATD/v2LkgPy2KipCiOLHDVgTx7ps/AnlWN3/+/Q4tMStqLWukK4dRlLv0 O+kw== 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=8ZupqnYwdfry1yDlXcIvfj0C01TyC2YPNUbKz1TOZak=; b=PykxYgycv+zdcwLtEzByTt+ikehqPM0lVn5+ncjRYns3pNVAThVshhPN6Gybaj9l8C qQURUiOb9U8bdxNVuAr9X8BobnExh2rLeSsx3sccW1kEA6RcbABlknhSf/JVJUcSYSs4 qUZXvKMBoMJmyMVxDwqLFj9cdBiYj1vJ/zJa6WPRgvdHqWCq71xc2tp8o8nLDFQvqhNo jRB3nW63rmbh9wxLpPvC8CE/kMT/fLCb2waaHb9SKZ/Ukd8Yl1+ukqUNS+5yESZaR52y +CZTd0OBhGgTUX+fhCwP+vC3KO/YogO9fVhcaVe95L4lVQcCSCMUp23tP0Ayfgd63qq8 lZNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=roiBrov5; 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 142si1751618pgf.35.2019.06.28.02.16.10; Fri, 28 Jun 2019 02:16:26 -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=@gmail.com header.s=20161025 header.b=roiBrov5; 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 S1726712AbfF1JPx (ORCPT + 99 others); Fri, 28 Jun 2019 05:15:53 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:35361 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726508AbfF1JPw (ORCPT ); Fri, 28 Jun 2019 05:15:52 -0400 Received: by mail-pl1-f195.google.com with SMTP id w24so2911893plp.2 for ; Fri, 28 Jun 2019 02:15:52 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=8ZupqnYwdfry1yDlXcIvfj0C01TyC2YPNUbKz1TOZak=; b=roiBrov5fpCRmVYIJCjceBC0rbNG5/vkCUUjuHOd52D33+4pAG4Grwu0jhlyUHI2zu XZI0M70wU/LuSr02xV3Y9+gidtGOriKOeeB4kGpBHeK0H9SSa0a/DP4kuO6Lx3lP4DKT sCbGND7lVARatvP1K0S1+SwnjRUtg4K7oeVEfaLaT9w69k2EZycaMqe6xWko7lMTML4M vJJeSP/iLHfFvN3zT8jYM7C4IGfnIDqTVx9CAwcQ3E0CGK/R3vBadkkMsug+2a8ZIkyJ 3epxb2+5BJPaYXQTRMUOnx1Pj/tIAduN1pvjqY12AE95NNNT7RolxtmHjqbXZ+H9IVrS bfRQ== 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:mime-version:content-transfer-encoding; bh=8ZupqnYwdfry1yDlXcIvfj0C01TyC2YPNUbKz1TOZak=; b=Y3qOlqSUTe5Ui4KDMKU6d0vry1y3n8xrDVwPdIB7I4mrTZyxddZ6YtBEsXAzfhoW+q AjbcrEpv6YALEA0ulT8OocQ0BfenqxxuN5vRhRlf6wb3PhsS28ZbA9IG9zF5ZqaSfI+r HUaAsr4KPgSrw2RP3yjIRibTH0oPflPjZEkbznSHcSrQbLoj8uZofFXOycziJ4x65z3B u47YCIXHiL3EByjZ4nrA9489lsR7IGnNNj0CIEuunLJeLvnCKbnbwS5fpOBDPSYtGsfF R5tEtQDIE8rr5uduJTOaUeNA2na+tP5QvPbhd0XD53ya11SKYtzy7UVbrEwjLCwlAKHp T9WQ== X-Gm-Message-State: APjAAAVqT4OlXt8LBFpFC0lagkEdoys1J6l0Mo/htQu64RhdGpoqV8JP S0ryo4acAv972dUnodXT2To= X-Received: by 2002:a17:902:7247:: with SMTP id c7mr10188437pll.202.1561713352391; Fri, 28 Jun 2019 02:15:52 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id x65sm1754521pfd.139.2019.06.28.02.15.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Jun 2019 02:15:51 -0700 (PDT) From: Yuyang Du To: peterz@infradead.org, will.deacon@arm.com, mingo@kernel.org Cc: bvanassche@acm.org, ming.lei@redhat.com, frederic@kernel.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, longman@redhat.com, paulmck@linux.vnet.ibm.com, boqun.feng@gmail.com, Yuyang Du Subject: [PATCH v3 02/30] locking/lockdep: Change return type of add_chain_cache() Date: Fri, 28 Jun 2019 17:15:00 +0800 Message-Id: <20190628091528.17059-3-duyuyang@gmail.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20190628091528.17059-1-duyuyang@gmail.com> References: <20190628091528.17059-1-duyuyang@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The function add_chain_cache() adds a new chain - the current lock chain - into the lock_chains cache if it does not exist in there. Previously if failed to add an integer 0 is returned and if successful 1 is returned. Change the return type to the pointer of the chain if the new chain is added or NULL if otherwise. No functional change. Signed-off-by: Yuyang Du --- kernel/locking/lockdep.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index e30e9e4..3546894 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -2714,12 +2714,12 @@ static struct lock_chain *alloc_lock_chain(void) * Adds a dependency chain into chain hashtable. And must be called with * graph_lock held. * - * Return 0 if fail, and graph_lock is released. - * Return 1 if succeed, with graph_lock held. + * Return NULL if failed, and graph_lock is released. + * Return the new chain if successful, with graph_lock held. */ -static inline int add_chain_cache(struct task_struct *curr, - struct held_lock *hlock, - u64 chain_key) +static inline struct lock_chain *add_chain_cache(struct task_struct *curr, + struct held_lock *hlock, + u64 chain_key) { struct lock_class *class = hlock_class(hlock); struct hlist_head *hash_head = chainhashentry(chain_key); @@ -2732,16 +2732,16 @@ static inline int add_chain_cache(struct task_struct *curr, * lockdep won't complain about its own locking errors. */ if (DEBUG_LOCKS_WARN_ON(!irqs_disabled())) - return 0; + return NULL; chain = alloc_lock_chain(); if (!chain) { if (!debug_locks_off_graph_unlock()) - return 0; + return NULL; print_lockdep_off("BUG: MAX_LOCKDEP_CHAINS too low!"); dump_stack(); - return 0; + return NULL; } chain->chain_key = chain_key; chain->irq_context = hlock->irq_context; @@ -2762,18 +2762,18 @@ static inline int add_chain_cache(struct task_struct *curr, nr_chain_hlocks += chain->depth; } else { if (!debug_locks_off_graph_unlock()) - return 0; + return NULL; print_lockdep_off("BUG: MAX_LOCKDEP_CHAIN_HLOCKS too low!"); dump_stack(); - return 0; + return NULL; } hlist_add_head_rcu(&chain->entry, hash_head); debug_atomic_inc(chain_lookup_misses); inc_chains(); - return 1; + return chain; } /* -- 1.8.3.1