Re: [PATCH] sched: activate SCHED BATCH expired

From: Nick Piggin
Date: Fri Mar 17 2006 - 08:43:38 EST


Con Kolivas wrote:
On Saturday 18 March 2006 00:26, Nick Piggin wrote:

Con Kolivas wrote:

-static inline void __activate_task(task_t *p, runqueue_t *rq)
+static void __activate_task(task_t *p, runqueue_t *rq)
{
- enqueue_task(p, rq->active);
+ if (batch_task(p))
+ enqueue_task(p, rq->expired);
+ else
+ enqueue_task(p, rq->active);
inc_nr_running(p, rq);
}

I prefer:

prio_array_t *target = rq->active;
if (batch_task(p))
target = rq->expired;
enqueue_task(p, target);

Because gcc can use things like predicated instructions for it.
But perhaps it is smart enough these days to recognise this?
At least in the past I have seen it start using cmov after doing
such a conversion.

At any rate, I think it looks nicer as well. IMO, of course.


Well on my one boring architecture here is a before and after, gcc 4.1.0 with optimise for size kernel config:

I'm not attached to the style, just the feature. If you think it's warranted I'll change it.


I guess it isn't doing the cmov because it doesn't want to do the
extra load in the common case, which is fair enough (are you compiling
for a pentiumpro+, without generic x86 support? what about if you
turn off optimise for size?)

At least other archtectures might be able to make better use of it,
and I agree even for i386 the code looks better (and slightly smaller).

--
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com -
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/