linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/hugetlb: try preferred node first when alloc gigantic page from cma
@ 2020-08-30 14:04 Li Xinhai
  2020-08-31 21:44 ` Mike Kravetz
  0 siblings, 1 reply; 6+ messages in thread
From: Li Xinhai @ 2020-08-30 14:04 UTC (permalink / raw)
  To: linux-mm; +Cc: akpm, Roman Gushchin, Mike Kravetz, Michal Hocko

Since commit cf11e85fc08cc6a4 ("mm: hugetlb: optionally allocate gigantic
hugepages using cma"), the gigantic page would be allocated from node
which is not the preferred node, although there are pages available from
that node. The reason is that the nid parameter has been ignored in
alloc_gigantic_page().

After this patch, the preferred node is tried first before other allowed
nodes.

Fixes: cf11e85fc08cc6a4 ("mm: hugetlb: optionally allocate gigantic hugepages using cma")
Cc: Roman Gushchin <guro@fb.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Michal Hocko <mhocko@kernel.org>
Signed-off-by: Li Xinhai <lixinhai.lxh@gmail.com>
---
 mm/hugetlb.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index a301c2d672bf..4a28b8853d47 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1256,8 +1256,15 @@ static struct page *alloc_gigantic_page(struct hstate *h, gfp_t gfp_mask,
 		struct page *page;
 		int node;
 
+		if (hugetlb_cma[nid]) {
+			page = cma_alloc(hugetlb_cma[nid], nr_pages,
+					huge_page_order(h), true);
+			if (page)
+				return page;
+		}
+
 		for_each_node_mask(node, *nodemask) {
-			if (!hugetlb_cma[node])
+			if (node == nid || !hugetlb_cma[node])
 				continue;
 
 			page = cma_alloc(hugetlb_cma[node], nr_pages,
-- 
2.18.4



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

end of thread, other threads:[~2020-09-01 14:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-30 14:04 [PATCH] mm/hugetlb: try preferred node first when alloc gigantic page from cma Li Xinhai
2020-08-31 21:44 ` Mike Kravetz
2020-09-01 13:41   ` Michal Hocko
2020-09-01 14:20     ` Li Xinhai
2020-09-01 14:53       ` Michal Hocko
2020-09-01 14:59         ` Li Xinhai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox