Re: [PATCH]Avoid the overflow when calculate the proportion of bdi quota

2007-12-14 Thread Peter Zijlstra
On Fri, 2007-12-14 at 09:47 +0100, Peter Zijlstra wrote: > How about something like this: > > diff --git a/lib/proportions.c b/lib/proportions.c > index 332d8c5..4afb330 100644 > --- a/lib/proportions.c > +++ b/lib/proportions.c > @@ -190,6 +190,8 @@ prop_adjust_shift(int *pl_shift, unsigned lon

Re: [PATCH]Avoid the overflow when calculate the proportion of bdi quota

2007-12-14 Thread Peter Zijlstra
On Fri, 2007-12-14 at 16:26 +0800, zhejiang wrote: > On Thu, 2007-12-13 at 22:54 +0100, Peter Zijlstra wrote: > > On Thu, 2007-12-13 at 11:30 +0800, zhejiang wrote: > > > __percpu_counter_add() cache the result in percpu variable until it > > > exceeds the batch. > > > The prop_norm_percpu() use t

Re: [PATCH]Avoid the overflow when calculate the proportion of bdi quota

2007-12-14 Thread zhejiang
On Thu, 2007-12-13 at 22:54 +0100, Peter Zijlstra wrote: > On Thu, 2007-12-13 at 11:30 +0800, zhejiang wrote: > > __percpu_counter_add() cache the result in percpu variable until it > > exceeds the batch. > > The prop_norm_percpu() use the percpu_counter_read(&pl->events) to read > > the counter ,a

Re: [PATCH]Avoid the overflow when calculate the proportion of bdi quota

2007-12-13 Thread Peter Zijlstra
On Thu, 2007-12-13 at 11:30 +0800, zhejiang wrote: > __percpu_counter_add() cache the result in percpu variable until it > exceeds the batch. > The prop_norm_percpu() use the percpu_counter_read(&pl->events) to read > the counter ,and use percpu_counter_add(&pl->events, -half) to half the > counte

[PATCH]Avoid the overflow when calculate the proportion of bdi quota

2007-12-12 Thread zhejiang
__percpu_counter_add() cache the result in percpu variable until it exceeds the batch. The prop_norm_percpu() use the percpu_counter_read(&pl->events) to read the counter ,and use percpu_counter_add(&pl->events, -half) to half the counter. There are potential problems: 1.The counter may be negativ