* [PATCH V2] mm/memremap: fix spurious large folio warning for FS-DAX
@ 2025-12-19 12:37 John Groves
2025-12-19 14:14 ` David Hildenbrand (Red Hat)
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: John Groves @ 2025-12-19 12:37 UTC (permalink / raw)
To: David Hildenbrand, Oscar Salvador, Andrew Morton
Cc: John Groves, John Groves, Darrick J . Wong, Dan Williams,
Gregory Price, Balbir Singh, Alistair Popple, linux-mm,
linux-kernel, linux-cxl, linux-fsdevel, Aravind Ramesh,
Ajay Joshi, John Groves
From: John Groves <John@Groves.net>
This patch addresses a warning that I discovered while working on famfs,
which is an fs-dax file system that virtually always does PMD faults
(next famfs patch series coming after the holidays).
However, XFS also does PMD faults in fs-dax mode, and it also triggers
the warning. It takes some effort to get XFS to do a PMD fault, but
instructions to reproduce it are below.
The VM_WARN_ON_ONCE(folio_test_large(folio)) check in
free_zone_device_folio() incorrectly triggers for MEMORY_DEVICE_FS_DAX
when PMD (2MB) mappings are used.
FS-DAX legitimately creates large file-backed folios when handling PMD
faults. This is a core feature of FS-DAX that provides significant
performance benefits by mapping 2MB regions directly to persistent
memory. When these mappings are unmapped, the large folios are freed
through free_zone_device_folio(), which triggers the spurious warning.
The warning was introduced by commit that added support for large zone
device private folios. However, that commit did not account for FS-DAX
file-backed folios, which have always supported large (PMD-sized)
mappings.
The check distinguishes between anonymous folios (which clear
AnonExclusive flags for each sub-page) and file-backed folios. For
file-backed folios, it assumes large folios are unexpected - but this
assumption is incorrect for FS-DAX.
The fix is to exempt MEMORY_DEVICE_FS_DAX from the large folio warning,
allowing FS-DAX to continue using PMD mappings without triggering false
warnings.
Fixes: d245f9b4ab80 ("mm/zone_device: support large zone device private folios")
Signed-off-by: John Groves <john@groves.net>
---
Change since V1: Deleted the warning altogether, rather than exempting
fs-dax.
=== How to reproduce ===
A reproducer is available at:
git clone https://github.com/jagalactic/dax-pmd-test.git
cd xfs-dax-test
make
sudo make test
This will set up XFS on pmem with 2MB stripe alignment and run a test
that triggers the warning.
Alternatively, follow the manual steps below.
Prerequisites:
- Linux kernel with FS-DAX support and CONFIG_DEBUG_VM=y
- A pmem device (real or emulated)
- An fsdax namespace configured via ndctl as /dev/pmem0
Manual steps:
1. Create an fsdax namespace (if not already present):
# ndctl create-namespace -m fsdax -e namespace0.0
2. Create XFS with 2MB stripe alignment:
# mkfs.xfs -f -d su=2m,sw=1 /dev/pmem0
# mount -o dax /dev/pmem0 /mnt/pmem
3. Compile and run the reproducer:
# gcc -Wall -O2 -o dax_pmd_test dax_pmd_test.c
# ./dax_pmd_test /mnt/pmem/testfile
4. Check dmesg for the warning:
WARNING: mm/memremap.c:431 at free_zone_device_folio+0x.../0x...
Note: The 2MB stripe alignment (-d su=2m,sw=1) is critical. XFS normally
allocates blocks at arbitrary offsets, causing PMD faults to fall back
to PTE faults. The stripe alignment forces 2MB-aligned allocations,
allowing PMD faults to succeed and exposing this bug.
mm/memremap.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/mm/memremap.c b/mm/memremap.c
index 4c2e0d68eb27..63c6ab4fdf08 100644
--- a/mm/memremap.c
+++ b/mm/memremap.c
@@ -427,8 +427,6 @@ void free_zone_device_folio(struct folio *folio)
if (folio_test_anon(folio)) {
for (i = 0; i < nr; i++)
__ClearPageAnonExclusive(folio_page(folio, i));
- } else {
- VM_WARN_ON_ONCE(folio_test_large(folio));
}
/*
base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
--
2.49.0
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH V2] mm/memremap: fix spurious large folio warning for FS-DAX
2025-12-19 12:37 [PATCH V2] mm/memremap: fix spurious large folio warning for FS-DAX John Groves
@ 2025-12-19 14:14 ` David Hildenbrand (Red Hat)
2025-12-19 20:08 ` dan.j.williams
2025-12-19 20:47 ` Alison Schofield
2 siblings, 0 replies; 4+ messages in thread
From: David Hildenbrand (Red Hat) @ 2025-12-19 14:14 UTC (permalink / raw)
To: John Groves, Oscar Salvador, Andrew Morton
Cc: John Groves, Darrick J . Wong, Dan Williams, Gregory Price,
Balbir Singh, Alistair Popple, linux-mm, linux-kernel, linux-cxl,
linux-fsdevel, Aravind Ramesh, Ajay Joshi
On 12/19/25 13:37, John Groves wrote:
> From: John Groves <John@Groves.net>
>
> This patch addresses a warning that I discovered while working on famfs,
> which is an fs-dax file system that virtually always does PMD faults
> (next famfs patch series coming after the holidays).
>
> However, XFS also does PMD faults in fs-dax mode, and it also triggers
> the warning. It takes some effort to get XFS to do a PMD fault, but
> instructions to reproduce it are below.
>
> The VM_WARN_ON_ONCE(folio_test_large(folio)) check in
> free_zone_device_folio() incorrectly triggers for MEMORY_DEVICE_FS_DAX
> when PMD (2MB) mappings are used.
>
> FS-DAX legitimately creates large file-backed folios when handling PMD
> faults. This is a core feature of FS-DAX that provides significant
> performance benefits by mapping 2MB regions directly to persistent
> memory. When these mappings are unmapped, the large folios are freed
> through free_zone_device_folio(), which triggers the spurious warning.
>
> The warning was introduced by commit that added support for large zone
> device private folios. However, that commit did not account for FS-DAX
> file-backed folios, which have always supported large (PMD-sized)
> mappings.
>
> The check distinguishes between anonymous folios (which clear
> AnonExclusive flags for each sub-page) and file-backed folios. For
> file-backed folios, it assumes large folios are unexpected - but this
> assumption is incorrect for FS-DAX.
>
> The fix is to exempt MEMORY_DEVICE_FS_DAX from the large folio warning,
> allowing FS-DAX to continue using PMD mappings without triggering false
> warnings.
>
> Fixes: d245f9b4ab80 ("mm/zone_device: support large zone device private folios")
> Signed-off-by: John Groves <john@groves.net>
> ---
>
> Change since V1: Deleted the warning altogether, rather than exempting
> fs-dax.
>
> === How to reproduce ===
>
> A reproducer is available at:
>
> git clone https://github.com/jagalactic/dax-pmd-test.git
> cd xfs-dax-test
> make
> sudo make test
>
> This will set up XFS on pmem with 2MB stripe alignment and run a test
> that triggers the warning.
>
> Alternatively, follow the manual steps below.
>
> Prerequisites:
> - Linux kernel with FS-DAX support and CONFIG_DEBUG_VM=y
> - A pmem device (real or emulated)
> - An fsdax namespace configured via ndctl as /dev/pmem0
>
> Manual steps:
>
> 1. Create an fsdax namespace (if not already present):
> # ndctl create-namespace -m fsdax -e namespace0.0
>
> 2. Create XFS with 2MB stripe alignment:
> # mkfs.xfs -f -d su=2m,sw=1 /dev/pmem0
> # mount -o dax /dev/pmem0 /mnt/pmem
>
> 3. Compile and run the reproducer:
> # gcc -Wall -O2 -o dax_pmd_test dax_pmd_test.c
> # ./dax_pmd_test /mnt/pmem/testfile
>
> 4. Check dmesg for the warning:
> WARNING: mm/memremap.c:431 at free_zone_device_folio+0x.../0x...
>
> Note: The 2MB stripe alignment (-d su=2m,sw=1) is critical. XFS normally
> allocates blocks at arbitrary offsets, causing PMD faults to fall back
> to PTE faults. The stripe alignment forces 2MB-aligned allocations,
> allowing PMD faults to succeed and exposing this bug.
>
>
> mm/memremap.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/mm/memremap.c b/mm/memremap.c
> index 4c2e0d68eb27..63c6ab4fdf08 100644
> --- a/mm/memremap.c
> +++ b/mm/memremap.c
> @@ -427,8 +427,6 @@ void free_zone_device_folio(struct folio *folio)
> if (folio_test_anon(folio)) {
> for (i = 0; i < nr; i++)
> __ClearPageAnonExclusive(folio_page(folio, i));
> - } else {
> - VM_WARN_ON_ONCE(folio_test_large(folio));
> }
>
LGTM
Acked-by: David Hildenbrand (Red Hat) <david@kernel.org>
--
Cheers
David
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH V2] mm/memremap: fix spurious large folio warning for FS-DAX
2025-12-19 12:37 [PATCH V2] mm/memremap: fix spurious large folio warning for FS-DAX John Groves
2025-12-19 14:14 ` David Hildenbrand (Red Hat)
@ 2025-12-19 20:08 ` dan.j.williams
2025-12-19 20:47 ` Alison Schofield
2 siblings, 0 replies; 4+ messages in thread
From: dan.j.williams @ 2025-12-19 20:08 UTC (permalink / raw)
To: John Groves, David Hildenbrand, Oscar Salvador, Andrew Morton
Cc: John Groves, John Groves, Darrick J . Wong, Dan Williams,
Gregory Price, Balbir Singh, Alistair Popple, linux-mm,
linux-kernel, linux-cxl, linux-fsdevel, Aravind Ramesh,
Ajay Joshi, John Groves
John Groves wrote:
[..]
> The fix is to exempt MEMORY_DEVICE_FS_DAX from the large folio warning,
> allowing FS-DAX to continue using PMD mappings without triggering false
> warnings.
As you note, this patch no longer exempts MEMORY_DEVICE_FS_DAX explicitly, it just
removes the bogus warning, so maybe Andrew can adjust this note on
applying?
> Fixes: d245f9b4ab80 ("mm/zone_device: support large zone device private folios")
> Signed-off-by: John Groves <john@groves.net>
> ---
>
> Change since V1: Deleted the warning altogether, rather than exempting
> fs-dax.
>
> === How to reproduce ===
>
> A reproducer is available at:
>
> git clone https://github.com/jagalactic/dax-pmd-test.git
> cd xfs-dax-test
> make
> sudo make test
Thanks John, outside of the fixup above, this looks good to me.
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Now, my first thoughts when seeing this were:
"ooh, I want that test in the regression suite"
...then:
"wait, that sounds exactly like the existing dax.sh test [1]"
[1]: https://github.com/pmem/ndctl/blob/main/test/dax.sh
Alison reports that indeed that existing test triggers the problem which
indicates some process problems to solve.
- Folks touching mm/memremap.c (and anything dax related) do not know
about / run the regression tests.
- The bespoke nature of the dax testing environment needs some work to
get it into a kselftest amenable flow, or otherwise need more
automation to run those tests automatically upon seeing those files
touched in linux-next so folks see breakage like this earlier.
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH V2] mm/memremap: fix spurious large folio warning for FS-DAX
2025-12-19 12:37 [PATCH V2] mm/memremap: fix spurious large folio warning for FS-DAX John Groves
2025-12-19 14:14 ` David Hildenbrand (Red Hat)
2025-12-19 20:08 ` dan.j.williams
@ 2025-12-19 20:47 ` Alison Schofield
2 siblings, 0 replies; 4+ messages in thread
From: Alison Schofield @ 2025-12-19 20:47 UTC (permalink / raw)
To: John Groves
Cc: David Hildenbrand, Oscar Salvador, Andrew Morton, John Groves,
Darrick J . Wong, Dan Williams, Gregory Price, Balbir Singh,
Alistair Popple, linux-mm, linux-kernel, linux-cxl,
linux-fsdevel, Aravind Ramesh, Ajay Joshi
On Fri, Dec 19, 2025 at 06:37:17AM -0600, John Groves wrote:
> From: John Groves <John@Groves.net>
>
> This patch addresses a warning that I discovered while working on famfs,
> which is an fs-dax file system that virtually always does PMD faults
> (next famfs patch series coming after the holidays).
>
> However, XFS also does PMD faults in fs-dax mode, and it also triggers
> the warning. It takes some effort to get XFS to do a PMD fault, but
> instructions to reproduce it are below.
>
> The VM_WARN_ON_ONCE(folio_test_large(folio)) check in
> free_zone_device_folio() incorrectly triggers for MEMORY_DEVICE_FS_DAX
> when PMD (2MB) mappings are used.
>
> FS-DAX legitimately creates large file-backed folios when handling PMD
> faults. This is a core feature of FS-DAX that provides significant
> performance benefits by mapping 2MB regions directly to persistent
> memory. When these mappings are unmapped, the large folios are freed
> through free_zone_device_folio(), which triggers the spurious warning.
>
> The warning was introduced by commit that added support for large zone
> device private folios. However, that commit did not account for FS-DAX
> file-backed folios, which have always supported large (PMD-sized)
> mappings.
>
> The check distinguishes between anonymous folios (which clear
> AnonExclusive flags for each sub-page) and file-backed folios. For
> file-backed folios, it assumes large folios are unexpected - but this
> assumption is incorrect for FS-DAX.
>
> The fix is to exempt MEMORY_DEVICE_FS_DAX from the large folio warning,
> allowing FS-DAX to continue using PMD mappings without triggering false
> warnings.
>
> Fixes: d245f9b4ab80 ("mm/zone_device: support large zone device private folios")
> Signed-off-by: John Groves <john@groves.net>
> ---
Tested-by: Alison Schofield <alison.schofield@intel.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-12-19 20:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-19 12:37 [PATCH V2] mm/memremap: fix spurious large folio warning for FS-DAX John Groves
2025-12-19 14:14 ` David Hildenbrand (Red Hat)
2025-12-19 20:08 ` dan.j.williams
2025-12-19 20:47 ` Alison Schofield
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox