From: Michal Hocko Date: Tue, 10 Jan 2012 23:08:02 +0000 (-0800) Subject: mm: fix off-by-two in __zone_watermark_ok() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=df0a6daa01fa3856c08f4274d4f21a8092caa480;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git mm: fix off-by-two in __zone_watermark_ok() Commit 88f5acf88ae6 ("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 Signed-off-by: Michal Hocko Acked-by: Mel Gorman Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 4f95bcf0f2b1..59153da58c69 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1525,7 +1525,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)