<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/kernel/kthread.c, branch v2.6.12.2</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v2.6.12.2</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v2.6.12.2'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2005-05-01T15:58:47Z</updated>
<entry>
<title>[PATCH] use smp_mb/wmb/rmb where possible</title>
<updated>2005-05-01T15:58:47Z</updated>
<author>
<name>akpm@osdl.org</name>
<email>akpm@osdl.org</email>
</author>
<published>2005-05-01T15:58:47Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=d59dd4620fb8d6422555a9e2b82a707718e68327'/>
<id>urn:sha1:d59dd4620fb8d6422555a9e2b82a707718e68327</id>
<content type='text'>
Replace a number of memory barriers with smp_ variants.  This means we won't
take the unnecessary hit on UP machines.

Signed-off-by: Anton Blanchard &lt;anton@samba.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@osdl.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@osdl.org&gt;
</content>
</entry>
<entry>
<title>[PATCH] fix keventd execution dependency</title>
<updated>2005-01-08T05:52:32Z</updated>
<author>
<name>Ingo Molnar</name>
<email>mingo@elte.hu</email>
</author>
<published>2005-01-08T05:52:32Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=d12ca5252a7bcb4749d7a477c44027d8ae238c7f'/>
<id>urn:sha1:d12ca5252a7bcb4749d7a477c44027d8ae238c7f</id>
<content type='text'>
We dont want to execute off keventd since it might hold a semaphore our
callers hold too.  This can happen when kthread_create() is called from
within keventd.  This happened due to the IRQ threading patches but it
could happen with other code too.

Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
Signed-off-by: Andrew Morton &lt;akpm@osdl.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@osdl.org&gt;
</content>
</entry>
<entry>
<title>[PATCH] clean up cpumask_t temporaries</title>
<updated>2004-06-24T01:52:44Z</updated>
<author>
<name>Andrew Morton</name>
<email>akpm@osdl.org</email>
</author>
<published>2004-06-24T01:52:44Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=a3dcb7f41eced06d4e43365fefd98a3b9b48e340'/>
<id>urn:sha1:a3dcb7f41eced06d4e43365fefd98a3b9b48e340</id>
<content type='text'>
From: Rusty Russell &lt;rusty@rustcorp.com.au&gt;

Paul Jackson's cpumask tour-de-force allows us to get rid of those stupid
temporaries which we used to hold CPU_MASK_ALL to hand them to functions.
This used to break NR_CPUS &gt; BITS_PER_LONG.

Signed-off-by: Rusty Russell &lt;rusty@rustcorp.com.au&gt;
Signed-off-by: Andrew Morton &lt;akpm@osdl.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@osdl.org&gt;
</content>
</entry>
<entry>
<title>[PATCH] Export kthread primitives</title>
<updated>2004-06-01T01:35:56Z</updated>
<author>
<name>Rusty Russell</name>
<email>rusty@rustcorp.com.au</email>
</author>
<published>2004-06-01T01:35:56Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=9102d1e21ddb02c1f84998116a341941bb99d5c1'/>
<id>urn:sha1:9102d1e21ddb02c1f84998116a341941bb99d5c1</id>
<content type='text'>
kthreads are not just for breakfast anymore.

Signed-off-by: Rusty Russell &lt;rusty@rustcorp.com.au&gt; (creator)
Signed-off-by: Linus Torvalds &lt;torvalds@osdl.org&gt;
</content>
</entry>
<entry>
<title>[PATCH] kthreads hold files open</title>
<updated>2004-03-15T23:22:15Z</updated>
<author>
<name>Andrew Morton</name>
<email>akpm@osdl.org</email>
</author>
<published>2004-03-15T23:22:15Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=cd74e1dcb5fd9d6775de1c78f9fd2740d0bdde0c'/>
<id>urn:sha1:cd74e1dcb5fd9d6775de1c78f9fd2740d0bdde0c</id>
<content type='text'>
keventd and friends are currently holding /dev/console open three times.
It's all inherited from init.

