All of lore.kernel.org
 help / color / mirror / Atom feed
* [peterz-queue:locking/core 8/13] include/linux/compiler.h:315:38: error: call to '__compiletime_assert_323' declared with attribute error: Unsupported access size for {READ, WRITE}_ONCE().
@ 2020-01-24 18:01 kbuild test robot
  2020-01-24 23:44 ` Peter Zijlstra
  0 siblings, 1 reply; 17+ messages in thread
From: kbuild test robot @ 2020-01-24 18:01 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 5383 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git locking/core
head:   6a828d2acef57e23fe302603cde806e43965692d
commit: 1080f2a2a586e76f228cf6badf91b83670883a5f [8/13] READ_ONCE: Enforce atomicity for {READ,WRITE}_ONCE() memory accesses
config: m68k-multi_defconfig (attached as .config)
compiler: m68k-linux-gcc (GCC) 7.5.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        git checkout 1080f2a2a586e76f228cf6badf91b83670883a5f
        # save the attached .config to linux build tree
        GCC_VERSION=7.5.0 make.cross ARCH=m68k 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from include/linux/kernel.h:11:0,
                    from mm/gup.c:2:
   mm/gup.c: In function 'follow_pmd_mask.isra.52':
>> include/linux/compiler.h:315:38: error: call to '__compiletime_assert_323' declared with attribute error: Unsupported access size for {READ,WRITE}_ONCE().
     _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
                                         ^
   include/linux/compiler.h:296:4: note: in definition of macro '__compiletime_assert'
       prefix ## suffix();    \
       ^~~~~~
   include/linux/compiler.h:315:2: note: in expansion of macro '_compiletime_assert'
     _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
     ^~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:328:2: note: in expansion of macro 'compiletime_assert'
     compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \
     ^~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:221:2: note: in expansion of macro 'compiletime_assert_rwonce_type'
     compiletime_assert_rwonce_type(x);    \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:225:22: note: in expansion of macro 'READ_ONCE_NOCHECK'
    #define READ_ONCE(x) READ_ONCE_NOCHECK(x)
                         ^~~~~~~~~~~~~~~~~
   mm/gup.c:323:11: note: in expansion of macro 'READ_ONCE'
     pmdval = READ_ONCE(*pmd);
              ^~~~~~~~~
   include/linux/compiler.h:315:38: error: call to '__compiletime_assert_348' declared with attribute error: Unsupported access size for {READ,WRITE}_ONCE().
     _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
                                         ^
   include/linux/compiler.h:296:4: note: in definition of macro '__compiletime_assert'
       prefix ## suffix();    \
       ^~~~~~
   include/linux/compiler.h:315:2: note: in expansion of macro '_compiletime_assert'
     _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
     ^~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:328:2: note: in expansion of macro 'compiletime_assert'
     compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \
     ^~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:221:2: note: in expansion of macro 'compiletime_assert_rwonce_type'
     compiletime_assert_rwonce_type(x);    \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:225:22: note: in expansion of macro 'READ_ONCE_NOCHECK'
    #define READ_ONCE(x) READ_ONCE_NOCHECK(x)
                         ^~~~~~~~~~~~~~~~~
   mm/gup.c:348:12: note: in expansion of macro 'READ_ONCE'
      pmdval = READ_ONCE(*pmd);
               ^~~~~~~~~

vim +/__compiletime_assert_323 +315 include/linux/compiler.h

9a8ab1c39970a4 Daniel Santos 2013-02-21  301  
9a8ab1c39970a4 Daniel Santos 2013-02-21  302  #define _compiletime_assert(condition, msg, prefix, suffix) \
9a8ab1c39970a4 Daniel Santos 2013-02-21  303  	__compiletime_assert(condition, msg, prefix, suffix)
9a8ab1c39970a4 Daniel Santos 2013-02-21  304  
9a8ab1c39970a4 Daniel Santos 2013-02-21  305  /**
9a8ab1c39970a4 Daniel Santos 2013-02-21  306   * compiletime_assert - break build and emit msg if condition is false
9a8ab1c39970a4 Daniel Santos 2013-02-21  307   * @condition: a compile-time constant condition to check
9a8ab1c39970a4 Daniel Santos 2013-02-21  308   * @msg:       a message to emit if condition is false
9a8ab1c39970a4 Daniel Santos 2013-02-21  309   *
9a8ab1c39970a4 Daniel Santos 2013-02-21  310   * In tradition of POSIX assert, this macro will break the build if the
9a8ab1c39970a4 Daniel Santos 2013-02-21  311   * supplied condition is *false*, emitting the supplied error message if the
9a8ab1c39970a4 Daniel Santos 2013-02-21  312   * compiler has support to do so.
9a8ab1c39970a4 Daniel Santos 2013-02-21  313   */
9a8ab1c39970a4 Daniel Santos 2013-02-21  314  #define compiletime_assert(condition, msg) \
9a8ab1c39970a4 Daniel Santos 2013-02-21 @315  	_compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
9a8ab1c39970a4 Daniel Santos 2013-02-21  316  

:::::: The code at line 315 was first introduced by commit
:::::: 9a8ab1c39970a4938a72d94e6fd13be88a797590 bug.h, compiler.h: introduce compiletime_assert & BUILD_BUG_ON_MSG

:::::: TO: Daniel Santos <daniel.santos@pobox.com>
:::::: CC: Linus Torvalds <torvalds@linux-foundation.org>

---
0-DAY kernel test infrastructure                 Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 16752 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [peterz-queue:locking/core 8/13] include/linux/compiler.h:315:38: error: call to '__compiletime_assert_323' declared with attribute error: Unsupported access size for {READ, WRITE}_ONCE().
  2020-01-24 18:01 [peterz-queue:locking/core 8/13] include/linux/compiler.h:315:38: error: call to '__compiletime_assert_323' declared with attribute error: Unsupported access size for {READ, WRITE}_ONCE() kbuild test robot
@ 2020-01-24 23:44 ` Peter Zijlstra
  2020-01-27 11:42   ` Will Deacon
  0 siblings, 1 reply; 17+ messages in thread
From: Peter Zijlstra @ 2020-01-24 23:44 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2536 bytes --]

On Sat, Jan 25, 2020 at 02:01:28AM +0800, kbuild test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git locking/core
> head:   6a828d2acef57e23fe302603cde806e43965692d
> commit: 1080f2a2a586e76f228cf6badf91b83670883a5f [8/13] READ_ONCE: Enforce atomicity for {READ,WRITE}_ONCE() memory accesses
> config: m68k-multi_defconfig (attached as .config)
> compiler: m68k-linux-gcc (GCC) 7.5.0
> reproduce:
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         git checkout 1080f2a2a586e76f228cf6badf91b83670883a5f
>         # save the attached .config to linux build tree
>         GCC_VERSION=7.5.0 make.cross ARCH=m68k 
> 
> If you fix the issue, kindly add following tag
> Reported-by: kbuild test robot <lkp@intel.com>
> 
> All errors (new ones prefixed by >>):
> 
>    In file included from include/linux/kernel.h:11:0,
>                     from mm/gup.c:2:
>    mm/gup.c: In function 'follow_pmd_mask.isra.52':
> >> include/linux/compiler.h:315:38: error: call to '__compiletime_assert_323' declared with attribute error: Unsupported access size for {READ,WRITE}_ONCE().
>      _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
>                                          ^
>    include/linux/compiler.h:296:4: note: in definition of macro '__compiletime_assert'
>        prefix ## suffix();    \
>        ^~~~~~
>    include/linux/compiler.h:315:2: note: in expansion of macro '_compiletime_assert'
>      _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
>      ^~~~~~~~~~~~~~~~~~~
>    include/linux/compiler.h:328:2: note: in expansion of macro 'compiletime_assert'
>      compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \
>      ^~~~~~~~~~~~~~~~~~
>    include/linux/compiler.h:221:2: note: in expansion of macro 'compiletime_assert_rwonce_type'
>      compiletime_assert_rwonce_type(x);    \
>      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>    include/linux/compiler.h:225:22: note: in expansion of macro 'READ_ONCE_NOCHECK'
>     #define READ_ONCE(x) READ_ONCE_NOCHECK(x)
>                          ^~~~~~~~~~~~~~~~~
>    mm/gup.c:323:11: note: in expansion of macro 'READ_ONCE'
>      pmdval = READ_ONCE(*pmd);
>               ^~~~~~~~~

Because m68k haz:

arch/m68k/include/asm/page.h:typedef struct { unsigned long pmd[16]; } pmd_t;

W.T.F.

I'll go think about that later, I need sleep.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [peterz-queue:locking/core 8/13] include/linux/compiler.h:315:38: error: call to '__compiletime_assert_323' declared with attribute error: Unsupported access size for {READ, WRITE}_ONCE().
  2020-01-24 23:44 ` Peter Zijlstra
@ 2020-01-27 11:42   ` Will Deacon
  2020-01-27 12:15     ` Will Deacon
  0 siblings, 1 reply; 17+ messages in thread
From: Will Deacon @ 2020-01-27 11:42 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 1523 bytes --]

[+Geert]

On Sat, Jan 25, 2020 at 12:44:39AM +0100, Peter Zijlstra wrote:
> On Sat, Jan 25, 2020 at 02:01:28AM +0800, kbuild test robot wrote:
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git locking/core

[...]

> >    mm/gup.c:323:11: note: in expansion of macro 'READ_ONCE'
> >      pmdval = READ_ONCE(*pmd);
> >               ^~~~~~~~~
> 
> Because m68k haz:
> 
> arch/m68k/include/asm/page.h:typedef struct { unsigned long pmd[16]; } pmd_t;
> 
> W.T.F.
> 
> I'll go think about that later, I need sleep.

As far as I can tell, the /core/ mm code only ever looks at the first entry
of the array, so it may be possible to do something like the diff below.
The pmd_alloc_one()/pmd_free() functions for m68k don't seem to rely on
pmd_t being statically sized, but I don't have a way to test this.

Will

--->8

diff --git a/arch/m68k/include/asm/page.h b/arch/m68k/include/asm/page.h
index 05e1e1e77a9a..be62ee2902f8 100644
--- a/arch/m68k/include/asm/page.h
+++ b/arch/m68k/include/asm/page.h
@@ -22,9 +22,9 @@
  * These are used to make use of C type-checking..
  */
 #if !defined(CONFIG_MMU) || CONFIG_PGTABLE_LEVELS == 3
-typedef struct { unsigned long pmd[16]; } pmd_t;
-#define pmd_val(x)	((&x)->pmd[0])
-#define __pmd(x)	((pmd_t) { { (x) }, })
+typedef union { unsigned long val; unsigned long pmd[0]; } pmd_t;
+#define pmd_val(x)	((&x)->val)
+#define __pmd(x)	((pmd_t) { .val = (x), })
 #endif
 
 typedef struct { unsigned long pte; } pte_t;

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [peterz-queue:locking/core 8/13] include/linux/compiler.h:315:38: error: call to '__compiletime_assert_323' declared with attribute error: Unsupported access size for {READ, WRITE}_ONCE().
  2020-01-27 11:42   ` Will Deacon
@ 2020-01-27 12:15     ` Will Deacon
  2020-01-27 12:29       ` Peter Zijlstra
  0 siblings, 1 reply; 17+ messages in thread
From: Will Deacon @ 2020-01-27 12:15 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 1086 bytes --]

On Mon, Jan 27, 2020 at 11:42:25AM +0000, Will Deacon wrote:
> [+Geert]
> 
> On Sat, Jan 25, 2020 at 12:44:39AM +0100, Peter Zijlstra wrote:
> > On Sat, Jan 25, 2020 at 02:01:28AM +0800, kbuild test robot wrote:
> > > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git locking/core
> 
> [...]
> 
> > >    mm/gup.c:323:11: note: in expansion of macro 'READ_ONCE'
> > >      pmdval = READ_ONCE(*pmd);
> > >               ^~~~~~~~~
> > 
> > Because m68k haz:
> > 
> > arch/m68k/include/asm/page.h:typedef struct { unsigned long pmd[16]; } pmd_t;
> > 
> > W.T.F.
> > 
> > I'll go think about that later, I need sleep.
> 
> As far as I can tell, the /core/ mm code only ever looks at the first entry
> of the array, so it may be possible to do something like the diff below.
> The pmd_alloc_one()/pmd_free() functions for m68k don't seem to rely on
> pmd_t being statically sized, but I don't have a way to test this.

D'oh, just spotted:

  #define PTABLE_SIZE (PTRS_PER_PMD * sizeof(pmd_t))

So that would need adjusting as well.

Will

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [peterz-queue:locking/core 8/13] include/linux/compiler.h:315:38: error: call to '__compiletime_assert_323' declared with attribute error: Unsupported access size for {READ, WRITE}_ONCE().
  2020-01-27 12:15     ` Will Deacon
@ 2020-01-27 12:29       ` Peter Zijlstra
  2020-01-27 12:53         ` Will Deacon
  0 siblings, 1 reply; 17+ messages in thread
From: Peter Zijlstra @ 2020-01-27 12:29 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 1487 bytes --]

On Mon, Jan 27, 2020 at 12:15:44PM +0000, Will Deacon wrote:
> On Mon, Jan 27, 2020 at 11:42:25AM +0000, Will Deacon wrote:
> > [+Geert]
> > 
> > On Sat, Jan 25, 2020 at 12:44:39AM +0100, Peter Zijlstra wrote:
> > > On Sat, Jan 25, 2020 at 02:01:28AM +0800, kbuild test robot wrote:
> > > > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git locking/core
> > 
> > [...]
> > 
> > > >    mm/gup.c:323:11: note: in expansion of macro 'READ_ONCE'
> > > >      pmdval = READ_ONCE(*pmd);
> > > >               ^~~~~~~~~
> > > 
> > > Because m68k haz:
> > > 
> > > arch/m68k/include/asm/page.h:typedef struct { unsigned long pmd[16]; } pmd_t;
> > > 
> > > W.T.F.
> > > 
> > > I'll go think about that later, I need sleep.
> > 
> > As far as I can tell, the /core/ mm code only ever looks at the first entry
> > of the array, so it may be possible to do something like the diff below.
> > The pmd_alloc_one()/pmd_free() functions for m68k don't seem to rely on
> > pmd_t being statically sized, but I don't have a way to test this.
> 
> D'oh, just spotted:
> 
>   #define PTABLE_SIZE (PTRS_PER_PMD * sizeof(pmd_t))
> 
> So that would need adjusting as well.

And...

include/linux/mm.h:     atomic_long_add(PTRS_PER_PMD * sizeof(pmd_t), &mm->pgtables_bytes);
include/linux/mm.h:     atomic_long_sub(PTRS_PER_PMD * sizeof(pmd_t), &mm->pgtables_bytes);
include/linux/mm.h:     unsigned long mask = ~(PTRS_PER_PMD * sizeof(pmd_t) - 1);


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [peterz-queue:locking/core 8/13] include/linux/compiler.h:315:38: error: call to '__compiletime_assert_323' declared with attribute error: Unsupported access size for {READ, WRITE}_ONCE().
  2020-01-27 12:29       ` Peter Zijlstra
@ 2020-01-27 12:53         ` Will Deacon
  2020-01-27 13:07           ` Peter Zijlstra
  0 siblings, 1 reply; 17+ messages in thread
From: Will Deacon @ 2020-01-27 12:53 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 1967 bytes --]

On Mon, Jan 27, 2020 at 01:29:02PM +0100, Peter Zijlstra wrote:
> On Mon, Jan 27, 2020 at 12:15:44PM +0000, Will Deacon wrote:
> > On Mon, Jan 27, 2020 at 11:42:25AM +0000, Will Deacon wrote:
> > > [+Geert]
> > > 
> > > On Sat, Jan 25, 2020 at 12:44:39AM +0100, Peter Zijlstra wrote:
> > > > On Sat, Jan 25, 2020 at 02:01:28AM +0800, kbuild test robot wrote:
> > > > > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git locking/core
> > > 
> > > [...]
> > > 
> > > > >    mm/gup.c:323:11: note: in expansion of macro 'READ_ONCE'
> > > > >      pmdval = READ_ONCE(*pmd);
> > > > >               ^~~~~~~~~
> > > > 
> > > > Because m68k haz:
> > > > 
> > > > arch/m68k/include/asm/page.h:typedef struct { unsigned long pmd[16]; } pmd_t;
> > > > 
> > > > W.T.F.
> > > > 
> > > > I'll go think about that later, I need sleep.
> > > 
> > > As far as I can tell, the /core/ mm code only ever looks at the first entry
> > > of the array, so it may be possible to do something like the diff below.
> > > The pmd_alloc_one()/pmd_free() functions for m68k don't seem to rely on
> > > pmd_t being statically sized, but I don't have a way to test this.
> > 
> > D'oh, just spotted:
> > 
> >   #define PTABLE_SIZE (PTRS_PER_PMD * sizeof(pmd_t))
> > 
> > So that would need adjusting as well.
> 
> And...
> 
> include/linux/mm.h:     atomic_long_add(PTRS_PER_PMD * sizeof(pmd_t), &mm->pgtables_bytes);
> include/linux/mm.h:     atomic_long_sub(PTRS_PER_PMD * sizeof(pmd_t), &mm->pgtables_bytes);

I suppose this may end up cancelling each other out, so I doubt it's
catastophic, but still agree that we should fix it...

> include/linux/mm.h:     unsigned long mask = ~(PTRS_PER_PMD * sizeof(pmd_t) - 1);

... this one doesn't get compiled for m68k.

Geert -- what stops us from bumping PTRS_PER_PMD from 8 to 128 when PMDs
are not being folded, and getting rid of the array member in 'pmd_t'
completely?

Will

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [peterz-queue:locking/core 8/13] include/linux/compiler.h:315:38: error: call to '__compiletime_assert_323' declared with attribute error: Unsupported access size for {READ, WRITE}_ONCE().
  2020-01-27 12:53         ` Will Deacon
@ 2020-01-27 13:07           ` Peter Zijlstra
  2020-01-27 13:36             ` Geert Uytterhoeven
  0 siblings, 1 reply; 17+ messages in thread
From: Peter Zijlstra @ 2020-01-27 13:07 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 1111 bytes --]

On Mon, Jan 27, 2020 at 12:53:11PM +0000, Will Deacon wrote:
> On Mon, Jan 27, 2020 at 01:29:02PM +0100, Peter Zijlstra wrote:

> > And...
> > 
> > include/linux/mm.h:     atomic_long_add(PTRS_PER_PMD * sizeof(pmd_t), &mm->pgtables_bytes);
> > include/linux/mm.h:     atomic_long_sub(PTRS_PER_PMD * sizeof(pmd_t), &mm->pgtables_bytes);
> 
> I suppose this may end up cancelling each other out, so I doubt it's
> catastophic, but still agree that we should fix it...
> 
> > include/linux/mm.h:     unsigned long mask = ~(PTRS_PER_PMD * sizeof(pmd_t) - 1);
> 
> ... this one doesn't get compiled for m68k.

I suspected as much; but I figured that if i'd fix those first two, i'd
also have to fix this one for consistencies sake.

> Geert -- what stops us from bumping PTRS_PER_PMD from 8 to 128 when PMDs
> are not being folded, and getting rid of the array member in 'pmd_t'
> completely?

For now I've stuck in:

https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git/commit/?h=locking/core&id=1bf8a85e92254a4c6eb14dcea09d46da2066679b

