]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mm: clear pages_scanned only if draining a pcp adds pages to the buddy allocator...
authorKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Sat, 21 Jul 2012 00:54:09 +0000 (10:54 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 25 Jul 2012 03:02:28 +0000 (13:02 +1000)
commit 2ff754fa8f ("mm: clear pages_scanned only if draining a pcp adds
pages to the buddy allocator again") fixed one free_pcppages_bulk()
misuse.  But two another miuse still exist.

This patch fixes it.

Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Acked-by: David Rientjes <rientjes@google.com>
Acked-by: Mel Gorman <mel@csn.ul.ie>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: Minchan Kim <minchan@kernel.org>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Rik van Riel <riel@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/page_alloc.c

index 3f2486208ef63be817cb4086199ff6b28787375e..441d77c3e810db0c8b938960a1c6e6322fa7fd04 100644 (file)
@@ -1157,8 +1157,10 @@ void drain_zone_pages(struct zone *zone, struct per_cpu_pages *pcp)
                to_drain = pcp->batch;
        else
                to_drain = pcp->count;
-       free_pcppages_bulk(zone, to_drain, pcp);
-       pcp->count -= to_drain;
+       if (to_drain > 0) {
+               free_pcppages_bulk(zone, to_drain, pcp);
+               pcp->count -= to_drain;
+       }
        local_irq_restore(flags);
 }
 #endif
@@ -3914,7 +3916,8 @@ static int __zone_pcp_update(void *data)
                pcp = &pset->pcp;
 
                local_irq_save(flags);
-               free_pcppages_bulk(zone, pcp->count, pcp);
+               if (pcp->count > 0)
+                       free_pcppages_bulk(zone, pcp->count, pcp);
                setup_pageset(pset, batch);
                local_irq_restore(flags);
        }