lkml.org 
[lkml]   [2006]   [Apr]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [patch 2.6.16-mm2 8/9] sched throttle tree extract - maximize timeslice accounting
From
Date
This patch maximizes time slice accounting.  A task which receives too
much CPU time due to missing the timer interrupt will have the excess
deducted from it's next slice.

Signed-off-by: Mike Galbraith <efault@gmx.de>

--- linux-2.6.16-mm2/kernel/sched.c-7.implement_throttle 2006-03-24 09:36:08.000000000 +0100
+++ linux-2.6.16-mm2/kernel/sched.c 2006-03-24 09:40:33.000000000 +0100
@@ -2966,13 +2966,28 @@ static void refresh_timeslice(task_t *p)
unsigned int slice = last_slice(p);
unsigned int slice_avg, cpu, idle;
long run_time = -1 * p->slice_time_ns;
+ long slice_time_ns = task_timeslice_ns(p);
int w = MAX_BONUS, delta, bonus;

/*
- * Update time_slice.
+ * Update time_slice. Account for unused fragment,
+ * or excess time received due to missed tick.
*/
- p->slice_time_ns = task_timeslice_ns(p);
- p->time_slice = task_timeslice(p);
+ p->slice_time_ns += slice_time_ns;
+ /*
+ * Not common, but this does happen on SMP systems.
+ * Timeslice theft of this magnitude has never been
+ * observed in the wild, so assume that this is BS,
+ * and give the poor task it's full slice. Theory:
+ * mostly idle task migrates between CPUs numerous
+ * times during it's slice, timestamp rounding leads
+ * to wildly inaccurate calculation. Rounding has
+ * maximum effect on those who stretch their slice,
+ * but is also fairly meaningless, so ignore it.
+ */
+ if (unlikely(p->slice_time_ns < NS_TICK))
+ p->slice_time_ns = slice_time_ns;
+ p->time_slice = NS_TO_JIFFIES(p->slice_time_ns);
set_last_slice(p, p->time_slice);

/*

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-04-01 11:28    [W:0.101 / U:30.628 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site