]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
locking/lockdep: Change the return type of __cq_dequeue()
authorYuyang Du <duyuyang@gmail.com>
Mon, 6 May 2019 08:19:29 +0000 (16:19 +0800)
committerIngo Molnar <mingo@kernel.org>
Mon, 3 Jun 2019 09:55:46 +0000 (11:55 +0200)
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 <duyuyang@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
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 <mingo@kernel.org>
kernel/locking/lockdep.c

index d467ba825dca3d7dfbbc97df3d4b691b5c9324fb..d23dcb47389e69107264df11d06d16ee76c7291b 100644 (file)
@@ -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;