Re: [PATCH] Speedup divides by cpu_power in scheduler

From: Ingo Molnar
Date: Thu Feb 22 2007 - 03:01:50 EST



* Eric Dumazet <dada1@xxxxxxxxxxxxx> wrote:

> I noticed expensive divides done in try_to_wakeup() and
> find_busiest_group() on a bi dual core Opteron machine (total of 4
> cores), moderatly loaded (15.000 context switch per second)
>
> oprofile numbers :

nice patch! Ack for -mm testing:

Acked-by: Ingo Molnar <mingo@xxxxxxx>

one general suggestion: could you rename ->cpu_power to ->__cpu_power?
That makes it perfectly clear that this field's semantics have changed
and that it should never be manipulated directly without also changing
->reciprocal_cpu_power, and will also flag any out of tree code
trivially.

> + * Divide a load by a sched group cpu_power : (load / sg->cpu_power)
> + * Since cpu_power is a 'constant', we can use a reciprocal divide.
> + */
> +static inline u32 sg_div_cpu_power(const struct sched_group *sg, u32 load)
> +{
> + return reciprocal_divide(load, sg->reciprocal_cpu_power);
> +}
> +/*
> + * Each time a sched group cpu_power is changed,
> + * we must compute its reciprocal value
> + */
> +static inline void sg_inc_cpu_power(struct sched_group *sg, u32 val)
> +{
> + sg->cpu_power += val;
> + BUG_ON(sg->cpu_power == 0);
> + sg->reciprocal_cpu_power = reciprocal_value(sg->cpu_power);
> +}

Could you remove the BUG_ON() - it will most likely cause the
non-inlining of these functions if CONFIG_CC_OPTIMIZE_FOR_SIZE=y and
CONFIG_FORCED_INLINING is disabled (which is a popular combination in
distro kernels, it reduces the kernel's size by over 30%). And it's not
like we'll be able to overlook a divide by zero crash in
reciprocal_value() anyway, if cpu_power were to be zero ;-)

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