[v3 1/4] mm: hugetlb_vmemmap: Use nid of the head page to reallocate it

Usama Arif posted 4 patches 2 years, 3 months ago
There is a newer version of this series
[v3 1/4] mm: hugetlb_vmemmap: Use nid of the head page to reallocate it
Posted by Usama Arif 2 years, 3 months ago
If tail page prep and initialization is skipped, then the "start"
page will not contain the correct nid. Use the nid from first
vmemap page.

Signed-off-by: Usama Arif <usama.arif@bytedance.com>
---
 mm/hugetlb_vmemmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c
index c2007ef5e9b0..208907f2c5e1 100644
--- a/mm/hugetlb_vmemmap.c
+++ b/mm/hugetlb_vmemmap.c
@@ -324,7 +324,7 @@ static int vmemmap_remap_free(unsigned long start, unsigned long end,
 		.reuse_addr	= reuse,
 		.vmemmap_pages	= &vmemmap_pages,
 	};
-	int nid = page_to_nid((struct page *)start);
+	int nid = page_to_nid((struct page *)reuse);
 	gfp_t gfp_mask = GFP_KERNEL | __GFP_THISNODE | __GFP_NORETRY |
 			__GFP_NOWARN;
 
-- 
2.25.1
Re: [v3 1/4] mm: hugetlb_vmemmap: Use nid of the head page to reallocate it
Posted by Muchun Song 2 years, 3 months ago

> On Aug 25, 2023, at 19:18, Usama Arif <usama.arif@bytedance.com> wrote:
> 
> If tail page prep and initialization is skipped, then the "start"
> page will not contain the correct nid. Use the nid from first
> vmemap page.
> 
> Signed-off-by: Usama Arif <usama.arif@bytedance.com>

Make sense even if without your optimization. Because the nid is
used for allocation for "reuse" page, it really should be extracted
from "reuse" page instead of "start" page.

Reviewed-by: Muchun Song <songmuchun@bytedance.com>
Re: [v3 1/4] mm: hugetlb_vmemmap: Use nid of the head page to reallocate it
Posted by Mike Kravetz 2 years, 3 months ago
On 08/28/23 15:15, Muchun Song wrote:
> 
> 
> > On Aug 25, 2023, at 19:18, Usama Arif <usama.arif@bytedance.com> wrote:
> > 
> > If tail page prep and initialization is skipped, then the "start"
> > page will not contain the correct nid. Use the nid from first
> > vmemap page.
> > 
> > Signed-off-by: Usama Arif <usama.arif@bytedance.com>
> 
> Make sense even if without your optimization. Because the nid is
> used for allocation for "reuse" page, it really should be extracted
> from "reuse" page instead of "start" page.
> 
> Reviewed-by: Muchun Song <songmuchun@bytedance.com>

Agree that using reuse is better than start here.  However, IIUC there is no
way start and reuse could be on different nodes today.

Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
-- 
Mike Kravetz