Commit 00a87a38 authored by Ingo Molnar's avatar Ingo Molnar Committed by Linus Torvalds

[PATCH] Fix task_hot() balancing

This fixes the integer underflow in task_hot() noticed by Kenneth W Chen
and makes use of p->last_ran to separate load-balancing timestamps (used
by task_hot()) from interactivity timestamps.  (which two interfered)

compiled, booted on x86 SMP.

Confirmed by Kenneth Chen <kenneth.w.chen@intel.com> to fix the db
transaction processing workload that showed the balancing problem.
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 90b1f609
......@@ -449,7 +449,7 @@ struct task_struct {
unsigned long sleep_avg;
long interactive_credit;
unsigned long long timestamp;
unsigned long long timestamp, last_ran;
int activated;
unsigned long policy;
......
......@@ -180,7 +180,8 @@ static unsigned int task_timeslice(task_t *p)
else
return SCALE_PRIO(DEF_TIMESLICE, p->static_prio);
}
#define task_hot(p, now, sd) ((now) - (p)->timestamp < (sd)->cache_hot_time)
#define task_hot(p, now, sd) ((long long) ((now) - (p)->last_ran) \
< (long long) (sd)->cache_hot_time)
enum idle_type
{
......@@ -2764,7 +2765,7 @@ asmlinkage void __sched schedule(void)
if (!(HIGH_CREDIT(prev) || LOW_CREDIT(prev)))
prev->interactive_credit--;
}
prev->timestamp = now;
prev->timestamp = prev->last_ran = now;
sched_info_switch(prev, next);
if (likely(prev != next)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment