Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp408486yba; Wed, 24 Apr 2019 03:27:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqz3++D6aZIvZPAmLJecb2N1YLODdUkPIvzVe9xyYbGdC8yhcV/NELyVtSUt2rvpyXtYZERF X-Received: by 2002:a17:902:8b86:: with SMTP id ay6mr14427223plb.4.1556101659151; Wed, 24 Apr 2019 03:27:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556101659; cv=none; d=google.com; s=arc-20160816; b=jAbf/vYS8nflWEJFH3HWwyj64vrAg+Nl8uAJd9vvVi53zCP+Kzmdej6OVg5eQz0bsg LNLjjwWzSqWX974zCvDQn/qJGkm/mu6w4LCDQ/+87cYeC0a6mT75EnOoxPp7VCLJ+MTj mqXyNZX9z5cmOk4l58aSlOgmAbzLZAc7KDzMd+URQp++tPerh2xlspkeUtscC3sORmBY QlScxzdrRDZp5DU3ZqtLOw32nLyO6GHOiNekBRnMfqxz0cdKLEe6rFAGdTLMdKXYJayi csXGPsJq3LsDuErelJVMt6hGY7xRkBBFtE24UiUA21gUX8qLaaTupTCwMj3UX2TkDvyX WE5Q== 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=rhJZpnLOBOQ02N5rKilhuEzxJdUJm5UkAKEws5ZBLPc=; b=qQzJVdp2cKq/QGjfBTyzXoiDRk5loqkqnv5Rrs3jDL9449Ddg9QXYZY31uyZRJxipd x4KBUAbizHvHra8agIr3CI2mGB/U/sUkWAXU1sGDyYGRSAwS7VAuQZn/rKnqYV6W3Ct1 QOnpymdDnk4F3p4RbRQj9ERI61q+G6OdRXMWg/cXSqllbp6P3p8nLZNZDLn+tLmONJz7 m7OgfYVEDjPxdpuOC13SalCxbLfpcLJb9hjUfKfRU8ToZqMA4+swI4+b99oWMda5oQqu lV8bdHu+Dmh0TeeSK4aQNeheGRJAqBJo95Wwo6GlCqHwB1j4lH/PS+TZAE5vImaxGi1D gOsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=U+Jrb3yE; 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 j23si4835663pff.108.2019.04.24.03.27.23; Wed, 24 Apr 2019 03:27:39 -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=U+Jrb3yE; 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 S1729507AbfDXKVL (ORCPT + 99 others); Wed, 24 Apr 2019 06:21:11 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:38312 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729174AbfDXKVI (ORCPT ); Wed, 24 Apr 2019 06:21:08 -0400 Received: by mail-pl1-f196.google.com with SMTP id f36so9059849plb.5 for ; Wed, 24 Apr 2019 03:21:07 -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=rhJZpnLOBOQ02N5rKilhuEzxJdUJm5UkAKEws5ZBLPc=; b=U+Jrb3yE8AQ5/gNnyaAAOPNj2fFpvgy5rkxz9PBLoOEhe6L2YP0rrca2vQ3SCyjhYI EGLgfG4c7lZIpeuulxu7MJAQRM2wOZJTvDqveZPsPYarIPXIOzgOhHX33f8ErGGzAesL pl/9sctMGLkt3klHNINT0ywG44Cw8D7/63jcRJkdMEW5+nvDx5JKLsO4JvPdPJ9OsgxI y8y0mpByp+EsWLEpTPg3in51Rx8bGAGmPnGgE5OFDeZbfTYFIDsoE68rzc7HMObT1xwS u2Y34yEwWuFkEFmxwByodtorNOFs89yAuwTF92iwISk4Mb6Osmku7f9TjJ0Hd4hrjPQH 3HQw== 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=rhJZpnLOBOQ02N5rKilhuEzxJdUJm5UkAKEws5ZBLPc=; b=nAAEQMEUhnmJtSHpJt3Cfvum8pEy0a684es+YRtZBwvImaIMyzu9kz3OhapTrD3AwP C22BB+w9nvH0S8pZk2irgdO/Vk3uTr1ETqQ1qjd3mfxdw7DcKJzhZ/d0wWgttac7kd7Y L1y0i6EL0ULEDV2Gy8pGXv3qNbPdpoWsjzDE3GQB4spZxOwbCuC0oeEaeeA8/tx1bf2B csphH7iNCxY5A/pYetV+3gBkwtmmmwwc8cXxs9ERFXkcDL71BEJ6ahT5DXQk9eicc3Kf 6HanHmvdfuFdIjk5szE3cjpXWY84MoeQ3SeX0WUL6VXtbstC+aeFjBf13f83kSFYSuDM g4bw== X-Gm-Message-State: APjAAAUI+y9iVdr93wH86v+78Le2TLAiqunxq1eKydTcHtOwWgW2cNIc xAzd0dGZLOTO7aGauQfpUKQ= X-Received: by 2002:a17:902:e08a:: with SMTP id cb10mr2172407plb.160.1556101267647; Wed, 24 Apr 2019 03:21:07 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id v19sm25051604pfn.62.2019.04.24.03.21.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Apr 2019 03:21:07 -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 13/28] locking/lockdep: Change the return type of __cq_dequeue() Date: Wed, 24 Apr 2019 18:19:19 +0800 Message-Id: <20190424101934.51535-14-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 With the change, we can slightly adjust the code to iterate the queue in BFS search, which simplifies the code. No functional change. Signed-off-by: Yuyang Du --- kernel/locking/lockdep.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 683aaf60..225eeeb 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -1302,14 +1302,21 @@ static inline int __cq_enqueue(struct circular_queue *cq, struct lock_list *elem return 0; } -static inline int __cq_dequeue(struct circular_queue *cq, struct lock_list **elem) +/* + * Dequeue an element from the circular_queue, return the lock if the queue + * is not empty, or NULL if otherwise + */ +static inline struct lock_list * __cq_dequeue(struct circular_queue *cq) { + struct lock_list * lock; + if (__cq_empty(cq)) - return -1; + return NULL; - *elem = cq->element[cq->front]; + lock = cq->element[cq->front]; cq->front = (cq->front + 1) & CQ_MASK; - return 0; + + return lock; } static inline unsigned int __cq_get_elem_count(struct circular_queue *cq) @@ -1361,6 +1368,7 @@ static int __bfs(struct lock_list *source_entry, int forward) { struct lock_list *entry; + struct lock_list *lock; struct list_head *head; struct circular_queue *cq = &lock_cq; int ret = 1; @@ -1382,10 +1390,7 @@ static int __bfs(struct lock_list *source_entry, __cq_init(cq); __cq_enqueue(cq, source_entry); - while (!__cq_empty(cq)) { - struct lock_list *lock; - - __cq_dequeue(cq, &lock); + while ((lock = __cq_dequeue(cq))) { if (!lock->class) { ret = -2; -- 1.8.3.1