Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp448159yba; Wed, 24 Apr 2019 04:13:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqyBjsoFGIWBe+SJPv6cgZ6iOWn6jc209yqV3WVx2AzSs1dTMaCiJE2vboajL6Gt/BqhytGG X-Received: by 2002:a17:902:54c:: with SMTP id 70mr32259408plf.210.1556104384145; Wed, 24 Apr 2019 04:13:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556104384; cv=none; d=google.com; s=arc-20160816; b=vg9NpMQEuVkWfkppbxWC2rjFZ3a118aYMb+zEMN8/LsySdrWLLKrVfj1XoCRkBkQwS jQy+3Pah51IrEKlRMjFxBZRtKeYeLMNrVkogzY5jTzUeUvCECfYY2jIIPXqNbNVMavSN hqNgK9G8dF7KyUyQzJ1sMaUMZldXP87S858OP/yxSsl2DXT58uruPja6+g1BqAYRNd13 MWnBmJJ2xF3RrIn7X7dW9jIIDp7AhoHBudZ46IkPkSGT9i2mmrl/nuEaqXRO655Z3Qa7 yb1q5dktG1J9FLhW7nQY+wRe5E0z5WX/Y/v0Ct/89+6XeoephsNLF3Mt4Ty2G0IDIZa3 zYcg== 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=B0zIug3byHnqFY6zU5sDm8sMZPCbIfr9tms2OJ2D7bM=; b=bf438rQndPcjvNGkS/kIDDD92Sa1+CozPLFZefljAMUaZo/CUhexCl4utfxaiqS+4q ZtrpC+w6woTWc1ilZtfgVpoqVVU0zt3edm+g43RLe6p7gxSzC6/P7fCIAfLSFe5HaL90 2HGVcpjwGe7DGkAH9PnxhgvV4LTBT0KZ5k6TLHYHUMqKpLiqjuppKRYECW3YJeyqqClh sQ5kVm0OFl4flQ68QgdUs83ZLCPgHVnM4FXGwpqLWSI7fvwPQd9hKdd7HztVv3fmid2T I/bw9bO+czXY3FMGOxcavyEoOxTKxx9jTksclZZjhyHY0wt9Q6wUywxHsdG2hniQZP4f zsSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=modEms7k; 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 o4si16733699pgp.160.2019.04.24.04.12.48; Wed, 24 Apr 2019 04:13:04 -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=modEms7k; 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 S1729953AbfDXKWu (ORCPT + 99 others); Wed, 24 Apr 2019 06:22:50 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:39631 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728141AbfDXKVF (ORCPT ); Wed, 24 Apr 2019 06:21:05 -0400 Received: by mail-pg1-f195.google.com with SMTP id l18so9032719pgj.6 for ; Wed, 24 Apr 2019 03:21:04 -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=B0zIug3byHnqFY6zU5sDm8sMZPCbIfr9tms2OJ2D7bM=; b=modEms7kAWuIj4U05MaCKH7+t44MS4tmNh9qXirSBnDawIXj80b+oBRyWdBq4FAqhY DVZtrlSdsbVTGZ/zwaBSpxdw1cLq78S/Scury6erBjmLOvNN8N+AW3/X7FccCfj1ISOk tT1kMgBvG6j9axARhFrRvIeHtM4X/AvUH6JSUIDlQqiRigh/dJck72uTU4cvVKQbUeSH J2Hy4KM8XgYB1aVqGYG7Jp4GhKVXzA09toczw4zhN5anRwaKR+uKjJo4w+z5JwxmsZc9 jMTQnyDa/bFLN3oMXMGcc9x8LSc58Nil67MuTtzyK5iKvBvEaIBIAw5d2XCBlXQE6cYU 7upQ== 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=B0zIug3byHnqFY6zU5sDm8sMZPCbIfr9tms2OJ2D7bM=; b=BwR8AxNOWu0cs1Woe/7mywVDaCsU+FGJm2lFlJhdaeFeo/qbVMcFBzTZFYFnrVhC6d aFiLmWQfnJog/X4ToXgcAkOY+DgF/Z00Yi452w6jBg13z/IKctWJafuW+lhouAgEOnyu qVLzydRKFwPLeYB2TG5IwbeComfILOrHT9Yij4F6kgTNdgqkIyYisXdWIxkRU4VesyEj pKXkXAPxSVXCFzSBKLGCoyMZANOUB+xzPRfZY6pvfi8m7/9mGFSarkrR1/RKeOnoVg/a oS2Za9b3LXEGyWiBmukAvqi9v5VKmB9rvWRVOpXo26WhYuVtbvoSn2jYdfSh4YGg+5/D 5XeA== X-Gm-Message-State: APjAAAWOZzACbFgU24AAes8EAWqFrea4qGOvPpvJVbyQjCum7Z8zUE0r a8W1p/xLUoyOWxfoq/Z/9GA= X-Received: by 2002:a62:6c43:: with SMTP id h64mr32818844pfc.123.1556101264605; Wed, 24 Apr 2019 03:21:04 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id v19sm25051604pfn.62.2019.04.24.03.21.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Apr 2019 03:21:04 -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 12/28] locking/lockdep: Change type of the element field in circular_queue Date: Wed, 24 Apr 2019 18:19:18 +0800 Message-Id: <20190424101934.51535-13-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 The element field is an array in struct circular_queue to keep track of locks in the search. Making it the same type as the locks avoids type cast. Also fix a typo and elaborate the comment above struct circular_queue. No functional change. Signed-off-by: Yuyang Du Reviewed-by: Bart Van Assche --- kernel/locking/lockdep.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 0543872..683aaf60 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -1257,13 +1257,16 @@ static int add_lock_to_list(struct lock_class *this, #define CQ_MASK (MAX_CIRCULAR_QUEUE_SIZE-1) /* - * The circular_queue and helpers is used to implement the - * breadth-first search(BFS)algorithem, by which we can build - * the shortest path from the next lock to be acquired to the - * previous held lock if there is a circular between them. + * The circular_queue and helpers are used to implement the graph + * breadth-first search (BFS) algorithm, by which we can determine whether + * there is a path from the next lock to be acquired to a previous held + * lock, which indicates that adding the -> lock dependency + * produces a circle in the lock dependency graph. Breadth-first search + * instead of depth-first search is used for finding the shortest circular + * path. */ struct circular_queue { - unsigned long element[MAX_CIRCULAR_QUEUE_SIZE]; + struct lock_list *element[MAX_CIRCULAR_QUEUE_SIZE]; unsigned int front, rear; }; @@ -1289,7 +1292,7 @@ static inline int __cq_full(struct circular_queue *cq) return ((cq->rear + 1) & CQ_MASK) == cq->front; } -static inline int __cq_enqueue(struct circular_queue *cq, unsigned long elem) +static inline int __cq_enqueue(struct circular_queue *cq, struct lock_list *elem) { if (__cq_full(cq)) return -1; @@ -1299,7 +1302,7 @@ static inline int __cq_enqueue(struct circular_queue *cq, unsigned long elem) return 0; } -static inline int __cq_dequeue(struct circular_queue *cq, unsigned long *elem) +static inline int __cq_dequeue(struct circular_queue *cq, struct lock_list **elem) { if (__cq_empty(cq)) return -1; @@ -1377,12 +1380,12 @@ static int __bfs(struct lock_list *source_entry, goto exit; __cq_init(cq); - __cq_enqueue(cq, (unsigned long)source_entry); + __cq_enqueue(cq, source_entry); while (!__cq_empty(cq)) { struct lock_list *lock; - __cq_dequeue(cq, (unsigned long *)&lock); + __cq_dequeue(cq, &lock); if (!lock->class) { ret = -2; @@ -1406,7 +1409,7 @@ static int __bfs(struct lock_list *source_entry, goto exit; } - if (__cq_enqueue(cq, (unsigned long)entry)) { + if (__cq_enqueue(cq, entry)) { ret = -1; goto exit; } -- 1.8.3.1