Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4131131ybi; Mon, 3 Jun 2019 06:15:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqx+py+aX3qOQ37m0cSWd2x7uqIC9RVymoZmym4CQ85mn/AjyapOu7+xXnzdOavnKB36ullr X-Received: by 2002:a17:902:7c10:: with SMTP id x16mr28528287pll.4.1559567705528; Mon, 03 Jun 2019 06:15:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559567705; cv=none; d=google.com; s=arc-20160816; b=V3HmrXkKBxJxgvDhNTw41TeMp6OORX84j7ecH99y0gI7h4vo0vCFbe+p79DJbkmSs/ lxVc2AojM/bh0hOfehnJFmcKnJz2A0QUrsZajOh8fx4PFvTuz9MouB7YPCQCEYObBX4W DOJYHLg1Qp1fCnrqJwWu0Mnri8X3xybIsbmTJCKEm21AkQPGOAO/pn0aexIiOsIAcL4B ygEiwPG3qYC+H148ins62lNIHCvMma1pxjeWMPXaS32lqNYKHUSTCJH2Fdql826NClgj zp7eTxdh8AqwTSJXTNPvHdvwFR+RnutzcqqQ1M6qevIdxGnoeSJ18eJ6cBNt5zh/7Zwj kpgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:dkim-signature:dkim-filter; bh=s34d0VTabWlRAkjesyhOO60Mw419kjVSeWCby5yulP8=; b=Gy7My70x6POHvWzm+KDJ/RFOdjzJFdorODIkQ7Nr8arC99k6SlhaG5/sh29zzz4+62 JNgKdN7R5OUM883ur6CsbMUfkzF7ig29m/HMdebkFH/PFoGLmwGuFj7jGoWieeoYLdnY Y/b0wXIoxEk7/KQp4cN7tbERTvynrmyUrFKE9KFJPF1qPWFM722LpM91jEtqa7bWILfP 4L2jvBGCZHZTgIMKDXAfaxfZwm7HQMwlqNZ1KL8Q6yA/8B4hxTVxi0baqvfaV+KQFNX9 H0tDCTy6Kp5rmWcrzRYky/7IX64zJxQZ6xQTMtiw01nvkeViJj0mqKzcb9qtLOF2mIRx jODg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2019051801 header.b=nbBgFkd5; 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=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d27si18756241pgl.202.2019.06.03.06.14.46; Mon, 03 Jun 2019 06:15: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=@zytor.com header.s=2019051801 header.b=nbBgFkd5; 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=NONE dis=NONE) header.from=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728212AbfFCNLi (ORCPT + 99 others); Mon, 3 Jun 2019 09:11:38 -0400 Received: from terminus.zytor.com ([198.137.202.136]:40581 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726516AbfFCNLi (ORCPT ); Mon, 3 Jun 2019 09:11:38 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x53DBRCf605320 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Mon, 3 Jun 2019 06:11:27 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x53DBRCf605320 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019051801; t=1559567488; bh=s34d0VTabWlRAkjesyhOO60Mw419kjVSeWCby5yulP8=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=nbBgFkd5QVru+VjsdIaaSNR6HTvaswSqRxu7Tff4o6KPMgQVsMvPW8UgOrhrX5Ak6 Pu8Hrrpi7zO/qtMTIiVzcr5r6ZZ9TtfjuhBu+ka0F8zFA2CcNv6ABXu7DfYkn+K1QA XO0IA0WcgQLWsSpaMVw1OOlqAdIUth1yWXUqGKE1E1zJ10dm7dF+fQfvPArIRmOv1h f5sbcQDSK4Jfb5i885gLxTR4ezOEfQsPz82PUUA//t6kXN8B5zmkD/ZY2kW1nZpnuB m0V6r/na0gZN+7i0ZiF6ooCSjlQElZ91k4S2TpXTv66382J5txw5AFo/gWqZfggPlD yWckU+Ni9nbug== Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x53DBQlb605317; Mon, 3 Jun 2019 06:11:26 -0700 Date: Mon, 3 Jun 2019 06:11:26 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Yuyang Du Message-ID: Cc: peterz@infradead.org, duyuyang@gmail.com, linux-kernel@vger.kernel.org, hpa@zytor.com, torvalds@linux-foundation.org, mingo@kernel.org, tglx@linutronix.de Reply-To: torvalds@linux-foundation.org, peterz@infradead.org, duyuyang@gmail.com, linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@kernel.org, tglx@linutronix.de In-Reply-To: <20190506081939.74287-9-duyuyang@gmail.com> References: <20190506081939.74287-9-duyuyang@gmail.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:locking/core] locking/lockdep: Define INITIAL_CHAIN_KEY for chain keys to start with Git-Commit-ID: f6ec8829ac9d59b637366c13038f15d6f6156fe1 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-0.3 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_96_Q,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, FREEMAIL_FORGED_REPLYTO autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: f6ec8829ac9d59b637366c13038f15d6f6156fe1 Gitweb: https://git.kernel.org/tip/f6ec8829ac9d59b637366c13038f15d6f6156fe1 Author: Yuyang Du AuthorDate: Mon, 6 May 2019 16:19:24 +0800 Committer: Ingo Molnar CommitDate: Mon, 3 Jun 2019 11:55:43 +0200 locking/lockdep: Define INITIAL_CHAIN_KEY for chain keys to start with Chain keys are computed using Jenkins hash function, which needs an initial hash to start with. Dedicate a macro to make this clear and configurable. A later patch changes this initial chain key. Signed-off-by: Yuyang Du Signed-off-by: Peter Zijlstra (Intel) Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: bvanassche@acm.org Cc: frederic@kernel.org Cc: ming.lei@redhat.com Cc: will.deacon@arm.com Link: https://lkml.kernel.org/r/20190506081939.74287-9-duyuyang@gmail.com Signed-off-by: Ingo Molnar --- include/linux/lockdep.h | 1 + init/init_task.c | 2 +- kernel/locking/lockdep.c | 18 +++++++++--------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index 5d05b8149f19..d4e69595dbd4 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h @@ -229,6 +229,7 @@ struct lock_chain { * bitfield and hitting the BUG in hlock_class(). */ #define MAX_LOCKDEP_KEYS ((1UL << MAX_LOCKDEP_KEYS_BITS) - 1) +#define INITIAL_CHAIN_KEY 0 struct held_lock { /* diff --git a/init/init_task.c b/init/init_task.c index 1b15cb90d64f..afa6ad795355 100644 --- a/init/init_task.c +++ b/init/init_task.c @@ -167,7 +167,7 @@ struct task_struct init_task #endif #ifdef CONFIG_LOCKDEP .lockdep_depth = 0, /* no locks held yet */ - .curr_chain_key = 0, + .curr_chain_key = INITIAL_CHAIN_KEY, .lockdep_recursion = 0, #endif #ifdef CONFIG_FUNCTION_GRAPH_TRACER diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index b7d9c28ecf3b..9edf6f12b711 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -362,7 +362,7 @@ static inline u64 iterate_chain_key(u64 key, u32 idx) void lockdep_init_task(struct task_struct *task) { task->lockdep_depth = 0; /* no locks held yet */ - task->curr_chain_key = 0; + task->curr_chain_key = INITIAL_CHAIN_KEY; task->lockdep_recursion = 0; } @@ -857,7 +857,7 @@ static u16 chain_hlocks[MAX_LOCKDEP_CHAIN_HLOCKS]; static bool check_lock_chain_key(struct lock_chain *chain) { #ifdef CONFIG_PROVE_LOCKING - u64 chain_key = 0; + u64 chain_key = INITIAL_CHAIN_KEY; int i; for (i = chain->base; i < chain->base + chain->depth; i++) @@ -2524,7 +2524,7 @@ static void print_chain_keys_held_locks(struct task_struct *curr, struct held_lock *hlock_next) { struct held_lock *hlock; - u64 chain_key = 0; + u64 chain_key = INITIAL_CHAIN_KEY; int depth = curr->lockdep_depth; int i = get_first_held_lock(curr, hlock_next); @@ -2544,7 +2544,7 @@ print_chain_keys_held_locks(struct task_struct *curr, struct held_lock *hlock_ne static void print_chain_keys_chain(struct lock_chain *chain) { int i; - u64 chain_key = 0; + u64 chain_key = INITIAL_CHAIN_KEY; int class_id; printk("depth: %u\n", chain->depth); @@ -2848,7 +2848,7 @@ static void check_chain_key(struct task_struct *curr) #ifdef CONFIG_DEBUG_LOCKDEP struct held_lock *hlock, *prev_hlock = NULL; unsigned int i; - u64 chain_key = 0; + u64 chain_key = INITIAL_CHAIN_KEY; for (i = 0; i < curr->lockdep_depth; i++) { hlock = curr->held_locks + i; @@ -2872,7 +2872,7 @@ static void check_chain_key(struct task_struct *curr) if (prev_hlock && (prev_hlock->irq_context != hlock->irq_context)) - chain_key = 0; + chain_key = INITIAL_CHAIN_KEY; chain_key = iterate_chain_key(chain_key, hlock->class_idx); prev_hlock = hlock; } @@ -3787,14 +3787,14 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass, /* * How can we have a chain hash when we ain't got no keys?! */ - if (DEBUG_LOCKS_WARN_ON(chain_key != 0)) + if (DEBUG_LOCKS_WARN_ON(chain_key != INITIAL_CHAIN_KEY)) return 0; chain_head = 1; } hlock->prev_chain_key = chain_key; if (separate_irq_context(curr, hlock)) { - chain_key = 0; + chain_key = INITIAL_CHAIN_KEY; chain_head = 1; } chain_key = iterate_chain_key(chain_key, class_idx); @@ -4636,7 +4636,7 @@ static void remove_class_from_lock_chain(struct pending_free *pf, return; recalc: - chain_key = 0; + chain_key = INITIAL_CHAIN_KEY; for (i = chain->base; i < chain->base + chain->depth; i++) chain_key = iterate_chain_key(chain_key, chain_hlocks[i] + 1); if (chain->depth && chain->chain_key == chain_key)