linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [RFC v2 0/4] add static huge zero folio support
@ 2025-07-24 14:49 Pankaj Raghav (Samsung)
  2025-07-24 14:49 ` [RFC v2 1/4] mm: rename huge_zero_page_shrinker to huge_zero_folio_shrinker Pankaj Raghav (Samsung)
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Pankaj Raghav (Samsung) @ 2025-07-24 14:49 UTC (permalink / raw)
  To: Suren Baghdasaryan, Ryan Roberts, Baolin Wang, Borislav Petkov,
	Ingo Molnar, H . Peter Anvin, Vlastimil Babka, Zi Yan,
	Mike Rapoport, Dave Hansen, Michal Hocko, David Hildenbrand,
	Lorenzo Stoakes, Andrew Morton, Thomas Gleixner, Nico Pache,
	Dev Jain, Liam R . Howlett, Jens Axboe
  Cc: linux-kernel, willy, linux-mm, x86, linux-block, linux-fsdevel,
	Darrick J . Wong, mcgrof, gost.dev, kernel, hch, Pankaj Raghav

From: Pankaj Raghav <p.raghav@samsung.com>

NOTE: I am resending as an RFC again based on Lorenzo's feedback. The
old series can be found here [1].

There are many places in the kernel where we need to zeroout larger
chunks but the maximum segment we can zeroout at a time by ZERO_PAGE
is limited by PAGE_SIZE.

This concern was raised during the review of adding Large Block Size support
to XFS[2][3].

This is especially annoying in block devices and filesystems where we
attach multiple ZERO_PAGEs to the bio in different bvecs. With multipage
bvec support in block layer, it is much more efficient to send out
larger zero pages as a part of a single bvec.

Some examples of places in the kernel where this could be useful:
- blkdev_issue_zero_pages()
- iomap_dio_zero()
- vmalloc.c:zero_iter()
- rxperf_process_call()
- fscrypt_zeroout_range_inline_crypt()
- bch2_checksum_update()
...

Usually huge_zero_folio is allocated on demand, and it will be
deallocated by the shrinker if there are no users of it left. At the moment,
huge_zero_folio infrastructure refcount is tied to the process lifetime
that created it. This might not work for bio layer as the completions
can be async and the process that created the huge_zero_folio might no
longer be alive. And, one of the main point that came during discussion
is to have something bigger than zero page as a drop-in replacement.

Add a config option STATIC_HUGE_ZERO_FOLIO that will always allocate
the huge_zero_folio, and it will never drop the reference. This makes
using the huge_zero_folio without having to pass any mm struct and does
not tie the lifetime of the zero folio to anything, making it a drop-in
replacement for ZERO_PAGE.

I have converted blkdev_issue_zero_pages() as an example as a part of
this series. I also noticed close to 4% performance improvement just by
replacing ZERO_PAGE with static huge_zero_folio.

I will send patches to individual subsystems using the huge_zero_folio
once this gets upstreamed.

Looking forward to some feedback.

[1] https://lore.kernel.org/linux-mm/20250707142319.319642-1-kernel@pankajraghav.com/
[2] https://lore.kernel.org/linux-xfs/20231027051847.GA7885@lst.de/
[3] https://lore.kernel.org/linux-xfs/ZitIK5OnR7ZNY0IG@infradead.org/

Changes since v1:
- Fixed all warnings.
- Added a retry feature after a particular time.
- Added Acked-by and Signed-off-by from David.

Changes since last series[1]:
- Instead of allocating a new page through memblock, use the same
  infrastructure as huge_zero_folio but raise the reference and never
  drop it. (David)
- And some minor cleanups based on Lorenzo's feedback.

Pankaj Raghav (4):
  mm: rename huge_zero_page_shrinker to huge_zero_folio_shrinker
  mm: add static huge zero folio
  mm: add largest_zero_folio() routine
  block: use largest_zero_folio in __blkdev_issue_zero_pages()

 arch/x86/Kconfig        |  1 +
 block/blk-lib.c         | 15 +++++-----
 include/linux/huge_mm.h | 35 ++++++++++++++++++++++
 mm/Kconfig              | 21 +++++++++++++
 mm/huge_memory.c        | 66 +++++++++++++++++++++++++++++++++--------
 5 files changed, 119 insertions(+), 19 deletions(-)


base-commit: 4c831e7a4b72b7ac16b84e4317dee635b170a663
-- 
2.49.0



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

end of thread, other threads:[~2025-08-04 10:41 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-24 14:49 [RFC v2 0/4] add static huge zero folio support Pankaj Raghav (Samsung)
2025-07-24 14:49 ` [RFC v2 1/4] mm: rename huge_zero_page_shrinker to huge_zero_folio_shrinker Pankaj Raghav (Samsung)
2025-07-25  2:52   ` Zi Yan
2025-08-01  4:18   ` Ritesh Harjani
2025-08-01 15:30     ` David Hildenbrand
2025-08-04  8:36       ` Pankaj Raghav (Samsung)
2025-08-01 15:53   ` Lorenzo Stoakes
2025-07-24 14:49 ` [RFC v2 2/4] mm: add static huge zero folio Pankaj Raghav (Samsung)
2025-08-01  4:23   ` Ritesh Harjani
2025-08-04  8:41     ` Pankaj Raghav (Samsung)
2025-08-01 15:49   ` David Hildenbrand
2025-08-04 10:41     ` Pankaj Raghav (Samsung)
2025-07-24 14:50 ` [RFC v2 3/4] mm: add largest_zero_folio() routine Pankaj Raghav (Samsung)
2025-08-01  4:30   ` Ritesh Harjani
2025-08-01 15:33     ` David Hildenbrand
2025-07-24 14:50 ` [RFC v2 4/4] block: use largest_zero_folio in __blkdev_issue_zero_pages() Pankaj Raghav (Samsung)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).