mbox series

[v3,00/15] Allocate and free frozen pages

Message ID 20241125210149.2976098-1-willy@infradead.org (mailing list archive)
Headers show
Series Allocate and free frozen pages | expand

Message

Matthew Wilcox (Oracle) Nov. 25, 2024, 9:01 p.m. UTC
Slab does not need to use the page refcount at all, and it can avoid
an atomic operation on page free.  Hugetlb wants to delay setting the
refcount until it has assembled a complete gigantic page.  We already
have the ability to freeze a page (safely reduce its reference count to
0), so this patchset adds APIs to allocate and free pages which are in
a frozen state.

This patchset is also a step towards the Glorious Future in which struct
page doesn't have a refcount; the users which need a refcount will have
one in their per-allocation memdesc.

v3:
 - Rebase to next-20241114
 - Drop patch for free_the_page() as it no longer exists; instead rename
   free_unref_page() to free_frozen_pages()
 - Add patch to make alloc_pages_mpol() static
 - Drop slab patch since slab is gone
 - There are now many more callers of post_alloc_hook() and prep_new_page()
   than there used to be, but I reviewed the changes and believe they are
   all changed in the appropriate commit.
 - Adapt to _noprof

v2: https://lore.kernel.org/linux-mm/20220809171854.3725722-1-willy@infradead.org/

Matthew Wilcox (Oracle) (15):
  mm/page_alloc: Cache page_zone() result in free_unref_page()
  mm: Make alloc_pages_mpol() static
  mm/page_alloc: Export free_frozen_pages() instead of free_unref_page()
  mm/page_alloc: Move set_page_refcounted() to callers of
    post_alloc_hook()
  mm/page_alloc: Move set_page_refcounted() to callers of
    prep_new_page()
  mm/page_alloc: Move set_page_refcounted() to callers of
    get_page_from_freelist()
  mm/page_alloc: Move set_page_refcounted() to callers of
    __alloc_pages_cpuset_fallback()
  mm/page_alloc: Move set_page_refcounted() to callers of
    __alloc_pages_may_oom()
  mm/page_alloc: Move set_page_refcounted() to callers of
    __alloc_pages_direct_compact()
  mm/page_alloc: Move set_page_refcounted() to callers of
    __alloc_pages_direct_reclaim()
  mm/page_alloc: Move set_page_refcounted() to callers of
    __alloc_pages_slowpath()
  mm/page_alloc: Move set_page_refcounted() to end of __alloc_pages()
  mm/page_alloc: Add __alloc_frozen_pages()
  mm/mempolicy: Add alloc_frozen_pages()
  slab: Allocate frozen pages

 include/linux/gfp.h  |  8 -------
 mm/compaction.c      |  2 ++
 mm/internal.h        | 21 +++++++++++++++---
 mm/mempolicy.c       | 53 ++++++++++++++++++++++++++++----------------
 mm/page_alloc.c      | 45 ++++++++++++++++++++++++-------------
 mm/page_frag_cache.c |  6 ++---
 mm/slub.c            |  6 ++---
 mm/swap.c            |  2 +-
 8 files changed, 90 insertions(+), 53 deletions(-)