2021-06-18 03:58:39

by Feng Tang

[permalink] [raw]
Subject: [PATCH v5 -mm 3/6] mm/mempolicy: enable page allocation for MPOL_PREFERRED_MANY for general cases

From: Ben Widawsky <[email protected]>

In order to support MPOL_PREFERRED_MANY which is used by
set_mempolicy(2), mbind(2), enable both alloc_pages() and
alloc_pages_vma() by using alloc_page_preferred_many().

Signed-off-by: Ben Widawsky <[email protected]>
Signed-off-by: Feng Tang <[email protected]>
---
mm/mempolicy.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index d17bf018efcc..9dce67fc9bb6 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -2207,6 +2207,12 @@ struct page *alloc_pages_vma(gfp_t gfp, int order, struct vm_area_struct *vma,
goto out;
}

+ if (pol->mode == MPOL_PREFERRED_MANY) {
+ page = alloc_page_preferred_many(gfp, order, pol);
+ mpol_cond_put(pol);
+ goto out;
+ }
+
if (unlikely(IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && hugepage)) {
int hpage_node = node;

@@ -2286,6 +2292,8 @@ struct page *alloc_pages(gfp_t gfp, unsigned order)
*/
if (pol->mode == MPOL_INTERLEAVE)
page = alloc_page_interleave(gfp, order, interleave_nodes(pol));
+ else if (pol->mode == MPOL_PREFERRED_MANY)
+ page = alloc_page_preferred_many(gfp, order, pol);
else
page = __alloc_pages(gfp, order,
policy_node(gfp, pol, numa_node_id()),
--
2.7.4