Steal the relevant parts of daemonize() to fix that up.
</content>
</entry>
<entry>
<title>[PATCH] use wait_task_inactive() in kthread_bind()</title>
<updated>2004-03-13T11:26:09Z</updated>
<author>
<name>Andrew Morton</name>
<email>akpm@osdl.org</email>
</author>
<published>2004-03-13T11:26:09Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=abf1e8535cefbd7de402f73366a2c0fbb7a96b04'/>
<id>urn:sha1:abf1e8535cefbd7de402f73366a2c0fbb7a96b04</id>
<content type='text'>
From: Rusty Russell &lt;rusty@rustcorp.com.au&gt;

Make it clear that the reason we do wait_task_inactive is because
kthread_bind frobs with k-&gt;thread_info-&gt;cpu, which is only legal because
the task is definitely not running.

We can't use the normal migration thread code here, because it doesn't let
us bind to cpus which are offline yet, and also because we use this to
start the migration threads themselves.
</content>
</entry>
<entry>
<title>[PATCH] kthread primitive</title>
<updated>2004-02-18T12:47:11Z</updated>
<author>
<name>Andrew Morton</name>
<email>akpm@osdl.org</email>
</author>
<published>2004-02-18T12:47:11Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=933ba10234f68f44af3a72afb3c0810b082c5a0e'/>
<id>urn:sha1:933ba10234f68f44af3a72afb3c0810b082c5a0e</id>
<content type='text'>
From: Rusty Russell &lt;rusty@rustcorp.com.au&gt;

These two patches provide the framework for stopping kernel threads to
allow hotplug CPU.  This one just adds kthread.c and kthread.h, next
one uses it.

Most importantly, adds a Monty Python quote to the kernel.

Details:

The hotplug CPU code introduces two major problems:

1) Threads which previously never stopped (migration thread,
   ksoftirqd, keventd) have to be stopped cleanly as CPUs go offline.
2) Threads which previously never had to be created now have
   to be created when a CPU goes online.

Unfortunately, stopping a thread is fairly baroque, involving memory
barriers, a completion and spinning until the task is actually dead
(for example, complete_and_exit() must be used if inside a module).

There are also three problems in starting a thread:
1) Doing it from a random process context risks environment contamination:
   better to do it from keventd to guarantee a clean environment, a-la
   call_usermodehelper.
2) Getting the task struct without races is a hard: see kernel/sched.c
   migration_call(), kernel/workqueue.c create_workqueue_thread().
3) There are races in starting a thread for a CPU which is not yet
   online: migration thread does a complex dance at the moment for
   a similar reason (there may be no migration thread to migrate us).

Place all this logic in some primitives to make life easier:
kthread_create() and kthread_stop().  These primitives require no
extra data-structures in the caller: they operate on normal "struct
task_struct"s.

Other changes:

- Expose keventd_up(), as keventd and migration threads will use kthread to
  launch, and kthread normally uses workqueues and must recognize this case.

- Kthreads created at boot before "keventd" are spawned directly.  However,
  this means that they don't have all signals blocked, and hence can be
  killed.  The simplest solution is to always explicitly block all signals in
  the kthread.

- Change over the migration threads, the workqueue threads and the
  ksoftirqd threads to use kthread.

- module.c currently spawns threads directly to stop the machine, so a
  module can be atomically tested for removal.

- Unfortunately, this means that the current task is manipulated (which
  races with set_cpus_allowed, for example), and it can't set its priority
  artificially high.  Using a kernel thread can solve this cleanly, and with
  kthread_run, it's simple.

- kthreads use keventd, so they inherit its cpus_allowed mask.  Unset it.
  All current users set it explicity anyway, but it's nice to fix.

- call_usermode_helper uses keventd, so the process created inherits its
  cpus_allowed mask.  Unset it.

- Prevent errors in boot when cpus_possible() contains a cpu which is not
  online (ie.  a cpu didn't come up).  This doesn't happen on x86, since a
  boot failure makes that CPU no longer possible (hacky, but it works).

- When the cpu fails to come up, some callbacks do kthread_stop(), which
  doesn't work without keventd (which hasn't started yet).  Call it directly,
  and take care that it restores signal state (note: do_sigaction does a
  flush on blocked signals, so we don't need to repeat it).
</content>
</entry>
</feed>
