mm/page_vma_mapped: revalidate and do proper check before return device-private pmd
Subsystems (3)
PATCH 1/1 mm/page_vma_mapped: revalidate and do proper check before return device-private pmd
For pmd_trans_huge() and pmd_is_migration_entry(), we does following before return the pmd entry:
* re-validate pmd entry after PTL
* check PVMW_MIGRATION
* check_pmd()
* handle on pte level if split under us
But for device-private pmd, we just return after pmd_lock().
If a softleaf entry is present, e.g. device-private pmd, the existing code simply acquires the PMD lock and returns success even if PVMW_MIGRATION is set (indicating a migration entry is sought), meaning that the caller can incorrectly interpret the entry as something it is not, causing data corruption.
This patch fixes commit 65edfda6f3f2 ("mm/rmap: extend rmap and migration support device-private entries") by following the same pattern as pmd_trans_huge() and pmd_is_migration_entry() for device private entry.
---
v3:
* remove cleanup part, only fix the issue for device-private entry
* refine user effect description based on Lorenzo's suggestion
v2: https://lore.kernel.org/all/[email protected]/T/#u
* specify the possible error case of current code and user visible effect
* besides fix, cleanup the pmd entry handling based on David's suggestion
v1: https://lore.kernel.org/linux-mm/[email protected]/
--- mm/page_vma_mapped.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-)
mm/page_vma_mapped.c +22 -10
@@ -270,21 +270,33 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)spin_unlock (pvmw->ptl); pvmw->ptl =NULL ; }else if (!pmd_present (pmde)) { -const softleaf_t entry =softleaf_from_pmd (pmde); +softleaf_t entry =softleaf_from_pmd (pmde);if (softleaf_is_device_private (entry)) { pvmw->ptl =pmd_lock (mm, pvmw->pmd); -return true; - } -if ((pvmw->flags &PVMW_SYNC ) && -thp_vma_suitable_order (vma, pvmw->address, -PMD_ORDER ) && - (pvmw->nr_pages >=HPAGE_PMD_NR )) -sync_with_folio_pmd_zap (mm, pvmw->pmd); + entry =softleaf_from_pmd (*pvmw->pmd); -step_forward (pvmw,PMD_SIZE ); -continue ; +if (softleaf_is_device_private (entry)) { +if (pvmw->flags &PVMW_MIGRATION ) +return not_found (pvmw); +if (!check_pmd (softleaf_to_pfn (entry), pvmw)) +return not_found (pvmw); +return true; + } +/* device-private pmd was split under us: handle on pte level */ +spin_unlock (pvmw->ptl); + pvmw->ptl =NULL ; + }else { +if ((pvmw->flags &PVMW_SYNC ) && +thp_vma_suitable_order (vma, pvmw->address, +PMD_ORDER ) && + (pvmw->nr_pages >=HPAGE_PMD_NR )) +sync_with_folio_pmd_zap (mm, pvmw->pmd); + +step_forward (pvmw,PMD_SIZE ); +continue ; + } }if (!map_pte (pvmw, &pmde, &ptl)) {if (!pvmw->pte)
Signature · 1 line
2.34.1
Oops, miss the v3 tag.
Also add Lance who gave a lot feedback.
Signature · 2 lines
Wei Yang Help you, Help me
Lorenzo Stoakes
maintainer+cc Lance, linux-kernel
Your subject line is 83 characters long and is way too detailed how about 'fix device-private PMD handling'?
You forgot to include [email protected] on the mail, lore seems to be a bit broken atm but in general it's helpful to include that.
Also is useful to make this [PATCH mm-hotfixes] to make it really clear it's intended as a hotfix.
Some commit msg language nits:
Quoted 2 lines · Wei Yang
For
pmd_trans_huge()andpmd_is_migration_entry(), we does following before return the pmd entry:
Sounds better as:
For PMD entries that satisfy pmd_trans_huge() or pmd_is_migration_entry(), we perform the following actions:
Quoted 7 lines
* re-validate pmd entry after PTL
* checkPVMW_MIGRATION
*check_pmd()
* handle on pte level if split under usBut for device-private pmd, we just return after
pmd_lock().
->
However, for device-private PMD entries, we simply acquire the PMD lock and return.
Also can you please give some justification here as to why all this also applies to device-private PMD? Right now it sounds hand wavey.
Quoted 6 lines
If a softleaf entry is present, e.g. device-private pmd, the existing code simply acquires the PMD lock and returns success even if
PVMW_MIGRATIONis set (indicating a migration entry is sought), meaning that the caller can incorrectly interpret the entry as something it is not, causing data corruption.
This is repetitive, you already mentioned device-private PMD, you already mentioned that it simply acquires the PMD lock.
You should talk about what issue it caused and why:
This is particularly problematic when PVMW_MIGRATION is set (meaning a migration entry is sought), as it causes a device-private PMD entry to be returned with a different data layout, causing memory corruption.
Quoted 4 lines
This patch fixes commit
65edfda6f3f2("mm/rmap: extend rmap and migration support device-private entries") by following the same pattern aspmd_trans_huge()andpmd_is_migration_entry()for device private entry.
This is pretty useless. We see what patch it fixes in the Fixes tag, and you're just repeating things you said above, I'd drop it.
Quoted 40 lines
Fixes 65edfda6f3f2 ("mm/rmap: extend rmap and migration support device-private entries")Cc <[email protected]>Signed-off-by Wei Yang <[email protected]>Suggested-by David Hildenbrand <[email protected]>Cc David Hildenbrand <[email protected]>Cc Balbir Singh <[email protected]>Cc SeongJae Park <[email protected]>Cc Zi Yan <[email protected]>Cc Lorenzo Stoakes <[email protected]>---
v3:
* remove cleanup part, only fix the issue for device-private entry
* refine user effect description based on Lorenzo's suggestion
v2: https://lore.kernel.org/all/[email protected]/T/#u
* specify the possible error case of current code and user visible effect
* besides fix, cleanup the pmd entry handling based on David's suggestionv1: https://lore.kernel.org/linux-mm/[email protected]/
--- mm/page_vma_mapped.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-)mm/page_vma_mapped.c +1
-3@@ -270,21 +270,33 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)spin_unlock (pvmw->ptl); pvmw->ptl =NULL ; }else if (!pmd_present (pmde)) { -const softleaf_t entry =softleaf_from_pmd (pmde); +softleaf_t entry =softleaf_from_pmd (pmde);if (softleaf_is_device_private (entry)) { pvmw->ptl =pmd_lock (mm, pvmw->pmd); -return true; - }
mm/page_vma_mapped.c bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw) · line 280
Quoted 10 lines
mm/page_vma_mapped.c +2
-7-if ((pvmw->flags &PVMW_SYNC ) && -thp_vma_suitable_order (vma, pvmw->address, -PMD_ORDER ) && - (pvmw->nr_pages >=HPAGE_PMD_NR )) -sync_with_folio_pmd_zap (mm, pvmw->pmd); + entry =softleaf_from_pmd (*pvmw->pmd); -step_forward (pvmw,PMD_SIZE ); -continue ; +if (softleaf_is_device_private (entry)) {
This is all very horrible. You have an example of how pmde is re-got in the pmd_trans_huge() branch and pmd_is_device_private_entry() exists...
We can just make this another branch and do the re-check more neatly.
I enclose a patch that does that (untested, please check).
Quoted 23 lines
mm/page_vma_mapped.c +19
-1+if (pvmw->flags &PVMW_MIGRATION ) +return not_found (pvmw); +if (!check_pmd (softleaf_to_pfn (entry), pvmw)) +return not_found (pvmw); +return true; + } +/* device-private pmd was split under us: handle on pte level */ +spin_unlock (pvmw->ptl); + pvmw->ptl =NULL ; + }else { +if ((pvmw->flags &PVMW_SYNC ) && +thp_vma_suitable_order (vma, pvmw->address, +PMD_ORDER ) && + (pvmw->nr_pages >=HPAGE_PMD_NR )) +sync_with_folio_pmd_zap (mm, pvmw->pmd); + +step_forward (pvmw,PMD_SIZE ); +continue ; + } }if (!map_pte (pvmw, &pmde, &ptl)) {if (!pvmw->pte) --
Quoted 2 lines
2.34.1
Thanks, Lorenzo
----8<----
From e6a3c1c782714ed831c4d46a14bb99226423bf59 Mon Sep 17 00:00:00 2001
From: Wei Yang <[email protected]>
Date: Mon, 22 Jun 2026 13:06:51 +0000
Subject: [PATCH] refactored
--- mm/page_vma_mapped.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
mm/page_vma_mapped.c +15 -5
@@ -269,14 +269,24 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)/* THP pmd was split under us: handle on pte level */ spin_unlock (pvmw->ptl); pvmw->ptl =NULL ; - }else if (!pmd_present (pmde)) { -const softleaf_t entry =softleaf_from_pmd (pmde); + }else if (pmd_is_device_private_entry (pmde)) { +softleaf_t entry; + + pvmw->ptl =pmd_lock (mm, pvmw->pmd); + pmde = *pvmw->pmd; + entry =softleaf_from_pmd (pmde); -if (softleaf_is_device_private (entry)) { - pvmw->ptl =pmd_lock (mm, pvmw->pmd); +if (likely (softleaf_is_device_private (entry))) { +if (pvmw->flags &PVMW_MIGRATION ) +return not_found (pvmw); +if (!check_pmd (softleaf_to_pfn (entry), pvmw)) +return not_found (pvmw);return true; } - +/* device-private pmd was split under us: handle on pte level */ +spin_unlock (pvmw->ptl); + pvmw->ptl =NULL ; + }else if (!pmd_present (pmde)) { if ((pvmw->flags & PVMW_SYNC) && thp_vma_suitable_order(vma, pvmw->address, PMD_ORDER) &&
--
2.54.0
Quoted 5 lines · Lorenzo Stoakes
+cc Lance, linux-kernel
Your subject line is 83 characters long and is way too detailed how about 'fix device-private PMD handling'?
Got it.
Quoted 2 lines
You forgot to include [email protected] on the mail, lore seems to be a bit broken atm but in general it's helpful to include that.
Got it.
So usually we send a patch to both linux-mm and linux-kernel? If so, I remember is later actions.
Quoted 4 lines
Also is useful to make this [PATCH mm-hotfixes] to make it really clear it's intended as a hotfix.
Got it.
Quoted 11 lines
Some commit msg language nits:
Quoted 2 lines · Wei Yang
For
pmd_trans_huge()andpmd_is_migration_entry(), we does following before return the pmd entry:Sounds better as:
For PMD entries that satisfy
pmd_trans_huge()orpmd_is_migration_entry(), we perform the following actions:
Sure.
Quoted 6 lines
Quoted 6 lines
* re-validate pmd entry after PTL
* checkPVMW_MIGRATION
*check_pmd()
* handle on pte level if split under us
Quoted 7 lines
Quoted 1 line
But for device-private pmd, we just return after
pmd_lock().->
However, for device-private PMD entries, we simply acquire the PMD lock and return.
Sure.
Quoted 3 lines
Also can you please give some justification here as to why all this also applies to device-private PMD? Right now it sounds hand wavey.
I thought below paragraph explain it. Not sure what justification is preferred.
Quoted 9 lines
Quoted 5 lines
If a softleaf entry is present, e.g. device-private pmd, the existing code simply acquires the PMD lock and returns success even if
PVMW_MIGRATIONis set (indicating a migration entry is sought), meaning that the caller can incorrectly interpret the entry as something it is not, causing data corruption.This is repetitive, you already mentioned device-private PMD, you already mentioned that it simply acquires the PMD lock.
Ah, I copied your suggestion from [1]. Hope I don't misunderstand it.
[1]: https://lore.kernel.org/linux-mm/ajUXNjRMraKb6k2n@lucifer/
Quoted 6 lines
You should talk about what issue it caused and why:
This is particularly problematic when
PVMW_MIGRATIONis set (meaning a migration entry is sought), as it causes a device-private PMD entry to be returned with a different data layout, causing memory corruption.
This looks good. I would take this one, if you prefer.
Quoted 8 lines
Quoted 4 lines
This patch fixes commit
65edfda6f3f2("mm/rmap: extend rmap and migration support device-private entries") by following the same pattern aspmd_trans_huge()andpmd_is_migration_entry()for device private entry.This is pretty useless. We see what patch it fixes in the Fixes tag, and you're just repeating things you said above, I'd drop it.
Got it.
Quoted 46 lines
Quoted 46 lines
Fixes 65edfda6f3f2 ("mm/rmap: extend rmap and migration support device-private entries")Cc <[email protected]>Signed-off-by Wei Yang <[email protected]>Suggested-by David Hildenbrand <[email protected]>Cc David Hildenbrand <[email protected]>Cc Balbir Singh <[email protected]>Cc SeongJae Park <[email protected]>Cc Zi Yan <[email protected]>Cc Lorenzo Stoakes <[email protected]>---
v3:
* remove cleanup part, only fix the issue for device-private entry
* refine user effect description based on Lorenzo's suggestion
v2: https://lore.kernel.org/all/[email protected]/T/#u
* specify the possible error case of current code and user visible effect
* besides fix, cleanup the pmd entry handling based on David's suggestionv1: https://lore.kernel.org/linux-mm/[email protected]/
--- mm/page_vma_mapped.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-)mm/page_vma_mapped.c +2
-8@@ -270,21 +270,33 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)spin_unlock (pvmw->ptl); pvmw->ptl =NULL ; }else if (!pmd_present (pmde)) { -const softleaf_t entry =softleaf_from_pmd (pmde); +softleaf_t entry =softleaf_from_pmd (pmde);if (softleaf_is_device_private (entry)) { pvmw->ptl =pmd_lock (mm, pvmw->pmd); -return true; - } -if ((pvmw->flags &PVMW_SYNC ) && -thp_vma_suitable_order (vma, pvmw->address, -PMD_ORDER ) && - (pvmw->nr_pages >=HPAGE_PMD_NR )) -sync_with_folio_pmd_zap (mm, pvmw->pmd); + entry =softleaf_from_pmd (*pvmw->pmd);
Quoted 9 lines
mm/page_vma_mapped.c bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw) · line 280
Quoted 3 lines
mm/page_vma_mapped.c +1
-2-step_forward (pvmw,PMD_SIZE ); -continue ; +if (softleaf_is_device_private (entry)) {This is all very horrible. You have an example of how pmde is re-got in the
pmd_trans_huge()branch andpmd_is_device_private_entry()exists...We can just make this another branch and do the re-check more neatly.
I plan to keep the change small, but yeah it is ugly.
Quoted 77 lines
I enclose a patch that does that (untested, please check).
Quoted 23 lines
mm/page_vma_mapped.c +19
-1+if (pvmw->flags &PVMW_MIGRATION ) +return not_found (pvmw); +if (!check_pmd (softleaf_to_pfn (entry), pvmw)) +return not_found (pvmw); +return true; + } +/* device-private pmd was split under us: handle on pte level */ +spin_unlock (pvmw->ptl); + pvmw->ptl =NULL ; + }else { +if ((pvmw->flags &PVMW_SYNC ) && +thp_vma_suitable_order (vma, pvmw->address, +PMD_ORDER ) && + (pvmw->nr_pages >=HPAGE_PMD_NR )) +sync_with_folio_pmd_zap (mm, pvmw->pmd); + +step_forward (pvmw,PMD_SIZE ); +continue ; + } }if (!map_pte (pvmw, &pmde, &ptl)) {if (!pvmw->pte) --Quoted 2 lines
2.34.1
Thanks, Lorenzo
----8<----
Quoted 1 line
From
e6a3c1c782714ed831c4d46a14bb99226423bf59Mon Sep 17 00:00:00 2001From: Wei Yang <[email protected]>
Date: Mon, 22 Jun 2026 13:06:51 +0000
Subject: [PATCH] refactoredSigned-off-by Lorenzo Stoakes <[email protected]>---
mm/page_vma_mapped.c| 20 +++++++++++++++-----1 file changed, 15 insertions(+), 5 deletions(-)mm/page_vma_mapped.c +15
-6@@ -269,14 +269,24 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)/* THP pmd was split under us: handle on pte level */ spin_unlock (pvmw->ptl); pvmw->ptl =NULL ; - }else if (!pmd_present (pmde)) { -const softleaf_t entry =softleaf_from_pmd (pmde); + }else if (pmd_is_device_private_entry (pmde)) { +softleaf_t entry; + + pvmw->ptl =pmd_lock (mm, pvmw->pmd); + pmde = *pvmw->pmd; + entry =softleaf_from_pmd (pmde); -if (softleaf_is_device_private (entry)) { - pvmw->ptl =pmd_lock (mm, pvmw->pmd); +if (likely (softleaf_is_device_private (entry))) { +if (pvmw->flags &PVMW_MIGRATION ) +return not_found (pvmw); +if (!check_pmd (softleaf_to_pfn (entry), pvmw)) +return not_found (pvmw);return true; } - +/* device-private pmd was split under us: handle on pte level */ +spin_unlock (pvmw->ptl); + pvmw->ptl =NULL ; + }else if (!pmd_present (pmde)) { if ((pvmw->flags & PVMW_SYNC) && thp_vma_suitable_order(vma, pvmw->address, PMD_ORDER) && --
Quoted 1 line
2.54.0
If we prefer this way, I will check and take it.
Signature · 2 lines
Wei Yang Help you, Help me
Lance Yang
reviewerQuoted 9 lines · Wei Yang
Quoted 5 lines · Lorenzo Stoakes
+cc Lance, linux-kernel
Your subject line is 83 characters long and is way too detailed how about 'fix device-private PMD handling'?
Got it.
Quoted 7 lines
Quoted 2 lines
You forgot to include [email protected] on the mail, lore seems to be a bit broken atm but in general it's helpful to include that.
Got it.
So usually we send a patch to both linux-mm and linux-kernel? If so, I remember is later actions.
Yeah, please keep linux-kernel copied too. For MM patches, linux-mm + linux-kernel is the right default, IMHO :)
Quoted 7 lines
Quoted 4 lines
Also is useful to make this [PATCH mm-hotfixes] to make it really clear it's intended as a hotfix.
Got it.
[...]
Quoted 41 lines
Quoted 41 lines
----8<----
Quoted 1 line
From
e6a3c1c782714ed831c4d46a14bb99226423bf59Mon Sep 17 00:00:00 2001From: Wei Yang <[email protected]>
Date: Mon, 22 Jun 2026 13:06:51 +0000
Subject: [PATCH] refactoredSigned-off-by Lorenzo Stoakes <[email protected]>---
mm/page_vma_mapped.c| 20 +++++++++++++++-----1 file changed, 15 insertions(+), 5 deletions(-)mm/page_vma_mapped.c +14
-5@@ -269,14 +269,24 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)/* THP pmd was split under us: handle on pte level */ spin_unlock (pvmw->ptl); pvmw->ptl =NULL ; - }else if (!pmd_present (pmde)) { -const softleaf_t entry =softleaf_from_pmd (pmde); + }else if (pmd_is_device_private_entry (pmde)) { +softleaf_t entry; + + pvmw->ptl =pmd_lock (mm, pvmw->pmd); + pmde = *pvmw->pmd; + entry =softleaf_from_pmd (pmde); -if (softleaf_is_device_private (entry)) { - pvmw->ptl =pmd_lock (mm, pvmw->pmd); +if (likely (softleaf_is_device_private (entry))) { +if (pvmw->flags &PVMW_MIGRATION ) +return not_found (pvmw); +if (!check_pmd (softleaf_to_pfn (entry), pvmw)) +return not_found (pvmw);return true; } - +/* device-private pmd was split under us: handle on pte level */ +spin_unlock (pvmw->ptl); + pvmw->ptl =NULL ;
Quoted 8 lines
Quoted 6 lines
mm/page_vma_mapped.c +1
-1+ }else if (!pmd_present (pmde)) { if ((pvmw->flags & PVMW_SYNC) && thp_vma_suitable_order(vma, pvmw->address, PMD_ORDER) && --2.54.0
If we prefer this way, I will check and take it.
And +1 on Lorenzo's diff. Much cleaner.
Cheers, Lance
Lorenzo Stoakes
maintainerQuoted 9 lines · Wei Yang
Quoted 5 lines · Lorenzo Stoakes
+cc Lance, linux-kernel
Your subject line is 83 characters long and is way too detailed how about 'fix device-private PMD handling'?
Got it.
Quoted 7 lines
Quoted 2 lines
You forgot to include [email protected] on the mail, lore seems to be a bit broken atm but in general it's helpful to include that.
Got it.
So usually we send a patch to both linux-mm and linux-kernel? If so, I remember is later actions.
Yeah it's better for dealing with kvack going wrong etc. :)
Quoted 36 lines
Quoted 5 lines
Also is useful to make this [PATCH mm-hotfixes] to make it really clear it's intended as a hotfix.
Got it.
Quoted 11 lines
Some commit msg language nits:
Quoted 2 lines · Wei Yang
For
pmd_trans_huge()andpmd_is_migration_entry(), we does following before return the pmd entry:Sounds better as:
For PMD entries that satisfy
pmd_trans_huge()orpmd_is_migration_entry(), we perform the following actions:Sure.
Quoted 6 lines
Quoted 6 lines
* re-validate pmd entry after PTL
* checkPVMW_MIGRATION
*check_pmd()
* handle on pte level if split under usQuoted 7 lines
Quoted 1 line
But for device-private pmd, we just return after
pmd_lock().->
However, for device-private PMD entries, we simply acquire the PMD lock and return.
Quoted 7 lines
Sure.
Quoted 3 lines
Also can you please give some justification here as to why all this also applies to device-private PMD? Right now it sounds hand wavey.
I thought below paragraph explain it. Not sure what justification is preferred.
Something about device private PMDs splitting the same way THP ones do, in the pmd_is_device_private_entry() branch of __split_huge_pmd_locked().
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
If a softleaf entry is present, e.g. device-private pmd, the existing code simply acquires the PMD lock and returns success even if
PVMW_MIGRATIONis set (indicating a migration entry is sought), meaning that the caller can incorrectly interpret the entry as something it is not, causing data corruption.
Quoted 7 lines
Quoted 3 lines
This is repetitive, you already mentioned device-private PMD, you already mentioned that it simply acquires the PMD lock.
Ah, I copied your suggestion from [1]. Hope I don't misunderstand it.
[1]: https://lore.kernel.org/linux-mm/ajUXNjRMraKb6k2n@lucifer/
Sure, thanks but in context with the above ends up being a bit repetitive.
Quoted 9 lines
Quoted 7 lines
You should talk about what issue it caused and why:
This is particularly problematic when
PVMW_MIGRATIONis set (meaning a migration entry is sought), as it causes a device-private PMD entry to be returned with a different data layout, causing memory corruption.This looks good. I would take this one, if you prefer.
Sure, thanks!
Quoted 142 lines
Quoted 9 lines
Quoted 5 lines
This patch fixes commit
65edfda6f3f2("mm/rmap: extend rmap and migration support device-private entries") by following the same pattern aspmd_trans_huge()andpmd_is_migration_entry()for device private entry.This is pretty useless. We see what patch it fixes in the Fixes tag, and you're just repeating things you said above, I'd drop it.
Got it.
Quoted 46 lines
Quoted 46 lines
Fixes 65edfda6f3f2 ("mm/rmap: extend rmap and migration support device-private entries")Cc <[email protected]>Signed-off-by Wei Yang <[email protected]>Suggested-by David Hildenbrand <[email protected]>Cc David Hildenbrand <[email protected]>Cc Balbir Singh <[email protected]>Cc SeongJae Park <[email protected]>Cc Zi Yan <[email protected]>Cc Lorenzo Stoakes <[email protected]>---
v3:
* remove cleanup part, only fix the issue for device-private entry
* refine user effect description based on Lorenzo's suggestion
v2: https://lore.kernel.org/all/[email protected]/T/#u
* specify the possible error case of current code and user visible effect
* besides fix, cleanup the pmd entry handling based on David's suggestionv1: https://lore.kernel.org/linux-mm/[email protected]/
--- mm/page_vma_mapped.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-)mm/page_vma_mapped.c +2
-8@@ -270,21 +270,33 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)spin_unlock (pvmw->ptl); pvmw->ptl =NULL ; }else if (!pmd_present (pmde)) { -const softleaf_t entry =softleaf_from_pmd (pmde); +softleaf_t entry =softleaf_from_pmd (pmde);if (softleaf_is_device_private (entry)) { pvmw->ptl =pmd_lock (mm, pvmw->pmd); -return true; - } -if ((pvmw->flags &PVMW_SYNC ) && -thp_vma_suitable_order (vma, pvmw->address, -PMD_ORDER ) && - (pvmw->nr_pages >=HPAGE_PMD_NR )) -sync_with_folio_pmd_zap (mm, pvmw->pmd); + entry =softleaf_from_pmd (*pvmw->pmd);Quoted 9 lines
mm/page_vma_mapped.c bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw) · line 280
Quoted 3 lines
mm/page_vma_mapped.c +1
-2-step_forward (pvmw,PMD_SIZE ); -continue ; +if (softleaf_is_device_private (entry)) {This is all very horrible. You have an example of how pmde is re-got in the
pmd_trans_huge()branch andpmd_is_device_private_entry()exists...We can just make this another branch and do the re-check more neatly.
I plan to keep the change small, but yeah it is ugly.
Quoted 72 lines
I enclose a patch that does that (untested, please check).
Quoted 23 lines
mm/page_vma_mapped.c +19
-1+if (pvmw->flags &PVMW_MIGRATION ) +return not_found (pvmw); +if (!check_pmd (softleaf_to_pfn (entry), pvmw)) +return not_found (pvmw); +return true; + } +/* device-private pmd was split under us: handle on pte level */ +spin_unlock (pvmw->ptl); + pvmw->ptl =NULL ; + }else { +if ((pvmw->flags &PVMW_SYNC ) && +thp_vma_suitable_order (vma, pvmw->address, +PMD_ORDER ) && + (pvmw->nr_pages >=HPAGE_PMD_NR )) +sync_with_folio_pmd_zap (mm, pvmw->pmd); + +step_forward (pvmw,PMD_SIZE ); +continue ; + } }if (!map_pte (pvmw, &pmde, &ptl)) {if (!pvmw->pte) --Quoted 2 lines
2.34.1
Thanks, Lorenzo
----8<----
Quoted 1 line
From
e6a3c1c782714ed831c4d46a14bb99226423bf59Mon Sep 17 00:00:00 2001From: Wei Yang <[email protected]>
Date: Mon, 22 Jun 2026 13:06:51 +0000
Subject: [PATCH] refactoredSigned-off-by Lorenzo Stoakes <[email protected]>---
mm/page_vma_mapped.c| 20 +++++++++++++++-----1 file changed, 15 insertions(+), 5 deletions(-)mm/page_vma_mapped.c +14
-5@@ -269,14 +269,24 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)/* THP pmd was split under us: handle on pte level */ spin_unlock (pvmw->ptl); pvmw->ptl =NULL ; - }else if (!pmd_present (pmde)) { -const softleaf_t entry =softleaf_from_pmd (pmde); + }else if (pmd_is_device_private_entry (pmde)) { +softleaf_t entry; + + pvmw->ptl =pmd_lock (mm, pvmw->pmd); + pmde = *pvmw->pmd; + entry =softleaf_from_pmd (pmde); -if (softleaf_is_device_private (entry)) { - pvmw->ptl =pmd_lock (mm, pvmw->pmd); +if (likely (softleaf_is_device_private (entry))) { +if (pvmw->flags &PVMW_MIGRATION ) +return not_found (pvmw); +if (!check_pmd (softleaf_to_pfn (entry), pvmw)) +return not_found (pvmw);return true; } - +/* device-private pmd was split under us: handle on pte level */ +spin_unlock (pvmw->ptl); + pvmw->ptl =NULL ;
Quoted 8 lines
Quoted 6 lines
mm/page_vma_mapped.c +1
-1+ }else if (!pmd_present (pmde)) { if ((pvmw->flags & PVMW_SYNC) && thp_vma_suitable_order(vma, pvmw->address, PMD_ORDER) && --2.54.0
If we prefer this way, I will check and take it.
Yeah, feel free to go ahead + use it :)
Quoted 4 lines
--
Wei Yang
Help you, Help me
Thanks, Lorenzo
Quoted 58 lines · Lorenzo Stoakes
Quoted 9 lines · Wei Yang
Quoted 5 lines · Lorenzo Stoakes
+cc Lance, linux-kernel
Your subject line is 83 characters long and is way too detailed how about 'fix device-private PMD handling'?
Got it.
Quoted 7 lines
Quoted 2 lines
You forgot to include [email protected] on the mail, lore seems to be a bit broken atm but in general it's helpful to include that.
Got it.
So usually we send a patch to both linux-mm and linux-kernel? If so, I remember is later actions.
Yeah it's better for dealing with kvack going wrong etc. :)
Quoted 38 lines
Quoted 5 lines
Also is useful to make this [PATCH mm-hotfixes] to make it really clear it's intended as a hotfix.
Got it.
Quoted 11 lines
Some commit msg language nits:
Quoted 2 lines · Wei Yang
For
pmd_trans_huge()andpmd_is_migration_entry(), we does following before return the pmd entry:Sounds better as:
For PMD entries that satisfy
pmd_trans_huge()orpmd_is_migration_entry(), we perform the following actions:Sure.
Quoted 6 lines
Quoted 6 lines
* re-validate pmd entry after PTL
* checkPVMW_MIGRATION
*check_pmd()
* handle on pte level if split under usQuoted 7 lines
Quoted 1 line
But for device-private pmd, we just return after
pmd_lock().->
However, for device-private PMD entries, we simply acquire the PMD lock and return.
Sure.
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
Also can you please give some justification here as to why all this also applies to device-private PMD? Right now it sounds hand wavey.
I thought below paragraph explain it. Not sure what justification is preferred.
Something about device private PMDs splitting the same way THP ones do, in the
pmd_is_device_private_entry()branch of__split_huge_pmd_locked().
Hi, Lorenzo
Thanks for your detailed suggestions.
I tried to add the justification here, and the following is the commit log after consolidate your suggestions.
For PMD entries that satisfy pmd_trans_huge() or pmd_is_migration_entry(), we perform the following actions:
* re-validate pmd entry after PTL
* check PVMW_MIGRATION
* check_pmd()
* handle on pte level if split under us
However, for device-private PMD entries, we simply acquire the PMD lock and return. This is not enough, as __split_huge_pmd_locked() would split a pmd device-private PMD under us just as it does for THP PMD.
This is particularly problematic when PVMW_MIGRATION is set (meaning a migration entry is sought), as it causes a device-private PMD entry to be returned with a different data layout, causing memory corruption.
Just feel this is not that smooth. Would you mind taking another look to see if I get your point correctly?
Signature · 2 lines
Wei Yang Help you, Help me
Lorenzo Stoakes
maintainerQuoted 88 lines · Wei Yang
Quoted 58 lines · Lorenzo Stoakes
Quoted 9 lines · Wei Yang
Quoted 5 lines · Lorenzo Stoakes
+cc Lance, linux-kernel
Your subject line is 83 characters long and is way too detailed how about 'fix device-private PMD handling'?
Got it.
Quoted 7 lines
Quoted 2 lines
You forgot to include [email protected] on the mail, lore seems to be a bit broken atm but in general it's helpful to include that.
Got it.
So usually we send a patch to both linux-mm and linux-kernel? If so, I remember is later actions.
Yeah it's better for dealing with kvack going wrong etc. :)
Quoted 38 lines
Quoted 5 lines
Also is useful to make this [PATCH mm-hotfixes] to make it really clear it's intended as a hotfix.
Got it.
Quoted 11 lines
Some commit msg language nits:
Quoted 2 lines · Wei Yang
For
pmd_trans_huge()andpmd_is_migration_entry(), we does following before return the pmd entry:Sounds better as:
For PMD entries that satisfy
pmd_trans_huge()orpmd_is_migration_entry(), we perform the following actions:Sure.
Quoted 6 lines
Quoted 6 lines
* re-validate pmd entry after PTL
* checkPVMW_MIGRATION
*check_pmd()
* handle on pte level if split under usQuoted 7 lines
Quoted 1 line
But for device-private pmd, we just return after
pmd_lock().->
However, for device-private PMD entries, we simply acquire the PMD lock and return.
Sure.
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
Also can you please give some justification here as to why all this also applies to device-private PMD? Right now it sounds hand wavey.
I thought below paragraph explain it. Not sure what justification is preferred.
Something about device private PMDs splitting the same way THP ones do, in the
pmd_is_device_private_entry()branch of__split_huge_pmd_locked().Hi, Lorenzo
Thanks for your detailed suggestions.
I tried to add the justification here, and the following is the commit log after consolidate your suggestions.
For PMD entries that satisfy
pmd_trans_huge()orpmd_is_migration_entry(), we perform the following actions:* re-validate pmd entry after PTL
* checkPVMW_MIGRATION
*check_pmd()
* handle on pte level if split under usHowever, for device-private PMD entries, we simply acquire the PMD lock and return. This is not enough, as
__split_huge_pmd_locked()would split a pmd device-private PMD under us just as it does for THP PMD.
Quoted 6 lines
This is particularly problematic when
PVMW_MIGRATIONis set (meaning a migration entry is sought), as it causes a device-private PMD entry to be returned with a different data layout, causing memory corruption.Just feel this is not that smooth. Would you mind taking another look to see if I get your point correctly?
Honestly I'd just drop the whole pmd_trans_huge()/pmd_is_migration_entry() bit and say:
Commit 65edfda6f3f2 ("mm/rmap: extend rmap and migration support device-private entries") introduced the concept of device-private PMD entries, but did not correctly update the rmap walk code to account for them.
As a result, when page_vma_mapped_walk() encounters device-private PMD entries, it takes no action other than to acquire the PMD lock and exit.
However this is highly problematic for two reasons - firstly, device private entries possess a PFN so check_pmd() needs to be called to ensure an overlapping PFN range.
Secondly, and more importantly, if PVMW_MIGRATION is set the caller assumes the returned entry is a migration entry, resulting in memory corruption when the caller tries to interpret the device private entry as such.
In addition, commit 146287290023 ("mm/huge_memory: implement device-private THP splitting") allowed device private PMDs to be split like THP mappings, but again did not update this code path.
As a result, we might race a PMD split prior to acquiring the PMD lock.
This patch addresses all of these issues by invoking check_pmd(), ensuring PMVW_MIGRATION is not set and checks whether a split raced us we do for PMD THP and migration entries.
Quoted 4 lines
--
Wei Yang
Help you, Help me
Cheers, Lorenzo
Quoted 121 lines · Lorenzo Stoakes
Quoted 88 lines · Wei Yang
Quoted 58 lines · Lorenzo Stoakes
Quoted 9 lines · Wei Yang
Quoted 5 lines · Lorenzo Stoakes
+cc Lance, linux-kernel
Your subject line is 83 characters long and is way too detailed how about 'fix device-private PMD handling'?
Got it.
Quoted 7 lines
Quoted 2 lines
You forgot to include [email protected] on the mail, lore seems to be a bit broken atm but in general it's helpful to include that.
Got it.
So usually we send a patch to both linux-mm and linux-kernel? If so, I remember is later actions.
Yeah it's better for dealing with kvack going wrong etc. :)
Quoted 38 lines
Quoted 5 lines
Also is useful to make this [PATCH mm-hotfixes] to make it really clear it's intended as a hotfix.
Got it.
Quoted 11 lines
Some commit msg language nits:
Quoted 2 lines · Wei Yang
For
pmd_trans_huge()andpmd_is_migration_entry(), we does following before return the pmd entry:Sounds better as:
For PMD entries that satisfy
pmd_trans_huge()orpmd_is_migration_entry(), we perform the following actions:Sure.
Quoted 6 lines
Quoted 6 lines
* re-validate pmd entry after PTL
* checkPVMW_MIGRATION
*check_pmd()
* handle on pte level if split under usQuoted 7 lines
Quoted 1 line
But for device-private pmd, we just return after
pmd_lock().->
However, for device-private PMD entries, we simply acquire the PMD lock and return.
Sure.
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
Also can you please give some justification here as to why all this also applies to device-private PMD? Right now it sounds hand wavey.
I thought below paragraph explain it. Not sure what justification is preferred.
Something about device private PMDs splitting the same way THP ones do, in the
pmd_is_device_private_entry()branch of__split_huge_pmd_locked().Hi, Lorenzo
Thanks for your detailed suggestions.
I tried to add the justification here, and the following is the commit log after consolidate your suggestions.
For PMD entries that satisfy
pmd_trans_huge()orpmd_is_migration_entry(), we perform the following actions:* re-validate pmd entry after PTL
* checkPVMW_MIGRATION
*check_pmd()
* handle on pte level if split under usHowever, for device-private PMD entries, we simply acquire the PMD lock and return. This is not enough, as
__split_huge_pmd_locked()would split a pmd device-private PMD under us just as it does for THP PMD.Quoted 6 lines
This is particularly problematic when
PVMW_MIGRATIONis set (meaning a migration entry is sought), as it causes a device-private PMD entry to be returned with a different data layout, causing memory corruption.Just feel this is not that smooth. Would you mind taking another look to see if I get your point correctly?
Honestly I'd just drop the whole pmd_trans_huge()/pmd_is_migration_entry() bit and say:
Commit
65edfda6f3f2("mm/rmap: extend rmap and migration support device-private entries") introduced the concept of device-private PMD entries, but did not correctly update the rmap walk code to account for them.As a result, when
page_vma_mapped_walk()encounters device-private PMD entries, it takes no action other than to acquire the PMD lock and exit.However this is highly problematic for two reasons - firstly, device private entries possess a PFN so
check_pmd()needs to be called to ensure an overlapping PFN range.Secondly, and more importantly, if
PVMW_MIGRATIONis set the caller assumes the returned entry is a migration entry, resulting in memory corruption when the caller tries to interpret the device private entry as such.In addition, commit 146287290023 ("
mm/huge_memory: implement device-private THP splitting") allowed device private PMDs to be split like THP mappings, but again did not update this code path.
Quoted 7 lines
As a result, we might race a PMD split prior to acquiring the PMD lock.
This patch addresses all of these issues by invoking
check_pmd(), ensuringPMVW_MIGRATIONis not set and checks whether a split raced us we do for PMD THP and migration entries.
Have to say this is much much better, thanks!
Quoted 2 lines
Cheers, Lorenzo
Signature · 2 lines
Wei Yang Help you, Help me
Lance Yang
reviewerQuoted 1 line · Lorenzo Stoakes
+cc Lance, linux-kernel
Thanks for the cc.
[...]
Quoted 47 lines
----8<----
Frome6a3c1c782714ed831c4d46a14bb99226423bf59Mon Sep 17 00:00:00 2001
From: Wei Yang <[email protected]>
Date: Mon, 22 Jun 2026 13:06:51 +0000
Subject: [PATCH] refactoredSigned-off-by Lorenzo Stoakes <[email protected]>--- mm/page_vma_mapped.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)mm/page_vma_mapped.c +15
-6@@ -269,14 +269,24 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)/* THP pmd was split under us: handle on pte level */ spin_unlock (pvmw->ptl); pvmw->ptl =NULL ; - }else if (!pmd_present (pmde)) { -const softleaf_t entry =softleaf_from_pmd (pmde); + }else if (pmd_is_device_private_entry (pmde)) { +softleaf_t entry; + + pvmw->ptl =pmd_lock (mm, pvmw->pmd); + pmde = *pvmw->pmd; + entry =softleaf_from_pmd (pmde); -if (softleaf_is_device_private (entry)) { - pvmw->ptl =pmd_lock (mm, pvmw->pmd); +if (likely (softleaf_is_device_private (entry))) { +if (pvmw->flags &PVMW_MIGRATION ) +return not_found (pvmw); +if (!check_pmd (softleaf_to_pfn (entry), pvmw)) +return not_found (pvmw);return true; } - +/* device-private pmd was split under us: handle on pte level */ +spin_unlock (pvmw->ptl); + pvmw->ptl =NULL ; + }else if (!pmd_present (pmde)) { if ((pvmw->flags & PVMW_SYNC) && thp_vma_suitable_order(vma, pvmw->address, PMD_ORDER) && --
Quoted 1 line
2.54.0
Cool, looks way cleaner :) Nothing jumped out at me :)
Cheers, Lance
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Wei,
kernel test robot noticed the following build errors:
[auto build test ERROR on akpm-mm/mm-everything]
url: https://github.com/intel-lab-lkp/linux/commits/Wei-Yang/mm-page_vma_mapped-revalidate-and-do-proper-check-before-return-device-private-pmd/20260623-012838 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything patch link: https://lore.kernel.org/r/20260622130651.23359-1-richard.weiyang%40gmail.com patch subject: [PATCH] mm/page_vma_mapped: revalidate and do proper check before return device-private pmd config: parisc-randconfig-002-20260623 (https://download.01.org/0day-ci/archive/20260624/[email protected]/config) compiler: hppa-linux-gcc (GCC) 8.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260624/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from <command-line>:
In function 'check_pmd.isra.24',
inlined from 'page_vma_mapped_walk' at mm/page_vma_mapped.c:283:11:
>> include/linux/compiler_types.h:699:38: error: call to '__compiletime_assert_406' declared with attribute error: BUILD_BUG failed
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^
include/linux/compiler_types.h:680:4: note: in definition of macro '__compiletime_assert'
prefix ## suffix(); \
^~~~~~
include/linux/compiler_types.h:699:2: note: in expansion of macro '_compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:40:37: note: in expansion of macro 'compiletime_assert'
#define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
^~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:60:21: note: in expansion of macro 'BUILD_BUG_ON_MSG'
#define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed")
^~~~~~~~~~~~~~~~
include/linux/huge_mm.h:113:28: note: in expansion of macro 'BUILD_BUG'
#define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; })
^~~~~~~~~
include/linux/huge_mm.h:117:26: note: in expansion of macro 'HPAGE_PMD_SHIFT'
#define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT)
^~~~~~~~~~~~~~~
include/linux/huge_mm.h:118:26: note: in expansion of macro 'HPAGE_PMD_ORDER'
#define HPAGE_PMD_NR (1<<HPAGE_PMD_ORDER)
^~~~~~~~~~~~~~~
mm/page_vma_mapped.c:142:13: note: in expansion of macro 'HPAGE_PMD_NR'
if ((pfn + HPAGE_PMD_NR - 1) < pvmw->pfn)
^~~~~~~~~~~~vim +/__compiletime_assert_406 +699 include/linux/compiler_types.h
eb5c2d4b45e3d2d Will Deacon 2020-07-21 685 eb5c2d4b45e3d2d Will Deacon 2020-07-21 686 #define _compiletime_assert(condition, msg, prefix, suffix) \ eb5c2d4b45e3d2d Will Deacon 2020-07-21 687 __compiletime_assert(condition, msg, prefix, suffix) eb5c2d4b45e3d2d Will Deacon 2020-07-21 688 eb5c2d4b45e3d2d Will Deacon 2020-07-21 689 /** eb5c2d4b45e3d2d Will Deacon 2020-07-21 690 * compiletime_assert - break build and emit msg if condition is false eb5c2d4b45e3d2d Will Deacon 2020-07-21 691 * @condition: a compile-time constant condition to check eb5c2d4b45e3d2d Will Deacon 2020-07-21 692 * @msg: a message to emit if condition is false eb5c2d4b45e3d2d Will Deacon 2020-07-21 693 * eb5c2d4b45e3d2d Will Deacon 2020-07-21 694 * In tradition of POSIX assert, this macro will break the build if the eb5c2d4b45e3d2d Will Deacon 2020-07-21 695 * supplied condition is *false*, emitting the supplied error message if the eb5c2d4b45e3d2d Will Deacon 2020-07-21 696 * compiler has support to do so. eb5c2d4b45e3d2d Will Deacon 2020-07-21 697 */ eb5c2d4b45e3d2d Will Deacon 2020-07-21 698 #define compiletime_assert(condition, msg) \
eb5c2d4b45e3d2d Will Deacon 2020-07-21 @699 _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)eb5c2d4b45e3d2d Will Deacon 2020-07-21 700
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Quoted 4 lines · kernel test robot
Hi Wei,
kernel test robot noticed the following build errors:
Thanks for reporting.
Quoted 7 lines
[auto build test ERROR on akpm-mm/mm-everything]
url: https://github.com/intel-lab-lkp/linux/commits/Wei-Yang/mm-page_vma_mapped-revalidate-and-do-proper-check-before-return-device-private-pmd/20260623-012838 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything patch link: https://lore.kernel.org/r/20260622130651.23359-1-richard.weiyang%40gmail.com patch subject: [PATCH] mm/page_vma_mapped: revalidate and do proper check before return device-private pmd config: parisc-randconfig-002-20260623 (https://download.01.org/0day-ci/archive/20260624/[email protected]/config)
So this is parisc arch.
In the config file, HAVE_ARCH_TRANSPARENT_HUGEPAGE is not defined. Which leads to !TRANSPARENT_HUGEPAGE and !PGTABLE_HAS_HUGE_LEAVES.
And then trigger the BUILD_BUG().
Quoted 32 lines
compiler: hppa-linux-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260624/[email protected]/reproduce)If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/All errors (new ones prefixed by >>):
In file included from <command-line>:
In function 'check_pmd.isra.24',inlined from 'page_vma_mapped_walk' at mm/page_vma_mapped.c:283:11:Quoted 1 line
Quoted 1 line
include/linux/compiler_types.h:699:38: error: call to '__compiletime_assert_406' declared with attribute error:BUILD_BUGfailed
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^
include/linux/compiler_types.h:680:4: note: in definition of macro '__compiletime_assert'prefix ## suffix(); \ ^~~~~~ include/linux/compiler_types.h:699:2: note: in expansion of macro '_compiletime_assert' _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) ^~~~~~~~~~~~~~~~~~~ include/linux/build_bug.h:40:37: note: in expansion of macro 'compiletime_assert' #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) ^~~~~~~~~~~~~~~~~~ include/linux/build_bug.h:60:21: note: in expansion of macro 'BUILD_BUG_ON_MSG' #define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed") ^~~~~~~~~~~~~~~~ include/linux/huge_mm.h:113:28: note: in expansion of macro 'BUILD_BUG' #define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; }) ^~~~~~~~~
include/linux/huge_mm.h:117:26: note: in expansion of macro 'HPAGE_PMD_SHIFT'
Quoted 9 lines
#define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT)
^~~~~~~~~~~~~~~
include/linux/huge_mm.h:118:26: note: in expansion of macro 'HPAGE_PMD_ORDER'
#define HPAGE_PMD_NR (1<<HPAGE_PMD_ORDER)
^~~~~~~~~~~~~~~
mm/page_vma_mapped.c:142:13: note: in expansion of macro 'HPAGE_PMD_NR'
if ((pfn + HPAGE_PMD_NR - 1) < pvmw->pfn)
^~~~~~~~~~~~This is in definition of check_pmd() which is already in kernel for a while.
I will update current version, and take a look to how to fix it.
Quoted 23 lines
vim +/__compiletime_assert_406 +699
include/linux/compiler_types.heb5c2d4b45e3d2d Will Deacon 2020-07-21 685 eb5c2d4b45e3d2d Will Deacon 2020-07-21 686 #define _compiletime_assert(condition, msg, prefix, suffix) \ eb5c2d4b45e3d2d Will Deacon 2020-07-21 687 __compiletime_assert(condition, msg, prefix, suffix) eb5c2d4b45e3d2d Will Deacon 2020-07-21 688 eb5c2d4b45e3d2d Will Deacon 2020-07-21 689 /** eb5c2d4b45e3d2d Will Deacon 2020-07-21 690 * compiletime_assert - break build and emit msg if condition is false eb5c2d4b45e3d2d Will Deacon 2020-07-21 691 * @condition: a compile-time constant condition to check eb5c2d4b45e3d2d Will Deacon 2020-07-21 692 * @msg: a message to emit if condition is false eb5c2d4b45e3d2d Will Deacon 2020-07-21 693 * eb5c2d4b45e3d2d Will Deacon 2020-07-21 694 * In tradition of POSIX assert, this macro will break the build if the eb5c2d4b45e3d2d Will Deacon 2020-07-21 695 * supplied condition is *false*, emitting the supplied error message if the eb5c2d4b45e3d2d Will Deacon 2020-07-21 696 * compiler has support to do so. eb5c2d4b45e3d2d Will Deacon 2020-07-21 697 */ eb5c2d4b45e3d2d Will Deacon 2020-07-21 698 #define compiletime_assert(condition, msg) \
eb5c2d4b45e3d2dWill Deacon 2020-07-21 @699_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)eb5c2d4b45e3d2dWill Deacon 2020-07-21 700--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Signature · 2 lines
Wei Yang Help you, Help me