Re: 2.5.75 as-iosched.c & asm-generic/div64.h breakage

Paul Mackerras (paulus@samba.org)
Sat, 12 Jul 2003 10:49:28 +1000


Andrew Morton writes:

> Mikael Pettersson <mikpe@csd.uu.se> wrote:
> >
> > drivers/block/as-iosched.c: In function `as_update_iohist':
> > drivers/block/as-iosched.c:840: warning: right shift count >= width of type
> > drivers/block/as-iosched.c:840: warning: passing arg 1 of `__div64_32' from incompatible pointer type
>
> You mean that code was in -mm for all those months and no ppc32 person
> bothered testing it? Bah.

We've only been getting those warnings since the changeover to the new
asm-generic/div64.h. Settle down. :)

> Something like this? (Could be sped up for 32-bit sector_t)
>
> diff -puN drivers/block/as-iosched.c~as-do_div-fix drivers/block/as-iosched.c
> --- 25/drivers/block/as-iosched.c~as-do_div-fix Fri Jul 11 14:00:55 2003
> +++ 25-akpm/drivers/block/as-iosched.c Fri Jul 11 14:00:58 2003
> @@ -836,8 +836,10 @@ static void as_update_iohist(struct as_i
> aic->seek_samples += 256;
> aic->seek_total += 256*seek_dist;
> if (aic->seek_samples) {
> - aic->seek_mean = aic->seek_total + 128;
> - do_div(aic->seek_mean, aic->seek_samples);
> + u64 seek_mean = aic->seek_total + 128;
> +
> + do_div(seek_mean, aic->seek_samples);
> + aic->seek_mean = seek_mean;
> }

There are several interesting aspects to this:

1. For some reason the LBD config option in drivers/block/Kconfig
depends on X86. (CONFIG_LBD is what makes sector_t an unsigned
long long instead of an unsigned long). I think the LBD option
should be available on all 32-bit platforms. Working out a neat
way to tell the config system that is left as an exercise for the
reader. :)

2. It seems to me that seek_total is bounded above by 1024 * the
maximum seek distance. I'm a bit concerned about that overflowing
32 bits - AFAICS I would only need a > 2GB disk (or do I mean
partition?) for that to happen. Could we make seek_total be a u64
unconditionally please?

3. I guess that adding 128 on to the seek_total is to get a
round-to-nearest effect in the division. In fact you need to add
on (seek_samples >> 1) to get that effect.

Regards,
Paul.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/