On 04.12.24 19:26, Guillaume Morin wrote:
Patch prefix should likely be "mm/hugetlb: ..."
FOLL_FORCE|FOLL_WRITE has never been properly supported for hugetlb
mappings. Since 1d8d14641fd94, we explicitly reject it. However
"Since commit 1d8d14641fd9 ("mm/hugetlb: support write-faults in shared
mappings") ..."
running software on hugetlb mappings is a useful optimization.
Multiple tools allow to use that such as Intel iodlr or
libhugetlbfs.
It would be better to link to the actual request where people ran into
that when using PTRACE_POKETEXT
That hugetlb is getting used is rather obvious :)
Cc: Muchun Song <muchun.song@xxxxxxxxx>
Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Cc: Peter Xu <peterx@xxxxxxxxxx>
Cc: David Hildenbrand <david@xxxxxxxxxx>
Cc: Eric Hagberg <ehagberg@xxxxxxxxxxxxxx>
Signed-off-by: Guillaume Morin <guillaume@xxxxxxxxxxx>
---
[...]
delayacct_wpcopy_end();
return 0;
@@ -5943,7 +5944,8 @@ static vm_fault_t hugetlb_wp(struct folio *pagecache_folio,
spin_lock(vmf->ptl);
vmf->pte = hugetlb_walk(vma, vmf->address, huge_page_size(h));
if (likely(vmf->pte && pte_same(huge_ptep_get(mm, vmf->address, vmf->pte), pte))) {
- pte_t newpte = make_huge_pte(vma, &new_folio->page, !unshare);
+ const bool writable = !unshare && (vma->vm_flags & VM_WRITE);
+ pte_t newpte = make_huge_pte(vma, &new_folio->page, writable);
/* Break COW or unshare */
huge_ptep_clear_flush(vma, vmf->address, vmf->pte);
After rebasing to [1] this hunk here can likely be dropped.
make_huge_pte() will perform the VM_WRITE check.
[1] https://lkml.kernel.org/r/20241204153100.1967364-1-david@xxxxxxxxxx
--
Cheers,
David / dhildenb