Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp430375img; Thu, 21 Mar 2019 00:59:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqySMEk8O9ggGmN9akumpCkEJvnFyV/ZVrisciWzn7WJssYzjaD/gGxTfAG6nuf6T8WRGG1E X-Received: by 2002:a62:5385:: with SMTP id h127mr2034873pfb.10.1553155174995; Thu, 21 Mar 2019 00:59:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553155174; cv=none; d=google.com; s=arc-20160816; b=nuBEG5ThYrK2Ue99N6k2kKswLwwJ2db8UPn6abhC3O2l+GTxA6ajLn5OEGBDIb4Wcv HMdex6uvtmzeHoa9OxKtzug+Nqn9C5NT8X3kClA6AJNqw/uy+LL395nQpVhjFWpnPjh6 xjKz1fnVSN5vhnzdvaj/O8D2HG7W5Bz+o4Y4BEB7v4DSIEr5gaD8sNGudJcEtKEZesWv 4NAt0Zr2X2oB6BJZPgDMcOzLOsB74fwM50kkJQAcFwIZvNbvzDw+mhXa120ms3HS2rJR Mc9N/lSQ9KIHTrEaLHEBwPrYHkuip7zkjyWzgzGbcyJqBYMRTyU5goq/xG9XCpkYwLjF 6SvA== 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=rrxP6v+2lHMkCgAoQ19mxfczpqRbnf20CLXAc3lvVaA=; b=sxcxmrWrlrYriEclPagvXzmUXks+pWkKZydfoVX7/Stdz9Yvmk9GlmqG6BVRtvnsAC NChIQA/D2Q1JLNpKsWS4sNiZan7vIgdmYwFKemDwrhoyzY2ede6ow/RJQzFy5AEQIlxv CLosgdf0fquYleDM9s1clo0flLSAktZd44chn4F0ngj2uF/eRMldyHR16PYdDmHpxGjo ZB/YfcIrcFgDH6F+H0RsPGy9dFPysl3U5r/2Sszunei0t9rfpuvGHmHxX58/vVkycLk8 7N9IJdUCyyOkLnOq7Zz8FItohwlUXK/yyVClzlSmpemXXKIFM9UFVKp4bc7qhXRZEkhg l6Yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Yfe0aSmN; 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 n79si3639898pfb.133.2019.03.21.00.59.19; Thu, 21 Mar 2019 00:59:34 -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=Yfe0aSmN; 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 S1728096AbfCUH6T (ORCPT + 99 others); Thu, 21 Mar 2019 03:58:19 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:36717 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728069AbfCUH6Q (ORCPT ); Thu, 21 Mar 2019 03:58:16 -0400 Received: by mail-pf1-f194.google.com with SMTP id p10so3797689pff.3 for ; Thu, 21 Mar 2019 00:58:15 -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=rrxP6v+2lHMkCgAoQ19mxfczpqRbnf20CLXAc3lvVaA=; b=Yfe0aSmNuUQCCIOJcuTUO7ldovYy7X85yJQDCU/UQm7f+bzIef2d+Iuxx6el1kmABO v92fEfOskbiNPQmZZiTnG3ZNWrWEIm8hLcwHaLAR4OEzuQeeNkfKt85sr+7CGgCTrbSB t62xg6BBsQsmgfiivAbmOacF7P6xrPF7/92LUahGBggpcdXN+VC7kE4hXPS4Cp6TDNJA upPPcj6IXFd4lfTDgDU1wkms07/WqYtACvqGDQBBgPLhHHdwFRA1lrx3/D81CuDroVDk Wc281eIDZck6Y20bigYLOIcQhCmJViXDVnKj6OqnuS10AoiZxAg/YHh5zU4BPUthOeMD CiWQ== 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=rrxP6v+2lHMkCgAoQ19mxfczpqRbnf20CLXAc3lvVaA=; b=gcfdsnC1XFzDrOaZmF9lJP8hxyaJxCoNeSPlbro5dnZxMZdm46FYETQJ60dlRFKvEy a7g6faDZ78HVXBJqXqD3AoSml1cTHEBj8Y2ZYyOBpCgL1n+obG0gMS1A1qcARoxoOD0b CDY8feQWJ2p39ep2b+HXiDSBv+fz4BCLpNbwJkOjAWvF7KAersqIJhPKATXfganuFKkE 8cEA0Q7NJllkxy5aC0n8CvtvnU9Xhpcp9QXOzwBQQ+j/Ki8kl7hMmycaAQ3QWCg4gHOv ykFv8lYQ5LwpXDtXVFREA5NjFwq5+lVY9kZmKiaQfq1iFlEyFMAKFieNCOKqOdYXEKqb NM9A== X-Gm-Message-State: APjAAAXMXtFEh0ohmqO0o2PjX2WXJSvuG/zecnqcu9tP3Z6PgeJ4jwD3 hSLPhyY69tCHnLaF9T/pWYI= X-Received: by 2002:a62:ae13:: with SMTP id q19mr2028836pff.152.1553155095423; Thu, 21 Mar 2019 00:58:15 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id e184sm6467148pfc.143.2019.03.21.00.58.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Mar 2019 00:58:15 -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, joe@perches.com, Yuyang Du Subject: [PATCH v3 14/18] locking/lockdep: Change the return type of __cq_dequeue() Date: Thu, 21 Mar 2019 15:57:21 +0800 Message-Id: <20190321075725.14054-15-duyuyang@gmail.com> X-Mailer: git-send-email 2.17.2 (Apple Git-113) In-Reply-To: <20190321075725.14054-1-duyuyang@gmail.com> References: <20190321075725.14054-1-duyuyang@gmail.com> 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 8167d69..ad16793 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -1317,14 +1317,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) @@ -1376,6 +1383,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; @@ -1397,10 +1405,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