diff options
author | Damien Zammit <damien@zamaudio.com> | 2023-03-06 07:05:19 +0000 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-03-07 01:08:19 +0100 |
commit | f34f362ad7e01a769e154cc4053b6c9b9f07998f (patch) | |
tree | 29532c1f49cdea7016f3041aa1d66a38bf2d8e7d /kern | |
parent | 2b4486d281efc9ee70c3e23a416b6ca5c43ba6ca (diff) | |
download | gnumach-f34f362ad7e01a769e154cc4053b6c9b9f07998f.tar.gz gnumach-f34f362ad7e01a769e154cc4053b6c9b9f07998f.tar.bz2 gnumach-f34f362ad7e01a769e154cc4053b6c9b9f07998f.zip |
kern: Fix MACH_LOCK_MON lock monitoring debug
TESTED:
- by setting MACH_LOCK_MON to 1 in configfrag.ac
and running "show all slocks" in kdb
- does not break default configured kernel
Message-Id: <20230306070512.292715-1-damien@zamaudio.com>
Diffstat (limited to 'kern')
-rw-r--r-- | kern/lock.c | 4 | ||||
-rw-r--r-- | kern/lock.h | 5 | ||||
-rw-r--r-- | kern/lock_mon.c | 8 | ||||
-rw-r--r-- | kern/thread.h | 4 |
4 files changed, 17 insertions, 4 deletions
diff --git a/kern/lock.c b/kern/lock.c index 81c6a129..f076c328 100644 --- a/kern/lock.c +++ b/kern/lock.c @@ -673,7 +673,11 @@ void db_show_all_slocks(void) #else /* MACH_SLOCKS && NCPUS == 1 */ void db_show_all_slocks(void) { +#if MACH_LOCK_MON + lip(); +#else db_printf("simple lock info not available\n"); +#endif } #endif /* MACH_SLOCKS && NCPUS == 1 */ #endif /* MACH_KDB */ diff --git a/kern/lock.h b/kern/lock.h index 4fcbe8ab..48976196 100644 --- a/kern/lock.h +++ b/kern/lock.h @@ -39,6 +39,11 @@ #if NCPUS > 1 #include <machine/lock.h>/*XXX*/ +#if MACH_LOCK_MON == 0 +#define simple_lock _simple_lock +#define simple_lock_try _simple_lock_try +#define simple_unlock _simple_unlock +#endif #endif #define MACH_SLOCKS ((NCPUS > 1) || MACH_LDEBUG) diff --git a/kern/lock_mon.c b/kern/lock_mon.c index a963ec05..bb446b7a 100644 --- a/kern/lock_mon.c +++ b/kern/lock_mon.c @@ -45,7 +45,8 @@ #include <mach/boolean.h> #include <kern/thread.h> #include <kern/lock.h> - +#include <machine/ipl.h> +#include <ddb/db_sym.h> def_simple_lock_data(extern , kdb_lock) def_simple_lock_data(extern , printf_lock) @@ -93,7 +94,6 @@ decl_simple_lock_data(, **lock) { struct lock_info *li = &(lock_info[HASH_LOCK(*lock)].info[0]); int i; - my_cpu = cpu_number(); for (i=0; i < LOCK_INFO_PER_BUCKET; i++, li++) if (li->lock) { @@ -114,7 +114,7 @@ void simple_lock(lock) decl_simple_lock_data(, *lock) { struct lock_info *li = locate_lock_info(&lock); - my_cpu = cpu_number(); + int my_cpu = cpu_number(); if (current_thread()) li->stack = current_thread()->lock_stack++; @@ -133,7 +133,7 @@ int simple_lock_try(lock) decl_simple_lock_data(, *lock) { struct lock_info *li = locate_lock_info(&lock); - my_cpu = cpu_number(); + int my_cpu = cpu_number(); if (curr_ipl[my_cpu]) li->masked++; diff --git a/kern/thread.h b/kern/thread.h index a5abefcc..f8232d1a 100644 --- a/kern/thread.h +++ b/kern/thread.h @@ -229,6 +229,10 @@ struct thread { #if NCPUS > 1 processor_t last_processor; /* processor this last ran on */ #endif /* NCPUS > 1 */ + +#if MACH_LOCK_MON + int lock_stack; +#endif }; /* typedef of thread_t is in kern/kern_types.h */ |