2022-02-09 13:11:30

by SeongJae Park

[permalink] [raw]
Subject: [PATCH for-mm 0/2] 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(+)

--
2.17.1



2022-02-09 13:11:49

by SeongJae Park

[permalink] [raw]
Subject: [PATCH for-mm 2/2] mm/gup: Make migrate_device_page() fails always if !CONFIG_DEVICE_PRIVATE

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

Signed-off-by: SeongJae Park <[email protected]>
---
mm/gup.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/mm/gup.c b/mm/gup.c
index 1df99a5e90cf..0cf59858114d 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -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
--
2.17.1


2022-02-09 13:58:34

by SeongJae Park

[permalink] [raw]
Subject: [PATCH for-mm 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

Signed-off-by: SeongJae Park <[email protected]>
---
mm/internal.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/mm/internal.h b/mm/internal.h
index 0d240e876831..248224369b34 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -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)
{
}
--
2.17.1


2022-02-09 16:32:43

by Geert Uytterhoeven

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

Hi Hugh,

On Wed, Feb 9, 2022 at 4:38 PM Hugh Dickins <[email protected]> wrote:
> 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

2022-02-09 19:12:40

by Hugh Dickins

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

On Wed, 9 Feb 2022, SeongJae Park wrote:
> 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
>
> Signed-off-by: SeongJae Park <[email protected]>
> ---
> mm/internal.h | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/mm/internal.h b/mm/internal.h
> index 0d240e876831..248224369b34 100644
> --- a/mm/internal.h
> +++ b/mm/internal.h
> @@ -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

2022-02-10 06:13:26

by Hugh Dickins

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

On Wed, 9 Feb 2022, Geert Uytterhoeven wrote:
> On Wed, Feb 9, 2022 at 4:38 PM Hugh Dickins <[email protected]> wrote:
> > 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

2022-02-10 06:22:58

by Hugh Dickins

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

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]
Signed-off-by: SeongJae Park <[email protected]>
Signed-off-by: Hugh Dickins <[email protected]>
---
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(+)

--- a/mm/internal.h
+++ b/mm/internal.h
@@ -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)
{
}

2022-02-10 20:10:22

by SeongJae Park

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

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]
> Signed-off-by: SeongJae Park <[email protected]>
> Signed-off-by: Hugh Dickins <[email protected]>
> ---
> Andrew, Stephen, please add as fix to
> mm-munlock-mlock_page-munlock_page-batch-by-pagevec.patch
> Thanks!

Thank you, Hugh!


Thanks,
SJ

>
> mm/internal.h | 2 ++
> 1 file changed, 2 insertions(+)
>
> --- a/mm/internal.h
> +++ b/mm/internal.h
> @@ -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)
> {
> }
>

2022-02-11 06:05:38

by Stephen Rothwell

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

Hi Hugh,

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]
> Signed-off-by: SeongJae Park <[email protected]>
> Signed-off-by: Hugh Dickins <[email protected]>
> ---
> 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(+)
>
> --- a/mm/internal.h
> +++ b/mm/internal.h
> @@ -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.

--
Cheers,
Stephen Rothwell


Attachments:
(No filename) (499.00 B)
OpenPGP digital signature