Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2202449yba; Mon, 6 May 2019 01:23:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqyKrXr1yHHR9QI+CuKeLkiO+7WYHDfisMWSFdfc38saNIPDihn0ujGhbWH1hbHFU8hs7Mxf X-Received: by 2002:a17:902:8214:: with SMTP id x20mr9460412pln.249.1557131018900; Mon, 06 May 2019 01:23:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557131018; cv=none; d=google.com; s=arc-20160816; b=eV5vef0/f7WoOZ/7Wtk6DE23c+CeYnrQgvCLT+JWygfhvZpaIAVtW9jPGpA4dWI2jU vIArO/r+Z3lTThSLMyaIlSQOENbsA4+umS6ddSauGzUsnOLMOMih10uO9uwEU+CgJfbK Px3Ks9ag3gahMhrM7q562MwNbdVJvAkUKiH+WUkJ/ECJPPnBFWEimH8cc1hQ5RI5MoZc aSHzO7YYx/LXQdg0Hr+bZWeB+CMWRyfFjrAHH52hFo8SFu1Qq5Q46tb0kgkuO8TO+gbs fBrEsTvHfSeqSHtqoNzc4+LlmXxGBHA5p/M9etBJKKsKra9x3relhIaTq1JpMX3xmS0l 4u/A== 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=t70GCGACIUWewKKDD5qrnEovI01jL9vwBiMVTScwpdQ=; b=dgZM6Za7YMCHWyb1odLL6h4WXox74c7U/b1YHHGHTBZNolDRmxsZP/sQ/J9sDJgZQL FQLgqcoURUthhqBD8mye6A5g6tQJuJYr871MN3hAvWQ7u0BwAX3f5amyj1uBiWRHUPUD GZUFqut/l13XIt1YZApof70ywTy9wis8scAnbb7QpuiHfxbsxQHZDLtPGhItTyucb96l +srFLH5kv5aQQk0czuEuTnh0JmU8aKqetD2egExzQWddt0fZw3lihsALKvp7hCFJsPHg VI0/5mTQlg/w/B8+1rcghJuwtxkfAqVYYGkEiswskW6PxOYoAI1+DYAydRuD/Ol7Ix6Q HSlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=oKpHRgXa; 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 h26si14363546pfn.240.2019.05.06.01.23.23; Mon, 06 May 2019 01:23:38 -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=oKpHRgXa; 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 S1726734AbfEFIU6 (ORCPT + 99 others); Mon, 6 May 2019 04:20:58 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:40068 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726722AbfEFIU4 (ORCPT ); Mon, 6 May 2019 04:20:56 -0400 Received: by mail-pg1-f196.google.com with SMTP id d31so6091803pgl.7 for ; Mon, 06 May 2019 01:20:56 -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=t70GCGACIUWewKKDD5qrnEovI01jL9vwBiMVTScwpdQ=; b=oKpHRgXa47NOgo/vGp8semc/qpulzzzXcb0ttnNg7EYsNlpSoFZWioiUrf26bGC98m eUSR7Bf5/qcCkM4+azAcADd6p3WmhznVa+1uMTr4pQuk4DeU0UWxmGBCD/r4+xuveWko /HjMWAMZpilSY3qMkE2b6ATMUdO41dCUl6s0Kur5Q/lXHCQo45PuQURtf/7rWwBqz+JO 8E82e1ZL9hS2Jkg3DeYWpvV1gZV5R59CLlOcxIiu4dSPkcJqfjhmwvVsi9cOFMRHYqNo k2XvmnWaii49/JGdhW2ZQEe51yxsdq6IlbcAfmh3ZhJQA/mFDJgr8CVD1iIHOBL40Fmu m8xw== 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=t70GCGACIUWewKKDD5qrnEovI01jL9vwBiMVTScwpdQ=; b=ihKc2BZ5lTaqH2mdCilxBKvnW2FYMI5FUWDvGvTtRsadPzpyM3YuR0UROK+Zho1pM0 t62dZ8u3Ji+wuukGEPOmJpLGN5uDpyiR0zVwYt7kFckcCPRAfFGFWwkH6RzO9nK6pPNm i2LW34n4xs0jxSlf1aWkzn37FmoOGwloZ5SqGPyRSKl2kmE9rDM0ZHTOYX91QP1k9W/d ZJCB2VbqoTSSwoeAtrgSxUuKm6V7TyfJKNEnBd5JsaWDHjK8q+DCuI88OxeZ/h+I/tlt 9aNQ885365tI3WspIUlYJVBqhGf1hvKYcstpNK+QPlpHNNuBxNVwD6FizoNUI1KWcFs7 EAMg== X-Gm-Message-State: APjAAAXmTSUfoXb7wT1CLp8u+MwK3hqAo+fv/4LHM3maWz4ZArWoKMfz s9+uHjbkHRiSRGP/wbEsD4s= X-Received: by 2002:a63:1604:: with SMTP id w4mr30773662pgl.148.1557130856083; Mon, 06 May 2019 01:20:56 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id v19sm20958013pfa.138.2019.05.06.01.20.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 May 2019 01:20:55 -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, Yuyang Du Subject: [PATCH v2 21/23] locking/lockdep: Consolidate lock usage bit initialization Date: Mon, 6 May 2019 16:19:37 +0800 Message-Id: <20190506081939.74287-22-duyuyang@gmail.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20190506081939.74287-1-duyuyang@gmail.com> References: <20190506081939.74287-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 Lock usage bit initialization is consolidated into one function mark_usage(). Trivial readability improvement. No functional change. Signed-off-by: Yuyang Du --- kernel/locking/lockdep.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 9d2728c..79bc6cd 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -3459,8 +3459,12 @@ void trace_softirqs_off(unsigned long ip) debug_atomic_inc(redundant_softirqs_off); } -static int mark_irqflags(struct task_struct *curr, struct held_lock *hlock) +static int +mark_usage(struct task_struct *curr, struct held_lock *hlock, int check) { + if (!check) + goto lock_used; + /* * If non-trylock use in a hardirq or softirq context, then * mark the lock as used in these contexts: @@ -3504,6 +3508,11 @@ static int mark_irqflags(struct task_struct *curr, struct held_lock *hlock) } } +lock_used: + /* mark it as used: */ + if (!mark_lock(curr, hlock, LOCK_USED)) + return 0; + return 1; } @@ -3545,8 +3554,8 @@ int mark_lock_irq(struct task_struct *curr, struct held_lock *this, return 1; } -static inline int mark_irqflags(struct task_struct *curr, - struct held_lock *hlock) +static inline int +mark_usage(struct task_struct *curr, struct held_lock *hlock, int check) { return 1; } @@ -3832,11 +3841,8 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass, #endif hlock->pin_count = pin_count; - if (check && !mark_irqflags(curr, hlock)) - return 0; - - /* mark it as used: */ - if (!mark_lock(curr, hlock, LOCK_USED)) + /* Initialize the lock usage bit */ + if (!mark_usage(curr, hlock, check)) return 0; /* -- 1.8.3.1