Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp241202img; Mon, 18 Mar 2019 02:01:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqwOA3IxtjrKgftgdbAzIEbxtKta3sxYJJgB8S2awgR3QVoGxETk4X7W6/h1AXIqSQ8WNWdr X-Received: by 2002:a17:902:765:: with SMTP id 92mr18353058pli.95.1552899667815; Mon, 18 Mar 2019 02:01:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552899667; cv=none; d=google.com; s=arc-20160816; b=iFMZ7+CAigpuKQU/gcuCvHoNgnDO8bDljl2bAE4e+aGuJVKV7Uvv1B7umkoruGUivO zG7GApjxHTy2ZBlgvD3J1spPXJy4AWNTlkUIE9mzwt/R9JcClbyJsQdhE/pxRuRZ6IOI ubzVoL+EjTs6YWndlJFLd6m58Cu/v4jY8pC1B3093uYCnbT9Gt3z2fM0RWNY1dLCybPy phTMKFWVfqr8t73v3PIMkU6c0eWEf21kmX0inDplOtXk2trkPGsFTCHPjmqxel99bFke Ahw6S/Or1yoMY7EEmt6ROPM/0YcHowiJYcDaQLOiDV7G221eSTRALXgRqTf9/Yt5I1Dn QWBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=6losf3tQR5/07kLvPHhQ7EAuCmSM+1UcqHl2cRw0n6k=; b=xxhpVwlNQ8efmJpqZmzEspdGvx57RVyYlUobr0xG/UJGTT8u3ReytNnifIZ55WdSyN IkrfWLYoHz8NWYt5R7MMrzKXJ2VviM0V1eTH3SmXmWnHuO3qtBnLkdyrpdyq2X7vECXG +5CT6ZhjY/g90U5iMNYCYnhj+ZLK+DG1tZqJ4PYu5tcoyLq8Gm0Ik0kYdwz34S1zxhGJ fFxm9M69RrnZwUgcH73whvR/+SaZ86cGK0ypLoFynS2K5DWZozxJAzQ/1Xn+WqDLR2VL Y4JcI6zAmzXDLRFxHbVyrvFuRPndYWnyiiCgwFcUkHlRYRvYl9sRzZwdVp44Nx21K/7q Umrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZlQ0phEF; 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 34si8470566pgs.553.2019.03.18.02.00.52; Mon, 18 Mar 2019 02:01:07 -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=ZlQ0phEF; 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 S1727556AbfCRI6i (ORCPT + 99 others); Mon, 18 Mar 2019 04:58:38 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:46470 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726872AbfCRI6h (ORCPT ); Mon, 18 Mar 2019 04:58:37 -0400 Received: by mail-pg1-f196.google.com with SMTP id a22so10888184pgg.13 for ; Mon, 18 Mar 2019 01:58:36 -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; bh=6losf3tQR5/07kLvPHhQ7EAuCmSM+1UcqHl2cRw0n6k=; b=ZlQ0phEF3nFFFNpLiBbLOOJjPR837QVb5AkF88VGIJSi79wAEM06a34TLCSYOPjymn 3mW7WuByjJ9AkDx5yTE8b3/4NiF7hZsCL30U8a2fRbJS1pXV5WOShG0/zTusG/GFiLp1 nr6oHgJzuH+8meK0u4R9cz7VEND4LziDakMSTdmxwc5Qj6SvxAxHa2mZ4w4oTSojBzyU t1zTIrhIy7WYIS740UXBWeFIib8RrV6LQy5Ho4DGHwOGaJr8U3sfH0fSjxvsugSpfKkW VFpzNI07vL6r0R9cNj9efGifp85Xh8hOaS6UYSz1N4DwhMLYBlSuwmBMN93Wg4MpJ1hf Eg0w== 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; bh=6losf3tQR5/07kLvPHhQ7EAuCmSM+1UcqHl2cRw0n6k=; b=QY7QPqZeXpLc2WA1cKCCYKDEgcvUU3H20/tH5n2XuoJAcdrzTEKK3tas7JrOA66Zo8 qP95j989AJTEOLdXj4tCNby/YdZKml3Yp4+tpB7tiYrm6/qzd6OYUCjpafJhUF3XWTlA 5ZzDiYb6/jfPcY579SfLxCQy1CkiXPanDmL2uO/GtmMSxp08+o+JD9CiyUVk6ZOgMeID n+Djwg+3is74EWknBWpfez6/qbUW6dpL5N7VmG26dR/A5voReNd7z7jZpC0ULwBQKGKW pq3yFX7x8RcIs3Jqvw0RKfMAwuna1tppwhEDATOuDQba5ELgaCbcCotrJhk1uBISwLmq 6FKw== X-Gm-Message-State: APjAAAVML4I01JIajhGL5Egbt2RofRDtiRR0e/4j7hlcJMHSpRZbEkE+ rDVVCiLixGWUd5vAaWU+QxA= X-Received: by 2002:aa7:9099:: with SMTP id i25mr18225923pfa.102.1552899516429; Mon, 18 Mar 2019 01:58:36 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id k8sm11147024pgq.37.2019.03.18.01.58.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Mar 2019 01:58:35 -0700 (PDT) From: Yuyang Du To: peterz@infradead.org, will.deacon@arm.com, mingo@kernel.org Cc: bvanassche@acm.org, ming.lei@redhat.com, linux-kernel@vger.kernel.org, Yuyang Du Subject: [PATCH v2 19/19] locking/lockdep: Change if to else-if when checking bfs errors Date: Mon, 18 Mar 2019 16:57:33 +0800 Message-Id: <20190318085733.3143-20-duyuyang@gmail.com> X-Mailer: git-send-email 2.17.2 (Apple Git-113) In-Reply-To: <20190318085733.3143-1-duyuyang@gmail.com> References: <20190318085733.3143-1-duyuyang@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org After BFS searching, we check whether there is an error. These checks are exclusive, so we can use "else if" instead of "if", which results in a bit optimized code. No functional change. Signed-off-by: Yuyang Du --- kernel/locking/lockdep.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 1d38bf6..3efc00e 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -1950,21 +1950,21 @@ static void print_lock_class_header(struct lock_class *class, int depth) this.class = hlock_class(prev); ret = find_usage_backwards(&this, bit_backwards, &target_entry); - if (ret < 0) { + if (unlikely(ret < 0)) { print_bfs_bug(ret); return 0; } - if (ret == 1) + else if (ret == 1) return ret; that.parent = NULL; that.class = hlock_class(next); ret = find_usage_forwards(&that, bit_forwards, &target_entry1); - if (ret < 0) { + if (unlikely(ret < 0)) { print_bfs_bug(ret); return 0; } - if (ret == 1) + else if (ret == 1) return ret; print_bad_irq_dependency(curr, &this, &that, @@ -2282,7 +2282,7 @@ static void print_deadlock_scenario(struct held_lock *nxt, debug_atomic_inc(nr_redundant); return 2; } - if (ret < 0) { + else if (unlikely(ret < 0)) { print_bfs_bug(ret); return 0; } @@ -2967,11 +2967,11 @@ static int mark_lock(struct task_struct *curr, struct held_lock *this, root.parent = NULL; root.class = hlock_class(this); ret = find_usage_forwards(&root, bit, &target_entry); - if (ret < 0) { + if (unlikely(ret < 0)) { print_bfs_bug(ret); return 0; } - if (ret == 1) + else if (ret == 1) return ret; print_irq_inversion_bug(curr, &root, target_entry, @@ -2994,11 +2994,11 @@ static int mark_lock(struct task_struct *curr, struct held_lock *this, root.parent = NULL; root.class = hlock_class(this); ret = find_usage_backwards(&root, bit, &target_entry); - if (ret < 0) { + if (unlikely(ret < 0)) { print_bfs_bug(ret); return 0; } - if (ret == 1) + else if (ret == 1) return ret; print_irq_inversion_bug(curr, &root, target_entry, -- 1.8.3.1