Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] cpuset: skip rcu check if task is in root cpuset

For systems that aren't using cpusets, but have them CONFIG_CPUSET enabled in
their kernel (eventually this may be most distribution kernels), this patch
removes even the minimal rcu_read_lock() from the memory page allocation path.

Actually, it removes that rcu call for any task that is in the root cpuset
(top_cpuset), which on systems not actively using cpusets, is all tasks.

We don't need the rcu check for tasks in the top_cpuset, because the
top_cpuset is statically allocated, so at no risk of being freed out from
underneath us.

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

authored by

Paul Jackson and committed by
Linus Torvalds
03a285f5 7edc5962

+9 -4
+9 -4
kernel/cpuset.c
··· 647 647 struct task_struct *tsk = current; 648 648 struct cpuset *cs; 649 649 650 - rcu_read_lock(); 651 - cs = rcu_dereference(tsk->cpuset); 652 - my_cpusets_mem_gen = cs->mems_generation; 653 - rcu_read_unlock(); 650 + if (tsk->cpuset == &top_cpuset) { 651 + /* Don't need rcu for top_cpuset. It's never freed. */ 652 + my_cpusets_mem_gen = top_cpuset.mems_generation; 653 + } else { 654 + rcu_read_lock(); 655 + cs = rcu_dereference(tsk->cpuset); 656 + my_cpusets_mem_gen = cs->mems_generation; 657 + rcu_read_unlock(); 658 + } 654 659 655 660 if (my_cpusets_mem_gen != tsk->cpuset_mems_generation) { 656 661 down(&callback_sem);