changeset 861:111936b70fcc

synch: minor mutex lock checking optimization This saves 23 bytes of instructions on amd64 which is not worth it, but we will need the out label for recursive lock policies anyway. Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Sat, 14 Jan 2023 13:44:43 -0500
parents 3c2e349df2d1
children 6075f43a5d72
files synch.c
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/synch.c	Fri Jan 13 11:03:28 2023 -0500
+++ b/synch.c	Sat Jan 14 13:44:43 2023 -0500
@@ -503,6 +503,10 @@
 	if (!atomic_read(&lockdep_on))
 		return;
 
+	held = last_acquired_lock();
+	if (!held)
+		goto out; /* nothing held, nothing to check */
+
 	/* check for deadlocks & recursive locking */
 	for_each_held_lock(i, held) {
 		if ((held->info != info) && (held->info->lc != info->lc))
@@ -516,6 +520,7 @@
 	if (check_circular_deps(info, where))
 		return;
 
+out:
 	held = held_stack_alloc();
 	if (!held) {
 		error_alloc(info, where, "lock nesting limit reached");