Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp240255img; Mon, 18 Mar 2019 01:59:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqzOUJ5nMY3ZjM7azWBbu4baxy6ANFdVjkY6zOZPH1VHC6gpdZyixgnuu4lD+vqNwDrZ7Bu0 X-Received: by 2002:a17:902:7610:: with SMTP id k16mr18390878pll.215.1552899585617; Mon, 18 Mar 2019 01:59:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552899585; cv=none; d=google.com; s=arc-20160816; b=yQgfJaDGGdj3cK4Q/yPuibTaG1urggEMs0ckjN4sQGrvWkUEDLd638c97BDj+vjVkB XxFKLJCF+HdTIsmrNAshP+0zVrhdFh5GT6nTg/ZlqH8D6Klfn5bHiAqtJ6ZVyy3ChRmx aQc3rwSj/wbCU7aTc9lWfY4klwCR0TNSe0vuJ/UQ3d9MrtuL9tMmJqfBxjx/yLidpI2W krRMgnk6KtsPVidT/k4d/1M6PhOd33F0eB7fKCpWIuunQDwrBS7lBKBqoa541MpdkNLL PIocnX6xMe9PCZbioUHwJopUOI6PAOWXsCP1RKTzT1/flCS7gVoQQcBytRwbjl4IHMYH HmOw== 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=z1HnwHwgfeXQ7XP8WlaW6BcJ+08knK59sSP1bt+0T7A=; b=oop4qdVBDCCIBCDZnmCKeRSKogFxe9w13rNPRrRouql9YaReMPDSvKvWl59odNCys4 NdAKiR0q6SchyqBuwAft0DDc/4MvLFN5Cr1E9Fdt25c0KgZYB8y809wokkuV5uOACBFc RzY3Tfm9i5WzuC6OkH7k7XiWQFqL882H0e01Sh7MuR1QGqUn1F0QPOGBtfucpEppLCil be1vNouFxRKzgeOkir9j6GTusxTSiju2u5slJy+vpl2mIYnc1OGRr5V3cQSBLcAsACVe 4SrDK7hdoAm7vXdHZtlm2+halIpR2pRSY1ePWx49Y3cdekrOAjHAdG2C9kC++dvyg2Z1 J9ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kqGLcFsD; 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 j26si9070620pfe.175.2019.03.18.01.59.30; Mon, 18 Mar 2019 01:59:45 -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=kqGLcFsD; 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 S1727502AbfCRI63 (ORCPT + 99 others); Mon, 18 Mar 2019 04:58:29 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:35286 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727493AbfCRI60 (ORCPT ); Mon, 18 Mar 2019 04:58:26 -0400 Received: by mail-pg1-f195.google.com with SMTP id g8so261478pgf.2 for ; Mon, 18 Mar 2019 01:58:25 -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=z1HnwHwgfeXQ7XP8WlaW6BcJ+08knK59sSP1bt+0T7A=; b=kqGLcFsDQ/VXqFdsppizRx9pVyQR7Kq9nE6zuYHPFtK0Nszdxf0OU3EYFrIbbEWoYf G2Y2j8zuxgEqGz9kFiHHfR1mgUI7Yim5pNsIt4x5fcJtYNNEpT2l28n3HY8KMIaZoKeY slzICrNyfwypOinG8IpfEnkBjCmhQHIgxbAOAyYIl8mJ6o45mksFUdvZGBW65lmOW47S +6mtYFQLuMkjEsBWXt3mXj7h9WAOZ2BTYdvdjKqddG5rBsc3imZ4a90nNRsTvbyfd6Nj 3iz6zr7vg2AHHqaeN8jDiiWZBA6JrXVPhFua8d+VkBH2QdLIeSnp1bMkm6e04yuUfom8 urMw== 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=z1HnwHwgfeXQ7XP8WlaW6BcJ+08knK59sSP1bt+0T7A=; b=c8WMlQCSIwo4VCqKLsKdFFnyRdFtpc3sDpTY10+EmfkfUm7HH7A8szp2LDznCQ0oNO Ow0QWB2l5L83ZJdg0FD3fICziwJ+AV5sdyZNSTf39vZxW5NUZ6+SkWa9GtQBrptHv/+N dXH8/A0GhL75KLfYGXgmQqhz1i4PppuxBpMauAW5c8v55QuqDr3lxe0JjDPSFA+TEo/Z NthyghquceEjwTKsi38Q5fnP0IT9jeOzqt+LvesNsEN1JsSaDCWokLgy0xL2tILjq6YC 0HgB7WiGXYfl7zM5BZZ6qnojIumQfrHE7hCKdRtWtfElVdfcMkTyhZ+vEC+H7lguXza8 0feg== X-Gm-Message-State: APjAAAXnQikidU3icTbdspFg7/9eYqmxaVGaU4txleQbd9vHgjWElfFD IXgqzm8FfLZZ/xBNuMMVeZY= X-Received: by 2002:aa7:9143:: with SMTP id 3mr18070202pfi.238.1552899505728; Mon, 18 Mar 2019 01:58:25 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id k8sm11147024pgq.37.2019.03.18.01.58.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Mar 2019 01:58:25 -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 15/19] locking/lockdep: Remove __cq_empty() Date: Mon, 18 Mar 2019 16:57:29 +0800 Message-Id: <20190318085733.3143-16-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 __cq_empty() can be embeded in __cq_dequeue(), removing it. We get slightly simpler code. No functional change. Signed-off-by: Yuyang Du --- kernel/locking/lockdep.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index a3fb112..ee8fe64 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -1297,11 +1297,6 @@ static inline void __cq_init(struct circular_queue *cq) lockdep_dependency_gen_id++; } -static inline int __cq_empty(struct circular_queue *cq) -{ - return (cq->front == cq->rear); -} - static inline int __cq_full(struct circular_queue *cq) { return ((cq->rear + 1) & CQ_MASK) == cq->front; @@ -1317,14 +1312,24 @@ 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) { - if (__cq_empty(cq)) - return -1; + struct lock_list * lock; - *elem = cq->element[cq->front]; + /* + * Is the circular_queue empty? + */ + if (cq->front == cq->rear) + return NULL; + + 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 +1381,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 +1403,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