sched/fair: Optimize cgroup pick_next_task_fair()
authorPeter Zijlstra <peterz@infradead.org>
Sat, 11 Feb 2012 05:05:00 +0000 (06:05 +0100)
committerIngo Molnar <mingo@kernel.org>
Mon, 10 Feb 2014 15:17:19 +0000 (16:17 +0100)
commit678d5718d8d099421b0dd54c01b0528f4aaf5919
treee2e31b84b5baee6e5496d6304f93c4a22e575846
parentf10447998a59b97747c16258a9c6e6a1512f27f3
sched/fair: Optimize cgroup pick_next_task_fair()

Since commit 2f36825b1 ("sched: Next buddy hint on sleep and preempt
path") it is likely we pick a new task from the same cgroup, doing a put
and then set on all intermediate entities is a waste of time, so try to
avoid this.

Measured using:

  mount nodev /cgroup -t cgroup -o cpu
  cd /cgroup
  mkdir a; cd a
  mkdir b; cd b
  mkdir c; cd c
  echo $$ > tasks
  perf stat --repeat 10 -- taskset 1 perf bench sched pipe

PRE :      4.542422684 seconds time elapsed   ( +-  0.33% )
POST:      4.389409991 seconds time elapsed   ( +-  0.32% )

Which shows a significant improvement of ~3.5%

Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tejun Heo <tj@kernel.org>
Link: http://lkml.kernel.org/r/1328936700.2476.17.camel@laptop
Signed-off-by: Ingo Molnar <mingo@kernel.org>
kernel/sched/fair.c