Skip to content

add static huge zero folio support#49

Closed
blktests-ci[bot] wants to merge 5 commits intolinus-master_basefrom
series/984633=>linus-master
Closed

add static huge zero folio support#49
blktests-ci[bot] wants to merge 5 commits intolinus-master_basefrom
series/984633=>linus-master

Conversation

@blktests-ci
Copy link
Copy Markdown

@blktests-ci blktests-ci Bot commented Jul 23, 2025

Pull request for series with
subject: add static huge zero folio support
version: 1
url: https://patchwork.kernel.org/project/linux-block/list/?series=984633

@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Jul 23, 2025

Upstream branch: 89be9a8
series: https://patchwork.kernel.org/project/linux-block/list/?series=984633
version: 1

@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Jul 24, 2025

Upstream branch: 25fae0b
series: https://patchwork.kernel.org/project/linux-block/list/?series=984633
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/984633=>linus-master branch from d3badf4 to 2ba5189 Compare July 24, 2025 06:40
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 87bbbbc to 6637119 Compare July 30, 2025 01:47
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Jul 30, 2025

Upstream branch: 14bed9b
series: https://patchwork.kernel.org/project/linux-block/list/?series=985623
version: 2

@blktests-ci blktests-ci Bot added V2 and removed V1 labels Jul 30, 2025
@blktests-ci blktests-ci Bot force-pushed the series/984633=>linus-master branch from 2ba5189 to 78181d5 Compare July 30, 2025 01:48
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 6637119 to f092a9b Compare July 31, 2025 04:25
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Jul 31, 2025

Upstream branch: 260f6f4
series: https://patchwork.kernel.org/project/linux-block/list/?series=985623
version: 2

@blktests-ci blktests-ci Bot force-pushed the series/984633=>linus-master branch from 78181d5 to e9533f8 Compare July 31, 2025 04:27
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from f092a9b to 0b59764 Compare July 31, 2025 17:58
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Jul 31, 2025

Upstream branch: d6084bb
series: https://patchwork.kernel.org/project/linux-block/list/?series=985623
version: 2

@blktests-ci blktests-ci Bot force-pushed the series/984633=>linus-master branch from e9533f8 to b59f676 Compare July 31, 2025 18:00
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 0b59764 to aee5bd3 Compare July 31, 2025 19:11
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Jul 31, 2025

Upstream branch: 831462f
series: https://patchwork.kernel.org/project/linux-block/list/?series=985623
version: 2

@blktests-ci blktests-ci Bot force-pushed the series/984633=>linus-master branch from b59f676 to 1652f6a Compare July 31, 2025 19:13
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from aee5bd3 to ef18525 Compare July 31, 2025 20:07
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Jul 31, 2025

Upstream branch: c93529a
series: https://patchwork.kernel.org/project/linux-block/list/?series=985623
version: 2

@blktests-ci blktests-ci Bot force-pushed the series/984633=>linus-master branch from 1652f6a to 5457f95 Compare July 31, 2025 20:09
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from ef18525 to 3851b3f Compare July 31, 2025 20:55
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Jul 31, 2025

Upstream branch: cbbf0a7
series: https://patchwork.kernel.org/project/linux-block/list/?series=985623
version: 2

@blktests-ci blktests-ci Bot force-pushed the series/984633=>linus-master branch from 5457f95 to c481bd3 Compare July 31, 2025 20:57
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 3851b3f to 28b3384 Compare July 31, 2025 23:42
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Jul 31, 2025

Upstream branch: 6a68cec
series: https://patchwork.kernel.org/project/linux-block/list/?series=985623
version: 2

@blktests-ci blktests-ci Bot force-pushed the series/984633=>linus-master branch from c481bd3 to 73e0c18 Compare July 31, 2025 23:44
@blktests-ci blktests-ci Bot force-pushed the series/984633=>linus-master branch from 33f001b to e9bcc53 Compare August 9, 2025 05:26
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 37dce65 to 4c26e9a Compare August 9, 2025 05:49
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 9, 2025

Upstream branch: 71a0760
series: https://patchwork.kernel.org/project/linux-block/list/?series=988113
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/984633=>linus-master branch from e9bcc53 to c639696 Compare August 9, 2025 05:54
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 4c26e9a to 1356209 Compare August 9, 2025 06:05
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 9, 2025

Upstream branch: 2988dfe
series: https://patchwork.kernel.org/project/linux-block/list/?series=988113
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/984633=>linus-master branch from c639696 to 255faf2 Compare August 9, 2025 06:10
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 1356209 to ae9bce3 Compare August 9, 2025 06:21
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 9, 2025

Upstream branch: c30a135
series: https://patchwork.kernel.org/project/linux-block/list/?series=988113
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/984633=>linus-master branch from 255faf2 to f5e112b Compare August 9, 2025 06:26
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from ae9bce3 to e263d6e Compare August 9, 2025 15:26
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 9, 2025

Upstream branch: 561c803
series: https://patchwork.kernel.org/project/linux-block/list/?series=988113
version: 1