let's see what the robots make of that.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [peterz-queue:locking/core 8/13] include/linux/compiler.h:315:38: error: call to '__compiletime_assert_323' declared with attribute error: Unsupported access size for {READ, WRITE}_ONCE().
  2020-01-27 13:07           ` Peter Zijlstra
@ 2020-01-27 13:36             ` Geert Uytterhoeven
  2020-01-27 14:43               ` Will Deacon
                                 ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Geert Uytterhoeven @ 2020-01-27 13:36 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 4418 bytes --]

Hi Peter, Will,

On Mon, Jan 27, 2020 at 2:07 PM Peter Zijlstra <peterz@infradead.org> wrote:
> On Mon, Jan 27, 2020 at 12:53:11PM +0000, Will Deacon wrote:
> > On Mon, Jan 27, 2020 at 01:29:02PM +0100, Peter Zijlstra wrote:
>
> > > And...
> > >
> > > include/linux/mm.h:     atomic_long_add(PTRS_PER_PMD * sizeof(pmd_t), &mm->pgtables_bytes);
> > > include/linux/mm.h:     atomic_long_sub(PTRS_PER_PMD * sizeof(pmd_t), &mm->pgtables_bytes);
> >
> > I suppose this may end up cancelling each other out, so I doubt it's
> > catastophic, but still agree that we should fix it...
> >
> > > include/linux/mm.h:     unsigned long mask = ~(PTRS_PER_PMD * sizeof(pmd_t) - 1);
> >
> > ... this one doesn't get compiled for m68k.
>
> I suspected as much; but I figured that if i'd fix those first two, i'd
> also have to fix this one for consistencies sake.
>
> > Geert -- what stops us from bumping PTRS_PER_PMD from 8 to 128 when PMDs
> > are not being folded, and getting rid of the array member in 'pmd_t'
> > completely?

TBH, I don't know...

>From a quick glance, it looks like '020/'030 may be the limiting factor.
I gave it a quick try (PTRS_PER_PMD from 8 to 128, changing the array
to a single entry, and fixing up the compile fallout), but it fails to boot
on ARAnyM (which BTW emulates an '040).

> For now I've stuck in:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git/commit/?h=locking/core&id=1bf8a85e92254a4c6eb14dcea09d46da2066679b
>
> let's see what the robots make of that.

They're not gonna like the stray "]" in

   +#define pmd_val(x) ((&x)->val])

;-)

With that fixed, it builds locally, build fails to boot in ARAnyM:

Unable to handle kernel access at virtual address (ptrval)
Oops: 00000000
Modules linked in:
PC: [<002f1a56>] memset+0x66/0x8c
SR: 2714  SP: (ptrval)  a2: 003db4fc
d0: 00000000    d1: 00000088    d2: 00000004    d3: 0000fffe
d4: 00000000    d5: 00000000    a0: 10ffff70    a1: 10ffff74
Process swapper (pid: 0, task=(ptrval))
Frame format=7 eff addr=11ffff70 ssw=0000 faddr=11ffff70
wb 1 stat/addr/data: 0000 00000000 00000000
wb 2 stat/addr/data: 0000 00000000 00000000
wb 3 stat/addr/data: 0000 11ffff70 00000000
push data: 00000000 00000000 00000000 00000000
Stack from 003d9ea0:
        10ffff70 00000088 00429d6e 10ffff70 00000000 00000088 00000088 00000000
        ffffffff 002f19f0 0042a4aa 00000088 00000010 00000000 00000000 00000000
        00000000 00000000 00000011 00000000 00000002 11000000 000a8c62 0040e754
        0042a47c 002f19f0 0042a670 00000000 00000000 ffffffff 00000011 11000439
        00001020 11000000 00000000 003f885c 003d9f8c 003d9f98 003d9f8c 00423f8c
        00000000 003d9f98 00000000 0000000c 003d9f8c 00000000 0000000c 00000008
Call Trace: [<00429d6e>] memblock_alloc_try_nid+0x70/0x82
 [<002f19f0>] memset+0x0/0x8c
 [<0042a4aa>] sparse_init_nid+0x2e/0x1a6
 [<000a8c62>] next_present_section_nr+0x0/0x2a
 [<0042a47c>] sparse_init_nid+0x0/0x1a6
 [<002f19f0>] memset+0x0/0x8c
 [<0042a670>] sparse_init+0x4e/0x90
 [<00001020>] kernel_pg_dir+0x20/0x1000
 [<00423f8c>] paging_init+0x414/0x452
 [<002ec07c>] strlcpy+0x0/0x4e
 [<00043a6c>] printk+0x0/0x18
 [<00424202>] atari_parse_bootinfo+0x0/0x2c
 [<00423570>] setup_arch+0x18e/0x23e
 [<00011000>] opc_1b+0x6/0xa
 [<004234ec>] setup_arch+0x10a/0x23e
 [<00043a6c>] printk+0x0/0x18
 [<00420ee2>] start_kernel+0x4a/0x40a
 [<00420344>] _sinittext+0x344/0x9e8
Code: 3212 22c0 22c0 22c0 22c0 22c0 22c0 22c0 <22c0> 51ca ffee 4242
5382 6ae6 0801 0001 6702 32c0 0801 0000 6702 1280 2008 241f
Disabling lock debugging due to kernel taint
Kernel panic - not syncing: Attempted to kill the idle task!
---[ end Kernel panic - not syncing: Attempted to kill the idle task! ]---

Interestingly, this crash looks very similar to the one I got after my small
experiment, although the code changes were completely different
(attached for reference, but won't apply for you, as I have some preliminary
 code from Mike Rapoport in my local tree).

Gr{oetje,eeting}s,

                        Geert


--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert(a)linux-m68k.org

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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: m68k-PTRS_PER_PMD-128.patch --]
[-- Type: text/x-patch, Size: 4524 bytes --]

diff --git a/arch/m68k/include/asm/motorola_pgtable.h b/arch/m68k/include/asm/motorola_pgtable.h
index 514dd5aefb05548a..b5532b7a23d47c7b 100644
--- a/arch/m68k/include/asm/motorola_pgtable.h
+++ b/arch/m68k/include/asm/motorola_pgtable.h
@@ -108,13 +108,7 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
 
 static inline void pmd_set(pmd_t *pmdp, pte_t *ptep)
 {
-	unsigned long ptbl = virt_to_phys(ptep) | _PAGE_TABLE | _PAGE_ACCESSED;
-	unsigned long *ptr = pmdp->pmd;
-	short i = 16;
-	while (--i >= 0) {
-		*ptr++ = ptbl;
-		ptbl += (sizeof(pte_t)*PTRS_PER_PTE/16);
-	}
+	pmdp->pmd = virt_to_phys(ptep) | _PAGE_TABLE | _PAGE_ACCESSED;
 }
 
 static inline void pud_set(pud_t *pudp, pmd_t *pmdp)
@@ -138,12 +132,7 @@ static inline void pud_set(pud_t *pudp, pmd_t *pmdp)
 #define pmd_none(pmd)		(!pmd_val(pmd))
 #define pmd_bad(pmd)		((pmd_val(pmd) & _DESCTYPE_MASK) != _PAGE_TABLE)
 #define pmd_present(pmd)	(pmd_val(pmd) & _PAGE_TABLE)
-#define pmd_clear(pmdp) ({			\
-	unsigned long *__ptr = pmdp->pmd;	\
-	short __i = 16;				\
-	while (--__i >= 0)			\
-		*__ptr++ = 0;			\
-})
+#define pmd_clear(pmdp) (pmdp->pmd = 0)
 #define pmd_page(pmd)		virt_to_page(__va(pmd_val(pmd)))
 
 
diff --git a/arch/m68k/include/asm/page.h b/arch/m68k/include/asm/page.h
index b76d9dbcb8427c45..7399f1a9280ffba0 100644
--- a/arch/m68k/include/asm/page.h
+++ b/arch/m68k/include/asm/page.h
@@ -22,8 +22,8 @@
  * These are used to make use of C type-checking..
  */
 #if !defined(CONFIG_MMU) || CONFIG_PGTABLE_LEVELS == 3
-typedef struct { unsigned long pmd[16]; } pmd_t;
-#define pmd_val(x)	((&x)->pmd[0])
+typedef struct { unsigned long pmd; } pmd_t;
+#define pmd_val(x)	((&x)->pmd)
 #define __pmd(x)	((pmd_t) { { (x) }, })
 #endif
 
diff --git a/arch/m68k/include/asm/pgtable_mm.h b/arch/m68k/include/asm/pgtable_mm.h
index 2bf5c3501e7870c9..0bb4a78450e56bc6 100644
--- a/arch/m68k/include/asm/pgtable_mm.h
+++ b/arch/m68k/include/asm/pgtable_mm.h
@@ -68,7 +68,7 @@
 #define PTRS_PER_PGD	1024
 #else
 #define PTRS_PER_PTE	1024
-#define PTRS_PER_PMD	8
+#define PTRS_PER_PMD	128
 #define PTRS_PER_PGD	128
 #endif
 #define USER_PTRS_PER_PGD	(TASK_SIZE/PGDIR_SIZE)
diff --git a/arch/m68k/mm/kmap.c b/arch/m68k/mm/kmap.c
index 5a96145f72910bde..96d4566c7b5cee01 100644
--- a/arch/m68k/mm/kmap.c
+++ b/arch/m68k/mm/kmap.c
@@ -79,11 +79,10 @@ static void __free_io_area(void *addr, unsigned long size)
 
 #if CONFIG_PGTABLE_LEVELS == 3
 		if (CPU_IS_020_OR_030) {
-			int pmd_off = (virtaddr/PTRTREESIZE) & 15;
-			int pmd_type = pmd_dir->pmd[pmd_off] & _DESCTYPE_MASK;
+			int pmd_type = pmd_dir->pmd & _DESCTYPE_MASK;
 
 			if (pmd_type == _PAGE_PRESENT) {
-				pmd_dir->pmd[pmd_off] = 0;
+				pmd_dir->pmd = 0;
 				virtaddr += PTRTREESIZE;
 				size -= PTRTREESIZE;
 				continue;
@@ -259,7 +258,7 @@ void __iomem *__ioremap(unsigned long physaddr, unsigned long size, int cachefla
 
 #if CONFIG_PGTABLE_LEVELS == 3
 		if (CPU_IS_020_OR_030) {
-			pmd_dir->pmd[(virtaddr/PTRTREESIZE) & 15] = physaddr;
+			pmd_dir->pmd = physaddr;
 			physaddr += PTRTREESIZE;
 			virtaddr += PTRTREESIZE;
 			size -= PTRTREESIZE;
@@ -364,11 +363,9 @@ void kernel_set_cachemode(void *addr, unsigned long size, int cmode)
 
 #if CONFIG_PGTABLE_LEVELS == 3
 		if (CPU_IS_020_OR_030) {
-			int pmd_off = (virtaddr/PTRTREESIZE) & 15;
-
-			if ((pmd_dir->pmd[pmd_off] & _DESCTYPE_MASK) == _PAGE_PRESENT) {
-				pmd_dir->pmd[pmd_off] = (pmd_dir->pmd[pmd_off] &
-							 _CACHEMASK040) | cmode;
+			if ((pmd_dir->pmd & _DESCTYPE_MASK) == _PAGE_PRESENT) {
+				pmd_dir->pmd = (pmd_dir->pmd & _CACHEMASK040) |
+					       cmode;
 				virtaddr += PTRTREESIZE;
 				size -= PTRTREESIZE;
 				continue;
diff --git a/arch/m68k/mm/motorola.c b/arch/m68k/mm/motorola.c
index 93825568ec174a2c..fe21a01da5a05d5d 100644
--- a/arch/m68k/mm/motorola.c
+++ b/arch/m68k/mm/motorola.c
@@ -165,7 +165,7 @@ static void __init map_node(int node)
 #ifdef DEBUG
 				pr_cont("[early term]");
 #endif
-				pmd_dir->pmd[(virtaddr/PTRTREESIZE) & 15] = physaddr;
+				pmd_dir->pmd = physaddr;
 				physaddr += PTRTREESIZE;
 			} else {
 				int i;
@@ -174,8 +174,8 @@ static void __init map_node(int node)
 #endif
 				zero_pgtable = kernel_ptr_table();
 				pte_dir = (pte_t *)zero_pgtable;
-				pmd_dir->pmd[0] = virt_to_phys(pte_dir) |
-					_PAGE_TABLE | _PAGE_ACCESSED;
+				pmd_dir->pmd = virt_to_phys(pte_dir) |
+					      _PAGE_TABLE | _PAGE_ACCESSED;
 				pte_val(*pte_dir++) = 0;
 				physaddr += PAGE_SIZE;
 				for (i = 1; i < 64; physaddr += PAGE_SIZE, i++)

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [peterz-queue:locking/core 8/13] include/linux/compiler.h:315:38: error: call to '__compiletime_assert_323' declared with attribute error: Unsupported access size for {READ, WRITE}_ONCE().
  2020-01-27 13:36             ` Geert Uytterhoeven
