]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mm: fix off-by-two in __zone_watermark_ok()
authorMichal Hocko <mhocko@suse.cz>
Thu, 8 Dec 2011 04:41:50 +0000 (15:41 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Fri, 9 Dec 2011 04:52:38 +0000 (15:52 +1100)
88f5acf8 ("mm: page allocator: adjust the per-cpu counter threshold when
memory is low") changed the form how free_pages is calculated but it
forgot that we used to do free_pages - ((1 << order) - 1) so we ended up
with off-by-two when calculating free_pages.

Reported-by: Wang Sheng-Hui <shhuiw@gmail.com>
Signed-off-by: Michal Hocko <mhocko@suse.cz>
Acked-by: Mel Gorman <mgorman@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/page_alloc.c

index c52349a0adb035201f43ede69f1361a13df02cd2..af5467e3faa4d7cc5488f17f08d1e0a881e13ca4 100644 (file)
@@ -1538,7 +1538,7 @@ static bool __zone_watermark_ok(struct zone *z, int order, unsigned long mark,
        long min = mark;
        int o;
 
-       free_pages -= (1 << order) + 1;
+       free_pages -= (1 << order) - 1;
        if (alloc_flags & ALLOC_HIGH)
                min -= min / 2;
        if (alloc_flags & ALLOC_HARDER)