aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorCody P Schafer <cody@linux.vnet.ibm.com>2013-07-03 18:01:32 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-07-03 19:07:27 -0400
commit998d39cb236fe464af86a3492a24d2f67ee1efc2 (patch)
treec093fb89e8d4a4b62e656f5becf92876ce13f958 /mm
parent8d7a8fa97abeb4fd6b3975d32c9f859875157770 (diff)
mm/page_alloc: protect pcp->batch accesses with ACCESS_ONCE
pcp->batch could change at any point, avoid relying on it being a stable value. Signed-off-by: Cody P Schafer <cody@linux.vnet.ibm.com> Cc: Gilad Ben-Yossef <gilad@benyossef.com> Cc: KOSAKI Motohiro <kosaki.motohiro@gmail.com> Cc: Mel Gorman <mgorman@suse.de> Cc: Pekka Enberg <penberg@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/page_alloc.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index eaaef2a09424..97b8f861e63d 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1182,10 +1182,12 @@ void drain_zone_pages(struct zone *zone, struct per_cpu_pages *pcp)
1182{ 1182{
1183 unsigned long flags; 1183 unsigned long flags;
1184 int to_drain; 1184 int to_drain;
1185 unsigned long batch;
1185 1186
1186 local_irq_save(flags); 1187 local_irq_save(flags);
1187 if (pcp->count >= pcp->batch) 1188 batch = ACCESS_ONCE(pcp->batch);
1188 to_drain = pcp->batch; 1189 if (pcp->count >= batch)
1190 to_drain = batch;
1189 else 1191 else
1190 to_drain = pcp->count; 1192 to_drain = pcp->count;
1191 if (to_drain > 0) { 1193 if (to_drain > 0) {
@@ -1353,8 +1355,9 @@ void free_hot_cold_page(struct page *page, int cold)
1353 list_add(&page->lru, &pcp->lists[migratetype]); 1355 list_add(&page->lru, &pcp->lists[migratetype]);
1354 pcp->count++; 1356 pcp->count++;
1355 if (pcp->count >= pcp->high) { 1357 if (pcp->count >= pcp->high) {
1356 free_pcppages_bulk(zone, pcp->batch, pcp); 1358 unsigned long batch = ACCESS_ONCE(pcp->batch);
1357 pcp->count -= pcp->batch; 1359 free_pcppages_bulk(zone, batch, pcp);
1360 pcp->count -= batch;
1358 } 1361 }
1359 1362
1360out: 1363out: