From b2b4af01d2f8789b89bf92be0474dbf6a071734a Mon Sep 17 00:00:00 2001 From: Josef 'Jeff' Sipek Date: Thu, 8 Dec 2011 22:25:34 -0500 Subject: [PATCH] cp: use sclp_msg to output information about locking badness Signed-off-by: Josef 'Jeff' Sipek --- cp/nucleus/ldep.c | 58 ++++++++++++++++--------------------------------------- 1 file changed, 17 insertions(+), 41 deletions(-) diff --git a/cp/nucleus/ldep.c b/cp/nucleus/ldep.c index 6f679da..df2197a 100644 --- a/cp/nucleus/ldep.c +++ b/cp/nucleus/ldep.c @@ -5,6 +5,7 @@ * details. */ +#include #include #include #include @@ -13,10 +14,6 @@ static spinlock_t __lock = SPIN_LOCK_UNLOCKED; static int ldep_enabled; -#define PBSIZE PAGE_SIZE -static char pbuf[PBSIZE]; -static int plen; - void ldep_on() { unsigned long mask; @@ -31,10 +28,9 @@ static int __get_stack_slot() current->nr_locks++; if (current->nr_locks == LDEP_STACK_SIZE) { - plen += snprintf(pbuf+plen, PBSIZE-plen, - "task '%s' exceeded the number of tracked " - "locks (%d)! disabling ldep!\n", current->name, - LDEP_STACK_SIZE); + sclp_msg("task '%s' exceeded the number of tracked " + "locks (%d)! disabling ldep!\n", current->name, + LDEP_STACK_SIZE); return 1; } @@ -43,26 +39,18 @@ static int __get_stack_slot() static void ldep_warn_head(char *lockname, void *addr) { - plen += snprintf(pbuf+plen, PBSIZE-plen, - "task '%s' is trying to acquire lock:\n", - current->name); - plen += snprintf(pbuf+plen, PBSIZE-plen, - " (%s), at: %p\n\n", lockname, addr); + sclp_msg("task '%s' is trying to acquire lock:\n", current->name); + sclp_msg(" (%s), at: %p\n\n", lockname, addr); } static void ldep_warn_recursive(char *lockname, void *addr, struct held_lock *held) { - plen = 0; - - plen += snprintf(pbuf+plen, PBSIZE-plen, - "[INFO: possible recursive locking detected]\n"); + sclp_msg("[INFO: possible recursive locking detected]\n"); ldep_warn_head(lockname, addr); - plen += snprintf(pbuf+plen, PBSIZE-plen, - "but task is already holding lock:\n\n"); - plen += snprintf(pbuf+plen, PBSIZE-plen, - " (%s), at: %p\n\n", held->lockname, held->ra); + sclp_msg("but task is already holding lock:\n\n"); + sclp_msg(" (%s), at: %p\n\n", held->lockname, held->ra); } static void print_held_locks() @@ -70,13 +58,10 @@ static void print_held_locks() struct held_lock *cur; int i; - plen += snprintf(pbuf+plen, PBSIZE-plen, - "\nlocks currently held:\n"); + sclp_msg("\nlocks currently held:\n"); for(i=0; inr_locks; i++) { cur = ¤t->lock_stack[i]; - plen += snprintf(pbuf+plen, PBSIZE-plen, - " #%d: (%s), at %p\n", i, cur->lockname, - cur->ra); + sclp_msg(" #%d: (%s), at %p\n", i, cur->lockname, cur->ra); } } @@ -102,7 +87,6 @@ void ldep_lock(void *lock, struct lock_class *c, char *lockname) continue; ldep_warn_recursive(lockname, ra, cur); - BUG(); ldep_enabled = 0; goto out; } @@ -142,14 +126,10 @@ void ldep_unlock(void *lock, char *lockname) goto found; } - plen = 0; - plen += snprintf(pbuf+plen, PBSIZE-plen, - "task '%s' is trying to release lock it doesn't have:\n", - current->name); - plen += snprintf(pbuf+plen, PBSIZE-plen, - " (%s), at %p\n", lockname, ra); + sclp_msg("task '%s' is trying to release lock it doesn't have:\n", + current->name); + sclp_msg(" (%s), at %p\n", lockname, ra); print_held_locks(); - BUG(); ldep_enabled = 0; @@ -182,14 +162,10 @@ void ldep_no_locks() if (!current->nr_locks) goto out; - plen = 0; - plen += snprintf(pbuf+plen, PBSIZE-plen, - "task '%s' is holding a lock when it shouldn't have:\n", - current->name); - plen += snprintf(pbuf+plen, PBSIZE-plen, - " at %p\n", ra); + sclp_msg("task '%s' is holding a lock when it shouldn't have:\n", + current->name); + sclp_msg(" at %p\n", ra); print_held_locks(); - BUG(); ldep_enabled = 0; -- 2.11.4.GIT