xfs
[Top] [All Lists]

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

To: Alex Elder <aelder@xxxxxxx>
Subject: Re: [PATCH 03/34] lib: percpu counter add unless less than functionality
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Wed, 22 Dec 2010 14:46:58 +1100
Cc: xfs@xxxxxxxxxxx
In-reply-to: <1292984414.2408.357.camel@doink>
References: <1292916570-25015-1-git-send-email-david@xxxxxxxxxxxxx> <1292916570-25015-4-git-send-email-david@xxxxxxxxxxxxx> <1292984414.2408.357.camel@doink>
User-agent: Mutt/1.5.20 (2009-06-14)
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

<Prev in Thread] Current Thread [Next in Thread>