Skip to contentSkip to conversation

Fix trivial build errors on -mm tree

PATCH In review SeongJae Park 4 participants 9 messages Feb 9, 2022 – Feb 11, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Fix trivial build errors on -mm tree

This patchset fixes a couple of build errors of latest -mm tree.

SeongJae Park (2):
mm/internal: Implement no-op mlock_page_drain() for !CONFIG_MMU mm/gup: Make migrate_device_page() fails always if
!CONFIG_DEVICE_PRIVATE

 mm/gup.c      | 9 +++++++++
 mm/internal.h | 1 +
 2 files changed, 10 insertions(+)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/2 mm/internal: Implement no-op mlock_page_drain() for !CONFIG_MMU

Commit 4b3b8bd6c8287 ("mm/munlock: mlock_page() munlock_page() batch by pagevec") in -mm tree[1] implements 'mlock_page_drain()' under CONFIG_MMU only, but the function is used by 'lru_add_drain_cpu()', which defined outside of CONFIG_MMU. As a result, below build error occurs.

/linux/mm/swap.c: In function 'lru_add_drain_cpu':
/linux/mm/swap.c:637:2: error: implicit declaration of function 'mlock_page_drain' [-Werror=implicit-function-declaration]
637 | mlock_page_drain(cpu);
| ^~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
/linux/scripts/Makefile.build:289: recipe for target 'mm/swap.o' failed

This commit fixes it by implementing no-op 'mlock_page_drain()' for !CONFIG_MMU case, similar to 'mlock_new_page()'.

[1] https://www.ozlabs.org/~akpm/mmotm/broken-out/mm-munlock-mlock_page-munlock_page-batch-by-pagevec.patch

---
 mm/internal.h | 1 +
 1 file changed, 1 insertion(+)
mm/internal.h +1 -0
index 0d240e876831..248224369b34 100644
@@ -508,6 +508,7 @@ static inline void mlock_vma_page(struct page *page,
 static inline void munlock_vma_page(struct page *page,
 			struct vm_area_struct *vma, bool compound) { }
 static inline void mlock_new_page(struct page *page) { }
+static inline void mlock_page_drain(int cpu) { }
 static inline void vunmap_range_noflush(unsigned long start, unsigned long end)
 {
 }
Signature · 1 line
2.17.1
#8 lore raw

PATCH 2/2 mm/gup: Make migrate_device_page() fails always if !CONFIG_DEVICE_PRIVATE

In reply to SeongJae Park

Commit 7059ac82be44 ("mm/gup.c: migrate device coherent pages when pinning instead of failing") in -mm tree[1] introduces 'migrate_device_page()', which uses several functions that defined under CONFIG_DEVICE_RIVATE. As a result, build under 'CONFIG_MIGRATION && !CONFIG_DEVICE_PRIVATE' fails as below.

LD .tmp_vmlinux.kallsyms1
mm/gup.o: In function `migrate_device_page':
/linux/mm/gup.c:1856: undefined reference to migrate_vma_setup' /linux/mm/gup.c:1876: undefined reference to migrate_vma_pages' /linux/mm/gup.c:1879: undefined reference to `migrate_vma_finalize' /linux/Makefile:1222: recipe for target 'vmlinux' failed make[1]: *** [vmlinux] Error 1

This commit fixes it by implementing an always-failing version of the function for !CONFIG_DEVICE_PRIVATE'.

[1] https://www.ozlabs.org/~akpm/mmotm/broken-out/mm-gupc-migrate-device-coherent-pages-when-pinning-instead-of-failing.patch

---
 mm/gup.c | 9 +++++++++
 1 file changed, 9 insertions(+)
mm/gup.c +9 -0
index 1df99a5e90cf..0cf59858114d 100644
@@ -1834,6 +1834,7 @@ struct page *get_dump_page(unsigned long addr)
 #endif /* CONFIG_ELF_CORE */
 
 #ifdef CONFIG_MIGRATION
+#ifdef CONFIG_DEVICE_PRIVATE
 /*
  * Migrates a device coherent page back to normal memory. Caller should have a
  * reference on page which will be copied to the new page if migration is
@@ -1887,6 +1888,14 @@ static struct page *migrate_device_page(struct page *page,
 
 	return dpage;
 }
+#else
+static inline struct page *migrate_device_page(struct page *page,
+					unsigned int gup_flags)
+{
+	return NULL;
+}
+#endif /* CONFIG_DEVICE_PRIVATE */
+
 
 /*
  * Check whether all pages are pinnable, if so return number of pages.  If some
Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH for-mm 1/2] mm/internal: Implement no-op mlock_page_drain() for !CONFIG_MMU

In reply to SeongJae Park
Quoted 28 lines · SeongJae Park

Commit 4b3b8bd6c8287 ("mm/munlock: mlock_page() munlock_page() batch by pagevec") in -mm tree[1] implements 'mlock_page_drain()' under CONFIG_MMU only, but the function is used by 'lru_add_drain_cpu()', which defined outside of CONFIG_MMU. As a result, below build error occurs.

/linux/mm/swap.c: In function 'lru_add_drain_cpu':
/linux/mm/swap.c:637:2: error: implicit declaration of function 'mlock_page_drain' [-Werror=implicit-function-declaration]
637 | mlock_page_drain(cpu);
| ^~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
/linux/scripts/Makefile.build:289: recipe for target 'mm/swap.o' failed

This commit fixes it by implementing no-op 'mlock_page_drain()' for !CONFIG_MMU case, similar to 'mlock_new_page()'.

[1] https://www.ozlabs.org/~akpm/mmotm/broken-out/mm-munlock-mlock_page-munlock_page-batch-by-pagevec.patch

---
 mm/internal.h | 1 +
 1 file changed, 1 insertion(+)
mm/internal.h +0 -0
index 0d240e876831..248224369b34 100644

mm/internal.h static inline void mlock_vma_page(struct page *page, · line 514

Quoted 7 lines
mm/internal.h +1 -0
@@ -508,6 +508,7 @@ static inline void mlock_vma_page(struct page *page,
 static inline void munlock_vma_page(struct page *page,
 			struct vm_area_struct *vma, bool compound) { }
 static inline void mlock_new_page(struct page *page) { }
+static inline void mlock_page_drain(int cpu) { }
 static inline void vunmap_range_noflush(unsigned long start, unsigned long end)
 {
 }

Thank you, SeongJae, and thank you Geert for reporting.

This patch is good as far as it goes, but Andrew, please don't add it right now: I need to think a bit more, and will send another (or Ack SeongJae's) later in the day.

The thing is, SeongJae's patch makes me wonder, why did it not need a !CONFIG_MMU definition for need_mlock_page_drain() too? That's because mm/swap.c's call to it is under an #ifdef CONFIG_SMP, and I imagine that CONFIG_MMU=n usually goes along with (but does not necessarily imply?) CONFIG_SMP=n. It'll be safer to add a need_mlock_page_drain() stub too.

But more seriously, is the mlock_page_drain() going to be called when it's wanted, when CONFIG_SMP is not set? I had forgotten how mm/swap.c goes in different directions (for some things but not for others) according to CONFIG_SMP. I'll look into it and come back later.

Thanks,
Hugh

#3 lore raw

Re: [PATCH for-mm 1/2] mm/internal: Implement no-op mlock_page_drain() for !CONFIG_MMU

Hi Hugh,

Quoted 5 lines · Hugh Dickins

The thing is, SeongJae's patch makes me wonder, why did it not need a !CONFIG_MMU definition for need_mlock_page_drain() too? That's because mm/swap.c's call to it is under an #ifdef CONFIG_SMP, and I imagine that CONFIG_MMU=n usually goes along with (but does not necessarily imply?) CONFIG_SMP=n. It'll be safer to add a need_mlock_page_drain() stub too.

RISC-V K210 is SMP without MMU.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#4 lore raw

Re: [PATCH for-mm 1/2] mm/internal: Implement no-op mlock_page_drain() for !CONFIG_MMU

Quoted 8 lines · Geert Uytterhoeven
Quoted 5 lines · Hugh Dickins

The thing is, SeongJae's patch makes me wonder, why did it not need a !CONFIG_MMU definition for need_mlock_page_drain() too? That's because mm/swap.c's call to it is under an #ifdef CONFIG_SMP, and I imagine that CONFIG_MMU=n usually goes along with (but does not necessarily imply?) CONFIG_SMP=n. It'll be safer to add a need_mlock_page_drain() stub too.

RISC-V K210 is SMP without MMU.

Thanks Geert, that makes it very clear that we also want the stub for need_mlock_page_drain(). I'll follow now with update of SeongJae's patch.

My fear of wider implications of not having CONFIG_SMP turned out to be a false alarm. The UP lru_add_drain_cpu() calls mlock_page_drain() just like the SMP one does: the difference between them is merely that the UP case doesn't need an efficient way for asking in advance whether drain on another cpu will be needed.

Hugh

#5 lore raw

PATCH v2 1/2 mm/internal: Implement no-op mlock_page_drain() for !CONFIG_MMU

In reply to Geert Uytterhoeven

From: SeongJae Park <[email protected]>

Commit 4b3b8bd6c8287 ("mm/munlock: mlock_page() munlock_page() batch by pagevec") in -mm tree[1] implements 'mlock_page_drain()' under CONFIG_MMU only, but the function is used by 'lru_add_drain_cpu()', which defined outside of CONFIG_MMU. As a result, below build error occurs.

/linux/mm/swap.c: In function 'lru_add_drain_cpu':
/linux/mm/swap.c:637:2: error: implicit declaration of function 'mlock_page_drain' [-Werror=implicit-function-declaration]
637 | mlock_page_drain(cpu);
| ^~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
/linux/scripts/Makefile.build:289: recipe for target 'mm/swap.o' failed

This commit fixes it by implementing no-op 'mlock_page_drain()' for !CONFIG_MMU case, similar to 'mlock_new_page()'.

[1] https://www.ozlabs.org/~akpm/mmotm/broken-out/mm-munlock-mlock_page-munlock_page-batch-by-pagevec.patch

[hughd: add need_mlock_page_drain() stub too]

---
Andrew, Stephen, please add as fix to mm-munlock-mlock_page-munlock_page-batch-by-pagevec.patch Thanks!

 mm/internal.h |    2 ++
 1 file changed, 2 insertions(+)
mm/internal.h +2 -0
@@ -508,6 +508,8 @@ static inline void mlock_vma_page(struct page *page,
 static inline void munlock_vma_page(struct page *page,
 			struct vm_area_struct *vma, bool compound) { }
 static inline void mlock_new_page(struct page *page) { }
+static inline bool need_mlock_page_drain(int cpu) { return false; }
+static inline void mlock_page_drain(int cpu) { }
 static inline void vunmap_range_noflush(unsigned long start, unsigned long end)
 {
 }
#6 lore raw

Re: [PATCH for-mm 1/2 v2] mm/internal: Implement no-op mlock_page_drain() for !CONFIG_MMU

Quoted 20 lines · On Wed, 9 Feb 2022 20:44:02 -0800 (PST) Hugh Dickins <[email protected]> wrote:

From: SeongJae Park <[email protected]>

Commit 4b3b8bd6c8287 ("mm/munlock: mlock_page() munlock_page() batch by pagevec") in -mm tree[1] implements 'mlock_page_drain()' under CONFIG_MMU only, but the function is used by 'lru_add_drain_cpu()', which defined outside of CONFIG_MMU. As a result, below build error occurs.

/linux/mm/swap.c: In function 'lru_add_drain_cpu':
/linux/mm/swap.c:637:2: error: implicit declaration of function 'mlock_page_drain' [-Werror=implicit-function-declaration]
637 | mlock_page_drain(cpu);
| ^~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
/linux/scripts/Makefile.build:289: recipe for target 'mm/swap.o' failed

This commit fixes it by implementing no-op 'mlock_page_drain()' for !CONFIG_MMU case, similar to 'mlock_new_page()'.

[1] https://www.ozlabs.org/~akpm/mmotm/broken-out/mm-munlock-mlock_page-munlock_page-batch-by-pagevec.patch

Quoted 7 lines
[hughd: add need_mlock_page_drain() stub too]

---
Andrew, Stephen, please add as fix to mm-munlock-mlock_page-munlock_page-batch-by-pagevec.patch Thanks!

Thank you, Hugh!

Thanks,
SJ

Quoted 16 lines
 mm/internal.h |    2 ++
 1 file changed, 2 insertions(+)
mm/internal.h +2 -0
@@ -508,6 +508,8 @@ static inline void mlock_vma_page(struct page *page,
 static inline void munlock_vma_page(struct page *page,
 			struct vm_area_struct *vma, bool compound) { }
 static inline void mlock_new_page(struct page *page) { }
+static inline bool need_mlock_page_drain(int cpu) { return false; }
+static inline void mlock_page_drain(int cpu) { }
 static inline void vunmap_range_noflush(unsigned long start, unsigned long end)
 {
 }
#7 lore raw

Re: [PATCH for-mm 1/2 v2] mm/internal: Implement no-op mlock_page_drain() for !CONFIG_MMU

In reply to Hugh Dickins

Hi Hugh,

Quoted 35 lines · On Wed, 9 Feb 2022 20:44:02 -0800 (PST) Hugh Dickins <[email protected]> wrote:

From: SeongJae Park <[email protected]>

Commit 4b3b8bd6c8287 ("mm/munlock: mlock_page() munlock_page() batch by pagevec") in -mm tree[1] implements 'mlock_page_drain()' under CONFIG_MMU only, but the function is used by 'lru_add_drain_cpu()', which defined outside of CONFIG_MMU. As a result, below build error occurs.

/linux/mm/swap.c: In function 'lru_add_drain_cpu':
/linux/mm/swap.c:637:2: error: implicit declaration of function 'mlock_page_drain' [-Werror=implicit-function-declaration]
637 | mlock_page_drain(cpu);
| ^~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
/linux/scripts/Makefile.build:289: recipe for target 'mm/swap.o' failed

This commit fixes it by implementing no-op 'mlock_page_drain()' for !CONFIG_MMU case, similar to 'mlock_new_page()'.

[1] https://www.ozlabs.org/~akpm/mmotm/broken-out/mm-munlock-mlock_page-munlock_page-batch-by-pagevec.patch

[hughd: add need_mlock_page_drain() stub too]

---
Andrew, Stephen, please add as fix to mm-munlock-mlock_page-munlock_page-batch-by-pagevec.patch Thanks!

 mm/internal.h |    2 ++
 1 file changed, 2 insertions(+)

mm/internal.h static inline void mlock_vma_page(struct page *page, · line 515

Quoted 8 lines
mm/internal.h +2 -0
@@ -508,6 +508,8 @@ static inline void mlock_vma_page(struct page *page,
 static inline void munlock_vma_page(struct page *page,
 			struct vm_area_struct *vma, bool compound) { }
 static inline void mlock_new_page(struct page *page) { }
+static inline bool need_mlock_page_drain(int cpu) { return false; }
+static inline void mlock_page_drain(int cpu) { }
 static inline void vunmap_range_noflush(unsigned long start, unsigned long end)
 {
 }

Added to linux-next from today.

Signature · 2 lines
Cheers,
Stephen Rothwell