All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/13] mm/gup: Unify hugetlb, part 2
@ 2024-01-03  9:14 ` peterx
  0 siblings, 0 replies; 143+ messages in thread
From: peterx @ 2024-01-03  9:14 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: James Houghton, David Hildenbrand, Kirill A . Shutemov, Yang Shi,
	peterx, linux-riscv, Andrew Morton, Aneesh Kumar K . V,
	Rik van Riel, Andrea Arcangeli, Axel Rasmussen, Mike Rapoport,
	John Hubbard, Vlastimil Babka, Michael Ellerman,
	Christophe Leroy, Andrew Jones, linuxppc-dev, Mike Kravetz,
	Muchun Song, linux-arm-kernel, Jason Gunthorpe,
	Christoph Hellwig, Lorenzo Stoakes, Matthew Wilcox

From: Peter Xu <peterx@redhat.com>

v2:
- Collect acks
- Patch 9:
  - Use READ_ONCE() to fetch pud entry [James]

rfc: https://lore.kernel.org/r/20231116012908.392077-1-peterx@redhat.com
v1:  https://lore.kernel.org/r/20231219075538.414708-1-peterx@redhat.com

This is v2 of the series, based on latest mm-unstalbe (856325d361df).

The series removes the hugetlb slow gup path after a previous refactor work
[1], so that slow gup now uses the exact same path to process all kinds of
memory including hugetlb.

For the long term, we may want to remove most, if not all, call sites of
huge_pte_offset().  It'll be ideal if that API can be completely dropped
from arch hugetlb API.  This series is one small step towards merging
hugetlb specific codes into generic mm paths.  From that POV, this series
removes one reference to huge_pte_offset() out of many others.

One goal of such a route is that we can reconsider merging hugetlb features
like High Granularity Mapping (HGM).  It was not accepted in the past
because it may add lots of hugetlb specific codes and make the mm code even
harder to maintain.  With a merged codeset, features like HGM can hopefully
share some code with THP, legacy (PMD+) or modern (continuous PTEs).

To make it work, the generic slow gup code will need to at least understand
hugepd, which is already done like so in fast-gup.  Fortunately it seems
that's the only major thing I need to teach slow GUP to share the common
path for now besides normal huge PxD entries.  Non-gup can be more
challenging, but that's a question for later.

There's one major difference for slow-gup on cont_pte / cont_pmd handling,
currently supported on three architectures (aarch64, riscv, ppc).  Before
the series, slow gup will be able to recognize e.g. cont_pte entries with
the help of huge_pte_offset() when hstate is around.  Now it's gone but
still working, by looking up pgtable entries one by one.

It's not ideal, but hopefully this change should not affect yet on major
workloads.  There's some more information in the commit message of the last
patch.  If this would be a concern, we can consider teaching slow gup to
recognize cont pte/pmd entries, and that should recover the lost
performance.  But I doubt its necessity for now, so I kept it as simple as
it can be.

Test Done
=========

This v1 went through the normal GUP smoke tests over different memory
types on archs (using VM instances): x86_64, aarch64, ppc64le.  For
aarch64, tested over 64KB cont_pte huge pages.  For ppc64le, tested over
16MB hugepd entries (Power8 hash MMU on 4K base page size).

Patch layout
=============

Patch 1-7:    Preparation works, or cleanups in relevant code paths
Patch 8-12:   Teach slow gup with all kinds of huge entries (pXd, hugepd)
Patch 13:     Drop hugetlb_follow_page_mask()

More information can be found in the commit messages of each patch.  Any
comment will be welcomed.  Thanks.

[1] https://lore.kernel.org/all/20230628215310.73782-1-peterx@redhat.com

Peter Xu (13):
  mm/Kconfig: CONFIG_PGTABLE_HAS_HUGE_LEAVES
  mm/hugetlb: Declare hugetlbfs_pagecache_present() non-static
  mm: Provide generic pmd_thp_or_huge()
  mm: Make HPAGE_PXD_* macros even if !THP
  mm: Introduce vma_pgtable_walk_{begin|end}()
  mm/gup: Drop folio_fast_pin_allowed() in hugepd processing
  mm/gup: Refactor record_subpages() to find 1st small page
  mm/gup: Handle hugetlb for no_page_table()
  mm/gup: Cache *pudp in follow_pud_mask()
  mm/gup: Handle huge pud for follow_pud_mask()
  mm/gup: Handle huge pmd for follow_pmd_mask()
  mm/gup: Handle hugepd for follow_page()
  mm/gup: Handle hugetlb in the generic follow_page_mask code

 include/linux/huge_mm.h |  25 +--
 include/linux/hugetlb.h |  16 +-
 include/linux/mm.h      |   3 +
 include/linux/pgtable.h |   4 +
 mm/Kconfig              |   3 +
 mm/gup.c                | 362 ++++++++++++++++++++++++++++++++--------
 mm/huge_memory.c        | 133 +--------------
 mm/hugetlb.c            |  75 +--------
 mm/internal.h           |   7 +-
 mm/memory.c             |  12 ++
 10 files changed, 342 insertions(+), 298 deletions(-)

-- 
2.41.0


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 143+ messages in thread

end of thread, other threads:[~2024-02-22  8:06 UTC | newest]

Thread overview: 143+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-03  9:14 [PATCH v2 00/13] mm/gup: Unify hugetlb, part 2 peterx
2024-01-03  9:14 ` peterx
2024-01-03  9:14 ` peterx
2024-01-03  9:14 ` peterx
2024-01-03  9:14 ` [PATCH v2 01/13] mm/Kconfig: CONFIG_PGTABLE_HAS_HUGE_LEAVES peterx
2024-01-03  9:14   ` peterx
2024-01-03  9:14   ` peterx
2024-01-03  9:14   ` peterx
2024-01-15 17:37   ` Jason Gunthorpe
2024-01-15 17:37     ` Jason Gunthorpe
2024-01-15 17:37     ` Jason Gunthorpe
2024-01-15 17:37     ` Jason Gunthorpe
2024-01-22  8:25     ` Peter Xu
2024-01-22  8:25       ` Peter Xu
2024-01-22  8:25       ` Peter Xu
2024-01-22  8:25       ` Peter Xu
2024-01-03  9:14 ` [PATCH v2 02/13] mm/hugetlb: Declare hugetlbfs_pagecache_present() non-static peterx
2024-01-03  9:14   ` peterx
2024-01-03  9:14   ` peterx
2024-01-03  9:14   ` peterx
2024-01-03  9:14 ` [PATCH v2 03/13] mm: Provide generic pmd_thp_or_huge() peterx
2024-01-03  9:14   ` peterx
2024-01-03  9:14   ` peterx
2024-01-03  9:14   ` peterx
2024-01-15 17:55   ` Jason Gunthorpe
2024-01-15 17:55     ` Jason Gunthorpe
2024-01-15 17:55     ` Jason Gunthorpe
2024-01-15 17:55     ` Jason Gunthorpe
2024-02-21  9:37     ` Peter Xu
2024-02-21  9:37       ` Peter Xu
2024-02-21  9:37       ` Peter Xu
2024-02-21  9:37       ` Peter Xu
2024-02-21 12:57       ` Jason Gunthorpe
2024-02-21 12:57         ` Jason Gunthorpe
2024-02-21 12:57         ` Jason Gunthorpe
2024-02-21 12:57         ` Jason Gunthorpe
2024-02-22  8:04         ` Peter Xu
2024-02-22  8:04           ` Peter Xu
2024-02-22  8:04           ` Peter Xu
2024-02-22  8:04           ` Peter Xu
2024-01-03  9:14 ` [PATCH v2 04/13] mm: Make HPAGE_PXD_* macros even if !THP peterx
2024-01-03  9:14   ` peterx
2024-01-03  9:14   ` peterx
2024-01-03  9:14   ` peterx
2024-01-15 17:59   ` Jason Gunthorpe
2024-01-15 17:59     ` Jason Gunthorpe
2024-01-15 17:59     ` Jason Gunthorpe
2024-01-15 17:59     ` Jason Gunthorpe
2024-01-03  9:14 ` [PATCH v2 05/13] mm: Introduce vma_pgtable_walk_{begin|end}() peterx
2024-01-03  9:14   ` peterx
2024-01-03  9:14   ` peterx
2024-01-03  9:14   ` peterx
2024-01-03  9:14 ` [PATCH v2 06/13] mm/gup: Drop folio_fast_pin_allowed() in hugepd processing peterx
2024-01-03  9:14   ` peterx
2024-01-03  9:14   ` peterx
2024-01-03  9:14   ` peterx
2024-01-15 18:37   ` Jason Gunthorpe
2024-01-15 18:37     ` Jason Gunthorpe
2024-01-15 18:37     ` Jason Gunthorpe
2024-01-15 18:37     ` Jason Gunthorpe
2024-01-16  6:30     ` Christophe Leroy
2024-01-16  6:30       ` Christophe Leroy
2024-01-16  6:30       ` Christophe Leroy
2024-01-16  6:30       ` Christophe Leroy
2024-01-16 12:31       ` Jason Gunthorpe
2024-01-16 12:31         ` Jason Gunthorpe
2024-01-16 12:31         ` Jason Gunthorpe
2024-01-16 12:31         ` Jason Gunthorpe
2024-01-16 18:32         ` Christophe Leroy
2024-01-16 18:32           ` Christophe Leroy
2024-01-16 18:32           ` Christophe Leroy
2024-01-17 13:22           ` Jason Gunthorpe
2024-01-17 13:22             ` Jason Gunthorpe
2024-01-17 13:22             ` Jason Gunthorpe
2024-01-17 13:22             ` Jason Gunthorpe
2024-01-18 15:15             ` Ryan Roberts
2024-01-18 15:15               ` Ryan Roberts
2024-01-18 15:15               ` Ryan Roberts
2024-01-18 15:15               ` Ryan Roberts
2024-02-21 11:55     ` Peter Xu
2024-02-21 11:55       ` Peter Xu
2024-02-21 11:55       ` Peter Xu
2024-02-21 11:55       ` Peter Xu
2024-01-03  9:14 ` [PATCH v2 07/13] mm/gup: Refactor record_subpages() to find 1st small page peterx
2024-01-03  9:14   ` peterx
2024-01-03  9:14   ` peterx
2024-01-03  9:14   ` peterx
2024-01-15 18:38   ` Jason Gunthorpe
2024-01-15 18:38     ` Jason Gunthorpe
2024-01-15 18:38     ` Jason Gunthorpe
2024-01-15 18:38     ` Jason Gunthorpe
2024-01-03  9:14 ` [PATCH v2 08/13] mm/gup: Handle hugetlb for no_page_table() peterx
2024-01-03  9:14   ` peterx
2024-01-03  9:14   ` peterx
2024-01-03  9:14   ` peterx
2024-01-15 18:39   ` Jason Gunthorpe
2024-01-15 18:39     ` Jason Gunthorpe
2024-01-15 18:39     ` Jason Gunthorpe
2024-01-15 18:39     ` Jason Gunthorpe
2024-01-03  9:14 ` [PATCH v2 09/13] mm/gup: Cache *pudp in follow_pud_mask() peterx
2024-01-03  9:14   ` peterx
2024-01-03  9:14   ` peterx
2024-01-03  9:14   ` peterx
2024-01-15 18:41   ` Jason Gunthorpe
2024-01-15 18:41     ` Jason Gunthorpe
2024-01-15 18:41     ` Jason Gunthorpe
2024-01-15 18:41     ` Jason Gunthorpe
2024-01-03  9:14 ` [PATCH v2 10/13] mm/gup: Handle huge pud for follow_pud_mask() peterx
2024-01-03  9:14   ` peterx
2024-01-03  9:14   ` peterx
2024-01-03  9:14   ` peterx
2024-01-15 18:49   ` Jason Gunthorpe
2024-01-15 18:49     ` Jason Gunthorpe
2024-01-15 18:49     ` Jason Gunthorpe
2024-01-15 18:49     ` Jason Gunthorpe
2024-02-21 11:49     ` Peter Xu
2024-02-21 11:49       ` Peter Xu
2024-02-21 11:49       ` Peter Xu
2024-02-21 11:49       ` Peter Xu
2024-01-03  9:14 ` [PATCH v2 11/13] mm/gup: Handle huge pmd for follow_pmd_mask() peterx
2024-01-03  9:14   ` peterx
2024-01-03  9:14   ` peterx
2024-01-03  9:14   ` peterx
2024-01-15 18:51   ` Jason Gunthorpe
2024-01-15 18:51     ` Jason Gunthorpe
2024-01-15 18:51     ` Jason Gunthorpe
2024-01-15 18:51     ` Jason Gunthorpe
2024-01-03  9:14 ` [PATCH v2 12/13] mm/gup: Handle hugepd for follow_page() peterx
2024-01-03  9:14   ` peterx
2024-01-03  9:14   ` peterx
2024-01-03  9:14   ` peterx
2024-01-03  9:14 ` [PATCH v2 13/13] mm/gup: Handle hugetlb in the generic follow_page_mask code peterx
2024-01-03  9:14   ` peterx
2024-01-03  9:14   ` peterx
2024-01-03  9:14   ` peterx
2024-01-03 11:14 ` [PATCH v2 00/13] mm/gup: Unify hugetlb, part 2 Christophe Leroy
2024-01-03 11:14   ` Christophe Leroy
2024-01-03 11:14   ` Christophe Leroy
2024-01-03 11:14   ` Christophe Leroy
2024-01-08  7:27   ` Peter Xu
2024-01-08  7:27     ` Peter Xu
2024-01-08  7:27     ` Peter Xu
2024-01-08  7:27     ` Peter Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.