From: Oleg Nesterov Date: Wed, 17 Jun 2009 23:27:45 +0000 (-0700) Subject: kthreads: rework kthread_stop() X-Git-Tag: v2.6.31-rc1~203 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=63706172f33;p=pandora-kernel.git kthreads: rework kthread_stop() Based on Eric's patch which in turn was based on my patch. kthread_stop() has the nasty problems: - it runs unpredictably long with the global semaphore held. - it deadlocks if kthread itself does kthread_stop() before it obeys the kthread_should_stop() request. - it is not useable if kthread exits on its own, see for example the ugly "wait_to_die:" hack in migration_thread() - it is not possible to just tell kthread it should stop, we must always wait for its exit. With this patch kthread() allocates all neccesary data (struct kthread) on its own stack, globals kthread_stop_xxx are deleted. ->vfork_done is used as a pointer into "struct kthread", this means kthread_stop() can easily wait for kthread's exit. Signed-off-by: Oleg Nesterov Cc: Christoph Hellwig Cc: "Eric W. Biederman" Cc: Ingo Molnar Cc: Pavel Emelyanov Cc: Rusty Russell Cc: Vitaliy Gusev Signed-off-by: Linus Torvalds --- Reading git-diff-tree failed