LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Eric Dumazet <dada1@cosmosbay.com>
Cc: Andrew Morton <akpm@linux-foundation.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Speedup divides by cpu_power in scheduler
Date: Thu, 22 Feb 2007 08:56:23 +0100	[thread overview]
Message-ID: <20070222075623.GB9800@elte.hu> (raw)
In-Reply-To: <45DD46E5.4060804@cosmosbay.com>


* Eric Dumazet <dada1@cosmosbay.com> 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@elte.hu>

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

  reply	other threads:[~2007-02-22  8:01 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-21 21:10 [Patch 1/2] cciss: fix for 2TB support Mike Miller (OS Dev)
2007-02-22  3:14 ` Andrew Morton
2007-02-22  7:31   ` [PATCH] Speedup divides by cpu_power in scheduler Eric Dumazet
2007-02-22  7:56     ` Ingo Molnar [this message]
2007-02-22  8:19     ` [PATCH, take 2] " Eric Dumazet
2007-02-22  8:19       ` Ingo Molnar
2007-02-22 16:51   ` [Patch 1/2] cciss: fix for 2TB support Mike Miller (OS Dev)
2007-02-22 21:24     ` Andrew Morton
2007-02-22 21:41       ` James Bottomley
2007-02-22 22:02         ` Mike Miller (OS Dev)
2007-02-22 22:06           ` James Bottomley
2007-02-23 20:52             ` Mike Miller (OS Dev)
2007-02-24  6:35               ` Andrew Morton
2007-02-22 20:18   ` Mike Miller (OS Dev)
2007-02-22 21:22     ` Miller, Mike (OS Dev)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070222075623.GB9800@elte.hu \
    --to=mingo@elte.hu \
    --cc=akpm@linux-foundation.org \
    --cc=dada1@cosmosbay.com \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [PATCH] Speedup divides by cpu_power in scheduler' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).