public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Arjan van de Ven <arjan@linux.intel.com>
Cc: linux-kernel@vger.kernel.org, mingo@elte.hu
Subject: Re: [patch 1/2] round_jiffies infrastructure
Date: Tue, 10 Oct 2006 11:56:52 -0700	[thread overview]
Message-ID: <20061010115652.4ef068bd.akpm@osdl.org> (raw)
In-Reply-To: <1160496210.3000.310.camel@laptopd505.fenrus.org>

On Tue, 10 Oct 2006 18:03:30 +0200
Arjan van de Ven <arjan@linux.intel.com> wrote:

> @@ -80,6 +80,56 @@ tvec_base_t boot_tvec_bases;
>  EXPORT_SYMBOL(boot_tvec_bases);
>  static DEFINE_PER_CPU(tvec_base_t *, tvec_bases) = &boot_tvec_bases;
>  
> +unsigned long __round_jiffies(unsigned long T, int CPU)
> +{
> +	int rem;
> +	int original  = T;
> +	rem = T % HZ;
> +	if (rem < HZ/4)
> +		T = T - rem;
> +	else
> +		T = T - rem + HZ;
> +	/* we don't want all cpus firing at once hitting the same lock/memory */
> +	T += CPU * 3;
> +	if (T <= jiffies) /* rounding ate our timeout entirely */
> +		return original;
> +	return T;
> +}
> +EXPORT_SYMBOL_GPL(__round_jiffies);
> +

c'mon Arjan.  If we're going to create new, kernel-wide,
exported-to-modules infrastructure then it deserves slightly more than zero
documentation.

Some commentary explaining/justifying the magic numbers in there would be
useful too.  The HZ/4, the cpu*3.

And coding style too, please: consistent spacing around arithmetic
operators, variables are lower case, constants are upper case.

  parent reply	other threads:[~2006-10-10 18:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-10 16:02 [patch 0/2] Introduce round_jiffies() to save spurious wakeups Arjan van de Ven
2006-10-10 16:03 ` [patch 1/2] round_jiffies infrastructure Arjan van de Ven
2006-10-10 16:04   ` [patch 2/2] round_jiffies users Arjan van de Ven
2006-10-10 16:47     ` Ingo Oeser
2006-10-10 16:59       ` Arjan van de Ven
2006-10-10 22:47     ` Paul Dickson
2006-10-10 23:52       ` Arjan van de Ven
2006-10-10 18:56   ` Andrew Morton [this message]
2006-10-10 20:48     ` [patch 1/2] round_jiffies infrastructure Arjan van de Ven
2006-10-16 13:42   ` Andi Kleen
2006-10-11 17:23 ` [patch 0/2] Introduce round_jiffies() to save spurious wakeups Christoph Hellwig
2006-10-11 17:54   ` Arjan van de Ven
2006-10-12 19:02     ` Christoph Hellwig

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=20061010115652.4ef068bd.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=arjan@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox