Commit 28a42b9ea7e42e1efb02cc2dcacba0b6af234e1b

Authored by Paul Jackson
Committed by Linus Torvalds
1 parent 18a19cb304

[PATCH] cpusets: confine pdflush to its cpuset

This patch keeps pdflush daemons on the same cpuset as their parent, the
kthread daemon.

Some large NUMA configurations put as much as they can of kernel threads
and other classic Unix load in what's called a bootcpuset, keeping the rest
of the system free for dedicated jobs.

This effort is thwarted by pdflush, which dynamically destroys and
recreates pdflush daemons depending on load.

It's easy enough to force the originally created pdflush deamons into the
bootcpuset, at system boottime.  But the pdflush threads created later were
allowed to run freely across the system, due to the necessary line in their
startup kthread():

        set_cpus_allowed(current, CPU_MASK_ALL);

By simply coding pdflush to start its threads with the cpus_allowed
restrictions of its cpuset (inherited from kthread, its parent) we can
ensure that dynamically created pdflush threads are also kept in the
bootcpuset.

On systems w/o cpusets, or w/o a bootcpuset implementation, the following
will have no affect, leaving pdflush to run on any CPU, as before.

Signed-off-by: Paul Jackson <pj@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

Showing 1 changed file with 13 additions and 0 deletions Side-by-side Diff

... ... @@ -20,6 +20,7 @@
20 20 #include <linux/fs.h> // Needed by writeback.h
21 21 #include <linux/writeback.h> // Prototypes pdflush_operation()
22 22 #include <linux/kthread.h>
  23 +#include <linux/cpuset.h>
23 24  
24 25  
25 26 /*
26 27  
... ... @@ -170,12 +171,24 @@
170 171 static int pdflush(void *dummy)
171 172 {
172 173 struct pdflush_work my_work;
  174 + cpumask_t cpus_allowed;
173 175  
174 176 /*
175 177 * pdflush can spend a lot of time doing encryption via dm-crypt. We
176 178 * don't want to do that at keventd's priority.
177 179 */
178 180 set_user_nice(current, 0);
  181 +
  182 + /*
  183 + * Some configs put our parent kthread in a limited cpuset,
  184 + * which kthread() overrides, forcing cpus_allowed == CPU_MASK_ALL.
  185 + * Our needs are more modest - cut back to our cpusets cpus_allowed.
  186 + * This is needed as pdflush's are dynamically created and destroyed.
  187 + * The boottime pdflush's are easily placed w/o these 2 lines.
  188 + */
  189 + cpus_allowed = cpuset_cpus_allowed(current);
  190 + set_cpus_allowed(current, cpus_allowed);
  191 +
179 192 return __pdflush(&my_work);
180 193 }
181 194