Index: linux-2.6.9-rc3-bk7/kernel/sched.c
===================================================================
--- linux-2.6.9-rc3-bk7.orig/kernel/sched.c	2004-10-08 15:21:14.604688703 +1000
+++ linux-2.6.9-rc3-bk7/kernel/sched.c	2004-10-08 15:21:15.963479446 +1000
@@ -71,7 +71,6 @@
  * Some helpers for converting nanosecond timing to jiffy resolution
  */
 #define NS_TO_JIFFIES(TIME)	((TIME) / (1000000000 / HZ))
-#define NSJIFFY			(1000000000 / HZ)	/* One jiffy in ns */
 
 int sched_compute = 0;
 /* 
@@ -2189,7 +2188,6 @@ void scheduler_tick(int user_ticks, int 
 	struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
 	runqueue_t *rq = this_rq();
 	task_t *p = current;
-	unsigned long debit;
 
 	rq->timestamp_last_tick = sched_clock();
 
@@ -2231,11 +2229,6 @@ void scheduler_tick(int user_ticks, int 
 	 */
 	if (unlikely(p->policy == SCHED_FIFO))
 		goto out;
-	debit = ns_diff(rq->timestamp_last_tick, p->timestamp);
-	if (debit < NSJIFFY) {
-		p->totalrun += debit;
-		goto out;
-	}
 
 	spin_lock(&rq->lock);
 	/*
@@ -2385,24 +2378,6 @@ static inline int dependent_sleeper(int 
 #endif
 
 /*
- * Tasks that have yield()ed get queued at lowest priority but once queued
- * run at their normal priority.
- */
-static void adjust_yield_prio(runqueue_t *rq, task_t *p)
-{
-	int newprio = effective_prio(p);
-	p->flags &= ~PF_YIELDED;
-	if (newprio != p->prio) {
-		if (likely(task_queued(p))) {
-			dequeue_task(p, rq);
-			p->prio = newprio;
-			enqueue_task(p, rq);
-		} else
-			p->prio = newprio;
-	}
-}
-
-/*
  * schedule() is the main scheduler function.
  */
 asmlinkage void __sched schedule(void)
@@ -2444,8 +2419,13 @@ need_resched:
 	schedstat_inc(rq, sched_cnt);
 	now = sched_clock();
 
-	prev->runtime = ns_diff(now, prev->timestamp);
 	spin_lock_irq(&rq->lock);
+	prev->runtime = ns_diff(now, prev->timestamp);
+	if (prev->timestamp > rq->timestamp_last_tick)
+		/*
+		 * We didnt get charged a tick for running, charge nanoseconds
+		 */
+		prev->totalrun += prev->runtime;
 
 	/*
 	 * if entering off of a kernel preemption go straight
@@ -2501,8 +2481,18 @@ switch_tasks:
 	rcu_qsctr_inc(task_cpu(prev));
 
 	prev->timestamp = now;
-	if (next->flags & PF_YIELDED)
-		adjust_yield_prio(rq, next);
+	if (next->flags & PF_YIELDED) {
+		/*
+		 * Tasks that have yield()ed get requeued at normal priority
+		 */
+		int newprio = effective_prio(next);
+		next->flags &= ~PF_YIELDED;
+		if (newprio != next->prio) {
+			dequeue_task(next, rq);
+			next->prio = newprio;
+			enqueue_task(next, rq);
+		}
+	}
 
 	sched_info_switch(prev, next);
 	if (likely(prev != next)) {
