summaryrefslogtreecommitdiff
path: root/sys/lockdoc/log.c
diff options
context:
space:
mode:
authorMerlin Scholz <merlin@scholz.ruhr>2023-03-16 03:03:49 +0100
committerMerlin Scholz <merlin@scholz.ruhr>2023-03-16 03:03:49 +0100
commitbf1ce4ce265b9f38a71f0bca82d8f0e8c055233a (patch)
tree35484e5bd2cfb7f8f1dc93d5b310e1870459fc50 /sys/lockdoc/log.c
parent1096504a73ba2e1c619ee0a8c8a5f091d17a71db (diff)
Implement file and line logging for mutex locks
This commit implements proper file and line logging as a proof of concept for mutex locks. The previous versions only logged the location inside the mutex_enter function, which was useless. To get correct filenames, calls to mutex_enter (which usually go directly to ASM) are replaced through the macro defined in lockdoc.h. This logs the according information and passes on the function call to the old ASM code. Furthermore, some other things like apm.c or patch.c had to be modified, to keep the code compilable, even with this new replacement macro. Also, the old logging methods in lockdebug.h have been removed, since we can not get the proper file and line by going through there. This commit only implements these changes for mutex_enter, mutex_spin_enter, mutex_exit and mutex_spin_exit, and serves as a template for changes in the other lock functions and types.
Diffstat (limited to 'sys/lockdoc/log.c')
-rw-r--r--sys/lockdoc/log.c48
1 files changed, 6 insertions, 42 deletions
diff --git a/sys/lockdoc/log.c b/sys/lockdoc/log.c
index 84aba0893f5..56815b93d75 100644
--- a/sys/lockdoc/log.c
+++ b/sys/lockdoc/log.c
@@ -79,9 +79,9 @@ void trace_irqs_on(struct trapframe *frame) {
cur_eflags = x86_read_flags();
if ((frame->tf_eflags & (1 << 9)) && !(cur_eflags & (1 << 9))) {
#ifdef DEBUG_TRAPS
- log_lock(V_WRITE, (struct lock_object*)PSEUDOLOCK_ADDR_HARDIRQ, __FILE__, __LINE__, frame->tf_trapno);
+ lockdoc_log_lock(V_WRITE, (struct lock_object*)PSEUDOLOCK_ADDR_HARDIRQ, __FILE__, __LINE__, frame->tf_trapno);
#else
- log_lock(V_WRITE, (struct lock_object*)PSEUDOLOCK_ADDR_HARDIRQ, __FILE__, __LINE__, LOCK_NONE);
+ lockdoc_log_lock(V_WRITE, (struct lock_object*)PSEUDOLOCK_ADDR_HARDIRQ, __FILE__, __LINE__, LOCK_NONE);
#endif
}
}
@@ -91,55 +91,19 @@ void trace_irqs_off(struct trapframe *frame) {
cur_eflags = x86_read_flags();
if ((frame->tf_eflags & (1 << 9)) && !(cur_eflags & (1 << 9))) {
#ifdef DEBUG_TRAPS
- log_lock(P_WRITE, (struct lock_object*)PSEUDOLOCK_ADDR_HARDIRQ, __FILE__, __LINE__, frame->tf_trapno);
+ lockdoc_log_lock(P_WRITE, (struct lock_object*)PSEUDOLOCK_ADDR_HARDIRQ, __FILE__, __LINE__, frame->tf_trapno);
#else
- log_lock(P_WRITE, (struct lock_object*)PSEUDOLOCK_ADDR_HARDIRQ, __FILE__, __LINE__, LOCK_NONE);
+ lockdoc_log_lock(P_WRITE, (struct lock_object*)PSEUDOLOCK_ADDR_HARDIRQ, __FILE__, __LINE__, LOCK_NONE);
#endif
}
}
-void lockdoc_alloc(const char *func, const char *file, size_t line, volatile void *lock, lockops_t *lo, uintptr_t initaddr){
-}
-
-void lockdoc_free(const char *func, const char *file, size_t line, volatile void *lock){
-}
-
-void lockdoc_wantlock(const char *func, const char *file, size_t line, const volatile void *lock, uintptr_t where, int shared){
-}
-
-void lockdoc_locked(const char *func, const char *file, size_t line, volatile void *lock, void *cvlock, uintptr_t where, int shared){
- // shared == 0 means exclusive (write) lock; shared > 0 means shared (read) lock
- if(shared > 0) {
- // TODO Check if LOCK_NONE is appropriate
- log_lock(P_READ, lock, file, line, LOCK_NONE);
- } else if (shared == 0){
- log_lock(P_WRITE, lock, file, line, LOCK_NONE);
- }
-}
-void lockdoc_unlocked(const char *func, const char *file, size_t line, volatile void *lock, uintptr_t where, int shared){
- // shared == 0 means exclusive (write) lock; shared > 0 means shared (read) lock
- if(shared > 0) {
- // TODO Check if LOCK_NONE is appropriate
- log_lock(V_READ, lock, file, line, LOCK_NONE);
- } else if (shared == 0){
- log_lock(V_WRITE, lock, file, line, LOCK_NONE);
- }
-}
-void lockdoc_barrier(const char *func, const char *file, size_t line, volatile void *spinlock, int slplocks){
-}
-
-void lockdoc_mem_check(const char *func, const char *file, size_t line, void *base, size_t sz){
-}
-
-void lockdoc_wakeup(const char *func, const char *file, size_t line, volatile void *lock, uintptr_t where){
-}
-
void __x86_disable_intr(const char *file, int line, const char *func){
u_long eflags;
eflags = x86_read_flags();
if (eflags & (1 << 9)){ // Check if interrupts were enabled in the first place
- log_lock(P_WRITE, (void*)PSEUDOLOCK_ADDR_HARDIRQ, file, line, LOCK_NONE);
+ lockdoc_log_lock(P_WRITE, (void*)PSEUDOLOCK_ADDR_HARDIRQ, file, line, LOCK_NONE);
}
lockdoc_x86_disable_intr();
}
@@ -158,7 +122,7 @@ void __x86_enable_intr(const char *file, int line, const char *func){
eflags = x86_read_flags();
if (!(eflags & (1 << 9))){ // Check if interrupts were disabled in the first place
- log_lock(V_WRITE, (void*)PSEUDOLOCK_ADDR_HARDIRQ, file, line, LOCK_NONE);
+ lockdoc_log_lock(V_WRITE, (void*)PSEUDOLOCK_ADDR_HARDIRQ, file, line, LOCK_NONE);
}
lockdoc_x86_enable_intr();
}