Re: [PATCH 03/34] lib: percpu counter add unless less than functionality

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Dec 21, 2010 at 08:20:14PM -0600, Alex Elder wrote:
> On Tue, 2010-12-21 at 18:28 +1100, Dave Chinner wrote: 
> > From: Dave Chinner <dchinner@xxxxxxxxxx>
> > 
> > To use the generic percpu counter infrastructure for counters that
> > require conditional addition based on a threshold value we need
> > special handling of the counter. Further, the caller needs to know
> > the status of the conditional addition to determine what action to
> > take depending on whether the addition occurred or not.  Examples of
> > this sort of usage are resource counters that cannot go below zero
> > (e.g. filesystem free blocks).
> > 
> > To allow XFS to replace it's complex roll-your-own per-cpu
> > superblock counters, a single generic conditional function is
> > required: percpu_counter_add_unless_lt(). This will add the amount
> > to the counter unless the result would be less than the given
> > threshold. A caller supplied threshold is required because XFS does
> > not necessarily use the same threshold for every counter.
> > 
> > percpu_counter_add_unless_lt() attempts to minimise counter lock
> > traversals by only taking the counter lock when the threshold is
> > within the error range of the current counter value. Hence when the
> > threshold is not within the counter error range, the counter will
> > still have the same scalability characteristics as the normal
> > percpu_counter_add() function.
> > 
> > Adding this functionality to the generic percpu counters allows us
> > to remove the much more complex and less efficient XFS percpu
> > counter code (~700 lines of code) and replace it with generic
> > percpu counters.
> > 
> > Signed-off-by: Dave Chinner <dchinner@xxxxxxxxxx>
> 
> I want to look at this one more closely again in the
> morning, but for now I'll just mention one nit, and
> one easily fixed problem.
> 
> 					-Alex
> 
> . . .
> 
> > + * Add @amount to @fdc if and only if result of addition is greater than or
>                      ^^^  should be fbc
> 
> > +EXPORT_SYMBOL(percpu_counter_add_unless_lt);
> > +
> 
> This has to be:
>     EXPORT_SYMBOL(__percpu_counter_add_unless_lt);
> (with leading underscores).

Yup, saw you comment about that on IRC overnight. Already fixed. ;)

Cheers,,

Dave.
-- 
Dave Chinner
david@xxxxxxxxxxxxx

_______________________________________________
xfs mailing list
xfs@xxxxxxxxxxx
http://oss.sgi.com/mailman/listinfo/xfs


[Index of Archives]     [Linux XFS Devel]     [Linux Filesystem Development]     [Filesystem Testing]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux