Re: [RFC][PATCH 1/3] per cpu counter fixes for unsigned long type counter overflow

From: Andreas Dilger
Date: Tue Apr 11 2006 - 03:55:01 EST


On Apr 10, 2006 18:09 -0700, Mingming Cao wrote:
> +static void __percpu_counter_mod(struct percpu_counter *fbc, long amount,
> + int ul_overflow_check)
> {
> + * Before updating the global counter, if we detect the
> + * updated new value will cause overflow, then we should not
> + * do the update from this local counter at this moment. (i.e.
> + * the local counter will not be cleared right now). The update
> + * will be deferred at some point until either other local
> + * counter updated the global counter first, or the local
> + * counter's value will not cause global counter overflow.

Wouldn't it be better to update the counter by the maximum amount possible
to avoid overflow/underflow?

Cheers, Andreas
--
Andreas Dilger
Principal Software Engineer
Cluster File Systems, Inc.

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