linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC 0/3] add STATIC_PMD_ZERO_PAGE config option
@ 2025-05-27  5:04 Pankaj Raghav
  2025-05-27  5:04 ` [RFC 1/3] mm: move huge_zero_folio from huge_memory.c to memory.c Pankaj Raghav
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Pankaj Raghav @ 2025-05-27  5:04 UTC (permalink / raw)
  To: Suren Baghdasaryan, Ryan Roberts, Vlastimil Babka, Baolin Wang,
	Borislav Petkov, Ingo Molnar, H . Peter Anvin, 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, linux-mm, linux-block, willy, x86, linux-fsdevel,
	Darrick J . Wong, mcgrof, gost.dev, kernel, hch, Pankaj Raghav

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[1][2].

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()
...

We already have huge_zero_folio that is allocated on demand, and it will be
deallocated by the shrinker if there are no users of it left.

But to use huge_zero_folio, we need to pass a mm struct and the
put_folio needs to be called in the destructor. This makes sense for
systems that have memory constraints but for bigger servers, it does not
matter if the PMD size is reasonable (like x86).

Add a config option STATIC_PMD_ZERO_PAGE that will always allocate
the huge_zero_folio, and it will never be freed. This makes using the
huge_zero_folio without having to pass any mm struct and a call to put_folio
in the destructor.

I have converted blkdev_issue_zero_pages() as an example as a part of
this series.

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-xfs/20231027051847.GA7885@lst.de/
[2] https://lore.kernel.org/linux-xfs/ZitIK5OnR7ZNY0IG@infradead.org/

Changes since v1:
- Added the config option based on the feedback from David.
- Removed iomap patches so that I don't clutter this series with too
  many subsystems.

Pankaj Raghav (3):
  mm: move huge_zero_folio from huge_memory.c to memory.c
  mm: add STATIC_PMD_ZERO_PAGE config option
  block: use mm_huge_zero_folio in __blkdev_issue_zero_pages()

 arch/x86/Kconfig        |   1 +
 block/blk-lib.c         |  16 ++++--
 include/linux/huge_mm.h |  16 ------
 include/linux/mm.h      |  16 ++++++
 mm/Kconfig              |  12 ++++
 mm/huge_memory.c        | 105 +---------------------------------
 mm/memory.c             | 121 ++++++++++++++++++++++++++++++++++++++++
 7 files changed, 164 insertions(+), 123 deletions(-)


base-commit: f1f6aceb82a55f87d04e2896ac3782162e7859bd
-- 
2.47.2


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

end of thread, other threads:[~2025-06-02 20:33 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-27  5:04 [RFC 0/3] add STATIC_PMD_ZERO_PAGE config option Pankaj Raghav
2025-05-27  5:04 ` [RFC 1/3] mm: move huge_zero_folio from huge_memory.c to memory.c Pankaj Raghav
2025-05-27  5:04 ` [RFC 2/3] mm: add STATIC_PMD_ZERO_PAGE config option Pankaj Raghav
2025-05-27 16:37   ` Dave Hansen
2025-05-27 18:00     ` Pankaj Raghav (Samsung)
2025-05-27 18:30       ` Dave Hansen
2025-05-27 19:28         ` Pankaj Raghav (Samsung)
2025-05-28 20:36       ` David Hildenbrand
2025-06-02  5:03   ` Christoph Hellwig
2025-06-02 14:49     ` Pankaj Raghav
2025-06-02 20:28       ` David Hildenbrand
2025-06-02 20:32         ` David Hildenbrand
2025-05-27  5:04 ` [RFC 3/3] block: use mm_huge_zero_folio in __blkdev_issue_zero_pages() Pankaj Raghav
2025-06-02  5:05   ` Christoph Hellwig
2025-06-02 15:34     ` Pankaj Raghav

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).