@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 10, 2025

Upstream branch: b96ddbc
series: https://patchwork.kernel.org/project/linux-block/list/?series=988113
version: 1

@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 10, 2025

Upstream branch: 2b38afc
series: https://patchwork.kernel.org/project/linux-block/list/?series=988113
version: 1

@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 10, 2025

Upstream branch: 8f5ae30
series: https://patchwork.kernel.org/project/linux-block/list/?series=988113
version: 1

@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 12, 2025

Upstream branch: 53e760d
series: https://patchwork.kernel.org/project/linux-block/list/?series=988113
version: 1

@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 12, 2025

Upstream branch: 0e39a73
series: https://patchwork.kernel.org/project/linux-block/list/?series=988113
version: 1

@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 12, 2025

Upstream branch: 8742b2d
series: https://patchwork.kernel.org/project/linux-block/list/?series=988113
version: 1

@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 13, 2025

Upstream branch: 91325f3
series: https://patchwork.kernel.org/project/linux-block/list/?series=988113
version: 1

@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 13, 2025

Upstream branch: 3a4a036
series: https://patchwork.kernel.org/project/linux-block/list/?series=988113
version: 1

@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 13, 2025

Upstream branch: dfc0f63
series: https://patchwork.kernel.org/project/linux-block/list/?series=988113
version: 1

@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 14, 2025

Upstream branch: 0cc5352
series: https://patchwork.kernel.org/project/linux-block/list/?series=988113
version: 1

@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 14, 2025

Upstream branch: 24ea63e
series: https://patchwork.kernel.org/project/linux-block/list/?series=988113
version: 1

@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 15, 2025

Upstream branch: d7ee5bd
series: https://patchwork.kernel.org/project/linux-block/list/?series=988113
version: 1

@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Aug 20, 2025

Upstream branch: b19a97d
series: https://patchwork.kernel.org/project/linux-block/list/?series=988113
version: 1

As we already moved from exposing huge_zero_page to huge_zero_folio,
change the name of the shrinker and the other helper function to reflect
that.

No functional changes.

Reviewed-by: Lorenzo Stoakes <[email protected]>
Suggested-by: David Hildenbrand <[email protected]>
Acked-by: David Hildenbrand <[email protected]>
Signed-off-by: Pankaj Raghav <[email protected]>
As all the helper functions has been renamed from *_page to *_folio,
rename the MM flag from MMF_HUGE_ZERO_PAGE to MMF_HUGE_ZERO_FOLIO.

No functional changes.

Suggested-by: David Hildenbrand <[email protected]>
Signed-off-by: Pankaj Raghav <[email protected]>
Reviewed-by: Lorenzo Stoakes <[email protected]>
Acked-by: David Hildenbrand <[email protected]>
Reviewed-by: Zi Yan <[email protected]>
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 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 single bvec.

This concern was raised during the review of adding LBS support to
XFS[1][2].

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 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 result in allocating
the huge zero folio on first request, if not already allocated, and turn
it static such that it can never get freed. 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.

If STATIC_HUGE_ZERO_FOLIO config option is enabled, then
mm_get_huge_zero_folio() will simply return this page instead of
dynamically allocating a new PMD page.

This option can waste memory in small systems or systems with 64k base
page size. So make it an opt-in and also add an option from individual
architecture so that we don't enable this feature for larger base page
size systems. Only x86 is enabled as a part of this series. Other
architectures shall be enabled as a follow-up to this series.

[1] https://lore.kernel.org/linux-xfs/[email protected]/
[2] https://lore.kernel.org/linux-xfs/[email protected]/

Co-developed-by: David Hildenbrand <[email protected]>
Signed-off-by: David Hildenbrand <[email protected]>
Signed-off-by: Pankaj Raghav <[email protected]>
Add largest_zero_folio() routine so that huge_zero_folio can be
used directly when CONFIG_STATIC_HUGE_ZERO_FOLIO is enabled. This will
return ZERO_PAGE folio if CONFIG_STATIC_HUGE_ZERO_FOLIO is disabled or
if we failed to allocate a huge_zero_folio.

Co-developed-by: David Hildenbrand <[email protected]>
Signed-off-by: David Hildenbrand <[email protected]>
Signed-off-by: Pankaj Raghav <[email protected]>
Reviewed-by: Lorenzo Stoakes <[email protected]>
Reviewed-by: Zi Yan <[email protected]>
Use largest_zero_folio() in __blkdev_issue_zero_pages().
On systems with CONFIG_STATIC_HUGE_ZERO_FOLIO enabled, we will end up
sending larger bvecs instead of multiple small ones.

Noticed a 4% increase in performance on a commercial NVMe SSD which does
not support OP_WRITE_ZEROES. The device's MDTS was 128K. The performance
gains might be bigger if the device supports bigger MDTS.

Signed-off-by: Pankaj Raghav <[email protected]>
Acked-by: Lorenzo Stoakes <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants