Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp445351yba; Wed, 24 Apr 2019 04:10:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqwnY/JaMSJVLLBAOLQN+a4Qs6pkRfy4ERZLmiYdyt0AKJpiaQdfK0AgP2o39D3RY2A8ZWcf X-Received: by 2002:a62:1815:: with SMTP id 21mr32714981pfy.107.1556104208631; Wed, 24 Apr 2019 04:10:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556104208; cv=none; d=google.com; s=arc-20160816; b=gZBQxHdaHYtnsbJILLH/giiRvH8roO2WmdPEeZ0me4QO3AmSxpWSmUiIkZ4uTKuT84 XGhh20o78Ro03a2cQRD4SB417O+GduKtw3IIR70x7YDmgJ9wsBgsDhLc4lXoeSaombJJ 3HTJw/r+CtYkn1rdbz7dqN5zHUtlbbmEN1fwXeIUZkZRczsAWQvGDeDDFOI/PtYah1pH PODHwDb7BLNTF4zK7y3oG04Kk/A4YbVjf+7tHBRNSbnACzJl755cwbRC7np4Q57hlvfn 8WzF63YDpfPnT9fWlzOA+YHhee+eZLx5UqHVkDDvOy6J2miNbtBDXOOdjXxHL275/xNU DF6A== 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=WVAxY5VbLxYG0IudT65LG8a11PjQGzGlAMRnmDJ0WLY=; b=nOz4dvEviBukCSG5BSvQTjriiKKctiWPyqqpoFWg31VTJBOBQgm+iBl1c7+nIvuQWr McHQGtoBQ49aiTFy0AePGtMp1CWb8xZzO31UDvHg15Ogu15oJg2GmCVMLUwmLNCtFDuf sWtlyRAM39ZAYVuQukHzBMYcmr+rqPfDOxwxxHOdIqAzKfsAhqRBloqU/hEkCvdXeOJx /peHVD8slhKZBGkeLEnPwOdTyqd0sq1KuDr9xjZ/svQ5M55xe2UbPDSJ53u1vwvv7ZU8 ImEE+vCOJmdMDNzIUhgWnyyXHKWi4sPXYyAp5CzEzThXsVV9h2o5gmUKRT68VSqlFIob oIGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=X9uHG703; 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 p10si10377157pgb.314.2019.04.24.04.09.53; Wed, 24 Apr 2019 04:10:08 -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=X9uHG703; 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 S1729787AbfDXKVe (ORCPT + 99 others); Wed, 24 Apr 2019 06:21:34 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:44826 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729754AbfDXKVd (ORCPT ); Wed, 24 Apr 2019 06:21:33 -0400 Received: by mail-pg1-f195.google.com with SMTP id z16so4550108pgv.11 for ; Wed, 24 Apr 2019 03:21:32 -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=WVAxY5VbLxYG0IudT65LG8a11PjQGzGlAMRnmDJ0WLY=; b=X9uHG703Zy5DHf5VSE2SKoFNX+ZaOgXHc2sTAOB4sGrHJr/jREGgmmqUR9nAgLShxp PezHdrJWpSnWNJfTj+Pg5oLf3MdWvY4iq+LzUR441/IXekx43+XD/S6Cd8V7KD3IVO9p uSL6Kv7fJU+Y5QWxBe6yCPrtEuKXR99tztGYyVNaj6897H/ZzyUF53h8FjWCYcBfKPQH KNudWoiZOiImjVTt8jp6uxmjYj1rB8tRJAm1vD0yt76zXvwOy87ryGhA3jxTq406ll4o SFapbRFdjh0E3EMFd7eyWDS3xnUWs+lQzf5ziotZDNv7sE72SzWwfxqcF4CFP2KVOxq0 qkkw== 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=WVAxY5VbLxYG0IudT65LG8a11PjQGzGlAMRnmDJ0WLY=; b=qNbQez+yptUUE6FDwa8edMjhtYk0uRCYcPXSrfNj4zVifBxzEywhQPrgpj12taJJqJ Cc4obMnYMvNPQ+GPcnYlLJtChcHyB1YNgmRpWBhSGyfDGJNrGlxnkp2qzKk+S5mfv334 wjWyrRzRjuDbUYrKWVbJtxVXPZ2zI3fQPmAE+xXYtOaycb7BCOwp0+9P4w04DqTCBcjA 2p+Ix1al96RYQLn//dkmjH3wrBDDUca1Dx0/gajUWhX6oz+B/Rb2jA8LgtzfK6LuM2w/ ZLEPGO5erq9ay8YgFh0dMGgo8+vvq0LNkDVULiMjE/8cdZbULkUvBTUbJu+Ll18G+gJf MK/Q== X-Gm-Message-State: APjAAAXzVL+N0B4T041dM7ZR6qie0XAtyLydi5PgNe4is894KFMNiqwM oSqIr0jrqbMUoDTdzSC9Ag4= X-Received: by 2002:a62:b61a:: with SMTP id j26mr31774649pff.203.1556101292574; Wed, 24 Apr 2019 03:21:32 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id v19sm25051604pfn.62.2019.04.24.03.21.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Apr 2019 03:21:32 -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 21/28] locking/lockdep: Consolidate lock usage bit initialization Date: Wed, 24 Apr 2019 18:19:27 +0800 Message-Id: <20190424101934.51535-22-duyuyang@gmail.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20190424101934.51535-1-duyuyang@gmail.com> References: <20190424101934.51535-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 4d42124..c08ec88 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -3354,8 +3354,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: @@ -3399,6 +3403,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; } @@ -3440,8 +3449,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; } @@ -3727,11 +3736,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