Re: [PATCH -v8a 3/7] sched: use a buddy to implementyield_task_fair

From: Peter Zijlstra
Date: Thu Feb 03 2011 - 07:57:51 EST


On Tue, 2011-02-01 at 09:51 -0500, Rik van Riel wrote:
> -static void yield_task_fair(struct rq *rq)
> -{
> - struct task_struct *curr = rq->curr;
> - struct cfs_rq *cfs_rq = task_cfs_rq(curr);
> - struct sched_entity *rightmost, *se = &curr->se;
> -
> - /*
> - * Are we the only task in the tree?
> - */
> - if (unlikely(rq->nr_running == 1))
> - return;
> -
> - clear_buddies(cfs_rq, se);
> -
> - if (likely(!sysctl_sched_compat_yield) && curr->policy != SCHED_BATCH) {
> - update_rq_clock(rq);
> - /*
> - * Update run-time statistics of the 'current'.
> - */
> - update_curr(cfs_rq);
> -
> - return;
> - }
> - /*
> - * Find the rightmost entry in the rbtree:
> - */
> - rightmost = __pick_last_entity(cfs_rq);
> - /*
> - * Already in the rightmost position?
> - */
> - if (unlikely(!rightmost || entity_before(rightmost, se)))
> - return;
> -
> - /*
> - * Minimally necessary key value to be last in the tree:
> - * Upon rescheduling, sched_class::put_prev_task() will place
> - * 'current' within the tree based on its new key value.
> - */
> - se->vruntime = rightmost->vruntime + 1;
> -}


This also wants the below bit in order to build without warnings for
SCHED_DEBUG=n:


---
Index: linux-2.6/kernel/sched_fair.c
===================================================================
--- linux-2.6.orig/kernel/sched_fair.c
+++ linux-2.6/kernel/sched_fair.c
@@ -431,6 +431,7 @@ static struct sched_entity *__pick_next_
return rb_entry(next, struct sched_entity, run_node);
}

+#ifdef CONFIG_SCHED_DEBUG
static struct sched_entity *__pick_last_entity(struct cfs_rq *cfs_rq)
{
struct rb_node *last = rb_last(&cfs_rq->tasks_timeline);
@@ -445,7 +446,6 @@ static struct sched_entity *__pick_last_
* Scheduling class statistics methods:
*/

-#ifdef CONFIG_SCHED_DEBUG
int sched_proc_update_handler(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp,
loff_t *ppos)

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