Re: [PATCH] Add module_kernel_thread for threads that live in modules.

From: Rusty Russell (
Date: Mon Jun 16 2003 - 01:50:33 EST

Hi Neil,

        There are several problems with this patch. Ignoring the fact
that you use __module_get. Firstly, you bump the module count
permentantly while the thread is running: how does it ever get
unloaded? Secondly, modprobe becomes your parent.

        There have been ambitious attempts to do a nice "thread
creation and stopping" interface before. Given the delicate logic
involved in shutting threads down, I think this makes sense. Maybe
something like:

/* Struct which identifies a kernel thread, handed to creator and
   thread. */
struct kthread
        int pid;
        int should_die; /* Thread should exit when this is set. */

        /* User supplied arg... */
        void *arg;

struct kthread *create_thread(int (*fn)(struct kthread*), void *arg,
                              unsigned long flags,
                              const char *namefmt, ...);
void cleanup_thread(struct kthread *);

create_thread would use keventd to start the thread, and stop_thread
would tell keventd to set should_die, wmb(), wake it up, and
sys_wait() for it.


  Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

This archive was generated by hypermail 2b29 : Mon Jun 23 2003 - 22:00:17 EST