xfs
[Top] [All Lists]

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

To: Dave Chinner <david@xxxxxxxxxxxxx>
Subject: Re: [PATCH 03/34] lib: percpu counter add unless less than functionality
From: Alex Elder <aelder@xxxxxxx>
Date: Tue, 21 Dec 2010 20:20:14 -0600
Cc: xfs@xxxxxxxxxxx
In-reply-to: <1292916570-25015-4-git-send-email-david@xxxxxxxxxxxxx>
References: <1292916570-25015-1-git-send-email-david@xxxxxxxxxxxxx> <1292916570-25015-4-git-send-email-david@xxxxxxxxxxxxx>
Reply-to: aelder@xxxxxxx
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).



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