From mboxrd@z Thu Jan 1 00:00:00 1970 From: Oleg Nesterov Subject: [PATCH 0/1] thinkpad-acpi: kill hotkey_thread_mutex Date: Thu, 7 Mar 2013 18:53:05 +0100 Message-ID: <20130307175305.GA15631@redhat.com> References: <201303042055.38040.maciej.rutecki@gmail.com> <1362504883-9180-1-git-send-email-msb@chromium.org> <20130305174838.GA7276@redhat.com> <20130305180542.GA12738@redhat.com> <20130305232603.GA16045@khazad-dum.debian.net> <20130306154420.GA7697@redhat.com> <20130306233232.GA12645@khazad-dum.debian.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <20130306233232.GA12645-ZGHd14iZgfaRjzvQDGKj+xxZW9W5cXbT@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ibm-acpi-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org To: Henrique de Moraes Holschuh Cc: Aaron Lu , ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org, Mandeep Singh Baines , ibm-acpi-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org, Linux Kernel Mailing List , platform-driver-x86-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-acpi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Tejun Heo , Andrew Morton List-Id: linux-acpi@vger.kernel.org On 03/06, Henrique de Moraes Holschuh wrote: > > On Wed, 06 Mar 2013, Oleg Nesterov wrote: > > > > 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); > > } > > } > > > > 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. > 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