mm: make DEFERRED_STRUCT_PAGE_INIT explicitly depend on SPARSEMEM
Subsystems (2)
PATCH 1/1 mm: make DEFERRED_STRUCT_PAGE_INIT explicitly depend on SPARSEMEM
The deferred memory initialization relies on section definitions, e.g PAGES_PER_SECTION, that are only available when CONFIG_SPARSEMEM=y on most architectures.
Initially DEFERRED_STRUCT_PAGE_INIT depended on explicit ARCH_SUPPORTS_DEFERRED_STRUCT_PAGE_INIT configuration option, but since the commit 2e3ca40f03bb13709df4 ("mm: relax deferred struct page requirements") this requirement was relaxed and now it is possible to enable DEFERRED_STRUCT_PAGE_INIT on architectures that support DISCONTINGMEM and NO_BOOTMEM which causes build failures.
For instance, setting SMP=y and DEFERRED_STRUCT_PAGE_INIT=y on arc causes the following build failure:
CC mm/page_alloc.omm/page_alloc.c: In function 'update_defer_init':mm/page_alloc.c:321:14: error: 'PAGES_PER_SECTION' undeclared (first use in this function); did you mean 'USEC_PER_SEC'?
(pfn & (PAGES_PER_SECTION - 1)) == 0) {
^~~~~~~~~~~~~~~~~
USEC_PER_SECmm/page_alloc.c:321:14: note: each undeclared identifier is reported only once for each function it appears in In file included from include/linux/cache.h:5:0,
from include/linux/printk.h:9,
from include/linux/kernel.h:14,
frominclude/asm-generic/bug.h:18,
fromarch/arc/include/asm/bug.h:32,
from include/linux/bug.h:5,
from include/linux/mmdebug.h:5,
from include/linux/mm.h:9,
from mm/page_alloc.c:18:mm/page_alloc.c: In function 'deferred_grow_zone':mm/page_alloc.c:1624:52: error:
'PAGES_PER_SECTION' undeclared (first use in this function); did you mean 'USEC_PER_SEC'?
unsigned long nr_pages_needed = ALIGN(1 << order, PAGES_PER_SECTION);
^
include/uapi/linux/kernel.h:11:47: note: in
definition of macro '__ALIGN_KERNEL_MASK'
#define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
^~~~
include/linux/kernel.h:58:22: note: in expansion
of macro '__ALIGN_KERNEL'
#define ALIGN(x, a) __ALIGN_KERNEL((x), (a))
^~~~~~~~~~~~~~
mm/page_alloc.c:1624:34: note: in expansion of
macro 'ALIGN'
unsigned long nr_pages_needed = ALIGN(1 << order, PAGES_PER_SECTION);
^~~~~In file included frominclude/asm-generic/bug.h:18:0,
fromarch/arc/include/asm/bug.h:32,
from include/linux/bug.h:5,
from include/linux/mmdebug.h:5,
from include/linux/mm.h:9,
from mm/page_alloc.c:18:mm/page_alloc.c: In function
'free_area_init_node':mm/page_alloc.c:6379:50: error:
'PAGES_PER_SECTION' undeclared (first use in this function); did you mean 'USEC_PER_SEC'?
pgdat->static_init_pgcnt = min_t(unsigned long, PAGES_PER_SECTION,
^
include/linux/kernel.h:812:22: note: in definition
of macro '__typecheck'
(!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
^
include/linux/kernel.h:836:24: note: in expansion
of macro '__safe_cmp'
__builtin_choose_expr(__safe_cmp(x, y), \
^~~~~~~~~~
include/linux/kernel.h:904:27: note: in expansion
of macro '__careful_cmp'
#define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <)
^~~~~~~~~~~~~
mm/page_alloc.c:6379:29: note: in expansion of
macro 'min_t'
pgdat->static_init_pgcnt = min_t(unsigned long, PAGES_PER_SECTION,
^~~~~include/linux/kernel.h:836:2: error: first argument to '__builtin_choose_expr' not a constant
__builtin_choose_expr(__safe_cmp(x, y), \
^include/linux/kernel.h:904:27: note: in expansion of macro '__careful_cmp'
#define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <)
^~~~~~~~~~~~~
mm/page_alloc.c:6379:29: note: in expansion of
macro 'min_t'
pgdat->static_init_pgcnt = min_t(unsigned long, PAGES_PER_SECTION,
^~~~~scripts/Makefile.build:317: recipe for target
'mm/page_alloc.o' failed
Let's make the DEFERRED_STRUCT_PAGE_INIT explicitly depend on SPARSEMEM as the systems that support DISCONTIGMEM do not seem to have that huge amounts of memory that would make DEFERRED_STRUCT_PAGE_INIT relevant.
--- mm/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/Kconfig +1 -1
@@ -635,7 +635,7 @@ config DEFERRED_STRUCT_PAGE_INIT bool "Defer initialisation of struct pages to kthreads" default n depends on NO_BOOTMEM - depends on !FLATMEM + depends on SPARSEMEM depends on !NEED_PER_CPU_KM help Ordinarily all struct pages are initialised during early boot in a
Signature · 1 line
2.7.4
Quoted 95 lines · Mike Rapoport
The deferred memory initialization relies on section definitions, e.g
PAGES_PER_SECTION, that are only available whenCONFIG_SPARSEMEM=yon most architectures.Initially
DEFERRED_STRUCT_PAGE_INITdepended on explicitARCH_SUPPORTS_DEFERRED_STRUCT_PAGE_INITconfiguration option, but since the commit2e3ca40f03bb13709df4("mm: relax deferred struct page requirements") this requirement was relaxed and now it is possible to enableDEFERRED_STRUCT_PAGE_INITon architectures that support DISCONTINGMEM andNO_BOOTMEMwhich causes build failures.For instance, setting SMP=y and DEFERRED_STRUCT_PAGE_INIT=y on arc causes the following build failure:
CC
mm/page_alloc.omm/page_alloc.c: In function 'update_defer_init':mm/page_alloc.c:321:14: error: 'PAGES_PER_SECTION' undeclared (first use in this function); did you mean 'USEC_PER_SEC'?(pfn & (PAGES_PER_SECTION - 1)) == 0) { ^~~~~~~~~~~~~~~~~ USEC_PER_SEC
mm/page_alloc.c:321:14: note: each undeclared identifier is reported only once for each function it appears in In file included frominclude/linux/cache.h:5:0,
frominclude/linux/printk.h:9,
frominclude/linux/kernel.h:14,
frominclude/asm-generic/bug.h:18,
fromarch/arc/include/asm/bug.h:32,from include/linux/bug.h:5, from include/linux/mmdebug.h:5, from include/linux/mm.h:9, from mm/page_alloc.c:18:
mm/page_alloc.c: In function 'deferred_grow_zone':mm/page_alloc.c:1624:52: error:
'PAGES_PER_SECTION' undeclared (first use in this function); did you mean 'USEC_PER_SEC'?unsigned long nr_pages_needed = ALIGN(1 << order, PAGES_PER_SECTION); ^ include/uapi/linux/kernel.h:11:47: note: in definition of macro '__ALIGN_KERNEL_MASK' #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask)) ^~~~ include/linux/kernel.h:58:22: note: in expansion of macro '__ALIGN_KERNEL' #define ALIGN(x, a) __ALIGN_KERNEL((x), (a)) ^~~~~~~~~~~~~~ mm/page_alloc.c:1624:34: note: in expansion of macro 'ALIGN' unsigned long nr_pages_needed = ALIGN(1 << order, PAGES_PER_SECTION); ^~~~~In file included from
include/asm-generic/bug.h:18:0,
fromarch/arc/include/asm/bug.h:32,from include/linux/bug.h:5, from include/linux/mmdebug.h:5, from include/linux/mm.h:9, from mm/page_alloc.c:18:
mm/page_alloc.c: In function
'free_area_init_node':mm/page_alloc.c:6379:50: error:
'PAGES_PER_SECTION' undeclared (first use in this function); did you mean 'USEC_PER_SEC'?
pgdat->static_init_pgcnt= min_t(unsigned long,PAGES_PER_SECTION,^ include/linux/kernel.h:812:22: note: in definition of macro '__typecheck' (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1))) ^ include/linux/kernel.h:836:24: note: in expansion of macro '__safe_cmp' __builtin_choose_expr(__safe_cmp(x, y), \ ^~~~~~~~~~ include/linux/kernel.h:904:27: note: in expansion of macro '__careful_cmp' #define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <) ^~~~~~~~~~~~~ mm/page_alloc.c:6379:29: note: in expansion of macro 'min_t' pgdat->static_init_pgcnt = min_t(unsigned long, PAGES_PER_SECTION, ^~~~~
include/linux/kernel.h:836:2: error: first argument to '__builtin_choose_expr' not a constant
__builtin_choose_expr(__safe_cmp(x, y), \
^include/linux/kernel.h:904:27: note: in expansion of macro '__careful_cmp'#define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <) ^~~~~~~~~~~~~ mm/page_alloc.c:6379:29: note: in expansion of macro 'min_t' pgdat->static_init_pgcnt = min_t(unsigned long, PAGES_PER_SECTION, ^~~~~
Quoted 6 lines
scripts/Makefile.build:317: recipe for target
'mm/page_alloc.o' failedLet's make the
DEFERRED_STRUCT_PAGE_INITexplicitly depend on SPARSEMEM as the systems that support DISCONTIGMEM do not seem to have that huge amounts of memory that would makeDEFERRED_STRUCT_PAGE_INITrelevant.
OK, I do not see any reasonable large machine would use DISCONTIGMEM. So this makes sense to me.
Quoted 1 line
Signed-off-by Mike Rapoport <[email protected]>
Quoted 20 lines
--- mm/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/Kconfig +1
-1@@ -635,7 +635,7 @@ config DEFERRED_STRUCT_PAGE_INIT bool "Defer initialisation of struct pages to kthreads" default n depends on NO_BOOTMEM - depends on !FLATMEM + depends on SPARSEMEM depends on !NEED_PER_CPU_KM help Ordinarily all struct pages are initialised during early boot in aSignature · 1 line
2.7.4
Signature · 2 lines
Michal Hocko SUSE Labs
This is something I also wanted to see, thank you.
Quoted 95 lines · Mike Rapoport
The deferred memory initialization relies on section definitions, e.g
PAGES_PER_SECTION, that are only available whenCONFIG_SPARSEMEM=yon most architectures.Initially
DEFERRED_STRUCT_PAGE_INITdepended on explicitARCH_SUPPORTS_DEFERRED_STRUCT_PAGE_INITconfiguration option, but since the commit2e3ca40f03bb13709df4("mm: relax deferred struct page requirements") this requirement was relaxed and now it is possible to enableDEFERRED_STRUCT_PAGE_INITon architectures that support DISCONTINGMEM andNO_BOOTMEMwhich causes build failures.For instance, setting SMP=y and DEFERRED_STRUCT_PAGE_INIT=y on arc causes the following build failure:
CC
mm/page_alloc.omm/page_alloc.c: In function 'update_defer_init':mm/page_alloc.c:321:14: error: 'PAGES_PER_SECTION' undeclared (first use in this function); did you mean 'USEC_PER_SEC'?(pfn & (PAGES_PER_SECTION - 1)) == 0) { ^~~~~~~~~~~~~~~~~ USEC_PER_SEC
mm/page_alloc.c:321:14: note: each undeclared identifier is reported only once for each function it appears in In file included frominclude/linux/cache.h:5:0,
frominclude/linux/printk.h:9,
frominclude/linux/kernel.h:14,
frominclude/asm-generic/bug.h:18,
fromarch/arc/include/asm/bug.h:32,from include/linux/bug.h:5, from include/linux/mmdebug.h:5, from include/linux/mm.h:9, from mm/page_alloc.c:18:
mm/page_alloc.c: In function 'deferred_grow_zone':mm/page_alloc.c:1624:52: error:
'PAGES_PER_SECTION' undeclared (first use in this function); did you mean 'USEC_PER_SEC'?unsigned long nr_pages_needed = ALIGN(1 << order, PAGES_PER_SECTION); ^ include/uapi/linux/kernel.h:11:47: note: in definition of macro '__ALIGN_KERNEL_MASK' #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask)) ^~~~ include/linux/kernel.h:58:22: note: in expansion of macro '__ALIGN_KERNEL' #define ALIGN(x, a) __ALIGN_KERNEL((x), (a)) ^~~~~~~~~~~~~~ mm/page_alloc.c:1624:34: note: in expansion of macro 'ALIGN' unsigned long nr_pages_needed = ALIGN(1 << order, PAGES_PER_SECTION); ^~~~~In file included from
include/asm-generic/bug.h:18:0,
fromarch/arc/include/asm/bug.h:32,from include/linux/bug.h:5, from include/linux/mmdebug.h:5, from include/linux/mm.h:9, from mm/page_alloc.c:18:
mm/page_alloc.c: In function
'free_area_init_node':mm/page_alloc.c:6379:50: error:
'PAGES_PER_SECTION' undeclared (first use in this function); did you mean 'USEC_PER_SEC'?
pgdat->static_init_pgcnt= min_t(unsigned long,PAGES_PER_SECTION,^ include/linux/kernel.h:812:22: note: in definition of macro '__typecheck' (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1))) ^ include/linux/kernel.h:836:24: note: in expansion of macro '__safe_cmp' __builtin_choose_expr(__safe_cmp(x, y), \ ^~~~~~~~~~ include/linux/kernel.h:904:27: note: in expansion of macro '__careful_cmp' #define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <) ^~~~~~~~~~~~~ mm/page_alloc.c:6379:29: note: in expansion of macro 'min_t' pgdat->static_init_pgcnt = min_t(unsigned long, PAGES_PER_SECTION, ^~~~~
include/linux/kernel.h:836:2: error: first argument to '__builtin_choose_expr' not a constant
__builtin_choose_expr(__safe_cmp(x, y), \
^include/linux/kernel.h:904:27: note: in expansion of macro '__careful_cmp'#define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <) ^~~~~~~~~~~~~ mm/page_alloc.c:6379:29: note: in expansion of macro 'min_t' pgdat->static_init_pgcnt = min_t(unsigned long, PAGES_PER_SECTION, ^~~~~
Quoted 8 lines
scripts/Makefile.build:317: recipe for target
'mm/page_alloc.o' failedLet's make the
DEFERRED_STRUCT_PAGE_INITexplicitly depend on SPARSEMEM as the systems that support DISCONTIGMEM do not seem to have that huge amounts of memory that would makeDEFERRED_STRUCT_PAGE_INITrelevant.Signed-off-by Mike Rapoport <[email protected]>
Thanks, I was running into that problem also.
Quoted 18 lines
--- mm/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/Kconfig +1
-1@@ -635,7 +635,7 @@ config DEFERRED_STRUCT_PAGE_INIT bool "Defer initialisation of struct pages to kthreads" default n depends on NO_BOOTMEM - depends on !FLATMEM + depends on SPARSEMEM depends on !NEED_PER_CPU_KM help Ordinarily all struct pages are initialised during early boot in a
Signature · 1 line
~Randy