lkml.org 
[lkml]   [2012]   [Jul]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [ 13/40] vmscan: shrinker->nr updates race and go wrong
    From
    Date
    On Thu, 2012-07-26 at 14:29 -0700, Greg Kroah-Hartman wrote:
    > From: Greg KH <gregkh@linuxfoundation.org>
    >
    > 3.0-stable review patch. If anyone has any objections, please let me know.
    >
    > ------------------
    >
    > From: Dave Chinner <dchinner@redhat.com>
    >
    > commit acf92b485cccf028177f46918e045c0c4e80ee10 upstream.
    >
    > Stable note: Not tracked in Bugzilla. This patch reduces excessive
    > reclaim of slab objects reducing the amount of information
    > that has to be brought back in from disk.
    >
    > shrink_slab() allows shrinkers to be called in parallel so the
    > struct shrinker can be updated concurrently. It does not provide any
    > exclusio for such updates, so we can get the shrinker->nr value
    > increasing or decreasing incorrectly.
    >
    > As a result, when a shrinker repeatedly returns a value of -1 (e.g.
    > a VFS shrinker called w/ GFP_NOFS), the shrinker->nr goes haywire,
    > sometimes updating with the scan count that wasn't used, sometimes
    > losing it altogether. Worse is when a shrinker does work and that
    > update is lost due to racy updates, which means the shrinker will do
    > the work again!
    >
    > Fix this by making the total_scan calculations independent of
    > shrinker->nr, and making the shrinker->nr updates atomic w.r.t. to
    > other updates via cmpxchg loops.
    [...]
    > --- a/mm/vmscan.c
    > +++ b/mm/vmscan.c
    > @@ -251,17 +251,29 @@ unsigned long shrink_slab(struct shrink_
    > unsigned long total_scan;
    [...]
    > + total_scan += delta;
    > + if (total_scan < 0) {
    [...]

    This condition is never true since total_scan is unsigned.
    I think 3.0.y needs this as well:

    commit 635697c663f38106063d5659f0cf2e45afcd4bb5
    Author: Konstantin Khlebnikov <khlebnikov@openvz.org>
    Date: Thu Dec 8 14:33:51 2011 -0800

    vmscan: fix initial shrinker size handling

    Ben.

    --
    Ben Hutchings
    Man invented language to satisfy his deep need to complain. - Lily Tomlin
    [unhandled content-type:application/pgp-signature]
    \
     
     \ /
      Last update: 2012-07-29 22:41    [W:0.051 / U:3.968 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site