linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: cma: improve utilization of cma pages
@ 2016-11-03  8:58 Chen Feng
  2016-11-03  9:54 ` kbuild test robot
  0 siblings, 1 reply; 3+ messages in thread
From: Chen Feng @ 2016-11-03  8:58 UTC (permalink / raw)
  To: puck.chen, akpm, mhocko, vbabka, hannes, kirill.shutemov, mgorman,
	iamjoonsoo.kim, linux-mm, linux-kernel
  Cc: oliver.fu, suzhuangluan, qijiwen, xuyiping, puck.chen

Currently, cma pages can only be use by fallback of movable.
When there is no movable pages, the pcp pages will also be refilled.

So use the cma type before movable pages, and let cma-type fallback to
movable type.

I also have seen Joonsoo Kim on cma-zone. Makes cma pages a zone. It's
a good idea. But while testing it, the cma zone can be exhausted soon.
Then the cma zone will always doing balance. The slab_scans and swap
ion/out will be too high.

CC: Qiu xishi <qiuxishi@huawei.com>
Signed-off-by: Chen Feng <puck.chen@hisilicon.com>
Reviewd-by: Fu Jun <oliver.fu@hisilicon.com>
---
 include/linux/gfp.h    |  3 +++
 include/linux/mmzone.h |  4 ++--
 mm/page_alloc.c        | 24 ++++++++----------------
 3 files changed, 13 insertions(+), 18 deletions(-)

diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index f8041f9de..0bb8599 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -270,6 +270,9 @@ static inline int gfpflags_to_migratetype(const gfp_t gfp_flags)
 	BUILD_BUG_ON((1UL << GFP_MOVABLE_SHIFT) != ___GFP_MOVABLE);
 	BUILD_BUG_ON((___GFP_MOVABLE >> GFP_MOVABLE_SHIFT) != MIGRATE_MOVABLE);
 
+	if (IS_ENABLED(CONFIG_CMA) && gfp_flags & __GFP_MOVABLE)
+		return MIGRATE_CMA;
+
 	if (unlikely(page_group_by_mobility_disabled))
 		return MIGRATE_UNMOVABLE;
 
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 0f088f3..c7875c1 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -39,8 +39,6 @@ enum {
 	MIGRATE_UNMOVABLE,
 	MIGRATE_MOVABLE,
 	MIGRATE_RECLAIMABLE,
-	MIGRATE_PCPTYPES,	/* the number of types on the pcp lists */
-	MIGRATE_HIGHATOMIC = MIGRATE_PCPTYPES,
 #ifdef CONFIG_CMA
 	/*
 	 * MIGRATE_CMA migration type is designed to mimic the way
@@ -57,6 +55,8 @@ enum {
 	 */
 	MIGRATE_CMA,
 #endif
+	MIGRATE_PCPTYPES,	/* the number of types on the pcp lists */
+	MIGRATE_HIGHATOMIC = MIGRATE_PCPTYPES,
 #ifdef CONFIG_MEMORY_ISOLATION
 	MIGRATE_ISOLATE,	/* can't allocate from here */
 #endif
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 8fd42aa..33ed6f3 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1828,17 +1828,6 @@ struct page *__rmqueue_smallest(struct zone *zone, unsigned int order,
 #endif
 };
 
-#ifdef CONFIG_CMA
-static struct page *__rmqueue_cma_fallback(struct zone *zone,
-					unsigned int order)
-{
-	return __rmqueue_smallest(zone, order, MIGRATE_CMA);
-}
-#else
-static inline struct page *__rmqueue_cma_fallback(struct zone *zone,
-					unsigned int order) { return NULL; }
-#endif
-
 /*
  * Move the free pages in a range to the free lists of the requested type.
  * Note that start_page and end_pages are not aligned on a pageblock
@@ -2171,10 +2160,13 @@ static struct page *__rmqueue(struct zone *zone, unsigned int order,
 	struct page *page;
 
 	page = __rmqueue_smallest(zone, order, migratetype);
-	if (unlikely(!page)) {
-		if (migratetype == MIGRATE_MOVABLE)
-			page = __rmqueue_cma_fallback(zone, order);
+	/* Fallback cma type to movable here */
+	if (!page && migratetype == MIGRATE_CMA) {
+		migratetype = MIGRATE_MOVABLE;
+		page = __rmqueue_smallest(zone, order, migratetype);
+	}
 
+	if (unlikely(!page)) {
 		if (!page)
 			page = __rmqueue_fallback(zone, order, migratetype);
 	}
@@ -2787,7 +2779,7 @@ bool __zone_watermark_ok(struct zone *z, unsigned int order, unsigned long mark,
 		if (alloc_harder)
 			return true;
 
-		for (mt = 0; mt < MIGRATE_PCPTYPES; mt++) {
+		for (mt = 0; mt < MIGRATE_PCPTYPES - 1; mt++) {
 			if (!list_empty(&area->free_list[mt]))
 				return true;
 		}
@@ -4206,10 +4198,10 @@ static void show_migration_types(unsigned char type)
 		[MIGRATE_UNMOVABLE]	= 'U',
 		[MIGRATE_MOVABLE]	= 'M',
 		[MIGRATE_RECLAIMABLE]	= 'E',
-		[MIGRATE_HIGHATOMIC]	= 'H',
 #ifdef CONFIG_CMA
 		[MIGRATE_CMA]		= 'C',
 #endif
+		[MIGRATE_HIGHATOMIC]	= 'H',
 #ifdef CONFIG_MEMORY_ISOLATION
 		[MIGRATE_ISOLATE]	= 'I',
 #endif
-- 
1.9.1

--
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] 3+ messages in thread

end of thread, other threads:[~2016-11-03 10:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-03  8:58 [PATCH] mm: cma: improve utilization of cma pages Chen Feng
2016-11-03  9:54 ` kbuild test robot
2016-11-03 10:40   ` Chen Feng

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).