• Hugh Dickins's avatar
    percpu_counter: extend _limited_add() to negative amounts · 1431996b
    Hugh Dickins authored
    Though tmpfs does not need it, percpu_counter_limited_add() can be twice
    as useful if it works sensibly with negative amounts (subs) - typically
    decrements towards a limit of 0 or nearby: as suggested by Dave Chinner.
    
    And in the course of that reworking, skip the percpu counter sum if it is
    already obvious that the limit would be passed: as suggested by Tim Chen.
    
    Extend the comment above __percpu_counter_limited_add(), defining the
    behaviour with positive and negative amounts, allowing negative limits,
    but not bothering about overflow beyond S64_MAX.
    
    Link: https://lkml.kernel.org/r/8f86083b-c452-95d4-365b-f16a2e4ebcd4@google.comSigned-off-by: default avatarHugh Dickins <hughd@google.com>
    Cc: Axel Rasmussen <axelrasmussen@google.com>
    Cc: Carlos Maiolino <cem@kernel.org>
    Cc: Christian Brauner <brauner@kernel.org>
    Cc: Chuck Lever <chuck.lever@oracle.com>
    Cc: Darrick J. Wong <djwong@kernel.org>
    Cc: Dave Chinner <dchinner@redhat.com>
    Cc: Jan Kara <jack@suse.cz>
    Cc: Johannes Weiner <hannes@cmpxchg.org>
    Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
    Cc: Tim Chen <tim.c.chen@intel.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    1431996b
percpu_counter.c 9.72 KB