public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [question] sched: idle_avg and migration latency
@ 2013-12-10 11:30 Daniel Lezcano
  2013-12-10 15:11 ` Mike Galbraith
  2013-12-10 15:20 ` Alex Shi
  0 siblings, 2 replies; 7+ messages in thread
From: Daniel Lezcano @ 2013-12-10 11:30 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: Alex Shi


Hi All,

I am trying to understand how is computed the idle_avg and how it is 
used regarding the migration latency.

1. What is the sysctl_sched_migration_cost value ? It is initialized to 
500000UL. Is it an arbitrarily chosen value ? Could it change depending 
on the hardware performances ?


2. The idle_balance function checks:

         if (this_rq->avg_idle < sysctl_sched_migration_cost)
                 return 0;

IIUC, it is not worth to migrate a task to this cpu as we expect to run 
another task before we can pull a task to the current cpu, right ?

Then if there is no task to balance we will enter idle, thus we 
initialize the idle_stamp to the current clock.

When another task is woken up with the ttwu_do_wakeup, the duration of 
the idle time is computed in there:

	if (rq->idle_stamp) {
		u64 delta = rq_clock(rq) - rq->idle_stamp;
		u64 max = 2*sysctl_sched_migration_cost;

		if (delta > max)
			rq->avg_idle = max;
		else
			update_avg(&rq->avg_idle, delta);
		rq->idle_stamp = 0;
	}

Why is the 'delta' leveraged by 'max' ?


3. And finally the function update_avg does:

	s64 diff = sample - *avg;
	*avg += diff >> 3;

Why is diff >> 3 used instead of the number of values ?

Thanks in advance for any answers

   -- Daniel

-- 
  <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-12-11  6:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-10 11:30 [question] sched: idle_avg and migration latency Daniel Lezcano
2013-12-10 15:11 ` Mike Galbraith
2013-12-10 18:31   ` Daniel Lezcano
2013-12-11  1:25     ` Alex Shi
2013-12-11  6:44     ` Mike Galbraith
2013-12-10 15:20 ` Alex Shi
2013-12-10 19:07   ` Daniel Lezcano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox