Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1474829pxj; Fri, 18 Jun 2021 07:57:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPeKPLPkqQ76VeT4PCOCTAEUgqcLm/zGIUn61cjVwcf8NFVHvV8BSEQHmC7Gpg2Se0IOXX X-Received: by 2002:a05:6e02:d05:: with SMTP id g5mr7191126ilj.34.1624028275596; Fri, 18 Jun 2021 07:57:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624028275; cv=none; d=google.com; s=arc-20160816; b=0M5JXoFyHD/jOAIuu0G9EWYzfcazI3PVVwiN04lZ6U3akMT3o5eLidtcASn5D/sIEx +aBOflaKPgml9Y/OGO9NKbtsh8SLlTVx17WgHoQZSKFRXbVVWkaRPdPyNiGHMN/ZBtqD AzdZzdJ5PhbSUCAHFbOoL5KVu1AhR8Y6YfaGZAp5I75xud66dBk46tnnCS8V6kSHwuF4 lKStB4r6/Yv/AQA8CE72TuzYTb1k6oQcmsQXY7/lWIqACoLnfHbr3UmZtZyxVA8EYi0v hEEgp51VyI+1R6J1+T3PV41ZUIkT5a3WiSh1eBxMFHIdnAEVq56VVGuG+sjmTAizWWno zxiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yJ2wc/yTA/kKyoo3dm7VmVcGUb+nPCIAk5AwTpaqjN4=; b=Pvbt/KXMD1D046OUPfFdk4XICjbkDBiyX3FVe8VYB7xs7CcXEapg6Fg8KwYE93QUDk b+8mGZDiKPPccWS59ixFNgE4umxf/7xlXqFKkr9KAASBNCbVyeiuJTXlLHSFSE612Ssq 9ZvhcA16YZh0IFJQIrbg6dDZRlmI2M+QrSN07Ir5HgwspOw+1D/57BoXH5GwGSj9C5vL wqomqiuZ7G8T/G9NixQN0mxc0Tz82Ky8XjbKMcxEBj3Q2zJAAqbtVtPSjD+eQK9uI0pG 5C841SJM2Korw52U59GyBODgtoBBNRnROweFc8exw/yD1TibTHHm7J9OJkYOVujmaRlp lFFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@me.com header.s=1a1hai header.b=E1dsB+0o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=me.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a12si2554371ilh.124.2021.06.18.07.57.42; Fri, 18 Jun 2021 07:57:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@me.com header.s=1a1hai header.b=E1dsB+0o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=me.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234810AbhFRO6P (ORCPT + 99 others); Fri, 18 Jun 2021 10:58:15 -0400 Received: from pv50p00im-ztdg10021101.me.com ([17.58.6.44]:54030 "EHLO pv50p00im-ztdg10021101.me.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234808AbhFRO6N (ORCPT ); Fri, 18 Jun 2021 10:58:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=1a1hai; t=1624028163; bh=yJ2wc/yTA/kKyoo3dm7VmVcGUb+nPCIAk5AwTpaqjN4=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=E1dsB+0oS6yvDKSGweQIjnkjrjcWTYsT8WpBrvni5R2X3DLsHbFVIv2BT/8sjZ8Qj jTLMNwYjB6MJfYIVCGNwFctBnjh/DO8pnbmhjgYfcG1TVU0IGS9WalU106NgE2O1sv pFOdhVBo9ewScmazCnYxiuXPWB3teHb62Bss7qdYmZOgyFSsQQSpu+E8G6srhiWjDq fiwT1VxTH3yvGQLw7JhKhXNVUzj/NuQdFbaodFw6J4glt31wn4pkDcdgnIENMHR3j3 vn0WKPAW7oDn85gPQMg8PZykqp48DbZ2StOMc0qux8jQ5v5jkCZL3cQcxYH1PZIoZ/ RJYJb61C9N7Iw== Received: from xiongwei.. (unknown [120.245.2.120]) by pv50p00im-ztdg10021101.me.com (Postfix) with ESMTPSA id A889E1801B2; Fri, 18 Jun 2021 14:56:00 +0000 (UTC) From: Xiongwei Song To: peterz@infradead.org, mingo@redhat.com, will@kernel.org, longman@redhat.com, boqun.feng@gmail.com Cc: linux-kernel@vger.kernel.org, Xiongwei Song Subject: [PATCH v2 2/3] locking/lockdep: Unlikely conditons about BFS_RMATCH Date: Fri, 18 Jun 2021 22:55:33 +0800 Message-Id: <20210618145534.438816-3-sxwjean@me.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210618145534.438816-1-sxwjean@me.com> References: <20210618145534.438816-1-sxwjean@me.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.790 definitions=2021-06-18_07:2021-06-18,2021-06-18 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 mlxscore=0 mlxlogscore=791 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-2009150000 definitions=main-2106180088 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiongwei Song The probability that graph walk will return BFS_RMATCH is slim, so unlikey conditons about BFS_RMATCH can improve performance a little bit. Signed-off-by: Xiongwei Song --- kernel/locking/lockdep.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index a8a66a2a9bc1..cb94097014d8 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -2750,7 +2750,7 @@ check_redundant(struct held_lock *src, struct held_lock *target) */ ret = check_path(target, &src_entry, hlock_equal, usage_skip, &target_entry); - if (ret == BFS_RMATCH) + if (unlikely(ret == BFS_RMATCH)) debug_atomic_inc(nr_redundant); return ret; @@ -2992,7 +2992,7 @@ check_prev_add(struct task_struct *curr, struct held_lock *prev, ret = check_redundant(prev, next); if (bfs_error(ret)) return 0; - else if (ret == BFS_RMATCH) + else if (unlikely(ret == BFS_RMATCH)) return 2; if (!*trace) { -- 2.30.2