Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4384749ybi; Mon, 3 Jun 2019 09:59:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqyYih4Q2sTkrs82v1MI0ZDisM0+vLtR8JxH5dQ2tuo7hdb6xExJwSzZLnsY69wbXOLK0+h/ X-Received: by 2002:a17:90a:338e:: with SMTP id n14mr30453457pjb.35.1559581172730; Mon, 03 Jun 2019 09:59:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559581172; cv=none; d=google.com; s=arc-20160816; b=i56J+48+GL98xmC7PtbDCjcnq6+YiW9f9GSZ4cDU5Dgk4Yc/N4NZxhTBYRLMQaZUO6 a82eJicKFjiZW/XgkwmxN2N2Q2iZAFSI9yFlNhhtqvVUhATnsH2uXMUYf6w2oU/b2NwY G4U0UvnSizcc0R14HcBorKMlt39I1BcJsjIBOgR0xZqA77isAwarJ+MuYlw5Ot3vs8vn 672z7iQsfham3w3X/ZlBP2mBPNEoploQA9fxElog2lY6uIAwPihF/H/GbKx+s4lJEK/F Yo6b7f9oBUGYLyJoPZ7qj7mN4o9mO4str5jADQmzCHRhzZrPB3j3ZY0QwZb75rIQcPD1 4BYw== 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=GRLkO+ZDYhVg+i2YTXLTWgXWujGKHdWWN1O3IXC/BiQ=; b=kriLPLnh80I6cxUyW1XlinCNAGxeiacheE2c8b3nLgumAtBfs4ezs254c15BRpsTd8 Iz6V2qzLqTX3NQ0aUZaxfAm8WQnoaIIsucg5oBIGfRZKGBAnkYFoHKbpztD+agrZ6ZYg +osFsT6SotNbfcwzbBYRcLpzJjCoH+3z3bc84zK51/0YwEnWCeCqy4t0qntOXn5FZ8My Zzg4kc9EBTlgC/QigQP8q+eUm2q9a7FnKdnjudBhJT/v9OCgz6nFVNHVjt2p6hRvwIHD DRX2lps4JxeFzyYqjpE/qa+sLseVFfB0QHyzalNWSav50stmd5E3GokaxQAlpN/eqLsB grDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2019051801 header.b=kPqR3vnG; 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 36si19890034pgx.477.2019.06.03.09.59.16; Mon, 03 Jun 2019 09:59:32 -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=kPqR3vnG; 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 S1728293AbfFCNIB (ORCPT + 99 others); Mon, 3 Jun 2019 09:08:01 -0400 Received: from terminus.zytor.com ([198.137.202.136]:46747 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726343AbfFCNIA (ORCPT ); Mon, 3 Jun 2019 09:08:00 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x53D7oQX604683 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Mon, 3 Jun 2019 06:07:50 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x53D7oQX604683 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019051801; t=1559567271; bh=GRLkO+ZDYhVg+i2YTXLTWgXWujGKHdWWN1O3IXC/BiQ=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=kPqR3vnGHzlQhOnXLJp+WM1Ie6kl4wThTSy+zSMFPcDf/Hdk1pInz9H78XFQwsW8V uZ1hY7NlGNRAzzYjlH0eTjoDDbnmKW9Lp/uI77HnxBxSYyU5UeJcBQQcQn6RAXBMUt 6wIRpzO2CeqX9tMmyba27rmUpySH9OsT3tqq2ESm3vRsX1niQoWqn+KpLYWFunjLDZ sFKsxR39SiIh9jWSxYHpkxcJPAPRspH/dLfTvz1hc0DaBNIx5gxQvBMa2Osw/nMUu1 7ueAHhEaacYk3a9UzpZCqWpUh/DP76tdf8n88Gg+MflVIkfwjcEX7/nqzBZNcJKGUc 0vhxosb0F13mA== Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x53D7on4604680; Mon, 3 Jun 2019 06:07:50 -0700 Date: Mon, 3 Jun 2019 06:07:50 -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: hpa@zytor.com, duyuyang@gmail.com, mingo@kernel.org, torvalds@linux-foundation.org, tglx@linutronix.de, peterz@infradead.org, linux-kernel@vger.kernel.org Reply-To: hpa@zytor.com, duyuyang@gmail.com, mingo@kernel.org, torvalds@linux-foundation.org, peterz@infradead.org, tglx@linutronix.de, linux-kernel@vger.kernel.org In-Reply-To: <20190506081939.74287-4-duyuyang@gmail.com> References: <20190506081939.74287-4-duyuyang@gmail.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:locking/core] locking/lockdep: Adjust lock usage bit character checks Git-Commit-ID: c52478f4f38ace598475413a08dba9b9fd827eaf 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: c52478f4f38ace598475413a08dba9b9fd827eaf Gitweb: https://git.kernel.org/tip/c52478f4f38ace598475413a08dba9b9fd827eaf Author: Yuyang Du AuthorDate: Mon, 6 May 2019 16:19:19 +0800 Committer: Ingo Molnar CommitDate: Mon, 3 Jun 2019 11:55:35 +0200 locking/lockdep: Adjust lock usage bit character checks The lock usage bit characters are defined and determined with tricks. Add some explanation to make it a bit clearer, then adjust the logic to check the usage, which optimizes the code a bit. No functional change. 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-4-duyuyang@gmail.com Signed-off-by: Ingo Molnar --- kernel/locking/lockdep.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 109b56267c8f..a033df00fd1d 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -500,15 +500,26 @@ static inline unsigned long lock_flag(enum lock_usage_bit bit) static char get_usage_char(struct lock_class *class, enum lock_usage_bit bit) { + /* + * The usage character defaults to '.' (i.e., irqs disabled and not in + * irq context), which is the safest usage category. + */ char c = '.'; - if (class->usage_mask & lock_flag(bit + LOCK_USAGE_DIR_MASK)) + /* + * The order of the following usage checks matters, which will + * result in the outcome character as follows: + * + * - '+': irq is enabled and not in irq context + * - '-': in irq context and irq is disabled + * - '?': in irq context and irq is enabled + */ + if (class->usage_mask & lock_flag(bit + LOCK_USAGE_DIR_MASK)) { c = '+'; - if (class->usage_mask & lock_flag(bit)) { - c = '-'; - if (class->usage_mask & lock_flag(bit + LOCK_USAGE_DIR_MASK)) + if (class->usage_mask & lock_flag(bit)) c = '?'; - } + } else if (class->usage_mask & lock_flag(bit)) + c = '-'; return c; }