@ 2020-01-27 14:43               ` Will Deacon
  2020-01-27 14:56                 ` Geert Uytterhoeven
  2020-01-27 14:44               ` Peter Zijlstra
  2020-01-28  9:46               ` Peter Zijlstra
  2 siblings, 1 reply; 17+ messages in thread
From: Will Deacon @ 2020-01-27 14:43 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 1540 bytes --]

Hi Geert,

On Mon, Jan 27, 2020 at 02:36:37PM +0100, Geert Uytterhoeven wrote:
> On Mon, Jan 27, 2020 at 2:07 PM Peter Zijlstra <peterz@infradead.org> wrote:
> > On Mon, Jan 27, 2020 at 12:53:11PM +0000, Will Deacon wrote:
> > > On Mon, Jan 27, 2020 at 01:29:02PM +0100, Peter Zijlstra wrote:
> >
> > > > And...
> > > >
> > > > include/linux/mm.h:     atomic_long_add(PTRS_PER_PMD * sizeof(pmd_t), &mm->pgtables_bytes);
> > > > include/linux/mm.h:     atomic_long_sub(PTRS_PER_PMD * sizeof(pmd_t), &mm->pgtables_bytes);
> > >
> > > I suppose this may end up cancelling each other out, so I doubt it's
> > > catastophic, but still agree that we should fix it...
> > >
> > > > include/linux/mm.h:     unsigned long mask = ~(PTRS_PER_PMD * sizeof(pmd_t) - 1);
> > >
> > > ... this one doesn't get compiled for m68k.
> >
> > I suspected as much; but I figured that if i'd fix those first two, i'd
> > also have to fix this one for consistencies sake.
> >
> > > Geert -- what stops us from bumping PTRS_PER_PMD from 8 to 128 when PMDs
> > > are not being folded, and getting rid of the array member in 'pmd_t'
> > > completely?
> 
> TBH, I don't know...
> 
> From a quick glance, it looks like '020/'030 may be the limiting factor.
> I gave it a quick try (PTRS_PER_PMD from 8 to 128, changing the array
> to a single entry, and fixing up the compile fallout), but it fails to boot
> on ARAnyM (which BTW emulates an '040).

Hmm, looks like that's packaged in Debian too. How are you feeding it
kernels?

Will

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [peterz-queue:locking/core 8/13] include/linux/compiler.h:315:38: error: call to '__compiletime_assert_323' declared with attribute error: Unsupported access size for {READ, WRITE}_ONCE().
  2020-01-27 13:36             ` Geert Uytterhoeven
  2020-01-27 14:43               ` Will Deacon
@ 2020-01-27 14:44               ` Peter Zijlstra
  2020-01-27 16:10                 ` Peter Zijlstra
  2020-01-28  9:46               ` Peter Zijlstra
  2 siblings, 1 reply; 17+ messages in thread
From: Peter Zijlstra @ 2020-01-27 14:44 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 527 bytes --]

On Mon, Jan 27, 2020 at 02:36:37PM +0100, Geert Uytterhoeven wrote:
> On Mon, Jan 27, 2020 at 2:07 PM Peter Zijlstra <peterz@infradead.org> wrote:

> > For now I've stuck in:
> >
> > https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git/commit/?h=locking/core&id=1bf8a85e92254a4c6eb14dcea09d46da2066679b
> >
> > let's see what the robots make of that.
> 
> They're not gonna like the stray "]" in
> 
>    +#define pmd_val(x) ((&x)->val])
> 
> ;-)

Damn!, also at dying on boot. Let me go stare harder.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [peterz-queue:locking/core 8/13] include/linux/compiler.h:315:38: error: call to '__compiletime_assert_323' declared with attribute error: Unsupported access size for {READ, WRITE}_ONCE().
  2020-01-27 14:43               ` Will Deacon
@ 2020-01-27 14:56                 ` Geert Uytterhoeven
  0 siblings, 0 replies; 17+ messages in thread
From: Geert Uytterhoeven @ 2020-01-27 14:56 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2155 bytes --]

Hi Will,

On Mon, Jan 27, 2020 at 3:43 PM Will Deacon <will@kernel.org> wrote:
> On Mon, Jan 27, 2020 at 02:36:37PM +0100, Geert Uytterhoeven wrote:
> > On Mon, Jan 27, 2020 at 2:07 PM Peter Zijlstra <peterz@infradead.org> wrote:
> > > On Mon, Jan 27, 2020 at 12:53:11PM +0000, Will Deacon wrote:
> > > > On Mon, Jan 27, 2020 at 01:29:02PM +0100, Peter Zijlstra wrote:
> > >
> > > > > And...
> > > > >
> > > > > include/linux/mm.h:     atomic_long_add(PTRS_PER_PMD * sizeof(pmd_t), &mm->pgtables_bytes);
> > > > > include/linux/mm.h:     atomic_long_sub(PTRS_PER_PMD * sizeof(pmd_t), &mm->pgtables_bytes);
> > > >
> > > > I suppose this may end up cancelling each other out, so I doubt it's
> > > > catastophic, but still agree that we should fix it...
> > > >
> > > > > include/linux/mm.h:     unsigned long mask = ~(PTRS_PER_PMD * sizeof(pmd_t) - 1);
> > > >
> > > > ... this one doesn't get compiled for m68k.
> > >
> > > I suspected as much; but I figured that if i'd fix those first two, i'd
> > > also have to fix this one for consistencies sake.
> > >
> > > > Geert -- what stops us from bumping PTRS_PER_PMD from 8 to 128 when PMDs
> > > > are not being folded, and getting rid of the array member in 'pmd_t'
> > > > completely?
> >
> > TBH, I don't know...
> >
> > From a quick glance, it looks like '020/'030 may be the limiting factor.
> > I gave it a quick try (PTRS_PER_PMD from 8 to 128, changing the array
> > to a single entry, and fixing up the compile fallout), but it fails to boot
> > on ARAnyM (which BTW emulates an '040).
>
> Hmm, looks like that's packaged in Debian too. How are you feeding it
> kernels?

https://wiki.debian.org/Aranym

There's also https://wiki.debian.org/M68k/QemuSystemM68k
Emulates a Quadra 800, i.e. '040, too.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert(a)linux-m68k.org

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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [peterz-queue:locking/core 8/13] include/linux/compiler.h:315:38: error: call to '__compiletime_assert_323' declared with attribute error: Unsupported access size for {READ, WRITE}_ONCE().
  2020-01-27 14:44               ` Peter Zijlstra
@ 2020-01-27 16:10                 ` Peter Zijlstra
  2020-01-27 16:17                   ` Peter Zijlstra
  0 siblings, 1 reply; 17+ messages in thread
From: Peter Zijlstra @ 2020-01-27 16:10 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 861 bytes --]

On Mon, Jan 27, 2020 at 03:44:57PM +0100, Peter Zijlstra wrote:
> On Mon, Jan 27, 2020 at 02:36:37PM +0100, Geert Uytterhoeven wrote:
> > On Mon, Jan 27, 2020 at 2:07 PM Peter Zijlstra <peterz@infradead.org> wrote:
> 
> > > For now I've stuck in:
> > >
> > > https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git/commit/?h=locking/core&id=1bf8a85e92254a4c6eb14dcea09d46da2066679b
> > >
> > > let's see what the robots make of that.
> > 
> > They're not gonna like the stray "]" in
> > 
> >    +#define pmd_val(x) ((&x)->val])
> > 
> > ;-)
> 
> Damn!, also at dying on boot. Let me go stare harder.

The great news is that I have this aranym thing working; the good news
is that I found a bug in my patch, the bad news is that that all doesn't
seem to help and it still explodes pretty much the same on boot.

