Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4134313ybi; Mon, 3 Jun 2019 06:17:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqxLZwkQxXuduVw1GHXwpAI40RiOoZaop6gPSZgkFJM76wQifdbGrygjpUGSITjmZxxHD1l9 X-Received: by 2002:a17:90a:35c8:: with SMTP id r66mr29968874pjb.17.1559567851404; Mon, 03 Jun 2019 06:17:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559567851; cv=none; d=google.com; s=arc-20160816; b=fYZfphsOebn7Kzhqt4JmGoIW9b1cHBZ2bOCf6D0y5AjucaB7fGft+GL9/ves8NpMfb 0AEl4J6vqhV4mIXglsXn7VKLjOFSXMzEmLIi/XjkG430PlVE+gOpwtFjCSTflb/DDkpx EWt/XTgZhiTQJKIJyVyFQtT7gJGn0pvADSTRb4ETocmem+JcSEJ5HEG3X4OwZwYCbwNh 5A14d4roBugXy/7Wau4gt54H4O6BUQMw9hMCahb6PFWxu2Qh6FEOexzeqUnnwH3QGR7t qD9/0bZ1XrFbmW8vHKYzOp/NuM736m471RSQGA9HDTmCiDXwn+VRtEQSuNKavSQHC3P3 bKkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:dkim-signature:dkim-filter; bh=p0X1AcJdJsIH9G1aM0A4a9ivY9INZIElMqFTamOmf8A=; b=gGjXrurNrY9nFgFjU7fb6og52U3bqKZ5w3tBba2xyRi+In+A2KbSBp+v4QKhuMjsYH BcodabR6J/Sf+y2oYOgdY8Krg2r4pZdNITKDJQ0l9Ys1ejc4WRY+Nsus1lQ5eecpQsqy w0G2b9rTfSMkZBRFuIqUXkn/CLAm6bB89vtCf2KhEImlB4tmJpWxULNMKmA4QYGJp+md Y10hkCGSdadqUwyk3x9knQDTa3AOyxL3SsQYfOK+yYU/RvgH/lHvGjgU4Pmv8k2hJOWK MXWO0Dy4Sp41L1YDFYem6LxT5NddlQKVoEvHKKy+BbhaQYQFHKDPbl0DGopHhRGRXdM1 sn4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2019051801 header.b=Bm3XqfXz; 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=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h34si20039899pld.187.2019.06.03.06.17.13; Mon, 03 Jun 2019 06:17:31 -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=@zytor.com header.s=2019051801 header.b=Bm3XqfXz; 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=NONE dis=NONE) header.from=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728262AbfFCNPS (ORCPT + 99 others); Mon, 3 Jun 2019 09:15:18 -0400 Received: from terminus.zytor.com ([198.137.202.136]:52223 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728057AbfFCNPR (ORCPT ); Mon, 3 Jun 2019 09:15:17 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x53DF7P7606021 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Mon, 3 Jun 2019 06:15:07 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x53DF7P7606021 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019051801; t=1559567707; bh=p0X1AcJdJsIH9G1aM0A4a9ivY9INZIElMqFTamOmf8A=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=Bm3XqfXzkExifPlghCK5WVJ1HKcULIBePGjx8gXu/sJYxoFJVVZBKxHDcQ7S7J4F7 3kklfYSARpHAyaB7Y+l/bv3jAe14td2b403zF8/xtg/mvPMLUtCilaK4DdVLCyvJK7 cPHyQpsrKV2W+cDr4CgQDdSXd6vtsdEoW5QwkZ4YHIdHsHoPZYxlzJAbvnZwcDo9Xa ciriEoCAyNSxkHmKWgOvIMus6+2DwT5f5JYlQP6berbVQzwvrZUN5Is1+sjdOveYcK vkCCKhFP4k+LRzfZhm0oVFAqI7j/IFYiYoYy9/wpWBTBha0KPYrbGLOG4uY1N3zMqf yiAhrE475+Ffw== Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x53DF6PX606015; Mon, 3 Jun 2019 06:15:06 -0700 Date: Mon, 3 Jun 2019 06:15:06 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Yuyang Du Message-ID: Cc: duyuyang@gmail.com, linux-kernel@vger.kernel.org, mingo@kernel.org, tglx@linutronix.de, torvalds@linux-foundation.org, peterz@infradead.org, hpa@zytor.com Reply-To: peterz@infradead.org, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, tglx@linutronix.de, mingo@kernel.org, duyuyang@gmail.com, hpa@zytor.com In-Reply-To: <20190506081939.74287-14-duyuyang@gmail.com> References: <20190506081939.74287-14-duyuyang@gmail.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:locking/core] locking/lockdep: Change the return type of __cq_dequeue() Git-Commit-ID: c1661325597f68bc9e632c4fa9c86983d56fba4f X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-0.3 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_96_Q,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, FREEMAIL_FORGED_REPLYTO autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: c1661325597f68bc9e632c4fa9c86983d56fba4f Gitweb: https://git.kernel.org/tip/c1661325597f68bc9e632c4fa9c86983d56fba4f Author: Yuyang Du AuthorDate: Mon, 6 May 2019 16:19:29 +0800 Committer: Ingo Molnar CommitDate: Mon, 3 Jun 2019 11:55:46 +0200 locking/lockdep: Change the return type of __cq_dequeue() 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 Signed-off-by: Peter Zijlstra (Intel) Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: bvanassche@acm.org Cc: frederic@kernel.org Cc: ming.lei@redhat.com Cc: will.deacon@arm.com Link: https://lkml.kernel.org/r/20190506081939.74287-14-duyuyang@gmail.com Signed-off-by: Ingo Molnar --- 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 d467ba825dca..d23dcb47389e 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -1308,14 +1308,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 a lock_list 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) @@ -1367,6 +1374,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; @@ -1388,10 +1396,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;