Mercurial > hvf > hvf-old
changeset 505:b1c6346f553c
cp: ldep should check for recursive locking
Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Sat, 23 Apr 2011 14:16:31 -0400 |
parents | bb72b65e387c |
children | 5cb01f04b0eb |
files | cp/include/ldep.h cp/nucleus/ldep.c |
diffstat | 2 files changed, 37 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/cp/include/ldep.h Fri Apr 22 15:43:29 2011 -0400 +++ b/cp/include/ldep.h Sat Apr 23 14:16:31 2011 -0400 @@ -11,9 +11,10 @@ #define LDEP_STACK_SIZE 10 struct held_lock { - void *ra; /* return address */ - void *lock; /* the lock */ - char *lockname; /* name of this lock */ + void *ra; /* return address */ + void *lock; /* the lock */ + char *lockname; /* name of this lock */ + struct lock_class *lclass; /* the class for this lock */ }; struct lock_class {
--- a/cp/nucleus/ldep.c Fri Apr 22 15:43:29 2011 -0400 +++ b/cp/nucleus/ldep.c Sat Apr 23 14:16:31 2011 -0400 @@ -36,6 +36,23 @@ return 0; } +static void ldep_warn_head(char *lockname, void *addr) +{ + con_printf(NULL, "task '%s' is trying to acquire lock:\n", + current->name); + con_printf(NULL, " (%s), at: %p\n\n", lockname, addr); +} + +static void ldep_warn_recursive(char *lockname, void *addr, struct held_lock *held) +{ + con_printf(NULL, "[INFO: possible recursive locking detected]\n"); + + ldep_warn_head(lockname, addr); + + con_printf(NULL, "but task is already holding lock:\n\n"); + con_printf(NULL, " (%s), at: %p\n\n", held->lockname, held->ra); +} + static void print_held_locks() { struct held_lock *cur; @@ -54,6 +71,8 @@ void *ra = __builtin_return_address(0); struct held_lock *cur; unsigned long mask; +// int ret; + int i; // LOCK spin_lock_intsave(&__lock, &mask); @@ -61,6 +80,19 @@ if (!ldep_enabled) goto out; + if (current->nr_locks) { + /* check for recursive locking */ + for(i=0; i<current->nr_locks; i++) { + cur = ¤t->lock_stack[i]; + if (cur->lclass != c) + continue; + + ldep_warn_recursive(lockname, ra, cur); + ldep_enabled = 0; + goto out; + } + } + /* ok, no issues, add the lock we're trying to get to the stack */ if (__get_stack_slot()) goto out; @@ -69,6 +101,7 @@ cur->ra = ra; cur->lock = lock; cur->lockname = lockname; + cur->lclass = c; out: // UNLOCK