Re: [RFC PATCH 01/14] sched: track the runnable average on aper-task entitiy basis

From: Peter Zijlstra
Date: Thu Feb 16 2012 - 08:28:25 EST


On Wed, 2012-02-01 at 17:38 -0800, Paul Turner wrote:
> +static __always_inline u64 decay_load(u64 val, int n)
> +{
> + for (;n && val;n--) {
> + val *= 4008;
> + val >>= 12;
> + }
> +
> + return val;
> +}

> + sa->runnable_avg_sum =
> + decay_load(sa->runnable_avg_sum, 1);
> + sa->runnable_avg_period =
> + decay_load(sa->runnable_avg_period, 1);

Since all you ever seem to do is:

x = decay(x, n);

and frequently run over the line limits it might make sense to either
introduce a CPP helper or make the first argument a pointer and ditch
the return value so we end up with something like:

decay(&x, n);


--
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/