Skip to contentSkip to conversation

mm/page_vma_mapped: guard check_pmd() with CONFIG_TRANSPARENT_HUGEPAGE

PATCH Applied Wei Yang 5 participants 15 messages Jun 24 – Sep 4

Subsystems (2)
lore
Share & tools
lore

Wei Yang

author
#0 lore raw

PATCH 1/1 mm/page_vma_mapped: guard check_pmd() with CONFIG_TRANSPARENT_HUGEPAGE

The kernel test robot reported a build failure on the parisc architecture when expanding HPAGE_PMD_NR in check_pmd().

mm/page_vma_mapped.c:142:13: note: in expansion of macro 'HPAGE_PMD_NR'

     if ((pfn + HPAGE_PMD_NR - 1) < pvmw->pfn)
                ^~~~~~~~~~~~

The config [1] in report link shows neither TRANSPARENT_HUGEPAGE nor HUGETLB_PAGE is defined. Then trigger the BUILD_BUG.

Fix it by define check_pmd() under CONFIG_TRANSPARENT_HUGEPAGE.

[1]: https://download.01.org/0day-ci/archive/20260624/[email protected]/config

Fixes 2aff7a4755be ("mm: Convert page_vma_mapped_walk to work on PFNs")
---
 mm/page_vma_mapped.c | 7 +++++++
 1 file changed, 7 insertions(+)
mm/page_vma_mapped.c +7 -0
index 17dff8aab9f9..4aac94d9e8a9 100644
@@ -136,6 +136,7 @@ static bool check_pte(struct page_vma_mapped_walk *pvmw, unsigned long pte_nr)
 	return true;
 }
 
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
 /* Returns true if the two ranges overlap.  Careful to not overflow. */
 static bool check_pmd(unsigned long pfn, struct page_vma_mapped_walk *pvmw)
 {
@@ -145,6 +146,12 @@ static bool check_pmd(unsigned long pfn, struct page_vma_mapped_walk *pvmw)
 		return false;
 	return true;
 }
+#else
+static bool check_pmd(unsigned long pfn, struct page_vma_mapped_walk *pvmw)
+{
+	return false;
+}
+#endif
 
 static void step_forward(struct page_vma_mapped_walk *pvmw, unsigned long size)
 {
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 11 lines · On Wed, 24 Jun 2026 08:23:59 +0000 Wei Yang <[email protected]> wrote:

The kernel test robot reported a build failure on the parisc architecture when expanding HPAGE_PMD_NR in check_pmd().

   mm/page_vma_mapped.c:142:13: note: in expansion of macro 'HPAGE_PMD_NR'
     if ((pfn + HPAGE_PMD_NR - 1) < pvmw->pfn)
                ^~~~~~~~~~~~

The config [1] in report link shows neither TRANSPARENT_HUGEPAGE nor HUGETLB_PAGE is defined. Then trigger the BUILD_BUG.

Fix it by define check_pmd() under CONFIG_TRANSPARENT_HUGEPAGE.

hm,

#ifdef CONFIG_PGTABLE_HAS_HUGE_LEAVES
#define HPAGE_PMD_SHIFT PMD_SHIFT
#define HPAGE_PUD_SHIFT PUD_SHIFT
#else
#define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; })
#define HPAGE_PUD_SHIFT ({ BUILD_BUG(); 0; })
#endif

Quoted 5 lines
mm/page_vma_mapped.c +1 -0
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
 /* Returns true if the two ranges overlap.  Careful to not overflow. */
 static bool check_pmd(unsigned long pfn, struct page_vma_mapped_walk *pvmw)
 {

mm/page_vma_mapped.c static bool check_pmd(unsigned long pfn, struct page_vma_mapped_walk *pvmw) · line 154

Quoted 9 lines
mm/page_vma_mapped.c +6 -0
@@ -145,6 +146,12 @@ static bool check_pmd(unsigned long pfn, struct page_vma_mapped_walk *pvmw)
 		return false;
 	return true;
 }
+#else
+static bool check_pmd(unsigned long pfn, struct page_vma_mapped_walk *pvmw)
+{
+	return false;
+}
+#endif

I'll leave it to others to decide if this is the most appropriate fix.

Sashiko had an off-topic complaint about the surrounding code:

	https://lore.kernel.org/oe-kbuild-all/[email protected]/
author
#2 lore raw
Quoted 41 lines · Andrew Morton
Quoted 11 lines · On Wed, 24 Jun 2026 08:23:59 +0000 Wei Yang <[email protected]> wrote:

The kernel test robot reported a build failure on the parisc architecture when expanding HPAGE_PMD_NR in check_pmd().

   mm/page_vma_mapped.c:142:13: note: in expansion of macro 'HPAGE_PMD_NR'
     if ((pfn + HPAGE_PMD_NR - 1) < pvmw->pfn)
                ^~~~~~~~~~~~

The config [1] in report link shows neither TRANSPARENT_HUGEPAGE nor HUGETLB_PAGE is defined. Then trigger the BUILD_BUG.

Fix it by define check_pmd() under CONFIG_TRANSPARENT_HUGEPAGE.

hm,

#ifdef CONFIG_PGTABLE_HAS_HUGE_LEAVES
#define HPAGE_PMD_SHIFT PMD_SHIFT
#define HPAGE_PUD_SHIFT PUD_SHIFT
#else
#define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; })
#define HPAGE_PUD_SHIFT ({ BUILD_BUG(); 0; })
#endif

Quoted 5 lines
mm/page_vma_mapped.c +1 -0
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
 /* Returns true if the two ranges overlap.  Careful to not overflow. */
 static bool check_pmd(unsigned long pfn, struct page_vma_mapped_walk *pvmw)
 {

mm/page_vma_mapped.c static bool check_pmd(unsigned long pfn, struct page_vma_mapped_walk *pvmw) · line 154

Quoted 9 lines
mm/page_vma_mapped.c +6 -0
@@ -145,6 +146,12 @@ static bool check_pmd(unsigned long pfn, struct page_vma_mapped_walk *pvmw)
 		return false;
 	return true;
 }
+#else
+static bool check_pmd(unsigned long pfn, struct page_vma_mapped_walk *pvmw)
+{
+	return false;
+}
+#endif

I'll leave it to others to decide if this is the most appropriate fix.

Quoted 2 lines

Sashiko had an off-topic complaint about the surrounding code:

	https://lore.kernel.org/oe-kbuild-all/[email protected]/

I see this robot reply, but not see the Sashiko comment.

How can I view Sashiko's commnet?

Signature · 2 lines
Wei Yang
Help you, Help me
maintainer
#3 lore raw
Quoted 6 lines · On Thu, 25 Jun 2026 03:46:29 +0000 Wei Yang <[email protected]> wrote:
Quoted 2 lines

Sashiko had an off-topic complaint about the surrounding code:

	https://lore.kernel.org/oe-kbuild-all/[email protected]/

I see this robot reply, but not see the Sashiko comment.

How can I view Sashiko's commnet?

oop sorry.

You can go to https://sashiko.dev/ and search for the email subject.

Or append your Message-ID to "https://sashiko.dev/#/patchset":

	https://sashiko.dev/#/patchset/[email protected]
author
#4 lore raw

+cc Balbir

Quoted 9 lines · Andrew Morton
Quoted 6 lines · On Thu, 25 Jun 2026 03:46:29 +0000 Wei Yang <[email protected]> wrote:
Quoted 2 lines

Sashiko had an off-topic complaint about the surrounding code:

	https://lore.kernel.org/oe-kbuild-all/[email protected]/

I see this robot reply, but not see the Sashiko comment.

How can I view Sashiko's commnet?

Quoted 8 lines

oop sorry.

You can go to https://sashiko.dev/ and search for the email subject.

Or append your Message-ID to "https://sashiko.dev/#/patchset":

	https://sashiko.dev/#/patchset/[email protected]

Got it, thansk

This one mentioned two things:

a. page_vma_mapped_walk() return without check
b. whether __split_huge_pmd_locked() would split device-private pmd

For a., it is being fixing at [1].

For b., to be honest I am not 100% for sure. If a device-private pmd could be file backed, then this looks like a bug.

Balbir,

Would you mind taking a look at the second comment raised by Sashiko?

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

Signature · 2 lines
Wei Yang
Help you, Help me
maintainer
#5 lore raw

+cc Roman for Sashiko discussion

Quoted 30 lines · Wei Yang

+cc Balbir

Quoted 9 lines · Andrew Morton
Quoted 6 lines · On Thu, 25 Jun 2026 03:46:29 +0000 Wei Yang <[email protected]> wrote:
Quoted 2 lines

Sashiko had an off-topic complaint about the surrounding code:

	https://lore.kernel.org/oe-kbuild-all/[email protected]/

I see this robot reply, but not see the Sashiko comment.

How can I view Sashiko's commnet?

Quoted 8 lines

oop sorry.

You can go to https://sashiko.dev/ and search for the email subject.

Or append your Message-ID to "https://sashiko.dev/#/patchset":

	https://sashiko.dev/#/patchset/[email protected]

Got it, thansk

This one mentioned two things:

a. page_vma_mapped_walk() return without check
b. whether __split_huge_pmd_locked() would split device-private pmd

For a., it is being fixing at [1].

Quoted 8 lines

For b., to be honest I am not 100% for sure. If a device-private pmd could be file backed, then this looks like a bug.

Balbir,

Would you mind taking a look at the second comment raised by Sashiko?

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

I continue to dislike that sashiko does this.

Series with... interesting use of AI :).. are already taking up more of the time we reviewers don't have... but interrupting existing review to mention random stuff is unhelpful I feel :)

I think the better use of time here would be for Balbir to perhaps ask AI to examine all cases where a PMD device private entry might crop up and to check to see if there's any other bugs similar to the ones we've encountered before?

Given Sashiko is very token-constrained, I also wonder whether this feature wouldn't be better disabled (or maybe have the ability to turn off per-subsystem?)

In a couple other cases the 'also consider' stuff actually took a bunch of time unnecessarily and I felt they interferred with the series landing.

Given the time constraints we all work under, it'd be better not to add to workload this way (having to figure out if the points are valid are a time drain in themselves).

Thanks, Lorenzo

#6 lore raw
In reply to Wei Yang
Quoted 30 lines · Wei Yang

+cc Balbir

Quoted 9 lines · Andrew Morton
Quoted 6 lines · On Thu, 25 Jun 2026 03:46:29 +0000 Wei Yang <[email protected]> wrote:
Quoted 2 lines

Sashiko had an off-topic complaint about the surrounding code:

	https://lore.kernel.org/oe-kbuild-all/[email protected]/

I see this robot reply, but not see the Sashiko comment.

How can I view Sashiko's commnet?

Quoted 8 lines

oop sorry.

You can go to https://sashiko.dev/ and search for the email subject.

Or append your Message-ID to "https://sashiko.dev/#/patchset":

	https://sashiko.dev/#/patchset/[email protected]

Got it, thansk

This one mentioned two things:

a. page_vma_mapped_walk() return without check
b. whether __split_huge_pmd_locked() would split device-private pmd

For a., it is being fixing at [1].

Quoted 9 lines

For b., to be honest I am not 100% for sure. If a device-private pmd could be file backed, then this looks like a bug.

Balbir,

Would you mind taking a look at the second comment raised by Sashiko?

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

device-private pmd's are not file backed

Balbir

maintainer
#7 lore raw
In reply to Wei Yang
Quoted 2 lines · Wei Yang

The kernel test robot reported a build failure on the parisc architecture when expanding HPAGE_PMD_NR in check_pmd().

Let me first say that I absolutely hate that we continue to support museum piece architectures to the point that we have to make changes in core code to accommodate them.

It's not unreasonable to ask retro people to either use older kernels or make a downstream fork.

People having to think about this upstream is so incredibly silly. As if we don't have enough work already...

Anyway, with that said...

Quoted 11 lines
   mm/page_vma_mapped.c:142:13: note: in expansion of macro 'HPAGE_PMD_NR'
     if ((pfn + HPAGE_PMD_NR - 1) < pvmw->pfn)
                ^~~~~~~~~~~~

The config [1] in report link shows neither TRANSPARENT_HUGEPAGE nor HUGETLB_PAGE is defined. Then trigger the BUILD_BUG.

Fix it by define check_pmd() under CONFIG_TRANSPARENT_HUGEPAGE.

[1]: https://download.01.org/0day-ci/archive/20260624/[email protected]/config

I think the fact this wasn't detected for 4 odd years goes to show how well tested stuff on this arch is... (unless this is a very unusual configuration at least).

Quoted 14 lines
Fixes 2aff7a4755be ("mm: Convert page_vma_mapped_walk to work on PFNs")
---
 mm/page_vma_mapped.c | 7 +++++++
 1 file changed, 7 insertions(+)
mm/page_vma_mapped.c +0 -0
index 17dff8aab9f9..4aac94d9e8a9 100644

mm/page_vma_mapped.c static bool check_pte(struct page_vma_mapped_walk *pvmw, unsigned long pte_nr) · line 139

Quoted 4 lines
mm/page_vma_mapped.c +1 -0
@@ -136,6 +136,7 @@ static bool check_pte(struct page_vma_mapped_walk *pvmw, unsigned long pte_nr)
 	return true;
 }
 
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE

As per Andrew, this should be CONFIG_PGTABLE_HAS_HUGE_LEAVES I think.

I don't like that CONFIG_T..HP is taken to mean 'anything to do with leaf page tables'. That's a mess and one we should unwind.

So don't make it worse, use CONFIG_PGTABLE_HAS_HUGE_LEAVES.

mm/page_vma_mapped.c static bool check_pmd(unsigned long pfn, struct page_vma_mapped_walk *pvmw) · line 152

Quoted 11 lines
mm/page_vma_mapped.c +4 -0
 /* Returns true if the two ranges overlap.  Careful to not overflow. */
 static bool check_pmd(unsigned long pfn, struct page_vma_mapped_walk *pvmw)
 {
@@ -145,6 +146,12 @@ static bool check_pmd(unsigned long pfn, struct page_vma_mapped_walk *pvmw)
 		return false;
 	return true;
 }
+#else
+static bool check_pmd(unsigned long pfn, struct page_vma_mapped_walk *pvmw)
+{
+	return false;

Should have a WARN_ON_ONCE("bug in stupid arch") or similar here ;)

Quoted 8 lines
mm/page_vma_mapped.c +2 -1
+}
+#endif
 
 static void step_forward(struct page_vma_mapped_walk *pvmw, unsigned long size)
 {
--

2.34.1

Thanks, Lorenzo

#8 lore raw
Quoted 7 lines · Lorenzo Stoakes
Quoted 2 lines · Wei Yang

The kernel test robot reported a build failure on the parisc architecture when expanding HPAGE_PMD_NR in check_pmd().

Let me first say that I absolutely hate that we continue to support museum piece architectures to the point that we have to make changes in core code to accommodate them.

I wonder why we shouldn't be able to trigger that on other archs with !CONFIG_TRANSPARENT_HUGEPAGE ?

I think the code just relies on pmd_trans_huge() == false, and consequently check_pmd will get compiled out completely.

Now, the report was against Wei's new patch.

There is *nothing* to be fixed for existing code.

Fixes 2aff7a4755be ("mm: Convert page_vma_mapped_walk to work on PFNs")

is just wrong?

Signature · 3 lines
Cheers,

David
maintainer
#9 lore raw
Quoted 11 lines · David Hildenbrand (Arm)
Quoted 7 lines · Lorenzo Stoakes
Quoted 2 lines · Wei Yang

The kernel test robot reported a build failure on the parisc architecture when expanding HPAGE_PMD_NR in check_pmd().

Let me first say that I absolutely hate that we continue to support museum piece architectures to the point that we have to make changes in core code to accommodate them.

I wonder why we shouldn't be able to trigger that on other archs with !CONFIG_TRANSPARENT_HUGEPAGE ?

I think this should just use CONFIG_PGTABLE_HAS_HUGE_LEAVES, since that's the property that literally defines whether check_pmd() makes any sense.

Quoted 7 lines

I think the code just relies on pmd_trans_huge() == false, and consequently check_pmd will get compiled out completely.

Now, the report was against Wei's new patch.

There is *nothing* to be fixed for existing code.

OK so it's a fix sent in the merge window, against a patch sent in the merge window. Great.

I mean, let's all chill here. Sip some wine. Some brandy. Some absinthe. Perhaps even some turpentine* for the connoisseurs!

Slow down a bit Wei!

You're sending a lot of fiddly series that require a lot of review and we're extremely busy with review already.

Please just relax and maybe go water your garden a bit. Have a cornetto :)

Quoted 5 lines
Fixes 2aff7a4755be ("mm: Convert page_vma_mapped_walk to work on PFNs")

is just wrong?

Yes therefore it is indeed.

Though it's really horrible that we relied on things getting compiled out like that... nasty!

Quoted 5 lines

--
Cheers,

David

Cheers, Lorenzo

*Obligatory safety notice for the overly literal: do not do this, this is a
joke.

#10 lore raw
Quoted 7 lines · Lorenzo Stoakes
Quoted 6 lines · David Hildenbrand (Arm)
Quoted 4 lines · Lorenzo Stoakes

Let me first say that I absolutely hate that we continue to support museum piece architectures to the point that we have to make changes in core code to accommodate them.

Quoted 5 lines
Quoted 2 lines

I wonder why we shouldn't be able to trigger that on other archs with !CONFIG_TRANSPARENT_HUGEPAGE ?

I think this should just use CONFIG_PGTABLE_HAS_HUGE_LEAVES, since that's the property that literally defines whether check_pmd() makes any sense.

I stated earlier (when motivating a proper cleanup of this) that I detest pmd_trans_huge(). And yes, like I did in foliowalk, we should just check for IS_ENABLED(CONFIG_PGTABLE_HAS_HUGE_LEAVES) instead.

Long story short: Wei's fix needs work, upstream is fine.

Signature · 3 lines
Cheers,

David
author
#11 lore raw
Quoted 11 lines · David Hildenbrand (Arm)
Quoted 10 lines · Lorenzo Stoakes
Quoted 8 lines · David Hildenbrand (Arm)
Quoted 4 lines · Lorenzo Stoakes

Let me first say that I absolutely hate that we continue to support museum piece architectures to the point that we have to make changes in core code to accommodate them.

I wonder why we shouldn't be able to trigger that on other archs with !CONFIG_TRANSPARENT_HUGEPAGE ?

Quoted 9 lines
Quoted 2 lines

I think this should just use CONFIG_PGTABLE_HAS_HUGE_LEAVES, since that's the property that literally defines whether check_pmd() makes any sense.

I stated earlier (when motivating a proper cleanup of this) that I detest pmd_trans_huge(). And yes, like I did in foliowalk, we should just check for IS_ENABLED(CONFIG_PGTABLE_HAS_HUGE_LEAVES) instead.

Long story short: Wei's fix needs work, upstream is fine.

Ok, I didn't notice this is caused by my fix because pmd_trans_huge() == false and check_pmd() skipped, but the newly add code doesn't. So I should merge this with the pmd_is_device_private_entry() fix patch.

And should wrap it with CONFIG_PGTABLE_HAS_HUGE_LEAVES instead of CONFIG_TRANSPARENT_HUGEPAGE.

But one more thing, I took a look into the robot test config and notice ARCH_ENABLE_THP_MIGRATION is not defined either, which depends on TRANSPARENT_HUGEPAGE (where pmd_trans_huge() depends). This means pmd_is_device_private_entry() == false on this test environment. And in theory it is false if TRANSPARENT_HUGEPAGE is not set.

So check_pmd() should be skipped too? Hope I am not too silly.

Quoted 4 lines
Signature · 3 lines
Cheers,

David
Signature · 2 lines
Wei Yang
Help you, Help me
author
#12 lore raw
Quoted 30 lines · Wei Yang
Quoted 11 lines · David Hildenbrand (Arm)
Quoted 10 lines · Lorenzo Stoakes
Quoted 8 lines · David Hildenbrand (Arm)
Quoted 4 lines · Lorenzo Stoakes

Let me first say that I absolutely hate that we continue to support museum piece architectures to the point that we have to make changes in core code to accommodate them.

I wonder why we shouldn't be able to trigger that on other archs with !CONFIG_TRANSPARENT_HUGEPAGE ?

Quoted 9 lines
Quoted 2 lines

I think this should just use CONFIG_PGTABLE_HAS_HUGE_LEAVES, since that's the property that literally defines whether check_pmd() makes any sense.

I stated earlier (when motivating a proper cleanup of this) that I detest pmd_trans_huge(). And yes, like I did in foliowalk, we should just check for IS_ENABLED(CONFIG_PGTABLE_HAS_HUGE_LEAVES) instead.

Long story short: Wei's fix needs work, upstream is fine.

Ok, I didn't notice this is caused by my fix because pmd_trans_huge() == false and check_pmd() skipped, but the newly add code doesn't. So I should merge this with the pmd_is_device_private_entry() fix patch.

And should wrap it with CONFIG_PGTABLE_HAS_HUGE_LEAVES instead of CONFIG_TRANSPARENT_HUGEPAGE.

Quoted 8 lines

But one more thing, I took a look into the robot test config and notice ARCH_ENABLE_THP_MIGRATION is not defined either, which depends on TRANSPARENT_HUGEPAGE (where pmd_trans_huge() depends). This means pmd_is_device_private_entry() == false on this test environment. And in theory it is false if TRANSPARENT_HUGEPAGE is not set.

So check_pmd() should be skipped too? Hope I am not too silly.

OK, I think I got the reason.

The error reported is against v3 [1], in which check_pmd() is just wrapped in pmd_present().

But in v4, the new added check_pmd() usage is wrapped in pmd_is_device_private_entry(), which is defined under ARCH_ENABLE_THP_MIGRATION.

I have download 0day test suite and try to reproduce it with the instruction. And prove v3 would trigger the error, while v4 doesn't. PS: thanks Lorenzo's suggestion to put into its own if branch, otherwise the code would be ugly.

Interesting lesson learned, thanks all for taking a look.

If so, I won't post a v5 for now.

[1]: https://lore.kernel.org/all/[email protected]/
[2]: https://lore.kernel.org/all/[email protected]/T/#u

Signature · 2 lines
Wei Yang
Help you, Help me
maintainer
#13 lore raw
In reply to Wei Yang
Quoted 34 lines · On Wed, 24 Jun 2026 08:23:59 +0000 Wei Yang <[email protected]> wrote:

The kernel test robot reported a build failure on the parisc architecture when expanding HPAGE_PMD_NR in check_pmd().

   mm/page_vma_mapped.c:142:13: note: in expansion of macro 'HPAGE_PMD_NR'
     if ((pfn + HPAGE_PMD_NR - 1) < pvmw->pfn)
                ^~~~~~~~~~~~

The config [1] in report link shows neither TRANSPARENT_HUGEPAGE nor HUGETLB_PAGE is defined. Then trigger the BUILD_BUG.

Fix it by define check_pmd() under CONFIG_TRANSPARENT_HUGEPAGE.

[1]: https://download.01.org/0day-ci/archive/20260624/[email protected]/config

Fixes 2aff7a4755be ("mm: Convert page_vma_mapped_walk to work on PFNs")

...

