Re: [patch 1/2] round_jiffies infrastructure

Andrew Morton
2006-10-10T18:57:08Z

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.