Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1974354ybl; Thu, 29 Aug 2019 01:33:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqzu9VL8tfLP4rEq6KKYjJmE1v/ZvapJ2eVodO9k4s8EEOoks211Bl+Swg/zXvo/QB9cJyZy X-Received: by 2002:a17:90a:3847:: with SMTP id l7mr8199580pjf.99.1567067585601; Thu, 29 Aug 2019 01:33:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567067585; cv=none; d=google.com; s=arc-20160816; b=GoKHZR64jm2zMgqPJtn6FMqV4Uq3TTbww6q7WU7J6DqSKecc+UYxCK4Xn4Ihcs5IUZ Q5lcKU91+BWGqIeacfr7fq3EKaV+yzEa0flsibbrdctBpjYITpC9Ewds7Gg94VP3qC1q Vfl23TZ/5Buo0zG2DG4jyLn4glwlyR4O3uWHkxoOHH585NxWr3Dovd7W3wtaeKwbYwuD x/REeWB67lOaKU0EpGFlYgtx96uGZunWJonUUHylIsuIQAIyjKcHscjrNSfvGIwOOTW+ F8zCF5kPRUuaH7jZQps1KhFj1SqcQ2eAludI9Y77gT20pawExLGGoR2/Pleo1JdakSCI U6ag== 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=m6tcKjo6eL3f+Qm7o9vpHNeE0P9WDqQ11+tf0hyw80Y=; b=04A7k03GdiFbbCzY0Tzku3WBLeQKFBdEitaon2fOfJEmMiSHOPIaFmwEO6p3QsY2qI XFcHutRCbWljTx6QYBdVZZdftRABOLj7i/GjUSPcXcAyfL/o3wJNNtGccnMXmzuAviUz hCXL9ps/Nsx3gS5Zew8JazBLQDAf4LtEajul1Dn3m3GVfvUhlgUYcROGB2tAHolL9JF6 zcVWCR11GWyWYciggIIKuc/YI/aYen7Sigq6Z53U24t2zm+MHsa8rx27qqtLrkD67TtT M9IumRVfJd7A3LMyXqMWvWC9CmaR9AYNaKVOfhYmeIj6JhkX2HgWedDuHSptd8jbl2rr tyOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NJkEthxS; 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 ck1si1241689plb.409.2019.08.29.01.32.50; Thu, 29 Aug 2019 01:33:05 -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=NJkEthxS; 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 S1727026AbfH2Iby (ORCPT + 99 others); Thu, 29 Aug 2019 04:31:54 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:38916 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725776AbfH2Ibx (ORCPT ); Thu, 29 Aug 2019 04:31:53 -0400 Received: by mail-pf1-f196.google.com with SMTP id y200so1570049pfb.6 for ; Thu, 29 Aug 2019 01:31:53 -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=m6tcKjo6eL3f+Qm7o9vpHNeE0P9WDqQ11+tf0hyw80Y=; b=NJkEthxSvl9dDQ2BI+SnuQcCJg1nw28grfBQjUIRdgTclzjWPgWJVETt7xqWV5zGSJ NXzEBLxMDUxziOTdTrtI4PVkdT4HvLjwdjzlS1UUd347lKvHBWH4nkyB1m8z9dWnyhnt 0m4EZWI7x1AG1P2vZ6chpiR9d2hUpDeW+0qBW0QztIZsOck7zmJTdYrdSaEiU2qrGFzd dPv7oF0/iPzXu5jhMRvJjtxIr4qyhfupiGAzXaiHTraQFicU+lo8nwMECuRp7jBB3MAx rO7m2cFXGUpShdDTlTy2/+nJGHOV0tE/4reG+sNviIUjTRW/H1g3W1gZiuJ1mzVNPdv5 ASvQ== 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=m6tcKjo6eL3f+Qm7o9vpHNeE0P9WDqQ11+tf0hyw80Y=; b=O1YrU40KyeWBWNcabqcN8yi/8Kdvi5XgbTEbXpJGp06nHaoKxZOL2R+VbhP9OkgpSt Sic8KAnsr8XvDpzU6M/K8DjWUrCk0AFZ7JWlzj1ebJ8wvcUIIToH0qcchnGrZf0eg4CG VhyUN/M9Eqcjac9xOLX8iUC27Z+dUFbNt4ifxmk6tUlQy1oBRkcK2hLV/zIa0E5Gfxim 9gBnesQtmyg8KE/pK4kT1P1U/shtNXCW1Jr73pgINwT0AT2l6A4s93QYuSI0aLvvUyEE 4o4jNibPTj/0fJKNuCeUXpfoheltfGgforxArarjyDWYGMClDCxW6PqFjyjPLMOwv/ky lCrA== X-Gm-Message-State: APjAAAVTvKqmQy796kWF87VkyHQahiAnsraiOJntk2dS3rXNQQ0cx6j4 ub9DQJdZ22Qnb5rP8OvZTtG2XcZJ7iJW6w== X-Received: by 2002:a17:90a:de11:: with SMTP id m17mr8443614pjv.38.1567067512938; Thu, 29 Aug 2019 01:31:52 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id v22sm1260155pgk.69.2019.08.29.01.31.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Aug 2019 01:31:52 -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 v4 02/30] locking/lockdep: Change return type of add_chain_cache() Date: Thu, 29 Aug 2019 16:31:04 +0800 Message-Id: <20190829083132.22394-3-duyuyang@gmail.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20190829083132.22394-1-duyuyang@gmail.com> References: <20190829083132.22394-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, 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 otherwise for later use. 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 3c89a50..9c9b408 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -2788,12 +2788,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); @@ -2806,16 +2806,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; @@ -2836,18 +2836,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