Skip to content

mm/hugetlb: fixes for PMD table sharing (incl. using mmu_gather)

David Hildenbrand (Red Hat) linux-arch linux-mm lkml stable 4 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest posting 2/24 patches 10 repliesIn review 3 of 4 applied
  2. v3 posting 1/23 patches 1 replySuperseded
  3. v24 patches 13 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v14 patches27 repliesApplied 4/4

Changes in v3 from the cover letter

* Rebased to 6.19-rc2 and retested on x86
* Changes on last patch:
* Introduce and use tlb_gather_mmu_vma() for properly setting up mmu_gather for hugetlb -- thanks to Harry for pointing me once again at the nasty hugetlb integration in mmu_gather
* Move tlb_remove_huge_tlb_entry() after move_huge_pte()
* For consistency, always call tlb_gather_mmu_vma() after flush_cache_range()
* Don't pass mmu_gather to hugetlb_change_protection(), simply use a local one for now. (avoids messing with tlb_start_vma() / tlb_start_end())
* Dropped Lorenzo's RB due to the changes

Patches in v3 posting 2/2 3 of 4 applied

#Subject and filesSizeRepliesApplied
1/4mm/hugetlb: fix hugetlb_pmd_shared()include/linux/hugetlb.h+1 -10 repliesApplied
2/4mm/hugetlb: fix two comments related to huge_pmd_unshare()mm/hugetlb.c+8 -160 repliesApplied
3/4mm/rmap: fix two comments related to huge_pmd_unshare()mm/rmap.c+4 -160 repliesApplied
4/4mm/hugetlb: fix excessive IPI broadcasts when unsharing PMD tables using mmu_gatherinclude/asm-generic/tlb.h include/linux/hugetlb.h include/linux/mm_types.h +3 more+208 -664 replies

Reviews trailers per patch

All 4 patches have a Reviewed-by or Acked-by.

PatchRik van RielLance YangHarry YooLaurence ObermanLorenzo StoakesOscar Salvador
SeriesT-b
1/4R-b R-b T-b R-b T-b R-b A-b
2/4R-b R-b T-b R-b A-b
3/4R-b T-b R-b A-b
4/4A-b T-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 6 reviewers.

Read the v3 thread

Cover letter [PATCH RESEND v3 0/4] mm/hugetlb: fixes for PMD table sharing (incl. using mmu_gather)

One functional fix, one performance regression fix, and two related comment fixes.

I cleaned up my prototype I recently shared [1] for the performance fix, deferring most of the cleanups I had in the prototype to a later point. While doing that I identified the other things.

The goal of this patch set is to be backported to stable trees "fairly" easily. At least patch #1 and #4.

Patch #1 fixes hugetlb_pmd_shared() not detecting any sharing Patch #2 + #3 are simple comment fixes that patch #4 interacts with. Patch #4 is a fix for the reported performance regression due to excessive IPI broadcasts during fork()+exit().

The last patch is all about TLB flushes, IPIs and mmu_gather.
Read: complicated

I added as much comments + description that I possibly could, and I am hoping for review from Jann.

There are plenty of cleanups in the future to be had + one reasonable optimization on x86. But that's all out of scope for this series.

Compile tested on plenty of architectures.

Runtime tested, with a focus on fixing the performance regression using the original reproducer [2] on x86.

[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/

--

v2 -> v3:
* Rebased to 6.19-rc2 and retested on x86
* Changes on last patch:
* Introduce and use tlb_gather_mmu_vma() for properly setting up mmu_gather for hugetlb -- thanks to Harry for pointing me once again at the nasty hugetlb integration in mmu_gather
* Move tlb_remove_huge_tlb_entry() after move_huge_pte()
* For consistency, always call tlb_gather_mmu_vma() after flush_cache_range()
* Don't pass mmu_gather to hugetlb_change_protection(), simply use a local one for now. (avoids messing with tlb_start_vma() / tlb_start_end())
* Dropped Lorenzo's RB due to the changes

v1 -> v2:
* Picked RB's/ACK's, hopefully I didn't miss any
* Added the initialization of fully_unshared_tables in __tlb_gather_mmu() (Thanks Nadav!)
* Refined some comments based on Lorenzo's feedback.

Cc Will Deacon <[email protected]>
Cc "Aneesh Kumar K.V" <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Nick Piggin <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Muchun Song <[email protected]>
Cc Oscar Salvador <[email protected]>
Cc "Liam R. Howlett" <[email protected]>
Cc Lorenzo Stoakes <[email protected]>
Cc Vlastimil Babka <[email protected]>
Cc Jann Horn <[email protected]>
Cc Pedro Falcato <[email protected]>
Cc Rik van Riel <[email protected]>
Cc Harry Yoo <[email protected]>
Cc Uschakow, Stanislav" <[email protected]>
Cc Laurence Oberman <[email protected]>
Cc Prakash Sangappa <[email protected]>
Cc Nadav Amit <[email protected]>

David Hildenbrand (Red Hat) (4):
mm/hugetlb: fix hugetlb_pmd_shared()
mm/hugetlb: fix two comments related to huge_pmd_unshare() mm/rmap: fix two comments related to huge_pmd_unshare() mm/hugetlb: fix excessive IPI broadcasts when unsharing PMD tables
using mmu_gather

 include/asm-generic/tlb.h |  77 +++++++++++++++++++++-
 include/linux/hugetlb.h   |  17 +++--
 include/linux/mm_types.h  |   1 +
 mm/hugetlb.c              | 131 +++++++++++++++++++++-----------------
 mm/mmu_gather.c           |  33 ++++++++++
 mm/rmap.c                 |  45 ++++++-------
 6 files changed, 213 insertions(+), 91 deletions(-)

base-commit: b927546677c876e26eba308550207c2ddf812a43

Signature · 1 line
2.52.0