Skip to content

thinkpad-acpi: kill hotkey_thread_mutex

Oleg Nesterov linux-acpi lkml platform-driver-x86 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest1 patch 5 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/1thinkpad-acpi: kill hotkey_thread_mutexdrivers/platform/x86/thinkpad_acpi.c+0 -105 replies

Reviews trailers per patch

The patch has a Reviewed-by or Acked-by.

PatchMandeep Singh BainesHenrique de Moraes Holschuh
1/1R-b A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/1] thinkpad-acpi: kill hotkey_thread_mutex
Quoted 14 lines · Henrique de Moraes Holschuh
Quoted 12 lines · Oleg Nesterov
	static void hotkey_poll_stop_sync(void)
	{
		if (tpacpi_hotkey_task) {
			kthread_stop(tpacpi_hotkey_task);
			tpacpi_hotkey_task = NULL;
			mutex_lock(&hotkey_thread_mutex);
			/* at this point, the thread did exit */
			mutex_unlock(&hotkey_thread_mutex);
		}
	}
Quoted 7 lines
Quoted 3 lines

And I simply do not understand the comment. This thread has already exited when kthread_stop() returns (OK, it can be running do_exit() paths but this doesn't matter). So this mutex_lock() buys nothing afaics.

It was added due to an oops, waaaaay back then. If it is not needed anymore, and there is zero chance of the kthread still being active when hotkey_poll_stop_sync() ends, hotkey_thread_mutex can be simply removed.

Well, there could be another bug. Say, hotkey_poll_stop_sync() can block on hotkey_thread_mutex if another thread was started. But at first glance this can't happen (hotkey_mutex), and even _if_ it can this needs another fix.

Quoted 1 line

Looks like it, if the current semanthics of ktread_stop() are syncronous.

IIRC, it always was... But at least currently it is certainly syncronous. kthread_stop(t) does wait_for_completion(t->vfork_done), complete(vfork_done) can't happen unless this task calls do_exit().

Hmm. I just noticed that the recent changes in kthread_stop() are not correct... But this is offtopic and doesn't affect thinkpad_acpi.c, I'll write another email later.

So, what do you think about (UNTESTED) 1/1 ?

Oleg.

------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the endpoint security space. For insight on selecting the right partner to tackle endpoint security challenges, access the full report.
http://p.sf.net/sfu/symantec-dev2dev