aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/locking/lockdep.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/locking/lockdep.c')
-rw-r--r--kernel/locking/lockdep.c24
1 files 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,
1262#define CQ_MASK (MAX_CIRCULAR_QUEUE_SIZE-1) 1262#define CQ_MASK (MAX_CIRCULAR_QUEUE_SIZE-1)
1263 1263
1264/* 1264/*
1265 * The circular_queue and helpers is used to implement the 1265 * The circular_queue and helpers are used to implement graph
1266 * breadth-first search(BFS)algorithem, by which we can build 1266 * breadth-first search (BFS) algorithm, by which we can determine
1267 * the shortest path from the next lock to be acquired to the 1267 * whether there is a path from a lock to another. In deadlock checks,
1268 * previous held lock if there is a circular between them. 1268 * a path from the next lock to be acquired to a previous held lock
1269 * indicates that adding the <prev> -> <next> lock dependency will
1270 * produce a circle in the graph. Breadth-first search instead of
1271 * depth-first search is used in order to find the shortest (circular)
1272 * path.
1269 */ 1273 */
1270struct circular_queue { 1274struct circular_queue {
1271 unsigned long element[MAX_CIRCULAR_QUEUE_SIZE]; 1275 struct lock_list *element[MAX_CIRCULAR_QUEUE_SIZE];
1272 unsigned int front, rear; 1276 unsigned int front, rear;
1273}; 1277};
1274 1278
@@ -1294,7 +1298,7 @@ static inline int __cq_full(struct circular_queue *cq)
1294 return ((cq->rear + 1) & CQ_MASK) == cq->front; 1298 return ((cq->rear + 1) & CQ_MASK) == cq->front;
1295} 1299}
1296 1300
1297static inline int __cq_enqueue(struct circular_queue *cq, unsigned long elem) 1301static inline int __cq_enqueue(struct circular_queue *cq, struct lock_list *elem)
1298{ 1302{
1299 if (__cq_full(cq)) 1303 if (__cq_full(cq))
1300 return -1; 1304 return -1;
@@ -1304,7 +1308,7 @@ static inline int __cq_enqueue(struct circular_queue *cq, unsigned long elem)
1304 return 0; 1308 return 0;
1305} 1309}
1306 1310
1307static inline int __cq_dequeue(struct circular_queue *cq, unsigned long *elem) 1311static inline int __cq_dequeue(struct circular_queue *cq, struct lock_list **elem)
1308{ 1312{
1309 if (__cq_empty(cq)) 1313 if (__cq_empty(cq))
1310 return -1; 1314 return -1;
@@ -1382,12 +1386,12 @@ static int __bfs(struct lock_list *source_entry,
1382 goto exit; 1386 goto exit;
1383 1387
1384 __cq_init(cq); 1388 __cq_init(cq);
1385 __cq_enqueue(cq, (unsigned long)source_entry); 1389 __cq_enqueue(cq, source_entry);
1386 1390
1387 while (!__cq_empty(cq)) { 1391 while (!__cq_empty(cq)) {
1388 struct lock_list *lock; 1392 struct lock_list *lock;
1389 1393
1390 __cq_dequeue(cq, (unsigned long *)&lock); 1394 __cq_dequeue(cq, &lock);
1391 1395
1392 if (!lock->class) { 1396 if (!lock->class) {
1393 ret = -2; 1397 ret = -2;
@@ -1411,7 +1415,7 @@ static int __bfs(struct lock_list *source_entry,
1411 goto exit; 1415 goto exit;
1412 } 1416 }
1413 1417
1414 if (__cq_enqueue(cq, (unsigned long)entry)) { 1418 if (__cq_enqueue(cq, entry)) {
1415 ret = -1; 1419 ret = -1;
1416 goto exit; 1420 goto exit;
1417 } 1421 }