More staring ahead.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [peterz-queue:locking/core 8/13] include/linux/compiler.h:315:38: error: call to '__compiletime_assert_323' declared with attribute error: Unsupported access size for {READ, WRITE}_ONCE().
  2020-01-27 16:10                 ` Peter Zijlstra
@ 2020-01-27 16:17                   ` Peter Zijlstra
  0 siblings, 0 replies; 17+ messages in thread
From: Peter Zijlstra @ 2020-01-27 16:17 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 1088 bytes --]

On Mon, Jan 27, 2020 at 05:10:01PM +0100, Peter Zijlstra wrote:
> On Mon, Jan 27, 2020 at 03:44:57PM +0100, Peter Zijlstra wrote:
> > On Mon, Jan 27, 2020 at 02:36:37PM +0100, Geert Uytterhoeven wrote:
> > > On Mon, Jan 27, 2020 at 2:07 PM Peter Zijlstra <peterz@infradead.org> wrote:
> > 
> > > > For now I've stuck in:
> > > >
> > > > https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git/commit/?h=locking/core&id=1bf8a85e92254a4c6eb14dcea09d46da2066679b
> > > >
> > > > let's see what the robots make of that.
> > > 
> > > They're not gonna like the stray "]" in
> > > 
> > >    +#define pmd_val(x) ((&x)->val])
> > > 
> > > ;-)
> > 
> > Damn!, also at dying on boot. Let me go stare harder.
> 
> The great news is that I have this aranym thing working; the good news
> is that I found a bug in my patch, the bad news is that that all doesn't
> seem to help and it still explodes pretty much the same on boot.
> 
> More staring ahead.

