@@ -54,6 +54,9 @@ static void unlock_check(struct lock *l)
if (l->in_con_path && this_cpu()->con_suspend == 0)
lock_error(l, "Unlock con lock with console not suspended", 3);
+
+ if (this_cpu()->lock_depth == 0)
+ lock_error(l, "Releasing lock with 0 depth", 4);
}
#else
@@ -73,6 +76,7 @@ bool try_lock(struct lock *l)
if (__try_lock(l)) {
if (l->in_con_path)
this_cpu()->con_suspend++;
+ this_cpu()->lock_depth++;
return true;
}
return false;
@@ -101,6 +105,7 @@ void unlock(struct lock *l)
unlock_check(l);
lwsync();
+ this_cpu()->lock_depth--;
l->lock_val = 0;
if (l->in_con_path) {
@@ -54,6 +54,7 @@ struct cpu_thread {
struct trace_info *trace;
uint64_t save_r1;
void *icp_regs;
+ uint32_t lock_depth;
uint32_t con_suspend;
bool con_need_flush;
bool in_mcount;
We want to move to pollers being run inly when no lock is held so let's start recording lock depth. It will also be a useful debugging tool. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> --- core/lock.c | 5 +++++ include/cpu.h | 1 + 2 files changed, 6 insertions(+)