Commit a4f10cfd authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] convert pdflush to kthread

From: Keith Owens <kaos@sgi.com>

New pdflush threads are launched on-demand by pdflush.

It turns out that on some architectures (eg, ia64) a kernel thread inherits
its parent's stack utilisation.  So after the thread-launches-a-thread
cycle has progressed sufficiently far we run out of stack space and crash.

Simple fix: convert pdflush to use kthreads.  All kthreads are parented by
keventd so there is no stack windup as a result of pdflush launching
pdflush.
parent c8e6164f
...@@ -5,6 +5,9 @@ ...@@ -5,6 +5,9 @@
* *
* 09Apr2002 akpm@zip.com.au * 09Apr2002 akpm@zip.com.au
* Initial version * Initial version
* 29Feb2004 kaos@sgi.com
* Move worker thread creation to kthread to avoid chewing
* up stack space with nested calls to kernel_thread.
*/ */
#include <linux/sched.h> #include <linux/sched.h>
...@@ -17,6 +20,7 @@ ...@@ -17,6 +20,7 @@
#include <linux/suspend.h> #include <linux/suspend.h>
#include <linux/fs.h> // Needed by writeback.h #include <linux/fs.h> // Needed by writeback.h
#include <linux/writeback.h> // Prototypes pdflush_operation() #include <linux/writeback.h> // Prototypes pdflush_operation()
#include <linux/kthread.h>
/* /*
...@@ -86,8 +90,6 @@ struct pdflush_work { ...@@ -86,8 +90,6 @@ struct pdflush_work {
static int __pdflush(struct pdflush_work *my_work) static int __pdflush(struct pdflush_work *my_work)
{ {
daemonize("pdflush");
current->flags |= PF_FLUSHER; current->flags |= PF_FLUSHER;
my_work->fn = NULL; my_work->fn = NULL;
my_work->who = current; my_work->who = current;
...@@ -207,7 +209,7 @@ int pdflush_operation(void (*fn)(unsigned long), unsigned long arg0) ...@@ -207,7 +209,7 @@ int pdflush_operation(void (*fn)(unsigned long), unsigned long arg0)
static void start_one_pdflush_thread(void) static void start_one_pdflush_thread(void)
{ {
kernel_thread(pdflush, NULL, CLONE_KERNEL); kthread_run(pdflush, NULL, "pdflush");
} }
static int __init pdflush_init(void) static int __init pdflush_init(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment