Skip to content

mm/gup: Unify hugetlb, speed up thp

Peter Xu linux-mm lkml 4 versions – Applied

Status from this message: [merged mm-stable] selftests-mm-add-gup-test-matrix-in-run_vmtestssh.patch removed from -mm tree

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest8 patches 0 repliesApplied 8/8
  2. v38 patches 8 repliesSuperseded
  3. v28 patches 13 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v17 patches31 repliesSuperseded

Changes in v4 from the cover letter

- Patch 2: check pte write for unsharing [David]
- Added more tags, rebased to akpm/mm-unstable

Patches in v4 All 8 applied

#Subject and filesSizeRepliesApplied
1/8mm/hugetlb: Handle FOLL_DUMP well in follow_page_mask()mm/gup.c mm/hugetlb.c+11 -70 repliesApplied
2/8mm/hugetlb: Prepare hugetlb_follow_page_mask() for FOLL_PINmm/hugetlb.c+22 -110 repliesApplied
3/8mm/hugetlb: Add page_mask for hugetlb_follow_page_mask()include/linux/hugetlb.h mm/gup.c mm/hugetlb.c+11 -50 repliesApplied
4/8mm/gup: Cleanup next_page handlingmm/gup.c+3 -40 repliesApplied
5/8mm/gup: Accelerate thp gup even for "pages != NULL"mm/gup.c+44 -70 repliesApplied
6/8mm/gup: Retire follow_hugetlb_page()fs/userfaultfd.c include/linux/hugetlb.h mm/gup.c +1 more+1 -2560 repliesApplied
7/8selftests/mm: Add -a to run_vmtests.shtools/testing/selftests/mm/run_vmtests.sh+8 -30 repliesApplied
8/8selftests/mm: Add gup test matrix in run_vmtests.shtools/testing/selftests/mm/run_vmtests.sh+32 -50 repliesApplied

Reviews trailers per patch

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

PatchMike KravetzDavid HildenbrandLorenzo Stoakes
1/8R-b R-b
2/8R-b R-b
3/8R-b
4/8A-b R-b
5/8R-b
6/8A-b
7/8A-b
8/8A-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 3 reviewers.

Read the v4 thread

Cover letter [PATCH v4 0/8] mm/gup: Unify hugetlb, speed up thp

v1: https://lore.kernel.org/r/[email protected]
v2: https://lore.kernel.org/r/[email protected]
v3: https://lore.kernel.org/r/[email protected]

v4:
- Patch 2: check pte write for unsharing [David]
- Added more tags, rebased to akpm/mm-unstable

Hugetlb has a special path for slow gup that follow_page_mask() is actually skipped completely along with faultin_page(). It's not only confusing, but also duplicating a lot of logics that generic gup already has, making hugetlb slightly special.

This patchset tries to dedup the logic, by first touching up the slow gup code to be able to handle hugetlb pages correctly with the current follow page and faultin routines (where we're mostly there.. due to 10 years ago we did try to optimize thp, but half way done; more below), then at the last patch drop the special path, then the hugetlb gup will always go the generic routine too via faultin_page().

Note that hugetlb is still special for gup, mostly due to the pgtable walking (hugetlb_walk()) that we rely on which is currently per-arch. But this is still one small step forward, and the diffstat might be a proof too that this might be worthwhile.

Then for the "speed up thp" side: as a side effect, when I'm looking at the chunk of code, I found that thp support is actually partially done. It doesn't mean that thp won't work for gup, but as long as **pages pointer passed over, the optimization will be skipped too. Patch 6 should address that, so for thp we now get full speed gup.

For a quick number, "chrt -f 1 ./gup_test -m 512 -t -L -n 1024 -r 10" gives me 13992.50us -> 378.50us. Gup_test is an extreme case, but just to show how it affects thp gups.

Patch 1-5:   prepares for the switch
Patch 6:     switchover to the new code and remove the old
Patch 7-8:   added some gup test matrix into run_vmtests.sh

Please review, thanks.

Peter Xu (8):
mm/hugetlb: Handle FOLL_DUMP well in follow_page_mask() mm/hugetlb: Prepare hugetlb_follow_page_mask() for FOLL_PIN mm/hugetlb: Add page_mask for hugetlb_follow_page_mask() mm/gup: Cleanup next_page handling
mm/gup: Accelerate thp gup even for "pages != NULL" mm/gup: Retire follow_hugetlb_page() selftests/mm: Add -a to run_vmtests.sh selftests/mm: Add gup test matrix in run_vmtests.sh

 fs/userfaultfd.c                          |   2 +-
 include/linux/hugetlb.h                   |  20 +-
 mm/gup.c                                  |  83 ++++---
 mm/hugetlb.c                              | 265 +++-------------------
 tools/testing/selftests/mm/run_vmtests.sh |  48 +++-
 5 files changed, 126 insertions(+), 292 deletions(-)
Signature · 1 line
2.41.0