[RFC PATCH v2 11/16] mm: Sets the migrate type in gfp_t flags

Juan Yescas <[email protected]>
Newsgroups gmane.linux.kernel,gmane.linux.kernel.mm,gmane.linux.kernel.mm
Message-ID <[email protected]>
This change sets the selected migrate type in gfp_t flags.

Signed-off-by: Juan Yescas <[email protected]>
---

Changes in v2:
	- Make sure that ZONE_MOVABLE is only used by MIGRATE_MOVABLE requests.

 mm/page_alloc_hogger.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/mm/page_alloc_hogger.c b/mm/page_alloc_hogger.c
index 0e9ac43e9868..4b72acfbc087 100644
--- a/mm/page_alloc_hogger.c
+++ b/mm/page_alloc_hogger.c
@@ -155,6 +155,24 @@ static inline void set_zone_to_alloc_from(int zone_idx, gfp_t *flags_ptr)
 	}
 }
 
+static inline void set_migrate_type_to_alloc_from(int migrate_type, gfp_t *flags_ptr)
+{
+	switch (migrate_type) {
+	case MIGRATE_UNMOVABLE:
+		*flags_ptr &= ~(__GFP_RECLAIMABLE | __GFP_MOVABLE);
+		break;
+	case MIGRATE_RECLAIMABLE:
+		*flags_ptr |= __GFP_RECLAIMABLE;
+		break;
+	case MIGRATE_HIGHATOMIC:
+		*flags_ptr |= __GFP_HIGH;
+		break;
+	case MIGRATE_MOVABLE: default:
+		*flags_ptr |= __GFP_MOVABLE;
+		break;
+	}
+}
+
 /**
  * req_page_alloc_write() - Allocates the pages on the requested node, zone,
  * order and migrate type. Once the allocation is performed, a file is created
@@ -179,6 +197,7 @@ static ssize_t req_page_alloc_write(struct file *file, const char __user *ubuf,
 		return -ENOMEM;
 
 	set_zone_to_alloc_from(req->zone_idx, &flags);
+	set_migrate_type_to_alloc_from(req->migrate_type, &flags);
 
 	kfree(allocs_ids);
 
@@ -248,6 +267,9 @@ static inline int create_migrate_type_subdirs(struct dentry *orderdir, int nid,
 		if (mtype == MIGRATE_ISOLATE) /* can't allocate from here */
 			continue;
 #endif
+		if (zone_idx == ZONE_MOVABLE && mtype != MIGRATE_MOVABLE)
+			continue;
+
 		snprintf(dirname, sizeof(dirname), "migrate-%s",
 			 migratetype_names[mtype]);
 		migratedir = debugfs_create_dir(dirname, orderdir);
-- 
2.55.0.629.g250fe7f194-goog
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.