[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241201212240.533824-3-peterx@redhat.com>
Date: Sun, 1 Dec 2024 16:22:35 -0500
From: Peter Xu <peterx@...hat.com>
To: linux-kernel@...r.kernel.org,
linux-mm@...ck.org
Cc: Rik van Riel <riel@...riel.com>,
Breno Leitao <leitao@...ian.org>,
Andrew Morton <akpm@...ux-foundation.org>,
peterx@...hat.com,
Muchun Song <muchun.song@...ux.dev>,
Oscar Salvador <osalvador@...e.de>,
Roman Gushchin <roman.gushchin@...ux.dev>,
Naoya Horiguchi <nao.horiguchi@...il.com>,
Ackerley Tng <ackerleytng@...gle.com>
Subject: [PATCH 2/7] mm/hugetlb: Stop using avoid_reserve flag in fork()
When fork() and stumble on top of a dma-pinned hugetlb private page, CoW
must happen during fork() to guarantee dma coherency.
In this specific path, hugetlb pages need to be allocated for the child
process. Stop using avoid_reserve=1 flag here: it's not required to be
used here, as dest_vma (which is destined to be a MAP_PRIVATE hugetlb vma)
will have no private vma resv map, and that will make sure it won't be able
to use a vma reservation later.
No functional change intended with this change. Said that, it's still
wanted to do this, so as to reduce the usage of avoid_reserve to the only
one user, which is also why this flag was introduced initially in commit
04f2cbe35699 ("hugetlb: guarantee that COW faults for a process that called
mmap(MAP_PRIVATE) on hugetlbfs will succeed"). I don't see whoever else
should set it at all.
Further patch will clean up resv accounting based on this.
Signed-off-by: Peter Xu <peterx@...hat.com>
---
mm/hugetlb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 9ce69fd22a01..8d4b4197d11b 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -5317,7 +5317,7 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
spin_unlock(src_ptl);
spin_unlock(dst_ptl);
/* Do not use reserve as it's private owned */
- new_folio = alloc_hugetlb_folio(dst_vma, addr, 1);
+ new_folio = alloc_hugetlb_folio(dst_vma, addr, 0);
if (IS_ERR(new_folio)) {
folio_put(pte_folio);
ret = PTR_ERR(new_folio);
--
2.47.0
Powered by blists - more mailing lists