Skip to contentSkip to conversation

thinkpad_acpi: moved hotkey_thread_mutex lock after set_freezable()

PATCH In review Artem Savkov 2 participants 3 messages Feb 24, 2013 – Feb 26, 2013 x86 platform drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 thinkpad_acpi: moved hotkey_thread_mutex lock after set_freezable()

set_freezable() checks freezing during which no locks should be held. hotkey_thread_mutex lock should be moved closer to where it is actually needed.

---
 drivers/platform/x86/thinkpad_acpi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/platform/x86/thinkpad_acpi.c +3 -3
index 22d8936..ffed96cd 100644
@@ -2463,13 +2463,13 @@ static int hotkey_kthread(void *data)
 	unsigned int poll_freq;
 	bool was_frozen;
 
-	mutex_lock(&hotkey_thread_mutex);
-
 	if (tpacpi_lifecycle == TPACPI_LIFE_EXITING)
 		goto exit;
 
 	set_freezable();
 
+	mutex_lock(&hotkey_thread_mutex);
+
 	so = 0;
 	si = 1;
 	t = 0;
@@ -2523,8 +2523,8 @@ static int hotkey_kthread(void *data)
 		si ^= 1;
 	}
 
-exit:
 	mutex_unlock(&hotkey_thread_mutex);
+exit:
 	return 0;
 }
 
Signature · 1 line
1.8.1.4
#1 lore raw
Quoted 3 lines · On Sun, 24 Feb 2013 13:22:02 +0400 Artem Savkov <[email protected]> wrote:

set_freezable() checks freezing during which no locks should be held. hotkey_thread_mutex lock should be moved closer to where it is actually needed.

Thanks.

When fixing a bug, we always like to see a full description of that bug so we can better work out which kernel versions need the fix.

Did you actually hit a lockup because of this? Or was it just from code inspection? Or ... ?

#2 lore raw
Quoted 11 lines · Andrew Morton
Quoted 3 lines · On Sun, 24 Feb 2013 13:22:02 +0400 Artem Savkov <[email protected]> wrote:

set_freezable() checks freezing during which no locks should be held. hotkey_thread_mutex lock should be moved closer to where it is actually needed.

Thanks.

When fixing a bug, we always like to see a full description of that bug so we can better work out which kernel versions need the fix.

Sorry, will do thah in future.

Quoted 2 lines

Did you actually hit a lockup because of this? Or was it just from code inspection? Or ... ?

I didn't hit an actual lockup, but I did hit a warning during boot. The warning was added by "lockdep: check that no locks held at freeze time" patch (2f2ff7b8979c50491b3cbce622d7bea4d44a8682 in linux-next.git)

Signature · 2 lines
Kind regards,
Artem