linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: cma: allocate pages from CMA if NR_FREE_PAGES approaches low water mark
@ 2012-11-12  8:59 Marek Szyprowski
  2012-11-14 22:58 ` Andrew Morton
  2012-11-20  0:01 ` Minchan Kim
  0 siblings, 2 replies; 12+ messages in thread
From: Marek Szyprowski @ 2012-11-12  8:59 UTC (permalink / raw)
  To: linux-mm, linaro-mm-sig, linux-kernel
  Cc: Marek Szyprowski, Kyungmin Park, Andrew Morton, Mel Gorman,
	Michal Nazarewicz, Minchan Kim, Bartlomiej Zolnierkiewicz

It has been observed that system tends to keep a lot of CMA free pages
even in very high memory pressure use cases. The CMA fallback for movable
pages is used very rarely, only when system is completely pruned from
MOVABLE pages, what usually means that the out-of-memory even will be
triggered very soon. To avoid such situation and make better use of CMA
pages, a heuristics is introduced which turns on CMA fallback for movable
pages when the real number of free pages (excluding CMA free pages)
approaches low water mark.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Kyungmin Park <kyungmin.park@samsung.com>
CC: Michal Nazarewicz <mina86@mina86.com>
---
 mm/page_alloc.c |    9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index fcb9719..90b51f3 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1076,6 +1076,15 @@ static struct page *__rmqueue(struct zone *zone, unsigned int order,
 {
 	struct page *page;
 
+#ifdef CONFIG_CMA
+	unsigned long nr_free = zone_page_state(zone, NR_FREE_PAGES);
+	unsigned long nr_cma_free = zone_page_state(zone, NR_FREE_CMA_PAGES);
+
+	if (migratetype == MIGRATE_MOVABLE && nr_cma_free &&
+	    nr_free - nr_cma_free < 2 * low_wmark_pages(zone))
+		migratetype = MIGRATE_CMA;
+#endif /* CONFIG_CMA */
+
 retry_reserve:
 	page = __rmqueue_smallest(zone, order, migratetype);
 
-- 
1.7.9.5

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-11-23  4:42 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-12  8:59 [PATCH] mm: cma: allocate pages from CMA if NR_FREE_PAGES approaches low water mark Marek Szyprowski
2012-11-14 22:58 ` Andrew Morton
2012-11-19 15:38   ` Marek Szyprowski
2012-11-19 20:43     ` Andrew Morton
2012-11-20  0:01 ` Minchan Kim
2012-11-20 14:49   ` Marek Szyprowski
2012-11-20 15:41     ` Michal Nazarewicz
2012-11-21  1:05     ` Minchan Kim
2012-11-21 13:07       ` Michal Nazarewicz
2012-11-21 13:25         ` Minchan Kim
2012-11-21 15:50       ` Marek Szyprowski
2012-11-23  4:42         ` Minchan Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).