2020-02-27 04:13:21

by Stephen Rothwell

[permalink] [raw]
Subject: linux-next: build failure after merge of the akpm tree

Hi all,

After merging the akpm tree, today's linux-next build (sparc defconfig)
failed like this:

In file included from include/linux/list.h:9:0,
from include/linux/smp.h:12,
from include/linux/kernel_stat.h:5,
from mm/memory.c:42:
mm/memory.c: In function 'insert_pages':
mm/memory.c:1523:41: error: implicit declaration of function 'pte_index'; did you mean 'page_index'? [-Werror=implicit-function-declaration]
remaining_pages_total, PTRS_PER_PTE - pte_index(addr));
^
include/linux/kernel.h:842:40: note: in definition of macro '__typecheck'
(!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
^
include/linux/kernel.h:866:24: note: in expansion of macro '__safe_cmp'
__builtin_choose_expr(__safe_cmp(x, y), \
^~~~~~~~~~
include/linux/kernel.h:934:27: note: in expansion of macro '__careful_cmp'
#define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <)
^~~~~~~~~~~~~
mm/memory.c:1522:26: note: in expansion of macro 'min_t'
pages_to_write_in_pmd = min_t(unsigned long,
^~~~~

Caused by patch

"mm/memory.c: add vm_insert_pages()"

sparc32 does not implement pte_index at all :-(

I have added the following patch for today. This may not be correct
or enough.

From: Stephen Rothwell <[email protected]>
Date: Thu, 27 Feb 2020 14:57:49 +1100
Subject: [PATCH] arch/sparc: add a definition of pte_index for the 32 bit kernel

This is now needed for vm_insert_pages()

Signed-off-by: Stephen Rothwell <[email protected]>
---
arch/sparc/include/asm/pgtable_32.h | 2 ++
1 file changed, 2 insertions(+)

diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
index 6d6f44c0cad9..dc7a4d69cb18 100644
--- a/arch/sparc/include/asm/pgtable_32.h
+++ b/arch/sparc/include/asm/pgtable_32.h
@@ -326,6 +326,8 @@ static inline pmd_t *pmd_offset(pud_t * dir, unsigned long address)
}

/* Find an entry in the third-level page table.. */
+#define pte_index(address) \
+ ((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
pte_t *pte_offset_kernel(pmd_t * dir, unsigned long address);

/*
--
2.25.0

--
Cheers,
Stephen Rothwell


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

2020-02-27 05:21:03

by Arjun Roy

[permalink] [raw]
Subject: Re: linux-next: build failure after merge of the akpm tree

On Wed, Feb 26, 2020 at 8:11 PM Stephen Rothwell <[email protected]> wrote:
>
> Hi all,
>
> After merging the akpm tree, today's linux-next build (sparc defconfig)
> failed like this:
>
> In file included from include/linux/list.h:9:0,
> from include/linux/smp.h:12,
> from include/linux/kernel_stat.h:5,
> from mm/memory.c:42:
> mm/memory.c: In function 'insert_pages':
> mm/memory.c:1523:41: error: implicit declaration of function 'pte_index'; did you mean 'page_index'? [-Werror=implicit-function-declaration]
> remaining_pages_total, PTRS_PER_PTE - pte_index(addr));
> ^
> include/linux/kernel.h:842:40: note: in definition of macro '__typecheck'
> (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
> ^
> include/linux/kernel.h:866:24: note: in expansion of macro '__safe_cmp'
> __builtin_choose_expr(__safe_cmp(x, y), \
> ^~~~~~~~~~
> include/linux/kernel.h:934:27: note: in expansion of macro '__careful_cmp'
> #define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <)
> ^~~~~~~~~~~~~
> mm/memory.c:1522:26: note: in expansion of macro 'min_t'
> pages_to_write_in_pmd = min_t(unsigned long,
> ^~~~~
>
> Caused by patch
>
> "mm/memory.c: add vm_insert_pages()"
>
> sparc32 does not implement pte_index at all :-(
>
> I have added the following patch for today. This may not be correct
> or enough.
>

Thank you for the patch. I still do not have much/any knowledge about
sparc in Linux, so will have to defer to those who know more. :(

-Arjun

> From: Stephen Rothwell <[email protected]>
> Date: Thu, 27 Feb 2020 14:57:49 +1100
> Subject: [PATCH] arch/sparc: add a definition of pte_index for the 32 bit kernel
>
> This is now needed for vm_insert_pages()
>
> Signed-off-by: Stephen Rothwell <[email protected]>
> ---
> arch/sparc/include/asm/pgtable_32.h | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
> index 6d6f44c0cad9..dc7a4d69cb18 100644
> --- a/arch/sparc/include/asm/pgtable_32.h
> +++ b/arch/sparc/include/asm/pgtable_32.h
> @@ -326,6 +326,8 @@ static inline pmd_t *pmd_offset(pud_t * dir, unsigned long address)
> }
>
> /* Find an entry in the third-level page table.. */
> +#define pte_index(address) \
> + ((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
> pte_t *pte_offset_kernel(pmd_t * dir, unsigned long address);
>
> /*
> --
> 2.25.0
>
> --
> Cheers,
> Stephen Rothwell

2020-02-27 09:03:26

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: linux-next: build failure after merge of the akpm tree

Hi Stephen et al,

On Thu, Feb 27, 2020 at 5:12 AM Stephen Rothwell <[email protected]> wrote:
> After merging the akpm tree, today's linux-next build (sparc defconfig)
> failed like this:
>
> In file included from include/linux/list.h:9:0,
> from include/linux/smp.h:12,
> from include/linux/kernel_stat.h:5,
> from mm/memory.c:42:
> mm/memory.c: In function 'insert_pages':
> mm/memory.c:1523:41: error: implicit declaration of function 'pte_index'; did you mean 'page_index'? [-Werror=implicit-function-declaration]
> remaining_pages_total, PTRS_PER_PTE - pte_index(addr));
> ^
> include/linux/kernel.h:842:40: note: in definition of macro '__typecheck'
> (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
> ^
> include/linux/kernel.h:866:24: note: in expansion of macro '__safe_cmp'
> __builtin_choose_expr(__safe_cmp(x, y), \
> ^~~~~~~~~~
> include/linux/kernel.h:934:27: note: in expansion of macro '__careful_cmp'
> #define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <)
> ^~~~~~~~~~~~~
> mm/memory.c:1522:26: note: in expansion of macro 'min_t'
> pages_to_write_in_pmd = min_t(unsigned long,
> ^~~~~

Same issue on m68k, as per a report from kisskb.

> Caused by patch
>
> "mm/memory.c: add vm_insert_pages()"
>
> sparc32 does not implement pte_index at all :-(

Seems like about only half of the architectures do.

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

2020-02-27 17:15:37

by Arjun Roy

[permalink] [raw]
Subject: Re: linux-next: build failure after merge of the akpm tree

On Thu, Feb 27, 2020 at 1:03 AM Geert Uytterhoeven <[email protected]> wrote:
>
> Hi Stephen et al,
>
> On Thu, Feb 27, 2020 at 5:12 AM Stephen Rothwell <[email protected]> wrote:
> > After merging the akpm tree, today's linux-next build (sparc defconfig)
> > failed like this:
> >
> > In file included from include/linux/list.h:9:0,
> > from include/linux/smp.h:12,
> > from include/linux/kernel_stat.h:5,
> > from mm/memory.c:42:
> > mm/memory.c: In function 'insert_pages':
> > mm/memory.c:1523:41: error: implicit declaration of function 'pte_index'; did you mean 'page_index'? [-Werror=implicit-function-declaration]
> > remaining_pages_total, PTRS_PER_PTE - pte_index(addr));
> > ^
> > include/linux/kernel.h:842:40: note: in definition of macro '__typecheck'
> > (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
> > ^
> > include/linux/kernel.h:866:24: note: in expansion of macro '__safe_cmp'
> > __builtin_choose_expr(__safe_cmp(x, y), \
> > ^~~~~~~~~~
> > include/linux/kernel.h:934:27: note: in expansion of macro '__careful_cmp'
> > #define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <)
> > ^~~~~~~~~~~~~
> > mm/memory.c:1522:26: note: in expansion of macro 'min_t'
> > pages_to_write_in_pmd = min_t(unsigned long,
> > ^~~~~
>
> Same issue on m68k, as per a report from kisskb.
>
> > Caused by patch
> >
> > "mm/memory.c: add vm_insert_pages()"
> >
> > sparc32 does not implement pte_index at all :-(
>
> Seems like about only half of the architectures do.
>

:/ I begin to suspect the only sane way to make this work is to have a
per-arch header defined method, returning a bool saying whether
pte_index() is meaningful or not on that arch, and early on in
vm_insert_pages() if that bool returns true, to just call
vm_insert_page() in a loop.

-Arjun

> 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

2020-02-27 17:45:58

by Arjun Roy

[permalink] [raw]
Subject: Re: linux-next: build failure after merge of the akpm tree

On Thu, Feb 27, 2020 at 9:13 AM Arjun Roy <[email protected]> wrote:
>
> On Thu, Feb 27, 2020 at 1:03 AM Geert Uytterhoeven <[email protected]> wrote:
> >
> > Hi Stephen et al,
> >
> > On Thu, Feb 27, 2020 at 5:12 AM Stephen Rothwell <[email protected]> wrote:
> > > After merging the akpm tree, today's linux-next build (sparc defconfig)
> > > failed like this:
> > >
> > > In file included from include/linux/list.h:9:0,
> > > from include/linux/smp.h:12,
> > > from include/linux/kernel_stat.h:5,
> > > from mm/memory.c:42:
> > > mm/memory.c: In function 'insert_pages':
> > > mm/memory.c:1523:41: error: implicit declaration of function 'pte_index'; did you mean 'page_index'? [-Werror=implicit-function-declaration]
> > > remaining_pages_total, PTRS_PER_PTE - pte_index(addr));
> > > ^
> > > include/linux/kernel.h:842:40: note: in definition of macro '__typecheck'
> > > (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
> > > ^
> > > include/linux/kernel.h:866:24: note: in expansion of macro '__safe_cmp'
> > > __builtin_choose_expr(__safe_cmp(x, y), \
> > > ^~~~~~~~~~
> > > include/linux/kernel.h:934:27: note: in expansion of macro '__careful_cmp'
> > > #define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <)
> > > ^~~~~~~~~~~~~
> > > mm/memory.c:1522:26: note: in expansion of macro 'min_t'
> > > pages_to_write_in_pmd = min_t(unsigned long,
> > > ^~~~~
> >
> > Same issue on m68k, as per a report from kisskb.
> >
> > > Caused by patch
> > >
> > > "mm/memory.c: add vm_insert_pages()"
> > >
> > > sparc32 does not implement pte_index at all :-(
> >
> > Seems like about only half of the architectures do.
> >
>
> :/ I begin to suspect the only sane way to make this work is to have a
> per-arch header defined method, returning a bool saying whether
> pte_index() is meaningful or not on that arch, and early on in
> vm_insert_pages() if that bool returns true, to just call
> vm_insert_page() in a loop.
>

So, here is what I propose: something like the following macro in a
per-arch header:

#define PTE_INDEX_DEFINED 1 // or 0 if it is not

In mm/memory.c, another macro:

#ifndef PTE_INDEX_DEFINED
#define PTE_INDEX_DEFINED 0
#endifndef

And inside vm_insert_pages:

int vm_insert_pages() {

#if PTE_INDEX_DEFINED

// The existing method

#else

for (i=0; i<n; ++i)
vm_insert_page(i)

#endif
}

That way:
1. No playing whack-a-mole with different architectures
2. Architecture that knows pte_index is meaningful works can define
this explicitly
3. Can remove the sparc patches modifying pte_index that Stephen and I
contributed.

If that sounds acceptable I can cook a patch.

Thanks,
-Arjun

> -Arjun
>
> > 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

2020-02-27 17:59:02

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: linux-next: build failure after merge of the akpm tree

Hi Arjun,

On Thu, Feb 27, 2020 at 6:45 PM Arjun Roy <[email protected]> wrote:
> On Thu, Feb 27, 2020 at 9:13 AM Arjun Roy <[email protected]> wrote:
> > On Thu, Feb 27, 2020 at 1:03 AM Geert Uytterhoeven <[email protected]> wrote:
> > > On Thu, Feb 27, 2020 at 5:12 AM Stephen Rothwell <[email protected]> wrote:
> > > > After merging the akpm tree, today's linux-next build (sparc defconfig)
> > > > failed like this:
> > > >
> > > > In file included from include/linux/list.h:9:0,
> > > > from include/linux/smp.h:12,
> > > > from include/linux/kernel_stat.h:5,
> > > > from mm/memory.c:42:
> > > > mm/memory.c: In function 'insert_pages':
> > > > mm/memory.c:1523:41: error: implicit declaration of function 'pte_index'; did you mean 'page_index'? [-Werror=implicit-function-declaration]
> > > > remaining_pages_total, PTRS_PER_PTE - pte_index(addr));
> > > > ^
> > > > include/linux/kernel.h:842:40: note: in definition of macro '__typecheck'
> > > > (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
> > > > ^
> > > > include/linux/kernel.h:866:24: note: in expansion of macro '__safe_cmp'
> > > > __builtin_choose_expr(__safe_cmp(x, y), \
> > > > ^~~~~~~~~~
> > > > include/linux/kernel.h:934:27: note: in expansion of macro '__careful_cmp'
> > > > #define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <)
> > > > ^~~~~~~~~~~~~
> > > > mm/memory.c:1522:26: note: in expansion of macro 'min_t'
> > > > pages_to_write_in_pmd = min_t(unsigned long,
> > > > ^~~~~
> > >
> > > Same issue on m68k, as per a report from kisskb.
> > >
> > > > Caused by patch
> > > >
> > > > "mm/memory.c: add vm_insert_pages()"
> > > >
> > > > sparc32 does not implement pte_index at all :-(
> > >
> > > Seems like about only half of the architectures do.
> > >
> >
> > :/ I begin to suspect the only sane way to make this work is to have a
> > per-arch header defined method, returning a bool saying whether
> > pte_index() is meaningful or not on that arch, and early on in
> > vm_insert_pages() if that bool returns true, to just call
> > vm_insert_page() in a loop.
> >
>
> So, here is what I propose: something like the following macro in a
> per-arch header:
>
> #define PTE_INDEX_DEFINED 1 // or 0 if it is not

pte_index is already a #define on architectures where it exists, so
you can just use that.

> In mm/memory.c, another macro:
>
> #ifndef PTE_INDEX_DEFINED
> #define PTE_INDEX_DEFINED 0
> #endifndef

No need for the above...

> And inside vm_insert_pages:
>
> int vm_insert_pages() {
>
> #if PTE_INDEX_DEFINED

... if you use "#ifdef" here.

>
> // The existing method
>
> #else
>
> for (i=0; i<n; ++i)
> vm_insert_page(i)
>
> #endif
> }
>
> That way:
> 1. No playing whack-a-mole with different architectures
> 2. Architecture that knows pte_index is meaningful works can define
> this explicitly
> 3. Can remove the sparc patches modifying pte_index that Stephen and I
> contributed.
>
> If that sounds acceptable I can cook a patch.

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

2020-02-27 18:52:54

by Arjun Roy

[permalink] [raw]
Subject: Re: linux-next: build failure after merge of the akpm tree

On Thu, Feb 27, 2020 at 9:57 AM Geert Uytterhoeven <[email protected]> wrote:
>
> Hi Arjun,
>
> On Thu, Feb 27, 2020 at 6:45 PM Arjun Roy <[email protected]> wrote:
> > On Thu, Feb 27, 2020 at 9:13 AM Arjun Roy <[email protected]> wrote:
> > > On Thu, Feb 27, 2020 at 1:03 AM Geert Uytterhoeven <[email protected]> wrote:
> > > > On Thu, Feb 27, 2020 at 5:12 AM Stephen Rothwell <[email protected]> wrote:
> > > > > After merging the akpm tree, today's linux-next build (sparc defconfig)
> > > > > failed like this:
> > > > >
> > > > > In file included from include/linux/list.h:9:0,
> > > > > from include/linux/smp.h:12,
> > > > > from include/linux/kernel_stat.h:5,
> > > > > from mm/memory.c:42:
> > > > > mm/memory.c: In function 'insert_pages':
> > > > > mm/memory.c:1523:41: error: implicit declaration of function 'pte_index'; did you mean 'page_index'? [-Werror=implicit-function-declaration]
> > > > > remaining_pages_total, PTRS_PER_PTE - pte_index(addr));
> > > > > ^
> > > > > include/linux/kernel.h:842:40: note: in definition of macro '__typecheck'
> > > > > (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
> > > > > ^
> > > > > include/linux/kernel.h:866:24: note: in expansion of macro '__safe_cmp'
> > > > > __builtin_choose_expr(__safe_cmp(x, y), \
> > > > > ^~~~~~~~~~
> > > > > include/linux/kernel.h:934:27: note: in expansion of macro '__careful_cmp'
> > > > > #define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <)
> > > > > ^~~~~~~~~~~~~
> > > > > mm/memory.c:1522:26: note: in expansion of macro 'min_t'
> > > > > pages_to_write_in_pmd = min_t(unsigned long,
> > > > > ^~~~~
> > > >
> > > > Same issue on m68k, as per a report from kisskb.
> > > >
> > > > > Caused by patch
> > > > >
> > > > > "mm/memory.c: add vm_insert_pages()"
> > > > >
> > > > > sparc32 does not implement pte_index at all :-(
> > > >
> > > > Seems like about only half of the architectures do.
> > > >
> > >
> > > :/ I begin to suspect the only sane way to make this work is to have a
> > > per-arch header defined method, returning a bool saying whether
> > > pte_index() is meaningful or not on that arch, and early on in
> > > vm_insert_pages() if that bool returns true, to just call
> > > vm_insert_page() in a loop.
> > >
> >
> > So, here is what I propose: something like the following macro in a
> > per-arch header:
> >
> > #define PTE_INDEX_DEFINED 1 // or 0 if it is not
>
> pte_index is already a #define on architectures where it exists, so
> you can just use that.
>
> > In mm/memory.c, another macro:
> >
> > #ifndef PTE_INDEX_DEFINED
> > #define PTE_INDEX_DEFINED 0
> > #endifndef
>
> No need for the above...
>
> > And inside vm_insert_pages:
> >
> > int vm_insert_pages() {
> >
> > #if PTE_INDEX_DEFINED
>
> ... if you use "#ifdef" here.
>

Sounds good, thanks. I'll cook up a patch and send it along.

-Arjun

> >
> > // The existing method
> >
> > #else
> >
> > for (i=0; i<n; ++i)
> > vm_insert_page(i)
> >
> > #endif
> > }
> >
> > That way:
> > 1. No playing whack-a-mole with different architectures
> > 2. Architecture that knows pte_index is meaningful works can define
> > this explicitly
> > 3. Can remove the sparc patches modifying pte_index that Stephen and I
> > contributed.
> >
> > If that sounds acceptable I can cook a patch.
>
> 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

2020-02-27 21:29:10

by Stephen Rothwell

[permalink] [raw]
Subject: Re: linux-next: build failure after merge of the akpm tree

Hi Arjun,

On Thu, 27 Feb 2020 10:50:51 -0800 Arjun Roy <[email protected]> wrote:
>
> On Thu, Feb 27, 2020 at 9:57 AM Geert Uytterhoeven <[email protected]> wrote:
>
> Sounds good, thanks. I'll cook up a patch and send it along.

You will need to keep the sparc64 patch to correct pte_index in this case.

--
Cheers,
Stephen Rothwell


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

2020-02-27 21:29:14

by Stephen Rothwell

[permalink] [raw]
Subject: Re: linux-next: build failure after merge of the akpm tree

Hi Geert,

On Thu, 27 Feb 2020 18:57:26 +0100 Geert Uytterhoeven <[email protected]> wrote:
>
> pte_index is already a #define on architectures where it exists, so
> you can just use that.

Except for x86 which has a static inline function and so will require
#define pte_index pte_index added in arch/x86/include/asm/pgtable.h.

--
Cheers,
Stephen Rothwell


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

2020-02-28 00:35:28

by Arjun Roy

[permalink] [raw]
Subject: Re: linux-next: build failure after merge of the akpm tree

On Thu, Feb 27, 2020 at 1:28 PM Stephen Rothwell <[email protected]> wrote:
>
> Hi Arjun,
>
> On Thu, 27 Feb 2020 10:50:51 -0800 Arjun Roy <[email protected]> wrote:
> >
> > On Thu, Feb 27, 2020 at 9:57 AM Geert Uytterhoeven <[email protected]> wrote:
> >
> > Sounds good, thanks. I'll cook up a patch and send it along.
>
> You will need to keep the sparc64 patch to correct pte_index in this case.
>
Agreed on sparc64; I think the sparc32 patch ought to be reverted,
though (since pte_index may be meaningless to it).

Thanks,
-Arjun

> --
> Cheers,
> Stephen Rothwell

2020-02-28 00:59:49

by Stephen Rothwell

[permalink] [raw]
Subject: Re: linux-next: build failure after merge of the akpm tree

Hi Arjun,

On Thu, 27 Feb 2020 16:34:48 -0800 Arjun Roy <[email protected]> wrote:
>
> Agreed on sparc64; I think the sparc32 patch ought to be reverted,
> though (since pte_index may be meaningless to it).

Agreed.

I will replace the sparc32 patch with your new ones in today's
linux-next.

--
Cheers,
Stephen Rothwell


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