Re: [PATCH 2/3] make kthread_create() more scalable
Oleg Nesterov <[EMAIL PROTECTED]> writes: > If kernel_thread(kthread) succeeds, kthread() can not fail on its path to > complete(&create->started) + schedule(). After that it can't be woken because > nobody can see the new task yet. This means: > > - we don't need tasklist_lock for find_task_by_pid(). Well we do need rcu_read_lock(); But if we are going to wait until the thread has run we can just pass back current. > - create_kthread() doesn't need to wait for create->started. Instead, > kthread_create() first waits for create->created to get the result of > kernel_thread(), then waits for create->started to synchronize with > kthread(). We can do even better. We only need a single completion. If it was an error create_create can complete it. Otherwise kthread() can complete it. Patch in a bit as soon as I finish testing... Eric - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/3] make kthread_create() more scalable
Andrew Morton <[EMAIL PROTECTED]> writes: > > OK, I fixed that up. > > The next patch (make-kthread_stop-scalable) removes the find_task_by_pid() > anyway. Ok. Neat. I still need to review these a little more I have a different set of criteria, but it is interesting work.. > Our kthread creation performance will be pretty poor anyway, due to the > need to do two (or more?) context switches. If we ever need > super-low-latency kernel thread creation (eg, on-demand threads for AIO) > then that code would need to go direct to kernel_thread(), I guess. Sure. AIO is a little bit of a different beast as it is IO for user space. If low latency is important for starting kernel threads the right answer would be to dig into the code and have a version rewrite kernel_thread so that we copied a reference process instead of the current. Right now my practical target is killing all of the kernel threads started with kernel_thread that then call daemonize. So we can remove daemonize, as it is a serious maintenance hazard. kthread needs just a little bit more work to support that. Eric - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/3] make kthread_create() more scalable
On Fri, 13 Apr 2007 15:51:29 -0600 [EMAIL PROTECTED] (Eric W. Biederman) wrote: > Andrew Morton <[EMAIL PROTECTED]> writes: > > > On Fri, 13 Apr 2007 17:02:01 +0400 > > Oleg Nesterov <[EMAIL PROTECTED]> wrote: > > > >> If kernel_thread(kthread) succeeds, kthread() can not fail on its path to > >> complete(&create->started) + schedule(). After that it can't be woken > >> because > >> nobody can see the new task yet. This means: > >> > >>- we don't need tasklist_lock for find_task_by_pid(). > >> > >>- create_kthread() doesn't need to wait for create->started. Instead, > >> kthread_create() first waits for create->created to get the result of > >> kernel_thread(), then waits for create->started to synchronize with > >> kthread(). > > > > Why don't we need tasklist_lock for find_task_by_pid()? I'd have though > > that > > we'd at least need rcu_read_lock(), and I'm not sure that the implicit > > understanding of pid-management internals here is a great idea. > > We need rcu_read_lock(). Or else something could permute the pid hash table > and get us into trouble. > OK, I fixed that up. The next patch (make-kthread_stop-scalable) removes the find_task_by_pid() anyway. Our kthread creation performance will be pretty poor anyway, due to the need to do two (or more?) context switches. If we ever need super-low-latency kernel thread creation (eg, on-demand threads for AIO) then that code would need to go direct to kernel_thread(), I guess. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/3] make kthread_create() more scalable
Andrew Morton <[EMAIL PROTECTED]> writes: > On Fri, 13 Apr 2007 17:02:01 +0400 > Oleg Nesterov <[EMAIL PROTECTED]> wrote: > >> If kernel_thread(kthread) succeeds, kthread() can not fail on its path to >> complete(&create->started) + schedule(). After that it can't be woken because >> nobody can see the new task yet. This means: >> >> - we don't need tasklist_lock for find_task_by_pid(). >> >> - create_kthread() doesn't need to wait for create->started. Instead, >>kthread_create() first waits for create->created to get the result of >>kernel_thread(), then waits for create->started to synchronize with >>kthread(). > > Why don't we need tasklist_lock for find_task_by_pid()? I'd have though that > we'd at least need rcu_read_lock(), and I'm not sure that the implicit > understanding of pid-management internals here is a great idea. We need rcu_read_lock(). Or else something could permute the pid hash table and get us into trouble. Eric - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/3] make kthread_create() more scalable
On Fri, 13 Apr 2007 17:02:01 +0400 Oleg Nesterov <[EMAIL PROTECTED]> wrote: > If kernel_thread(kthread) succeeds, kthread() can not fail on its path to > complete(&create->started) + schedule(). After that it can't be woken because > nobody can see the new task yet. This means: > > - we don't need tasklist_lock for find_task_by_pid(). > > - create_kthread() doesn't need to wait for create->started. Instead, > kthread_create() first waits for create->created to get the result of > kernel_thread(), then waits for create->started to synchronize with > kthread(). Why don't we need tasklist_lock for find_task_by_pid()? I'd have though that we'd at least need rcu_read_lock(), and I'm not sure that the implicit understanding of pid-management internals here is a great idea. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/