ARGH, pmdptr += val makes implicit use of sizeof(pmd_t) and that is all
sorts of buggered with this approach!!!

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [peterz-queue:locking/core 8/13] include/linux/compiler.h:315:38: error: call to '__compiletime_assert_323' declared with attribute error: Unsupported access size for {READ, WRITE}_ONCE().
  2020-01-27 13:36             ` Geert Uytterhoeven
  2020-01-27 14:43               ` Will Deacon
  2020-01-27 14:44               ` Peter Zijlstra
@ 2020-01-28  9:46               ` Peter Zijlstra
  2020-01-28 10:05                 ` Peter Zijlstra
  2 siblings, 1 reply; 17+ messages in thread
From: Peter Zijlstra @ 2020-01-28  9:46 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 9299 bytes --]

On Mon, Jan 27, 2020 at 02:36:37PM +0100, Geert Uytterhoeven wrote:
> Interestingly, this crash looks very similar to the one I got after my small
> experiment, although the code changes were completely different
> (attached for reference, but won't apply for you, as I have some preliminary
>  code from Mike Rapoport in my local tree).

So after reading the m68k programming reference manual and various other
online sources, I went and did the same.

The below boots on ARAnyM/68040, but afaict 020/030 is (still) broken.
That is, AFAICT it is currently broken and I preserved that, see the XXX
in the patch.

Basically, 040 (and later) have a fixed 7,7,{5,6} page-table setup,
where the last depends on the page-size selected (8k vs 4k), and head.S
selects 4K pages. For 030 (and earlier) we explicitly program 7,7,6 and
4K pages in %tc.

The below implements a straight forward 7,7,6 3 level page-table setup,
with the addition (for 020/030) of (broken) huge-page support.

Is there some 020/030 enabled emulator that I can try?

---
 arch/m68k/include/asm/motorola_pgtable.h | 15 ++----------
 arch/m68k/include/asm/page.h             |  6 ++---
 arch/m68k/include/asm/pgtable_mm.h       | 10 ++++----
 arch/m68k/mm/kmap.c                      | 40 ++++++++++++++++----------------
 arch/m68k/mm/motorola.c                  | 28 +++++++++++-----------
 5 files changed, 43 insertions(+), 56 deletions(-)

diff --git a/arch/m68k/include/asm/motorola_pgtable.h b/arch/m68k/include/asm/motorola_pgtable.h
index 62bedc61f110..4d94e462bb2b 100644
--- a/arch/m68k/include/asm/motorola_pgtable.h
+++ b/arch/m68k/include/asm/motorola_pgtable.h
@@ -108,13 +108,7 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
 
 static inline void pmd_set(pmd_t *pmdp, pte_t *ptep)
 {
-	unsigned long ptbl = virt_to_phys(ptep) | _PAGE_TABLE | _PAGE_ACCESSED;
-	unsigned long *ptr = pmdp->pmd;
-	short i = 16;
-	while (--i >= 0) {
-		*ptr++ = ptbl;
-		ptbl += (sizeof(pte_t)*PTRS_PER_PTE/16);
-	}
+	pmd_val(*pmdp) = virt_to_phys(ptep) | _PAGE_TABLE | _PAGE_ACCESSED;
 }
 
 static inline void pud_set(pud_t *pudp, pmd_t *pmdp)
@@ -138,12 +132,7 @@ static inline void pud_set(pud_t *pudp, pmd_t *pmdp)
 #define pmd_none(pmd)		(!pmd_val(pmd))
 #define pmd_bad(pmd)		((pmd_val(pmd) & _DESCTYPE_MASK) != _PAGE_TABLE)
 #define pmd_present(pmd)	(pmd_val(pmd) & _PAGE_TABLE)
-#define pmd_clear(pmdp) ({			\
-	unsigned long *__ptr = pmdp->pmd;	\
-	short __i = 16;				\
-	while (--__i >= 0)			\
-		*__ptr++ = 0;			\
-})
+#define pmd_clear(pmdp)		({ pmd_val(*pmdp) = 0; })
 #define pmd_page(pmd)		virt_to_page(__va(pmd_val(pmd)))
 
 
diff --git a/arch/m68k/include/asm/page.h b/arch/m68k/include/asm/page.h
index 05e1e1e77a9a..c02326b56ae2 100644
--- a/arch/m68k/include/asm/page.h
+++ b/arch/m68k/include/asm/page.h
@@ -22,9 +22,9 @@
  * These are used to make use of C type-checking..
  */
 #if !defined(CONFIG_MMU) || CONFIG_PGTABLE_LEVELS == 3
-typedef struct { unsigned long pmd[16]; } pmd_t;
-#define pmd_val(x)	((&x)->pmd[0])
-#define __pmd(x)	((pmd_t) { { (x) }, })
+typedef struct { unsigned long pmd; } pmd_t;
+#define pmd_val(x)	((&x)->pmd)
+#define __pmd(x)	((pmd_t) { (x) } )
 #endif
 
 typedef struct { unsigned long pte; } pte_t;
diff --git a/arch/m68k/include/asm/pgtable_mm.h b/arch/m68k/include/asm/pgtable_mm.h
index 2bf5c3501e78..f0e5167de834 100644
--- a/arch/m68k/include/asm/pgtable_mm.h
+++ b/arch/m68k/include/asm/pgtable_mm.h
@@ -36,7 +36,7 @@
 
 /* PMD_SHIFT determines the size of the area a second-level page table can map */
 #if CONFIG_PGTABLE_LEVELS == 3
-#define PMD_SHIFT	22
+#define PMD_SHIFT	18
 #endif
 #define PMD_SIZE	(1UL << PMD_SHIFT)
 #define PMD_MASK	(~(PMD_SIZE-1))
@@ -67,8 +67,8 @@
 #define PTRS_PER_PMD	1
 #define PTRS_PER_PGD	1024
 #else
-#define PTRS_PER_PTE	1024
-#define PTRS_PER_PMD	8
+#define PTRS_PER_PTE	64
+#define PTRS_PER_PMD	128
 #define PTRS_PER_PGD	128
 #endif
 #define USER_PTRS_PER_PGD	(TASK_SIZE/PGDIR_SIZE)
@@ -76,8 +76,8 @@
 
 /* Virtual address region for use by kernel_map() */
 #ifdef CONFIG_SUN3
-#define KMAP_START     0x0DC00000
-#define KMAP_END       0x0E000000
+#define KMAP_START	0x0dc00000
+#define KMAP_END	0x0e000000
 #elif defined(CONFIG_COLDFIRE)
 #define KMAP_START	0xe0000000
 #define KMAP_END	0xf0000000
diff --git a/arch/m68k/mm/kmap.c b/arch/m68k/mm/kmap.c
index 120030ad8dc4..9e3ce39e7fab 100644
--- a/arch/m68k/mm/kmap.c
+++ b/arch/m68k/mm/kmap.c
@@ -24,8 +24,6 @@
 
 #undef DEBUG
 
-#define PTRTREESIZE	(256*1024)
-
 /*
  * For 040/060 we can use the virtual memory area like other architectures,
  * but for 020/030 we want to use early termination page descriptors and we
@@ -50,7 +48,7 @@ static inline void free_io_area(void *addr)
 
 #else
 
-#define IO_SIZE		(256*1024)
+#define IO_SIZE		PMD_SIZE
 
 static struct vm_struct *iolist;
 
@@ -81,14 +79,13 @@ static void __free_io_area(void *addr, unsigned long size)
 
 #if CONFIG_PGTABLE_LEVELS == 3
 		if (CPU_IS_020_OR_030) {
-			int pmd_off = (virtaddr/PTRTREESIZE) & 15;
-			int pmd_type = pmd_dir->pmd[pmd_off] & _DESCTYPE_MASK;
+			int pmd_type = pmd_val(*pmd_dir) & _DESCTYPE_MASK;
 
 			if (pmd_type == _PAGE_PRESENT) {
-				pmd_dir->pmd[pmd_off] = 0;
-				virtaddr += PTRTREESIZE;
-				size -= PTRTREESIZE;
-				continue;
+				pmd_clear(pmd_dir);
+				virtaddr += PMD_SIZE;
+				size -= PMD_SIZE;
+
 			} else if (pmd_type == 0)
 				continue;
 		}
@@ -249,7 +246,7 @@ void __iomem *__ioremap(unsigned long physaddr, unsigned long size, int cachefla
 
 	while ((long)size > 0) {
 #ifdef DEBUG
-		if (!(virtaddr & (PTRTREESIZE-1)))
+		if (!(virtaddr & (PMD_SIZE-1)))
 			printk ("\npa=%#lx va=%#lx ", physaddr, virtaddr);
 #endif
 		pgd_dir = pgd_offset_k(virtaddr);
@@ -263,10 +260,14 @@ void __iomem *__ioremap(unsigned long physaddr, unsigned long size, int cachefla
 
 #if CONFIG_PGTABLE_LEVELS == 3
 		if (CPU_IS_020_OR_030) {
-			pmd_dir->pmd[(virtaddr/PTRTREESIZE) & 15] = physaddr;
-			physaddr += PTRTREESIZE;
-			virtaddr += PTRTREESIZE;
-			size -= PTRTREESIZE;
+			/*
+			 * XXX in order to work as EARLY_TERMINATION / huge_page
+			 * this should have _PAGE_PRESENT set ?!?
+			 */
+			pmd_val(*pmd_dir) = physaddr;
+			physaddr += PMD_SIZE;
+			virtaddr += PMD_SIZE;
+			size -= PMD_SIZE;
 		} else
 #endif
 		{
@@ -367,13 +368,12 @@ void kernel_set_cachemode(void *addr, unsigned long size, int cmode)
 
 #if CONFIG_PGTABLE_LEVELS == 3
 		if (CPU_IS_020_OR_030) {
-			int pmd_off = (virtaddr/PTRTREESIZE) & 15;
+			unsigned long pmd = pmd_val(*pmd_dir);
 
-			if ((pmd_dir->pmd[pmd_off] & _DESCTYPE_MASK) == _PAGE_PRESENT) {
-				pmd_dir->pmd[pmd_off] = (pmd_dir->pmd[pmd_off] &
-							 _CACHEMASK040) | cmode;
-				virtaddr += PTRTREESIZE;
-				size -= PTRTREESIZE;
+			if ((pmd & _DESCTYPE_MASK) == _PAGE_PRESENT) {
+				*pmd_dir = __pmd((pmd & _CACHEMASK040) | cmode);
+				virtaddr += PMD_SIZE;
+				size -= PMD_SIZE;
 				continue;
 			}
 		}
diff --git a/arch/m68k/mm/motorola.c b/arch/m68k/mm/motorola.c
index 4857985b8080..0d125e195133 100644
--- a/arch/m68k/mm/motorola.c
+++ b/arch/m68k/mm/motorola.c
@@ -116,8 +116,6 @@ static pmd_t * __init kernel_ptr_table(void)
 
 static void __init map_node(int node)
 {
-#define PTRTREESIZE (256*1024)
-#define ROOTTREESIZE (32*1024*1024)
 	unsigned long physaddr, virtaddr, size;
 	pgd_t *pgd_dir;
 	p4d_t *p4d_dir;
@@ -135,21 +133,21 @@ static void __init map_node(int node)
 
 	while (size > 0) {
 #ifdef DEBUG
-		if (!(virtaddr & (PTRTREESIZE-1)))
+		if (!(virtaddr & (PMD_SIZE-1)))
 			printk ("\npa=%#lx va=%#lx ", physaddr & PAGE_MASK,
 				virtaddr);
 #endif
 		pgd_dir = pgd_offset_k(virtaddr);
 		if (virtaddr && CPU_IS_020_OR_030) {
-			if (!(virtaddr & (ROOTTREESIZE-1)) &&
-			    size >= ROOTTREESIZE) {
+			if (!(virtaddr & (PGDIR_SIZE-1)) &&
+			    size >= PGDIR_SIZE) {
 #ifdef DEBUG
 				printk ("[very early term]");
 #endif
 				pgd_val(*pgd_dir) = physaddr;
-				size -= ROOTTREESIZE;
-				virtaddr += ROOTTREESIZE;
-				physaddr += ROOTTREESIZE;
+				size -= PGDIR_SIZE;
+				virtaddr += PGDIR_SIZE;
+				physaddr += PGDIR_SIZE;
 				continue;
 			}
 		}
@@ -169,8 +167,8 @@ static void __init map_node(int node)
 #ifdef DEBUG
 				printk ("[early term]");
 #endif
-				pmd_dir->pmd[(virtaddr/PTRTREESIZE) & 15] = physaddr;
-				physaddr += PTRTREESIZE;
+				pmd_val(*pmd_dir) = physaddr;
+				physaddr += PMD_SIZE;
 			} else {
 				int i;
 #ifdef DEBUG
@@ -178,15 +176,15 @@ static void __init map_node(int node)
 #endif
 				zero_pgtable = kernel_ptr_table();
 				pte_dir = (pte_t *)zero_pgtable;
-				pmd_dir->pmd[0] = virt_to_phys(pte_dir) |
-					_PAGE_TABLE | _PAGE_ACCESSED;
+				pmd_set(pmd_dir, pte_dir);
+
 				pte_val(*pte_dir++) = 0;
 				physaddr += PAGE_SIZE;
-				for (i = 1; i < 64; physaddr += PAGE_SIZE, i++)
+				for (i = 1; i < PTRS_PER_PTE; physaddr += PAGE_SIZE, i++)
 					pte_val(*pte_dir++) = physaddr;
 			}
-			size -= PTRTREESIZE;
-			virtaddr += PTRTREESIZE;
+			size -= PMD_SIZE;
+			virtaddr += PMD_SIZE;
 		} else {
 			if (!pmd_present(*pmd_dir)) {
 #ifdef DEBUG

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [peterz-queue:locking/core 8/13] include/linux/compiler.h:315:38: error: call to '__compiletime_assert_323' declared with attribute error: Unsupported access size for {READ, WRITE}_ONCE().
  2020-01-28  9:46               ` Peter Zijlstra
@ 2020-01-28 10:05                 ` Peter Zijlstra
  2020-01-28 10:32                   ` Geert Uytterhoeven
  2020-01-28 10:36                   ` Peter Zijlstra
  0 siblings, 2 replies; 17+ messages in thread
From: Peter Zijlstra @ 2020-01-28 10:05 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 1633 bytes --]

On Tue, Jan 28, 2020 at 10:46:20AM +0100, Peter Zijlstra wrote:
> On Mon, Jan 27, 2020 at 02:36:37PM +0100, Geert Uytterhoeven wrote:
> > Interestingly, this crash looks very similar to the one I got after my small
> > experiment, although the code changes were completely different
> > (attached for reference, but won't apply for you, as I have some preliminary
> >  code from Mike Rapoport in my local tree).
> 
> So after reading the m68k programming reference manual and various other
> online sources, I went and did the same.
> 
> The below boots on ARAnyM/68040, but afaict 020/030 is (still) broken.
> That is, AFAICT it is currently broken and I preserved that, see the XXX
> in the patch.
> 
> Basically, 040 (and later) have a fixed 7,7,{5,6} page-table setup,
> where the last depends on the page-size selected (8k vs 4k), and head.S
> selects 4K pages. For 030 (and earlier) we explicitly program 7,7,6 and
> 4K pages in %tc.
> 
> The below implements a straight forward 7,7,6 3 level page-table setup,
> with the addition (for 020/030) of (broken) huge-page support.
> 
> Is there some 020/030 enabled emulator that I can try?

> -#define PTRS_PER_PTE	1024
> -#define PTRS_PER_PMD	8
> +#define PTRS_PER_PTE	64
> +#define PTRS_PER_PMD	128
>  #define PTRS_PER_PGD	128

.oOh I think I finally understand why that code was the way it was. By
frobbing PTRS_PER_PTE to 1024 we fill a full page.

But doing that means we have to fit 16 actual PTE tables into the one
page, which is where that 'funny' 16-fold PMD comes from.

So while my patch boots, it is a giant waste of memory, *groan*

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [peterz-queue:locking/core 8/13] include/linux/compiler.h:315:38: error: call to '__compiletime_assert_323' declared with attribute error: Unsupported access size for {READ, WRITE}_ONCE().
  2020-01-28 10:05                 ` Peter Zijlstra
@ 2020-01-28 10:32                   ` Geert Uytterhoeven
  2020-01-28 10:36                   ` Peter Zijlstra
  1 sibling, 0 replies; 17+ messages in thread
From: Geert Uytterhoeven @ 2020-01-28 10:32 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2373 bytes --]

Hi Peter,

On Tue, Jan 28, 2020 at 11:05 AM Peter Zijlstra <peterz@infradead.org> wrote:
> On Tue, Jan 28, 2020 at 10:46:20AM +0100, Peter Zijlstra wrote:
> > On Mon, Jan 27, 2020 at 02:36:37PM +0100, Geert Uytterhoeven wrote:
> > > Interestingly, this crash looks very similar to the one I got after my small
> > > experiment, although the code changes were completely different
> > > (attached for reference, but won't apply for you, as I have some preliminary
> > >  code from Mike Rapoport in my local tree).
> >
> > So after reading the m68k programming reference manual and various other
> > online sources, I went and did the same.
> >
> > The below boots on ARAnyM/68040, but afaict 020/030 is (still) broken.
> > That is, AFAICT it is currently broken and I preserved that, see the XXX
> > in the patch.
> >
> > Basically, 040 (and later) have a fixed 7,7,{5,6} page-table setup,
> > where the last depends on the page-size selected (8k vs 4k), and head.S
> > selects 4K pages. For 030 (and earlier) we explicitly program 7,7,6 and
> > 4K pages in %tc.
> >
> > The below implements a straight forward 7,7,6 3 level page-table setup,
> > with the addition (for 020/030) of (broken) huge-page support.
> >
> > Is there some 020/030 enabled emulator that I can try?

Hatari, perhaps?

(CCing linux-m68k might help)

> > -#define PTRS_PER_PTE 1024
> > -#define PTRS_PER_PMD 8
> > +#define PTRS_PER_PTE 64
> > +#define PTRS_PER_PMD 128
> >  #define PTRS_PER_PGD 128
>
> .oOh I think I finally understand why that code was the way it was. By
> frobbing PTRS_PER_PTE to 1024 we fill a full page.

Exactly. Everything in the page table hierarchy is set up to fill full pages.

> But doing that means we have to fit 16 actual PTE tables into the one
> page, which is where that 'funny' 16-fold PMD comes from.
>
> So while my patch boots, it is a giant waste of memory, *groan*

Which is unfortunate, given the giant amounts of RAM available on typical
m68k systems...

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert(a)linux-m68k.org

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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [peterz-queue:locking/core 8/13] include/linux/compiler.h:315:38: error: call to '__compiletime_assert_323' declared with attribute error: Unsupported access size for {READ, WRITE}_ONCE().
  2020-01-28 10:05                 ` Peter Zijlstra
  2020-01-28 10:32                   ` Geert Uytterhoeven
@ 2020-01-28 10:36                   ` Peter Zijlstra
  1 sibling, 0 replies; 17+ messages in thread
From: Peter Zijlstra @ 2020-01-28 10:36 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 1998 bytes --]

On Tue, Jan 28, 2020 at 11:05:32AM +0100, Peter Zijlstra wrote:
> On Tue, Jan 28, 2020 at 10:46:20AM +0100, Peter Zijlstra wrote:
> > On Mon, Jan 27, 2020 at 02:36:37PM +0100, Geert Uytterhoeven wrote:
> > > Interestingly, this crash looks very similar to the one I got after my small
> > > experiment, although the code changes were completely different
> > > (attached for reference, but won't apply for you, as I have some preliminary
> > >  code from Mike Rapoport in my local tree).
> > 
> > So after reading the m68k programming reference manual and various other
> > online sources, I went and did the same.
> > 
> > The below boots on ARAnyM/68040, but afaict 020/030 is (still) broken.
> > That is, AFAICT it is currently broken and I preserved that, see the XXX
> > in the patch.
> > 
> > Basically, 040 (and later) have a fixed 7,7,{5,6} page-table setup,
> > where the last depends on the page-size selected (8k vs 4k), and head.S
> > selects 4K pages. For 030 (and earlier) we explicitly program 7,7,6 and
> > 4K pages in %tc.
> > 
> > The below implements a straight forward 7,7,6 3 level page-table setup,
> > with the addition (for 020/030) of (broken) huge-page support.
> > 
> > Is there some 020/030 enabled emulator that I can try?
> 
> > -#define PTRS_PER_PTE	1024
> > -#define PTRS_PER_PMD	8
> > +#define PTRS_PER_PTE	64
> > +#define PTRS_PER_PMD	128
> >  #define PTRS_PER_PGD	128
> 
> .oOh I think I finally understand why that code was the way it was. By
> frobbing PTRS_PER_PTE to 1024 we fill a full page.
> 
> But doing that means we have to fit 16 actual PTE tables into the one
> page, which is where that 'funny' 16-fold PMD comes from.
> 
> So while my patch boots, it is a giant waste of memory, *groan*

Let me go write a special allocator based on s390's pgalloc.c. I should
be able to write a simpler on I think, m68k lacks SMP (and therefore
SPLIT_PTE_PTLOCKS) and thus we should have the entire page-frame up for
grabs.

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2020-01-28 10:36 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-24 18:01 [peterz-queue:locking/core 8/13] include/linux/compiler.h:315:38: error: call to '__compiletime_assert_323' declared with attribute error: Unsupported access size for {READ, WRITE}_ONCE() kbuild test robot
2020-01-24 23:44 ` Peter Zijlstra
2020-01-27 11:42   ` Will Deacon
2020-01-27 12:15     ` Will Deacon
2020-01-27 12:29       ` Peter Zijlstra
2020-01-27 12:53         ` Will Deacon
2020-01-27 13:07           ` Peter Zijlstra
2020-01-27 13:36             ` Geert Uytterhoeven
2020-01-27 14:43               ` Will Deacon
2020-01-27 14:56                 ` Geert Uytterhoeven
2020-01-27 14:44               ` Peter Zijlstra
2020-01-27 16:10                 ` Peter Zijlstra
2020-01-27 16:17                   ` Peter Zijlstra
2020-01-28  9:46               ` Peter Zijlstra
2020-01-28 10:05                 ` Peter Zijlstra
2020-01-28 10:32                   ` Geert Uytterhoeven
2020-01-28 10:36                   ` Peter Zijlstra

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.