From: tip-bot for Yuyang Du <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: bvanassche@acm.org, tglx@linutronix.de, mingo@kernel.org,
peterz@infradead.org, torvalds@linux-foundation.org,
hpa@zytor.com, linux-kernel@vger.kernel.org, duyuyang@gmail.com
Subject: [tip:locking/core] locking/lockdep: Change type of the element field in circular_queue
Date: Mon, 3 Jun 2019 06:14:22 -0700 [thread overview]
Message-ID: <tip-aa4807719e076bfb2dee9c96adf2c648e47d472f@git.kernel.org> (raw)
In-Reply-To: <20190506081939.74287-13-duyuyang@gmail.com>
Commit-ID: aa4807719e076bfb2dee9c96adf2c648e47d472f
Gitweb: https://git.kernel.org/tip/aa4807719e076bfb2dee9c96adf2c648e47d472f
Author: Yuyang Du <duyuyang@gmail.com>
AuthorDate: Mon, 6 May 2019 16:19:28 +0800
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 3 Jun 2019 11:55:45 +0200
locking/lockdep: Change type of the element field in circular_queue
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 <duyuyang@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: frederic@kernel.org
Cc: ming.lei@redhat.com
Cc: will.deacon@arm.com
Link: https://lkml.kernel.org/r/20190506081939.74287-13-duyuyang@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
kernel/locking/lockdep.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index a9799f9ed093..d467ba825dca 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -1262,13 +1262,17 @@ 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 graph
+ * breadth-first search (BFS) algorithm, by which we can determine
+ * whether there is a path from a lock to another. In deadlock checks,
+ * a path from the next lock to be acquired to a previous held lock
+ * indicates that adding the <prev> -> <next> lock dependency will
+ * produce a circle in the graph. Breadth-first search instead of
+ * depth-first search is used in order to find 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;
};
@@ -1294,7 +1298,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;
@@ -1304,7 +1308,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;
@@ -1382,12 +1386,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;
@@ -1411,7 +1415,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;
}
next prev parent reply other threads:[~2019-06-03 13:14 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-06 8:19 [PATCH v2 00/23] locking/lockdep: Small improvements Yuyang Du
2019-05-06 8:19 ` [PATCH v2 01/23] locking/lockdep: Change all print_*() return type to void Yuyang Du
2019-06-03 13:06 ` [tip:locking/core] " tip-bot for Yuyang Du
2019-05-06 8:19 ` [PATCH v2 02/23] locking/lockdep: Add description and explanation in lockdep design doc Yuyang Du
2019-06-03 13:07 ` [tip:locking/core] " tip-bot for Yuyang Du
2019-05-06 8:19 ` [PATCH v2 03/23] locking/lockdep: Adjust lock usage bit character checks Yuyang Du
2019-06-03 13:07 ` [tip:locking/core] " tip-bot for Yuyang Du
2019-05-06 8:19 ` [PATCH v2 04/23] locking/lockdep: Remove useless conditional macro Yuyang Du
2019-06-03 13:08 ` [tip:locking/core] " tip-bot for Yuyang Du
2019-05-06 8:19 ` [PATCH v2 05/23] locking/lockdep: Print the right depth for chain key colission Yuyang Du
2019-06-03 13:09 ` [tip:locking/core] locking/lockdep: Print the right depth for chain key collision tip-bot for Yuyang Du
2019-05-06 8:19 ` [PATCH v2 06/23] locking/lockdep: Update obsolete struct field description Yuyang Du
2019-06-03 13:09 ` [tip:locking/core] " tip-bot for Yuyang Du
2019-05-06 8:19 ` [PATCH v2 07/23] locking/lockdep: Use lockdep_init_task for task initiation consistently Yuyang Du
2019-06-03 13:10 ` [tip:locking/core] " tip-bot for Yuyang Du
2019-05-06 8:19 ` [PATCH v2 08/23] locking/lockdep: Define INITIAL_CHAIN_KEY for chain keys to start with Yuyang Du
2019-06-03 13:11 ` [tip:locking/core] " tip-bot for Yuyang Du
2019-05-06 8:19 ` [PATCH v2 09/23] locking/lockdep: Change the range of class_idx in held_lock struct Yuyang Du
2019-06-03 13:12 ` [tip:locking/core] " tip-bot for Yuyang Du
2019-05-06 8:19 ` [PATCH v2 10/23] locking/lockdep: Remove unused argument in validate_chain() and check_deadlock() Yuyang Du
2019-06-03 13:12 ` [tip:locking/core] " tip-bot for Yuyang Du
2019-05-06 8:19 ` [PATCH v2 11/23] locking/lockdep: Update comment Yuyang Du
2019-06-03 13:13 ` [tip:locking/core] " tip-bot for Yuyang Du
2019-05-06 8:19 ` [PATCH v2 12/23] locking/lockdep: Change type of the element field in circular_queue Yuyang Du
2019-06-03 13:14 ` tip-bot for Yuyang Du [this message]
2019-05-06 8:19 ` [PATCH v2 13/23] locking/lockdep: Change the return type of __cq_dequeue() Yuyang Du
2019-06-03 13:15 ` [tip:locking/core] " tip-bot for Yuyang Du
2019-05-06 8:19 ` [PATCH v2 14/23] locking/lockdep: Avoid constant checks in __bfs by using offset reference Yuyang Du
2019-06-03 13:15 ` [tip:locking/core] " tip-bot for Yuyang Du
2019-05-06 8:19 ` [PATCH v2 15/23] locking/lockdep: Update comments on dependency search Yuyang Du
2019-06-03 13:16 ` [tip:locking/core] " tip-bot for Yuyang Du
2019-05-06 8:19 ` [PATCH v2 16/23] locking/lockdep: Add explanation to lock usage rules in lockdep design doc Yuyang Du
2019-06-03 13:17 ` [tip:locking/core] " tip-bot for Yuyang Du
2019-05-06 8:19 ` [PATCH v2 17/23] locking/lockdep: Remove redundant argument in check_deadlock Yuyang Du
2019-06-03 13:18 ` [tip:locking/core] " tip-bot for Yuyang Du
2019-05-06 8:19 ` [PATCH v2 18/23] locking/lockdep: Remove unused argument in __lock_release Yuyang Du
2019-06-03 13:18 ` [tip:locking/core] " tip-bot for Yuyang Du
2019-05-06 8:19 ` [PATCH v2 19/23] locking/lockdep: Refactorize check_noncircular and check_redundant Yuyang Du
2019-06-03 13:19 ` [tip:locking/core] " tip-bot for Yuyang Du
2019-05-06 8:19 ` [PATCH v2 20/23] locking/lockdep: Check redundant dependency only when CONFIG_LOCKDEP_SMALL Yuyang Du
2019-06-03 13:20 ` [tip:locking/core] " tip-bot for Yuyang Du
2019-05-06 8:19 ` [PATCH v2 21/23] locking/lockdep: Consolidate lock usage bit initialization Yuyang Du
2019-06-03 13:20 ` [tip:locking/core] " tip-bot for Yuyang Du
2019-05-06 8:19 ` [PATCH v2 22/23] locking/lockdep: Adjust new bit cases in mark_lock Yuyang Du
2019-06-03 13:21 ` [tip:locking/core] " tip-bot for Yuyang Du
2019-05-06 8:19 ` [PATCH v2 23/23] locking/lockdep: Remove !dir in lock irq usage check Yuyang Du
2019-06-03 13:22 ` [tip:locking/core] " tip-bot for Yuyang Du
2019-05-08 8:55 ` [PATCH v2 00/23] locking/lockdep: Small improvements Peter Zijlstra
2019-05-09 0:50 ` Yuyang Du
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-aa4807719e076bfb2dee9c96adf2c648e47d472f@git.kernel.org \
--to=tipbot@zytor.com \
--cc=bvanassche@acm.org \
--cc=duyuyang@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox