linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Barry Song <21cnbao@gmail.com>
To: akpm@linux-foundation.org
Cc: 21cnbao@gmail.com, chrisl@kernel.org, linux-mm@kvack.org,
	lorenzo.stoakes@oracle.com, wale.zhang.ftd@gmail.com
Subject: Re: [PATCH 1/1] mm,swapops: Fix compile error on set_pmd_migration_entry.
Date: Mon, 29 Dec 2025 11:07:41 +1300	[thread overview]
Message-ID: <20251228220742.11157-1-21cnbao@gmail.com> (raw)
In-Reply-To: <20251228133742.a1f90fc552d346c4c43aad8b@linux-foundation.org>

On Mon, Dec 29, 2025 at 10:37 AM Andrew Morton <akpm@linux-foundation.org> wrote:
>
> On Sat, 27 Dec 2025 17:58:40 +0800 wale zhang <wale.zhang.ftd@gmail.com> wrote:
>
> > > No. You still don’t understand my point. The BUILD_BUG means this
> > > code will never have a chance to be compiled under any possible
> > > kernel configuration. That makes it dead code. If there is any
> > > kernel .config in which it can be built, then we should fix it.
> > >
> > > This set_pmd_migration_entry() has no chance of ever being built.
> >
> > Hello Barry,
> >
>
> Please share the .config which was used to trigger this build error.
>
> (It is strange to have this should-never-be-compiled code.  Why not just
> delete it and let the compiler/linker report the error.)

Right. We should entirely drop it in mainline. If Wale does want an
O0 build, then the only call to set_pmd_migration_entry() that is not
under

#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION

is migrate_vma_collect_huge_pmd() in mm/migrate_device.c.

Then what we really need is as follows:

diff --git a/include/linux/swapops.h b/include/linux/swapops.h
index 8cfc966eae48..fdd4375d5d90 100644
--- a/include/linux/swapops.h
+++ b/include/linux/swapops.h
@@ -339,17 +339,6 @@ static inline pmd_t swp_entry_to_pmd(swp_entry_t entry)
 }
 
 #else  /* CONFIG_ARCH_ENABLE_THP_MIGRATION */
-static inline int set_pmd_migration_entry(struct page_vma_mapped_walk *pvmw,
-		struct page *page)
-{
-	BUILD_BUG();
-}
-
-static inline void remove_migration_pmd(struct page_vma_mapped_walk *pvmw,
-		struct page *new)
-{
-	BUILD_BUG();
-}
 
 static inline void pmd_migration_entry_wait(struct mm_struct *m, pmd_t *p) { }
 
diff --git a/mm/migrate_device.c b/mm/migrate_device.c
index 23379663b1e1..74d23c91626a 100644
--- a/mm/migrate_device.c
+++ b/mm/migrate_device.c
@@ -195,8 +195,9 @@ static int migrate_vma_collect_huge_pmd(pmd_t *pmdp, unsigned long start,
 		return migrate_vma_collect_skip(start, end, walk);
 	}
 
-	if (thp_migration_supported() &&
-		(migrate->flags & MIGRATE_VMA_SELECT_COMPOUND) &&
+
+#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION
+	if ((migrate->flags & MIGRATE_VMA_SELECT_COMPOUND) &&
 		(IS_ALIGNED(start, HPAGE_PMD_SIZE) &&
 		 IS_ALIGNED(end, HPAGE_PMD_SIZE))) {
 
@@ -226,6 +227,7 @@ static int migrate_vma_collect_huge_pmd(pmd_t *pmdp, unsigned long start,
 		spin_unlock(ptl);
 		return 0;
 	}
+#endif
 
 fallback:
 	spin_unlock(ptl);

Thanks
Barry



  reply	other threads:[~2025-12-28 22:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-25  9:40 Wale Zhang
2025-12-25 10:22 ` Barry Song
2025-12-26 11:45   ` wale zhang
2025-12-26 18:43     ` Barry Song
2025-12-27  7:51       ` wale zhang
2025-12-27  8:16         ` Barry Song
2025-12-27  9:58           ` wale zhang
2025-12-27 11:25             ` Barry Song
2025-12-28 21:37             ` Andrew Morton
2025-12-28 22:07               ` Barry Song [this message]
2025-12-29 11:37                 ` wale zhang
2025-12-30  5:00     ` Matthew Wilcox
2025-12-30  8:05       ` wale zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251228220742.11157-1-21cnbao@gmail.com \
    --to=21cnbao@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=chrisl@kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=wale.zhang.ftd@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox