shithub: riscv

Download patch

ref: 1b44caa0c40d7b722a7d9edd0a6eaefe1616c4b0
parent: a597496b19993379ad2cde4d7dd11e20b2122c00
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Apr 6 12:42:27 EDT 2024

kernel: print warning in rlock() and wlock() when we hold spinlocks

Just like for qlock(), print a warning when
the process calls rlock() and wlock() while
holding a spinlock.

--- a/sys/src/9/port/qlock.c
+++ b/sys/src/9/port/qlock.c
@@ -153,6 +153,11 @@
 {
 	Proc *p;
 
+	if(m->ilockdepth != 0)
+		print("rlock: %#p: ilockdepth %d\n", getcallerpc(&q), m->ilockdepth);
+	if(up != nil && up->nlocks)
+		print("rlock: %#p: nlocks %d\n", getcallerpc(&q), up->nlocks);
+
 	lock(&q->use);
 	rwstats.rlock++;
 	if(q->writer == 0 && q->head == nil){
@@ -208,6 +213,11 @@
 	uintptr pc;
 
 	pc = getcallerpc(&q);
+
+	if(m->ilockdepth != 0)
+		print("wlock: %#p: ilockdepth %d\n", pc, m->ilockdepth);
+	if(up != nil && up->nlocks)
+		print("wlock: %#p: nlocks %d\n", pc, up->nlocks);
 
 	lock(&q->use);
 	rwstats.wlock++;