Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4425150ybi; Mon, 3 Jun 2019 10:37:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXYAXgtEri+qjz73AmyPRFZKRSpIG/hFIMR/dCUC+maCyJwKxqz4MyXxUu93L6R9rhQxgF X-Received: by 2002:a62:1993:: with SMTP id 141mr31836467pfz.97.1559583446212; Mon, 03 Jun 2019 10:37:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559583446; cv=none; d=google.com; s=arc-20160816; b=XZgpo2j4B/2Nnln/jzrkjj3BiwpEgq8HSaBn2tOTCW3Aob5aGsIquUeWfvbHFkz9cp 3g8lwX95HZgXmNTgBG7qO+TsqYdcRU+oV9jijFSzCwY+htQW/3doNH35isukvvDgB6tG x9fwDaLMZdQheiyXyK+3qZid5tYwiFPpWU2j4XlP0siAVpFa2/Vca49/qbzDoNjyxsGS j4s2bj10zjhhd8kBePgT3Xh8wZFRRkau+D2BAuwjEbxFX07PfwebQODhKS2Vj6/2krVQ 2+pTr72m/5UCk5pjDYHErT4fcJ2qUu3gjP+IezHIt8uaj9usH7jip6J4rK1ItKGLYSTL qsNg== 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=+/YblooBhmh3VfISkyyYscIzCqvmEDgFKMuMVsNEiHk=; b=Gt0Up+VqzUGsIVit8eMD+1qD5lcezzgv4WHJwrHuZJuRp79IhDf3JQ2fNcLonx8TXw Yuh6+pGCod7y737dS/iCGUWA6DMse4i7/C6OrScnq1yKcQjOONApY+2t4SFAxZ00mspc u7MM1NqPh8IGxXxm4EEeOE113wk9e3MhjkqdxX7OL+fVzo/hZ6joIzU04fcQeXr/EBc4 W+T0qCAPfRWL8BaSJmqlEBf+4fyaqSZTpbs0PsK8HhUvKrMsDhOVb/ruqchnmG12HBI5 rcH4BtHXdyvDUQMv7iLMwqN50kYSqyzkvrVaJYDrRSIPQoBvLeAb/ogECfMVr3GpVcmr n3dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2019051801 header.b=NKB2F0yh; 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 g9si12201246plp.13.2019.06.03.10.37.09; Mon, 03 Jun 2019 10:37: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=@zytor.com header.s=2019051801 header.b=NKB2F0yh; 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 S1728428AbfFCNKy (ORCPT + 99 others); Mon, 3 Jun 2019 09:10:54 -0400 Received: from terminus.zytor.com ([198.137.202.136]:57321 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726516AbfFCNKy (ORCPT ); Mon, 3 Jun 2019 09:10:54 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x53DAhoi605284 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Mon, 3 Jun 2019 06:10:44 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x53DAhoi605284 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019051801; t=1559567444; bh=+/YblooBhmh3VfISkyyYscIzCqvmEDgFKMuMVsNEiHk=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=NKB2F0yhcI5q1Da4nB6DFEzrGJHVUyH32RALDOdPKFNTLKfWGBqlyjFfci53TYTEe FHJkfDRHiWS0evQgp5hQ1EJdz/hLHOQ1rNhYQMRIbZtCoTkmbQTsgKYFDs9qRiYJNa h11RJX1flKWKiXYO9ndNWnitHSFegxpsd/th4jbnremO47Iab+9A7iiJVkW9W5ks6D 43gruBgNt6f6oO7KLa54noTseT5MYtgOD2WryqDiIadi112Uw6XW96smLctskkeldW 3jgZj24RC1+cfECXQRKgOqCMIhHP4Q8MSQQqly4Gk2AGPfIKiGhop9Pw2/L7tIN2rR cDNmL5eRCG5SA== Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x53DAhAt605281; Mon, 3 Jun 2019 06:10:43 -0700 Date: Mon, 3 Jun 2019 06:10:43 -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, hpa@zytor.com, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, mingo@kernel.org, duyuyang@gmail.com, tglx@linutronix.de Reply-To: tglx@linutronix.de, mingo@kernel.org, duyuyang@gmail.com, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, hpa@zytor.com, peterz@infradead.org In-Reply-To: <20190506081939.74287-8-duyuyang@gmail.com> References: <20190506081939.74287-8-duyuyang@gmail.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:locking/core] locking/lockdep: Use lockdep_init_task for task initiation consistently Git-Commit-ID: e196e479a3b844da6e6e71e0d2a8694040cb4e52 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: e196e479a3b844da6e6e71e0d2a8694040cb4e52 Gitweb: https://git.kernel.org/tip/e196e479a3b844da6e6e71e0d2a8694040cb4e52 Author: Yuyang Du AuthorDate: Mon, 6 May 2019 16:19:23 +0800 Committer: Ingo Molnar CommitDate: Mon, 3 Jun 2019 11:55:42 +0200 locking/lockdep: Use lockdep_init_task for task initiation consistently Despite that there is a lockdep_init_task() which does nothing, lockdep initiates tasks by assigning lockdep fields and does so inconsistently. Fix this by using lockdep_init_task(). 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-8-duyuyang@gmail.com Signed-off-by: Ingo Molnar --- include/linux/lockdep.h | 7 ++++++- init/init_task.c | 2 ++ kernel/fork.c | 3 --- kernel/locking/lockdep.c | 11 ++++++++--- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index 851d44fa5457..5d05b8149f19 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h @@ -287,6 +287,8 @@ extern void lockdep_free_key_range(void *start, unsigned long size); extern asmlinkage void lockdep_sys_exit(void); extern void lockdep_set_selftest_task(struct task_struct *task); +extern void lockdep_init_task(struct task_struct *task); + extern void lockdep_off(void); extern void lockdep_on(void); @@ -411,6 +413,10 @@ extern void lock_unpin_lock(struct lockdep_map *lock, struct pin_cookie); #else /* !CONFIG_LOCKDEP */ +static inline void lockdep_init_task(struct task_struct *task) +{ +} + static inline void lockdep_off(void) { } @@ -503,7 +509,6 @@ enum xhlock_context_t { { .name = (_name), .key = (void *)(_key), } static inline void lockdep_invariant_state(bool force) {} -static inline void lockdep_init_task(struct task_struct *task) {} static inline void lockdep_free_task(struct task_struct *task) {} #ifdef CONFIG_LOCK_STAT diff --git a/init/init_task.c b/init/init_task.c index c70ef656d0f4..1b15cb90d64f 100644 --- a/init/init_task.c +++ b/init/init_task.c @@ -166,6 +166,8 @@ struct task_struct init_task .softirqs_enabled = 1, #endif #ifdef CONFIG_LOCKDEP + .lockdep_depth = 0, /* no locks held yet */ + .curr_chain_key = 0, .lockdep_recursion = 0, #endif #ifdef CONFIG_FUNCTION_GRAPH_TRACER diff --git a/kernel/fork.c b/kernel/fork.c index 75675b9bf6df..735d0b4a89e2 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1984,9 +1984,6 @@ static __latent_entropy struct task_struct *copy_process( p->pagefault_disabled = 0; #ifdef CONFIG_LOCKDEP - p->lockdep_depth = 0; /* no locks held yet */ - p->curr_chain_key = 0; - p->lockdep_recursion = 0; lockdep_init_task(p); #endif diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index bc1efc12a8c5..b7d9c28ecf3b 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -359,6 +359,13 @@ static inline u64 iterate_chain_key(u64 key, u32 idx) return k0 | (u64)k1 << 32; } +void lockdep_init_task(struct task_struct *task) +{ + task->lockdep_depth = 0; /* no locks held yet */ + task->curr_chain_key = 0; + task->lockdep_recursion = 0; +} + void lockdep_off(void) { current->lockdep_recursion++; @@ -4589,9 +4596,7 @@ void lockdep_reset(void) int i; raw_local_irq_save(flags); - current->curr_chain_key = 0; - current->lockdep_depth = 0; - current->lockdep_recursion = 0; + lockdep_init_task(current); memset(current->held_locks, 0, MAX_LOCK_DEPTH*sizeof(struct held_lock)); nr_hardirq_chains = 0; nr_softirq_chains = 0;