mm/page_vma_mapped.c +1 -0
@@ -136,6 +136,7 @@ static bool check_pte(struct page_vma_mapped_walk *pvmw, unsigned long pte_nr)
 	return true;
 }
 
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
 /* Returns true if the two ranges overlap.  Careful to not overflow. */
 static bool check_pmd(unsigned long pfn, struct page_vma_mapped_walk *pvmw)
 {
@@ -145,6 +146,12 @@ static bool check_pmd(unsigned long pfn, struct page_vma_mapped_walk *pvmw)
 		return false;
 	return true;

mm/page_vma_mapped.c static bool check_pmd(unsigned long pfn, struct page_vma_mapped_walk *pvmw) · line 157

Quoted 10 lines
mm/page_vma_mapped.c +6 -0
 }
+#else
+static bool check_pmd(unsigned long pfn, struct page_vma_mapped_walk *pvmw)
+{
+	return false;
+}
+#endif
 
 static void step_forward(struct page_vma_mapped_walk *pvmw, unsigned long size)
 {

lgtm, thanks.

You provoked Sashiko into talking about memory corruption and kernel panics in page_vma_mapped.c. Usual stuff.

	https://sashiko.dev/#/patchset/[email protected]

I'll cc likely suspects but boy do we need a way of being more organized about this.

author
#14 lore raw
Quoted 49 lines · Andrew Morton
Quoted 34 lines · On Wed, 24 Jun 2026 08:23:59 +0000 Wei Yang <[email protected]> wrote:

The kernel test robot reported a build failure on the parisc architecture when expanding HPAGE_PMD_NR in check_pmd().

   mm/page_vma_mapped.c:142:13: note: in expansion of macro 'HPAGE_PMD_NR'
     if ((pfn + HPAGE_PMD_NR - 1) < pvmw->pfn)
                ^~~~~~~~~~~~

The config [1] in report link shows neither TRANSPARENT_HUGEPAGE nor HUGETLB_PAGE is defined. Then trigger the BUILD_BUG.

Fix it by define check_pmd() under CONFIG_TRANSPARENT_HUGEPAGE.

[1]: https://download.01.org/0day-ci/archive/20260624/[email protected]/config

Fixes 2aff7a4755be ("mm: Convert page_vma_mapped_walk to work on PFNs")

...

mm/page_vma_mapped.c +1 -0
@@ -136,6 +136,7 @@ static bool check_pte(struct page_vma_mapped_walk *pvmw, unsigned long pte_nr)
 	return true;
 }
 
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
 /* Returns true if the two ranges overlap.  Careful to not overflow. */
 static bool check_pmd(unsigned long pfn, struct page_vma_mapped_walk *pvmw)
 {
@@ -145,6 +146,12 @@ static bool check_pmd(unsigned long pfn, struct page_vma_mapped_walk *pvmw)
 		return false;
 	return true;

mm/page_vma_mapped.c static bool check_pmd(unsigned long pfn, struct page_vma_mapped_walk *pvmw) · line 157

Quoted 10 lines
mm/page_vma_mapped.c +6 -0
 }
+#else
+static bool check_pmd(unsigned long pfn, struct page_vma_mapped_walk *pvmw)
+{
+	return false;
+}
+#endif
 
 static void step_forward(struct page_vma_mapped_walk *pvmw, unsigned long size)
 {

lgtm, thanks.

Quoted 5 lines

You provoked Sashiko into talking about memory corruption and kernel panics in page_vma_mapped.c. Usual stuff.

	https://sashiko.dev/#/patchset/[email protected]

Hi, Andrew

IIUC, the issue reported by Sashiko is fixed by

commit f84ca9b1888d ("mm/page_vma_mapped: fix device-private PMD handling")

Quoted 2 lines

I'll cc likely suspects but boy do we need a way of being more organized about this.

The build error fixed here is introduced by v3 [1], in which check_pmd() is invoked outside a conditional "if".

Then v4 [2] and v5 [3] call check_pmd() in a conditional "if" and at last David fix this with IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE).

Do you suggest still conditionally define check_pmd()? I may not follow your point.

Have a good day.

[1]: https://lore.kernel.org/all/[email protected]/
[2]: https://lore.kernel.org/all/[email protected]/T/#u
[3]: https://lore.kernel.org/linux-mm/[email protected]/

Signature · 2 lines
Wei Yang
Help you, Help me