lkml.org 
[lkml]   [2011]   [Apr]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[patch v2 1/4] percpu_counter: change return value and add comments
    the percpu_counter_*_positive() API SMP and UP aren't consistent. Add comments
    to explain it.
    Also if count < 0, returns 0 instead of 1 for *read_positive().

    Signed-off-by: Shaohua Li <shaohua.li@intel.com>

    ---
    include/linux/percpu_counter.h | 6 +++++-
    1 file changed, 5 insertions(+), 1 deletion(-)

    Index: linux/include/linux/percpu_counter.h
    ===================================================================
    --- linux.orig/include/linux/percpu_counter.h 2011-04-13 13:10:13.000000000 +0800
    +++ linux/include/linux/percpu_counter.h 2011-04-13 13:21:21.000000000 +0800
    @@ -75,7 +75,7 @@ static inline s64 percpu_counter_read_po
    barrier(); /* Prevent reloads of fbc->count */
    if (ret >= 0)
    return ret;
    - return 1;
    + return 0;
    }

    static inline int percpu_counter_initialized(struct percpu_counter *fbc)
    @@ -135,6 +135,10 @@ static inline s64 percpu_counter_read(st

    static inline s64 percpu_counter_read_positive(struct percpu_counter *fbc)
    {
    + /*
    + * percpu_counter is intended to track positive number. In UP case, the
    + * number should never be negative.
    + */
    return fbc->count;
    }



    \
     
     \ /
      Last update: 2011-04-13 10:09    [W:0.020 / U:0.340 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site