* include/linux/slab.h:663:78: error: subscripted value is neither array nor pointer nor vector
@ 2024-08-03 15:04 kernel test robot
2024-08-05 9:10 ` Vlastimil Babka
0 siblings, 1 reply; 7+ messages in thread
From: kernel test robot @ 2024-08-03 15:04 UTC (permalink / raw)
To: Kees Cook; +Cc: oe-kbuild-all, linux-kernel, Vlastimil Babka
Hi Kees,
FYI, the error/warning still remains.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 17712b7ea0756799635ba159cc773082230ed028
commit: 72e0fe2241ce113cbba339ca8c2450b167774530 mm/slab: Introduce kmem_buckets typedef
date: 4 weeks ago
config: m68k-alldefconfig (https://download.01.org/0day-ci/archive/20240803/202408032258.ShUXX4qU-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240803/202408032258.ShUXX4qU-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408032258.ShUXX4qU-lkp@intel.com/
All errors (new ones prefixed by >>):
arch/m68k/include/asm/page.h:10:25: error: 'CONFIG_PAGE_SHIFT' undeclared here (not in a function); did you mean 'CONFIG_LOG_BUF_SHIFT'?
10 | #define PAGE_SHIFT CONFIG_PAGE_SHIFT
| ^~~~~~~~~~~~~~~~~
arch/m68k/include/asm/page.h:11:40: note: in expansion of macro 'PAGE_SHIFT'
11 | #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
| ^~~~~~~~~~
arch/m68k/include/asm/thread_info.h:23:26: note: in expansion of macro 'PAGE_SIZE'
23 | #define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
| ^~~~~~~~~
include/linux/sched.h:1851:29: note: in expansion of macro 'THREAD_SIZE'
1851 | unsigned long stack[THREAD_SIZE/sizeof(long)];
| ^~~~~~~~~~~
arch/m68k/include/asm/page.h:10:25: warning: "CONFIG_PAGE_SHIFT" is not defined, evaluates to 0 [-Wundef]
10 | #define PAGE_SHIFT CONFIG_PAGE_SHIFT
| ^~~~~~~~~~~~~~~~~
arch/m68k/include/asm/page.h:11:40: note: in expansion of macro 'PAGE_SHIFT'
11 | #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
| ^~~~~~~~~~
include/linux/mm_types.h:531:6: note: in expansion of macro 'PAGE_SIZE'
531 | #if (PAGE_SIZE < PAGE_FRAG_CACHE_MAX_SIZE)
| ^~~~~~~~~
In file included from include/vdso/const.h:5,
from include/linux/const.h:4,
from include/linux/bits.h:5,
from include/linux/ratelimit_types.h:5,
from include/linux/printk.h:9,
from include/asm-generic/bug.h:22,
from arch/m68k/include/asm/bug.h:32,
from include/linux/bug.h:5,
from include/linux/thread_info.h:13:
arch/m68k/include/asm/page.h:10:25: warning: "CONFIG_PAGE_SHIFT" is not defined, evaluates to 0 [-Wundef]
10 | #define PAGE_SHIFT CONFIG_PAGE_SHIFT
| ^~~~~~~~~~~~~~~~~
include/uapi/linux/const.h:32:50: note: in definition of macro '__ALIGN_KERNEL_MASK'
32 | #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
| ^~~~
include/linux/mm_types.h:508:41: note: in expansion of macro '__ALIGN_MASK'
508 | #define PAGE_FRAG_CACHE_MAX_SIZE __ALIGN_MASK(32768, ~PAGE_MASK)
| ^~~~~~~~~~~~
arch/m68k/include/asm/page.h:11:40: note: in expansion of macro 'PAGE_SHIFT'
11 | #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
| ^~~~~~~~~~
arch/m68k/include/asm/page.h:12:28: note: in expansion of macro 'PAGE_SIZE'
12 | #define PAGE_MASK (~(PAGE_SIZE-1))
| ^~~~~~~~~
include/linux/mm_types.h:508:62: note: in expansion of macro 'PAGE_MASK'
508 | #define PAGE_FRAG_CACHE_MAX_SIZE __ALIGN_MASK(32768, ~PAGE_MASK)
| ^~~~~~~~~
include/linux/mm_types.h:531:18: note: in expansion of macro 'PAGE_FRAG_CACHE_MAX_SIZE'
531 | #if (PAGE_SIZE < PAGE_FRAG_CACHE_MAX_SIZE)
| ^~~~~~~~~~~~~~~~~~~~~~~~
arch/m68k/include/asm/page.h:10:25: warning: "CONFIG_PAGE_SHIFT" is not defined, evaluates to 0 [-Wundef]
10 | #define PAGE_SHIFT CONFIG_PAGE_SHIFT
| ^~~~~~~~~~~~~~~~~
include/uapi/linux/const.h:32:61: note: in definition of macro '__ALIGN_KERNEL_MASK'
32 | #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
| ^~~~
include/linux/mm_types.h:508:41: note: in expansion of macro '__ALIGN_MASK'
508 | #define PAGE_FRAG_CACHE_MAX_SIZE __ALIGN_MASK(32768, ~PAGE_MASK)
| ^~~~~~~~~~~~
arch/m68k/include/asm/page.h:11:40: note: in expansion of macro 'PAGE_SHIFT'
11 | #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
| ^~~~~~~~~~
arch/m68k/include/asm/page.h:12:28: note: in expansion of macro 'PAGE_SIZE'
12 | #define PAGE_MASK (~(PAGE_SIZE-1))
| ^~~~~~~~~
include/linux/mm_types.h:508:62: note: in expansion of macro 'PAGE_MASK'
508 | #define PAGE_FRAG_CACHE_MAX_SIZE __ALIGN_MASK(32768, ~PAGE_MASK)
| ^~~~~~~~~
include/linux/mm_types.h:531:18: note: in expansion of macro 'PAGE_FRAG_CACHE_MAX_SIZE'
531 | #if (PAGE_SIZE < PAGE_FRAG_CACHE_MAX_SIZE)
| ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from include/linux/init.h:5,
from include/linux/printk.h:6:
arch/m68k/include/asm/page.h:10:25: error: expression in static assertion is not an integer
10 | #define PAGE_SHIFT CONFIG_PAGE_SHIFT
| ^~~~~~~~~~~~~~~~~
include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~
include/linux/slab.h:527:1: note: in expansion of macro 'static_assert'
527 | static_assert(PAGE_SHIFT <= 20);
| ^~~~~~~~~~~~~
include/linux/slab.h:527:15: note: in expansion of macro 'PAGE_SHIFT'
527 | static_assert(PAGE_SHIFT <= 20);
| ^~~~~~~~~~
In file included from include/linux/irq.h:21,
from include/asm-generic/hardirq.h:17,
from ./arch/m68k/include/generated/asm/hardirq.h:1,
from include/linux/hardirq.h:11,
from include/linux/interrupt.h:11,
from include/linux/kernel_stat.h:9,
from arch/m68k/kernel/asm-offsets.c:16:
include/linux/slab.h:593:33: warning: 'assume_aligned' attribute argument <erroneous-expression> is not an integer constant [-Wattributes]
593 | __assume_page_alignment __alloc_size(1);
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/slab.h:596:33: warning: 'assume_aligned' attribute argument <erroneous-expression> is not an integer constant [-Wattributes]
596 | __assume_page_alignment __alloc_size(1);
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/slab.h: In function 'kmalloc_noprof':
>> include/linux/slab.h:663:78: error: subscripted value is neither array nor pointer nor vector
663 | kmalloc_caches[kmalloc_type(flags, _RET_IP_)][index],
| ^
include/linux/slab.h:656:30: warning: variable 'index' set but not used [-Wunused-but-set-variable]
656 | unsigned int index;
| ^~~~~
include/linux/slab.h: In function 'kmalloc_node_noprof':
include/linux/slab.h:680:78: error: subscripted value is neither array nor pointer nor vector
680 | kmalloc_caches[kmalloc_type(flags, _RET_IP_)][index],
| ^
include/linux/slab.h:673:30: warning: variable 'index' set but not used [-Wunused-but-set-variable]
673 | unsigned int index;
| ^~~~~
make[3]: *** [scripts/Makefile.build:117: arch/m68k/kernel/asm-offsets.s] Error 1
make[3]: Target 'prepare' not remade because of errors.
make[2]: *** [Makefile:1208: prepare0] Error 2
make[2]: Target 'prepare' not remade because of errors.
make[1]: *** [Makefile:240: __sub-make] Error 2
make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:240: __sub-make] Error 2
make: Target 'prepare' not remade because of errors.
vim +663 include/linux/slab.h
f1b6eb6e6be149 Christoph Lameter 2013-09-04 572
a0a44d9175b349 Vlastimil Babka 2024-05-27 573 /*
a0a44d9175b349 Vlastimil Babka 2024-05-27 574 * The following functions are not to be used directly and are intended only
a0a44d9175b349 Vlastimil Babka 2024-05-27 575 * for internal use from kmalloc() and kmalloc_node()
a0a44d9175b349 Vlastimil Babka 2024-05-27 576 * with the exception of kunit tests
a0a44d9175b349 Vlastimil Babka 2024-05-27 577 */
a0a44d9175b349 Vlastimil Babka 2024-05-27 578
a0a44d9175b349 Vlastimil Babka 2024-05-27 579 void *__kmalloc_noprof(size_t size, gfp_t flags)
a0a44d9175b349 Vlastimil Babka 2024-05-27 580 __assume_kmalloc_alignment __alloc_size(1);
f1b6eb6e6be149 Christoph Lameter 2013-09-04 581
a0a44d9175b349 Vlastimil Babka 2024-05-27 582 void *__kmalloc_node_noprof(size_t size, gfp_t flags, int node)
a0a44d9175b349 Vlastimil Babka 2024-05-27 583 __assume_kmalloc_alignment __alloc_size(1);
a0a44d9175b349 Vlastimil Babka 2024-05-27 584
a0a44d9175b349 Vlastimil Babka 2024-05-27 585 void *__kmalloc_cache_noprof(struct kmem_cache *s, gfp_t flags, size_t size)
a0a44d9175b349 Vlastimil Babka 2024-05-27 586 __assume_kmalloc_alignment __alloc_size(3);
7bd230a26648ac Suren Baghdasaryan 2024-03-21 587
a0a44d9175b349 Vlastimil Babka 2024-05-27 588 void *__kmalloc_cache_node_noprof(struct kmem_cache *s, gfp_t gfpflags,
a0a44d9175b349 Vlastimil Babka 2024-05-27 589 int node, size_t size)
a0a44d9175b349 Vlastimil Babka 2024-05-27 590 __assume_kmalloc_alignment __alloc_size(4);
7bd230a26648ac Suren Baghdasaryan 2024-03-21 591
a0a44d9175b349 Vlastimil Babka 2024-05-27 592 void *__kmalloc_large_noprof(size_t size, gfp_t flags)
a0a44d9175b349 Vlastimil Babka 2024-05-27 @593 __assume_page_alignment __alloc_size(1);
a0c3b940023eef Hyeonggon Yoo 2022-08-17 594
a0a44d9175b349 Vlastimil Babka 2024-05-27 595 void *__kmalloc_large_node_noprof(size_t size, gfp_t flags, int node)
a0a44d9175b349 Vlastimil Babka 2024-05-27 596 __assume_page_alignment __alloc_size(1);
a0c3b940023eef Hyeonggon Yoo 2022-08-17 597
f1b6eb6e6be149 Christoph Lameter 2013-09-04 598 /**
838de63b101147 Vlastimil Babka 2022-11-10 599 * kmalloc - allocate kernel memory
f1b6eb6e6be149 Christoph Lameter 2013-09-04 600 * @size: how many bytes of memory are required.
838de63b101147 Vlastimil Babka 2022-11-10 601 * @flags: describe the allocation context
f1b6eb6e6be149 Christoph Lameter 2013-09-04 602 *
f1b6eb6e6be149 Christoph Lameter 2013-09-04 603 * kmalloc is the normal method of allocating memory
f1b6eb6e6be149 Christoph Lameter 2013-09-04 604 * for objects smaller than page size in the kernel.
7e3528c3660a2e Randy Dunlap 2013-11-22 605 *
59bb47985c1db2 Vlastimil Babka 2019-10-06 606 * The allocated object address is aligned to at least ARCH_KMALLOC_MINALIGN
59bb47985c1db2 Vlastimil Babka 2019-10-06 607 * bytes. For @size of power of two bytes, the alignment is also guaranteed
ad59baa3169591 Vlastimil Babka 2024-07-03 608 * to be at least to the size. For other sizes, the alignment is guaranteed to
ad59baa3169591 Vlastimil Babka 2024-07-03 609 * be at least the largest power-of-two divisor of @size.
59bb47985c1db2 Vlastimil Babka 2019-10-06 610 *
01598ba6b1a863 Mike Rapoport 2018-11-11 611 * The @flags argument may be one of the GFP flags defined at
e9d198f2be851f Thorsten Scherer 2023-03-12 612 * include/linux/gfp_types.h and described at
01598ba6b1a863 Mike Rapoport 2018-11-11 613 * :ref:`Documentation/core-api/mm-api.rst <mm-api-gfp-flags>`
7e3528c3660a2e Randy Dunlap 2013-11-22 614 *
01598ba6b1a863 Mike Rapoport 2018-11-11 615 * The recommended usage of the @flags is described at
2370ae4b1d5aa7 Mauro Carvalho Chehab 2020-04-10 616 * :ref:`Documentation/core-api/memory-allocation.rst <memory_allocation>`
7e3528c3660a2e Randy Dunlap 2013-11-22 617 *
01598ba6b1a863 Mike Rapoport 2018-11-11 618 * Below is a brief outline of the most useful GFP flags
7e3528c3660a2e Randy Dunlap 2013-11-22 619 *
01598ba6b1a863 Mike Rapoport 2018-11-11 620 * %GFP_KERNEL
01598ba6b1a863 Mike Rapoport 2018-11-11 621 * Allocate normal kernel ram. May sleep.
7e3528c3660a2e Randy Dunlap 2013-11-22 622 *
01598ba6b1a863 Mike Rapoport 2018-11-11 623 * %GFP_NOWAIT
01598ba6b1a863 Mike Rapoport 2018-11-11 624 * Allocation will not sleep.
7e3528c3660a2e Randy Dunlap 2013-11-22 625 *
01598ba6b1a863 Mike Rapoport 2018-11-11 626 * %GFP_ATOMIC
01598ba6b1a863 Mike Rapoport 2018-11-11 627 * Allocation will not sleep. May use emergency pools.
7e3528c3660a2e Randy Dunlap 2013-11-22 628 *
7e3528c3660a2e Randy Dunlap 2013-11-22 629 * Also it is possible to set different flags by OR'ing
7e3528c3660a2e Randy Dunlap 2013-11-22 630 * in one or more of the following additional @flags:
7e3528c3660a2e Randy Dunlap 2013-11-22 631 *
838de63b101147 Vlastimil Babka 2022-11-10 632 * %__GFP_ZERO
838de63b101147 Vlastimil Babka 2022-11-10 633 * Zero the allocated memory before returning. Also see kzalloc().
838de63b101147 Vlastimil Babka 2022-11-10 634 *
01598ba6b1a863 Mike Rapoport 2018-11-11 635 * %__GFP_HIGH
01598ba6b1a863 Mike Rapoport 2018-11-11 636 * This allocation has high priority and may use emergency pools.
7e3528c3660a2e Randy Dunlap 2013-11-22 637 *
01598ba6b1a863 Mike Rapoport 2018-11-11 638 * %__GFP_NOFAIL
01598ba6b1a863 Mike Rapoport 2018-11-11 639 * Indicate that this allocation is in no way allowed to fail
7e3528c3660a2e Randy Dunlap 2013-11-22 640 * (think twice before using).
7e3528c3660a2e Randy Dunlap 2013-11-22 641 *
01598ba6b1a863 Mike Rapoport 2018-11-11 642 * %__GFP_NORETRY
01598ba6b1a863 Mike Rapoport 2018-11-11 643 * If memory is not immediately available,
7e3528c3660a2e Randy Dunlap 2013-11-22 644 * then give up at once.
7e3528c3660a2e Randy Dunlap 2013-11-22 645 *
01598ba6b1a863 Mike Rapoport 2018-11-11 646 * %__GFP_NOWARN
01598ba6b1a863 Mike Rapoport 2018-11-11 647 * If allocation fails, don't issue any warnings.
7e3528c3660a2e Randy Dunlap 2013-11-22 648 *
01598ba6b1a863 Mike Rapoport 2018-11-11 649 * %__GFP_RETRY_MAYFAIL
01598ba6b1a863 Mike Rapoport 2018-11-11 650 * Try really hard to succeed the allocation but fail
dcda9b04713c3f Michal Hocko 2017-07-12 651 * eventually.
f1b6eb6e6be149 Christoph Lameter 2013-09-04 652 */
7bd230a26648ac Suren Baghdasaryan 2024-03-21 653 static __always_inline __alloc_size(1) void *kmalloc_noprof(size_t size, gfp_t flags)
f1b6eb6e6be149 Christoph Lameter 2013-09-04 654 {
6fa57d78aa7f21 Kees Cook 2022-11-17 655 if (__builtin_constant_p(size) && size) {
cc252eae85e095 Vlastimil Babka 2018-10-26 656 unsigned int index;
3bf019334fbbb5 Kees Cook 2022-11-17 657
f1b6eb6e6be149 Christoph Lameter 2013-09-04 658 if (size > KMALLOC_MAX_CACHE_SIZE)
a0a44d9175b349 Vlastimil Babka 2024-05-27 659 return __kmalloc_large_noprof(size, flags);
f1b6eb6e6be149 Christoph Lameter 2013-09-04 660
cc252eae85e095 Vlastimil Babka 2018-10-26 661 index = kmalloc_index(size);
a0a44d9175b349 Vlastimil Babka 2024-05-27 662 return __kmalloc_cache_noprof(
3c615294058429 GONG, Ruiqi 2023-07-14 @663 kmalloc_caches[kmalloc_type(flags, _RET_IP_)][index],
f1b6eb6e6be149 Christoph Lameter 2013-09-04 664 flags, size);
f1b6eb6e6be149 Christoph Lameter 2013-09-04 665 }
7bd230a26648ac Suren Baghdasaryan 2024-03-21 666 return __kmalloc_noprof(size, flags);
f1b6eb6e6be149 Christoph Lameter 2013-09-04 667 }
7bd230a26648ac Suren Baghdasaryan 2024-03-21 668 #define kmalloc(...) alloc_hooks(kmalloc_noprof(__VA_ARGS__))
ce6a50263d4dde Christoph Lameter 2013-01-10 669
:::::: The code at line 663 was first introduced by commit
:::::: 3c6152940584290668b35fa0800026f6a1ae05fe Randomized slab caches for kmalloc()
:::::: TO: GONG, Ruiqi <gongruiqi@huaweicloud.com>
:::::: CC: Vlastimil Babka <vbabka@suse.cz>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: include/linux/slab.h:663:78: error: subscripted value is neither array nor pointer nor vector
2024-08-03 15:04 include/linux/slab.h:663:78: error: subscripted value is neither array nor pointer nor vector kernel test robot
@ 2024-08-05 9:10 ` Vlastimil Babka
2024-08-06 6:33 ` Philip Li
0 siblings, 1 reply; 7+ messages in thread
From: Vlastimil Babka @ 2024-08-05 9:10 UTC (permalink / raw)
To: kernel test robot, Kees Cook; +Cc: oe-kbuild-all, linux-kernel
On 8/3/24 17:04, kernel test robot wrote:
> Hi Kees,
>
> FYI, the error/warning still remains.
But it's also still misattributed to this commit?
https://lore.kernel.org/all/CAMuHMdWMSpv1BbvCqf0Abfxf0sGp+5it-m1GtFR2nGuQ5-ZCAg@mail.gmail.com/
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: 17712b7ea0756799635ba159cc773082230ed028
> commit: 72e0fe2241ce113cbba339ca8c2450b167774530 mm/slab: Introduce kmem_buckets typedef
> date: 4 weeks ago
> config: m68k-alldefconfig (https://download.01.org/0day-ci/archive/20240803/202408032258.ShUXX4qU-lkp@intel.com/config)
> compiler: m68k-linux-gcc (GCC) 14.1.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240803/202408032258.ShUXX4qU-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202408032258.ShUXX4qU-lkp@intel.com/
>
> All errors (new ones prefixed by >>):
>
> arch/m68k/include/asm/page.h:10:25: error: 'CONFIG_PAGE_SHIFT' undeclared here (not in a function); did you mean 'CONFIG_LOG_BUF_SHIFT'?
> 10 | #define PAGE_SHIFT CONFIG_PAGE_SHIFT
> | ^~~~~~~~~~~~~~~~~
> arch/m68k/include/asm/page.h:11:40: note: in expansion of macro 'PAGE_SHIFT'
> 11 | #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
> | ^~~~~~~~~~
> arch/m68k/include/asm/thread_info.h:23:26: note: in expansion of macro 'PAGE_SIZE'
> 23 | #define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
> | ^~~~~~~~~
> include/linux/sched.h:1851:29: note: in expansion of macro 'THREAD_SIZE'
> 1851 | unsigned long stack[THREAD_SIZE/sizeof(long)];
> | ^~~~~~~~~~~
> arch/m68k/include/asm/page.h:10:25: warning: "CONFIG_PAGE_SHIFT" is not defined, evaluates to 0 [-Wundef]
> 10 | #define PAGE_SHIFT CONFIG_PAGE_SHIFT
> | ^~~~~~~~~~~~~~~~~
> arch/m68k/include/asm/page.h:11:40: note: in expansion of macro 'PAGE_SHIFT'
> 11 | #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
> | ^~~~~~~~~~
> include/linux/mm_types.h:531:6: note: in expansion of macro 'PAGE_SIZE'
> 531 | #if (PAGE_SIZE < PAGE_FRAG_CACHE_MAX_SIZE)
> | ^~~~~~~~~
> In file included from include/vdso/const.h:5,
> from include/linux/const.h:4,
> from include/linux/bits.h:5,
> from include/linux/ratelimit_types.h:5,
> from include/linux/printk.h:9,
> from include/asm-generic/bug.h:22,
> from arch/m68k/include/asm/bug.h:32,
> from include/linux/bug.h:5,
> from include/linux/thread_info.h:13:
> arch/m68k/include/asm/page.h:10:25: warning: "CONFIG_PAGE_SHIFT" is not defined, evaluates to 0 [-Wundef]
> 10 | #define PAGE_SHIFT CONFIG_PAGE_SHIFT
> | ^~~~~~~~~~~~~~~~~
> include/uapi/linux/const.h:32:50: note: in definition of macro '__ALIGN_KERNEL_MASK'
> 32 | #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
> | ^~~~
> include/linux/mm_types.h:508:41: note: in expansion of macro '__ALIGN_MASK'
> 508 | #define PAGE_FRAG_CACHE_MAX_SIZE __ALIGN_MASK(32768, ~PAGE_MASK)
> | ^~~~~~~~~~~~
> arch/m68k/include/asm/page.h:11:40: note: in expansion of macro 'PAGE_SHIFT'
> 11 | #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
> | ^~~~~~~~~~
> arch/m68k/include/asm/page.h:12:28: note: in expansion of macro 'PAGE_SIZE'
> 12 | #define PAGE_MASK (~(PAGE_SIZE-1))
> | ^~~~~~~~~
> include/linux/mm_types.h:508:62: note: in expansion of macro 'PAGE_MASK'
> 508 | #define PAGE_FRAG_CACHE_MAX_SIZE __ALIGN_MASK(32768, ~PAGE_MASK)
> | ^~~~~~~~~
> include/linux/mm_types.h:531:18: note: in expansion of macro 'PAGE_FRAG_CACHE_MAX_SIZE'
> 531 | #if (PAGE_SIZE < PAGE_FRAG_CACHE_MAX_SIZE)
> | ^~~~~~~~~~~~~~~~~~~~~~~~
> arch/m68k/include/asm/page.h:10:25: warning: "CONFIG_PAGE_SHIFT" is not defined, evaluates to 0 [-Wundef]
> 10 | #define PAGE_SHIFT CONFIG_PAGE_SHIFT
> | ^~~~~~~~~~~~~~~~~
> include/uapi/linux/const.h:32:61: note: in definition of macro '__ALIGN_KERNEL_MASK'
> 32 | #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
> | ^~~~
> include/linux/mm_types.h:508:41: note: in expansion of macro '__ALIGN_MASK'
> 508 | #define PAGE_FRAG_CACHE_MAX_SIZE __ALIGN_MASK(32768, ~PAGE_MASK)
> | ^~~~~~~~~~~~
> arch/m68k/include/asm/page.h:11:40: note: in expansion of macro 'PAGE_SHIFT'
> 11 | #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
> | ^~~~~~~~~~
> arch/m68k/include/asm/page.h:12:28: note: in expansion of macro 'PAGE_SIZE'
> 12 | #define PAGE_MASK (~(PAGE_SIZE-1))
> | ^~~~~~~~~
> include/linux/mm_types.h:508:62: note: in expansion of macro 'PAGE_MASK'
> 508 | #define PAGE_FRAG_CACHE_MAX_SIZE __ALIGN_MASK(32768, ~PAGE_MASK)
> | ^~~~~~~~~
> include/linux/mm_types.h:531:18: note: in expansion of macro 'PAGE_FRAG_CACHE_MAX_SIZE'
> 531 | #if (PAGE_SIZE < PAGE_FRAG_CACHE_MAX_SIZE)
> | ^~~~~~~~~~~~~~~~~~~~~~~~
> In file included from include/linux/init.h:5,
> from include/linux/printk.h:6:
> arch/m68k/include/asm/page.h:10:25: error: expression in static assertion is not an integer
> 10 | #define PAGE_SHIFT CONFIG_PAGE_SHIFT
> | ^~~~~~~~~~~~~~~~~
> include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
> 78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
> | ^~~~
> include/linux/slab.h:527:1: note: in expansion of macro 'static_assert'
> 527 | static_assert(PAGE_SHIFT <= 20);
> | ^~~~~~~~~~~~~
> include/linux/slab.h:527:15: note: in expansion of macro 'PAGE_SHIFT'
> 527 | static_assert(PAGE_SHIFT <= 20);
> | ^~~~~~~~~~
> In file included from include/linux/irq.h:21,
> from include/asm-generic/hardirq.h:17,
> from ./arch/m68k/include/generated/asm/hardirq.h:1,
> from include/linux/hardirq.h:11,
> from include/linux/interrupt.h:11,
> from include/linux/kernel_stat.h:9,
> from arch/m68k/kernel/asm-offsets.c:16:
> include/linux/slab.h:593:33: warning: 'assume_aligned' attribute argument <erroneous-expression> is not an integer constant [-Wattributes]
> 593 | __assume_page_alignment __alloc_size(1);
> | ^~~~~~~~~~~~~~~~~~~~~~~
> include/linux/slab.h:596:33: warning: 'assume_aligned' attribute argument <erroneous-expression> is not an integer constant [-Wattributes]
> 596 | __assume_page_alignment __alloc_size(1);
> | ^~~~~~~~~~~~~~~~~~~~~~~
> include/linux/slab.h: In function 'kmalloc_noprof':
>>> include/linux/slab.h:663:78: error: subscripted value is neither array nor pointer nor vector
> 663 | kmalloc_caches[kmalloc_type(flags, _RET_IP_)][index],
> | ^
> include/linux/slab.h:656:30: warning: variable 'index' set but not used [-Wunused-but-set-variable]
> 656 | unsigned int index;
> | ^~~~~
> include/linux/slab.h: In function 'kmalloc_node_noprof':
> include/linux/slab.h:680:78: error: subscripted value is neither array nor pointer nor vector
> 680 | kmalloc_caches[kmalloc_type(flags, _RET_IP_)][index],
> | ^
> include/linux/slab.h:673:30: warning: variable 'index' set but not used [-Wunused-but-set-variable]
> 673 | unsigned int index;
> | ^~~~~
> make[3]: *** [scripts/Makefile.build:117: arch/m68k/kernel/asm-offsets.s] Error 1
> make[3]: Target 'prepare' not remade because of errors.
> make[2]: *** [Makefile:1208: prepare0] Error 2
> make[2]: Target 'prepare' not remade because of errors.
> make[1]: *** [Makefile:240: __sub-make] Error 2
> make[1]: Target 'prepare' not remade because of errors.
> make: *** [Makefile:240: __sub-make] Error 2
> make: Target 'prepare' not remade because of errors.
>
>
> vim +663 include/linux/slab.h
>
> f1b6eb6e6be149 Christoph Lameter 2013-09-04 572
> a0a44d9175b349 Vlastimil Babka 2024-05-27 573 /*
> a0a44d9175b349 Vlastimil Babka 2024-05-27 574 * The following functions are not to be used directly and are intended only
> a0a44d9175b349 Vlastimil Babka 2024-05-27 575 * for internal use from kmalloc() and kmalloc_node()
> a0a44d9175b349 Vlastimil Babka 2024-05-27 576 * with the exception of kunit tests
> a0a44d9175b349 Vlastimil Babka 2024-05-27 577 */
> a0a44d9175b349 Vlastimil Babka 2024-05-27 578
> a0a44d9175b349 Vlastimil Babka 2024-05-27 579 void *__kmalloc_noprof(size_t size, gfp_t flags)
> a0a44d9175b349 Vlastimil Babka 2024-05-27 580 __assume_kmalloc_alignment __alloc_size(1);
> f1b6eb6e6be149 Christoph Lameter 2013-09-04 581
> a0a44d9175b349 Vlastimil Babka 2024-05-27 582 void *__kmalloc_node_noprof(size_t size, gfp_t flags, int node)
> a0a44d9175b349 Vlastimil Babka 2024-05-27 583 __assume_kmalloc_alignment __alloc_size(1);
> a0a44d9175b349 Vlastimil Babka 2024-05-27 584
> a0a44d9175b349 Vlastimil Babka 2024-05-27 585 void *__kmalloc_cache_noprof(struct kmem_cache *s, gfp_t flags, size_t size)
> a0a44d9175b349 Vlastimil Babka 2024-05-27 586 __assume_kmalloc_alignment __alloc_size(3);
> 7bd230a26648ac Suren Baghdasaryan 2024-03-21 587
> a0a44d9175b349 Vlastimil Babka 2024-05-27 588 void *__kmalloc_cache_node_noprof(struct kmem_cache *s, gfp_t gfpflags,
> a0a44d9175b349 Vlastimil Babka 2024-05-27 589 int node, size_t size)
> a0a44d9175b349 Vlastimil Babka 2024-05-27 590 __assume_kmalloc_alignment __alloc_size(4);
> 7bd230a26648ac Suren Baghdasaryan 2024-03-21 591
> a0a44d9175b349 Vlastimil Babka 2024-05-27 592 void *__kmalloc_large_noprof(size_t size, gfp_t flags)
> a0a44d9175b349 Vlastimil Babka 2024-05-27 @593 __assume_page_alignment __alloc_size(1);
> a0c3b940023eef Hyeonggon Yoo 2022-08-17 594
> a0a44d9175b349 Vlastimil Babka 2024-05-27 595 void *__kmalloc_large_node_noprof(size_t size, gfp_t flags, int node)
> a0a44d9175b349 Vlastimil Babka 2024-05-27 596 __assume_page_alignment __alloc_size(1);
> a0c3b940023eef Hyeonggon Yoo 2022-08-17 597
> f1b6eb6e6be149 Christoph Lameter 2013-09-04 598 /**
> 838de63b101147 Vlastimil Babka 2022-11-10 599 * kmalloc - allocate kernel memory
> f1b6eb6e6be149 Christoph Lameter 2013-09-04 600 * @size: how many bytes of memory are required.
> 838de63b101147 Vlastimil Babka 2022-11-10 601 * @flags: describe the allocation context
> f1b6eb6e6be149 Christoph Lameter 2013-09-04 602 *
> f1b6eb6e6be149 Christoph Lameter 2013-09-04 603 * kmalloc is the normal method of allocating memory
> f1b6eb6e6be149 Christoph Lameter 2013-09-04 604 * for objects smaller than page size in the kernel.
> 7e3528c3660a2e Randy Dunlap 2013-11-22 605 *
> 59bb47985c1db2 Vlastimil Babka 2019-10-06 606 * The allocated object address is aligned to at least ARCH_KMALLOC_MINALIGN
> 59bb47985c1db2 Vlastimil Babka 2019-10-06 607 * bytes. For @size of power of two bytes, the alignment is also guaranteed
> ad59baa3169591 Vlastimil Babka 2024-07-03 608 * to be at least to the size. For other sizes, the alignment is guaranteed to
> ad59baa3169591 Vlastimil Babka 2024-07-03 609 * be at least the largest power-of-two divisor of @size.
> 59bb47985c1db2 Vlastimil Babka 2019-10-06 610 *
> 01598ba6b1a863 Mike Rapoport 2018-11-11 611 * The @flags argument may be one of the GFP flags defined at
> e9d198f2be851f Thorsten Scherer 2023-03-12 612 * include/linux/gfp_types.h and described at
> 01598ba6b1a863 Mike Rapoport 2018-11-11 613 * :ref:`Documentation/core-api/mm-api.rst <mm-api-gfp-flags>`
> 7e3528c3660a2e Randy Dunlap 2013-11-22 614 *
> 01598ba6b1a863 Mike Rapoport 2018-11-11 615 * The recommended usage of the @flags is described at
> 2370ae4b1d5aa7 Mauro Carvalho Chehab 2020-04-10 616 * :ref:`Documentation/core-api/memory-allocation.rst <memory_allocation>`
> 7e3528c3660a2e Randy Dunlap 2013-11-22 617 *
> 01598ba6b1a863 Mike Rapoport 2018-11-11 618 * Below is a brief outline of the most useful GFP flags
> 7e3528c3660a2e Randy Dunlap 2013-11-22 619 *
> 01598ba6b1a863 Mike Rapoport 2018-11-11 620 * %GFP_KERNEL
> 01598ba6b1a863 Mike Rapoport 2018-11-11 621 * Allocate normal kernel ram. May sleep.
> 7e3528c3660a2e Randy Dunlap 2013-11-22 622 *
> 01598ba6b1a863 Mike Rapoport 2018-11-11 623 * %GFP_NOWAIT
> 01598ba6b1a863 Mike Rapoport 2018-11-11 624 * Allocation will not sleep.
> 7e3528c3660a2e Randy Dunlap 2013-11-22 625 *
> 01598ba6b1a863 Mike Rapoport 2018-11-11 626 * %GFP_ATOMIC
> 01598ba6b1a863 Mike Rapoport 2018-11-11 627 * Allocation will not sleep. May use emergency pools.
> 7e3528c3660a2e Randy Dunlap 2013-11-22 628 *
> 7e3528c3660a2e Randy Dunlap 2013-11-22 629 * Also it is possible to set different flags by OR'ing
> 7e3528c3660a2e Randy Dunlap 2013-11-22 630 * in one or more of the following additional @flags:
> 7e3528c3660a2e Randy Dunlap 2013-11-22 631 *
> 838de63b101147 Vlastimil Babka 2022-11-10 632 * %__GFP_ZERO
> 838de63b101147 Vlastimil Babka 2022-11-10 633 * Zero the allocated memory before returning. Also see kzalloc().
> 838de63b101147 Vlastimil Babka 2022-11-10 634 *
> 01598ba6b1a863 Mike Rapoport 2018-11-11 635 * %__GFP_HIGH
> 01598ba6b1a863 Mike Rapoport 2018-11-11 636 * This allocation has high priority and may use emergency pools.
> 7e3528c3660a2e Randy Dunlap 2013-11-22 637 *
> 01598ba6b1a863 Mike Rapoport 2018-11-11 638 * %__GFP_NOFAIL
> 01598ba6b1a863 Mike Rapoport 2018-11-11 639 * Indicate that this allocation is in no way allowed to fail
> 7e3528c3660a2e Randy Dunlap 2013-11-22 640 * (think twice before using).
> 7e3528c3660a2e Randy Dunlap 2013-11-22 641 *
> 01598ba6b1a863 Mike Rapoport 2018-11-11 642 * %__GFP_NORETRY
> 01598ba6b1a863 Mike Rapoport 2018-11-11 643 * If memory is not immediately available,
> 7e3528c3660a2e Randy Dunlap 2013-11-22 644 * then give up at once.
> 7e3528c3660a2e Randy Dunlap 2013-11-22 645 *
> 01598ba6b1a863 Mike Rapoport 2018-11-11 646 * %__GFP_NOWARN
> 01598ba6b1a863 Mike Rapoport 2018-11-11 647 * If allocation fails, don't issue any warnings.
> 7e3528c3660a2e Randy Dunlap 2013-11-22 648 *
> 01598ba6b1a863 Mike Rapoport 2018-11-11 649 * %__GFP_RETRY_MAYFAIL
> 01598ba6b1a863 Mike Rapoport 2018-11-11 650 * Try really hard to succeed the allocation but fail
> dcda9b04713c3f Michal Hocko 2017-07-12 651 * eventually.
> f1b6eb6e6be149 Christoph Lameter 2013-09-04 652 */
> 7bd230a26648ac Suren Baghdasaryan 2024-03-21 653 static __always_inline __alloc_size(1) void *kmalloc_noprof(size_t size, gfp_t flags)
> f1b6eb6e6be149 Christoph Lameter 2013-09-04 654 {
> 6fa57d78aa7f21 Kees Cook 2022-11-17 655 if (__builtin_constant_p(size) && size) {
> cc252eae85e095 Vlastimil Babka 2018-10-26 656 unsigned int index;
> 3bf019334fbbb5 Kees Cook 2022-11-17 657
> f1b6eb6e6be149 Christoph Lameter 2013-09-04 658 if (size > KMALLOC_MAX_CACHE_SIZE)
> a0a44d9175b349 Vlastimil Babka 2024-05-27 659 return __kmalloc_large_noprof(size, flags);
> f1b6eb6e6be149 Christoph Lameter 2013-09-04 660
> cc252eae85e095 Vlastimil Babka 2018-10-26 661 index = kmalloc_index(size);
> a0a44d9175b349 Vlastimil Babka 2024-05-27 662 return __kmalloc_cache_noprof(
> 3c615294058429 GONG, Ruiqi 2023-07-14 @663 kmalloc_caches[kmalloc_type(flags, _RET_IP_)][index],
> f1b6eb6e6be149 Christoph Lameter 2013-09-04 664 flags, size);
> f1b6eb6e6be149 Christoph Lameter 2013-09-04 665 }
> 7bd230a26648ac Suren Baghdasaryan 2024-03-21 666 return __kmalloc_noprof(size, flags);
> f1b6eb6e6be149 Christoph Lameter 2013-09-04 667 }
> 7bd230a26648ac Suren Baghdasaryan 2024-03-21 668 #define kmalloc(...) alloc_hooks(kmalloc_noprof(__VA_ARGS__))
> ce6a50263d4dde Christoph Lameter 2013-01-10 669
>
> :::::: The code at line 663 was first introduced by commit
> :::::: 3c6152940584290668b35fa0800026f6a1ae05fe Randomized slab caches for kmalloc()
>
> :::::: TO: GONG, Ruiqi <gongruiqi@huaweicloud.com>
> :::::: CC: Vlastimil Babka <vbabka@suse.cz>
>
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: include/linux/slab.h:663:78: error: subscripted value is neither array nor pointer nor vector
2024-08-05 9:10 ` Vlastimil Babka
@ 2024-08-06 6:33 ` Philip Li
0 siblings, 0 replies; 7+ messages in thread
From: Philip Li @ 2024-08-06 6:33 UTC (permalink / raw)
To: Vlastimil Babka; +Cc: kernel test robot, Kees Cook, oe-kbuild-all, linux-kernel
On Mon, Aug 05, 2024 at 11:10:16AM +0200, Vlastimil Babka wrote:
> On 8/3/24 17:04, kernel test robot wrote:
> > Hi Kees,
> >
> > FYI, the error/warning still remains.
>
> But it's also still misattributed to this commit?
Sorry, we will avoid reporting against this commit in future.
>
> https://lore.kernel.org/all/CAMuHMdWMSpv1BbvCqf0Abfxf0sGp+5it-m1GtFR2nGuQ5-ZCAg@mail.gmail.com/
>
> > tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > head: 17712b7ea0756799635ba159cc773082230ed028
> > commit: 72e0fe2241ce113cbba339ca8c2450b167774530 mm/slab: Introduce kmem_buckets typedef
> > date: 4 weeks ago
> > config: m68k-alldefconfig (https://download.01.org/0day-ci/archive/20240803/202408032258.ShUXX4qU-lkp@intel.com/config)
> > compiler: m68k-linux-gcc (GCC) 14.1.0
> > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240803/202408032258.ShUXX4qU-lkp@intel.com/reproduce)
> >
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <lkp@intel.com>
> > | Closes: https://lore.kernel.org/oe-kbuild-all/202408032258.ShUXX4qU-lkp@intel.com/
> >
> > All errors (new ones prefixed by >>):
> >
> > arch/m68k/include/asm/page.h:10:25: error: 'CONFIG_PAGE_SHIFT' undeclared here (not in a function); did you mean 'CONFIG_LOG_BUF_SHIFT'?
> > 10 | #define PAGE_SHIFT CONFIG_PAGE_SHIFT
> > | ^~~~~~~~~~~~~~~~~
> > arch/m68k/include/asm/page.h:11:40: note: in expansion of macro 'PAGE_SHIFT'
> > 11 | #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
> > | ^~~~~~~~~~
> > arch/m68k/include/asm/thread_info.h:23:26: note: in expansion of macro 'PAGE_SIZE'
> > 23 | #define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
> > | ^~~~~~~~~
> > include/linux/sched.h:1851:29: note: in expansion of macro 'THREAD_SIZE'
> > 1851 | unsigned long stack[THREAD_SIZE/sizeof(long)];
> > | ^~~~~~~~~~~
> > arch/m68k/include/asm/page.h:10:25: warning: "CONFIG_PAGE_SHIFT" is not defined, evaluates to 0 [-Wundef]
> > 10 | #define PAGE_SHIFT CONFIG_PAGE_SHIFT
> > | ^~~~~~~~~~~~~~~~~
> > arch/m68k/include/asm/page.h:11:40: note: in expansion of macro 'PAGE_SHIFT'
> > 11 | #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
> > | ^~~~~~~~~~
> > include/linux/mm_types.h:531:6: note: in expansion of macro 'PAGE_SIZE'
> > 531 | #if (PAGE_SIZE < PAGE_FRAG_CACHE_MAX_SIZE)
> > | ^~~~~~~~~
> > In file included from include/vdso/const.h:5,
> > from include/linux/const.h:4,
> > from include/linux/bits.h:5,
> > from include/linux/ratelimit_types.h:5,
> > from include/linux/printk.h:9,
> > from include/asm-generic/bug.h:22,
> > from arch/m68k/include/asm/bug.h:32,
> > from include/linux/bug.h:5,
> > from include/linux/thread_info.h:13:
> > arch/m68k/include/asm/page.h:10:25: warning: "CONFIG_PAGE_SHIFT" is not defined, evaluates to 0 [-Wundef]
> > 10 | #define PAGE_SHIFT CONFIG_PAGE_SHIFT
> > | ^~~~~~~~~~~~~~~~~
> > include/uapi/linux/const.h:32:50: note: in definition of macro '__ALIGN_KERNEL_MASK'
> > 32 | #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
> > | ^~~~
> > include/linux/mm_types.h:508:41: note: in expansion of macro '__ALIGN_MASK'
> > 508 | #define PAGE_FRAG_CACHE_MAX_SIZE __ALIGN_MASK(32768, ~PAGE_MASK)
> > | ^~~~~~~~~~~~
> > arch/m68k/include/asm/page.h:11:40: note: in expansion of macro 'PAGE_SHIFT'
> > 11 | #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
> > | ^~~~~~~~~~
> > arch/m68k/include/asm/page.h:12:28: note: in expansion of macro 'PAGE_SIZE'
> > 12 | #define PAGE_MASK (~(PAGE_SIZE-1))
> > | ^~~~~~~~~
> > include/linux/mm_types.h:508:62: note: in expansion of macro 'PAGE_MASK'
> > 508 | #define PAGE_FRAG_CACHE_MAX_SIZE __ALIGN_MASK(32768, ~PAGE_MASK)
> > | ^~~~~~~~~
> > include/linux/mm_types.h:531:18: note: in expansion of macro 'PAGE_FRAG_CACHE_MAX_SIZE'
> > 531 | #if (PAGE_SIZE < PAGE_FRAG_CACHE_MAX_SIZE)
> > | ^~~~~~~~~~~~~~~~~~~~~~~~
> > arch/m68k/include/asm/page.h:10:25: warning: "CONFIG_PAGE_SHIFT" is not defined, evaluates to 0 [-Wundef]
> > 10 | #define PAGE_SHIFT CONFIG_PAGE_SHIFT
> > | ^~~~~~~~~~~~~~~~~
> > include/uapi/linux/const.h:32:61: note: in definition of macro '__ALIGN_KERNEL_MASK'
> > 32 | #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
> > | ^~~~
> > include/linux/mm_types.h:508:41: note: in expansion of macro '__ALIGN_MASK'
> > 508 | #define PAGE_FRAG_CACHE_MAX_SIZE __ALIGN_MASK(32768, ~PAGE_MASK)
> > | ^~~~~~~~~~~~
> > arch/m68k/include/asm/page.h:11:40: note: in expansion of macro 'PAGE_SHIFT'
> > 11 | #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
> > | ^~~~~~~~~~
> > arch/m68k/include/asm/page.h:12:28: note: in expansion of macro 'PAGE_SIZE'
> > 12 | #define PAGE_MASK (~(PAGE_SIZE-1))
> > | ^~~~~~~~~
> > include/linux/mm_types.h:508:62: note: in expansion of macro 'PAGE_MASK'
> > 508 | #define PAGE_FRAG_CACHE_MAX_SIZE __ALIGN_MASK(32768, ~PAGE_MASK)
> > | ^~~~~~~~~
> > include/linux/mm_types.h:531:18: note: in expansion of macro 'PAGE_FRAG_CACHE_MAX_SIZE'
> > 531 | #if (PAGE_SIZE < PAGE_FRAG_CACHE_MAX_SIZE)
> > | ^~~~~~~~~~~~~~~~~~~~~~~~
> > In file included from include/linux/init.h:5,
> > from include/linux/printk.h:6:
> > arch/m68k/include/asm/page.h:10:25: error: expression in static assertion is not an integer
> > 10 | #define PAGE_SHIFT CONFIG_PAGE_SHIFT
> > | ^~~~~~~~~~~~~~~~~
> > include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
> > 78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
> > | ^~~~
> > include/linux/slab.h:527:1: note: in expansion of macro 'static_assert'
> > 527 | static_assert(PAGE_SHIFT <= 20);
> > | ^~~~~~~~~~~~~
> > include/linux/slab.h:527:15: note: in expansion of macro 'PAGE_SHIFT'
> > 527 | static_assert(PAGE_SHIFT <= 20);
> > | ^~~~~~~~~~
> > In file included from include/linux/irq.h:21,
> > from include/asm-generic/hardirq.h:17,
> > from ./arch/m68k/include/generated/asm/hardirq.h:1,
> > from include/linux/hardirq.h:11,
> > from include/linux/interrupt.h:11,
> > from include/linux/kernel_stat.h:9,
> > from arch/m68k/kernel/asm-offsets.c:16:
> > include/linux/slab.h:593:33: warning: 'assume_aligned' attribute argument <erroneous-expression> is not an integer constant [-Wattributes]
> > 593 | __assume_page_alignment __alloc_size(1);
> > | ^~~~~~~~~~~~~~~~~~~~~~~
> > include/linux/slab.h:596:33: warning: 'assume_aligned' attribute argument <erroneous-expression> is not an integer constant [-Wattributes]
> > 596 | __assume_page_alignment __alloc_size(1);
> > | ^~~~~~~~~~~~~~~~~~~~~~~
> > include/linux/slab.h: In function 'kmalloc_noprof':
> >>> include/linux/slab.h:663:78: error: subscripted value is neither array nor pointer nor vector
> > 663 | kmalloc_caches[kmalloc_type(flags, _RET_IP_)][index],
> > | ^
> > include/linux/slab.h:656:30: warning: variable 'index' set but not used [-Wunused-but-set-variable]
> > 656 | unsigned int index;
> > | ^~~~~
> > include/linux/slab.h: In function 'kmalloc_node_noprof':
> > include/linux/slab.h:680:78: error: subscripted value is neither array nor pointer nor vector
> > 680 | kmalloc_caches[kmalloc_type(flags, _RET_IP_)][index],
> > | ^
> > include/linux/slab.h:673:30: warning: variable 'index' set but not used [-Wunused-but-set-variable]
> > 673 | unsigned int index;
> > | ^~~~~
> > make[3]: *** [scripts/Makefile.build:117: arch/m68k/kernel/asm-offsets.s] Error 1
> > make[3]: Target 'prepare' not remade because of errors.
> > make[2]: *** [Makefile:1208: prepare0] Error 2
> > make[2]: Target 'prepare' not remade because of errors.
> > make[1]: *** [Makefile:240: __sub-make] Error 2
> > make[1]: Target 'prepare' not remade because of errors.
> > make: *** [Makefile:240: __sub-make] Error 2
> > make: Target 'prepare' not remade because of errors.
> >
> >
> > vim +663 include/linux/slab.h
> >
> > f1b6eb6e6be149 Christoph Lameter 2013-09-04 572
> > a0a44d9175b349 Vlastimil Babka 2024-05-27 573 /*
> > a0a44d9175b349 Vlastimil Babka 2024-05-27 574 * The following functions are not to be used directly and are intended only
> > a0a44d9175b349 Vlastimil Babka 2024-05-27 575 * for internal use from kmalloc() and kmalloc_node()
> > a0a44d9175b349 Vlastimil Babka 2024-05-27 576 * with the exception of kunit tests
> > a0a44d9175b349 Vlastimil Babka 2024-05-27 577 */
> > a0a44d9175b349 Vlastimil Babka 2024-05-27 578
> > a0a44d9175b349 Vlastimil Babka 2024-05-27 579 void *__kmalloc_noprof(size_t size, gfp_t flags)
> > a0a44d9175b349 Vlastimil Babka 2024-05-27 580 __assume_kmalloc_alignment __alloc_size(1);
> > f1b6eb6e6be149 Christoph Lameter 2013-09-04 581
> > a0a44d9175b349 Vlastimil Babka 2024-05-27 582 void *__kmalloc_node_noprof(size_t size, gfp_t flags, int node)
> > a0a44d9175b349 Vlastimil Babka 2024-05-27 583 __assume_kmalloc_alignment __alloc_size(1);
> > a0a44d9175b349 Vlastimil Babka 2024-05-27 584
> > a0a44d9175b349 Vlastimil Babka 2024-05-27 585 void *__kmalloc_cache_noprof(struct kmem_cache *s, gfp_t flags, size_t size)
> > a0a44d9175b349 Vlastimil Babka 2024-05-27 586 __assume_kmalloc_alignment __alloc_size(3);
> > 7bd230a26648ac Suren Baghdasaryan 2024-03-21 587
> > a0a44d9175b349 Vlastimil Babka 2024-05-27 588 void *__kmalloc_cache_node_noprof(struct kmem_cache *s, gfp_t gfpflags,
> > a0a44d9175b349 Vlastimil Babka 2024-05-27 589 int node, size_t size)
> > a0a44d9175b349 Vlastimil Babka 2024-05-27 590 __assume_kmalloc_alignment __alloc_size(4);
> > 7bd230a26648ac Suren Baghdasaryan 2024-03-21 591
> > a0a44d9175b349 Vlastimil Babka 2024-05-27 592 void *__kmalloc_large_noprof(size_t size, gfp_t flags)
> > a0a44d9175b349 Vlastimil Babka 2024-05-27 @593 __assume_page_alignment __alloc_size(1);
> > a0c3b940023eef Hyeonggon Yoo 2022-08-17 594
> > a0a44d9175b349 Vlastimil Babka 2024-05-27 595 void *__kmalloc_large_node_noprof(size_t size, gfp_t flags, int node)
> > a0a44d9175b349 Vlastimil Babka 2024-05-27 596 __assume_page_alignment __alloc_size(1);
> > a0c3b940023eef Hyeonggon Yoo 2022-08-17 597
> > f1b6eb6e6be149 Christoph Lameter 2013-09-04 598 /**
> > 838de63b101147 Vlastimil Babka 2022-11-10 599 * kmalloc - allocate kernel memory
> > f1b6eb6e6be149 Christoph Lameter 2013-09-04 600 * @size: how many bytes of memory are required.
> > 838de63b101147 Vlastimil Babka 2022-11-10 601 * @flags: describe the allocation context
> > f1b6eb6e6be149 Christoph Lameter 2013-09-04 602 *
> > f1b6eb6e6be149 Christoph Lameter 2013-09-04 603 * kmalloc is the normal method of allocating memory
> > f1b6eb6e6be149 Christoph Lameter 2013-09-04 604 * for objects smaller than page size in the kernel.
> > 7e3528c3660a2e Randy Dunlap 2013-11-22 605 *
> > 59bb47985c1db2 Vlastimil Babka 2019-10-06 606 * The allocated object address is aligned to at least ARCH_KMALLOC_MINALIGN
> > 59bb47985c1db2 Vlastimil Babka 2019-10-06 607 * bytes. For @size of power of two bytes, the alignment is also guaranteed
> > ad59baa3169591 Vlastimil Babka 2024-07-03 608 * to be at least to the size. For other sizes, the alignment is guaranteed to
> > ad59baa3169591 Vlastimil Babka 2024-07-03 609 * be at least the largest power-of-two divisor of @size.
> > 59bb47985c1db2 Vlastimil Babka 2019-10-06 610 *
> > 01598ba6b1a863 Mike Rapoport 2018-11-11 611 * The @flags argument may be one of the GFP flags defined at
> > e9d198f2be851f Thorsten Scherer 2023-03-12 612 * include/linux/gfp_types.h and described at
> > 01598ba6b1a863 Mike Rapoport 2018-11-11 613 * :ref:`Documentation/core-api/mm-api.rst <mm-api-gfp-flags>`
> > 7e3528c3660a2e Randy Dunlap 2013-11-22 614 *
> > 01598ba6b1a863 Mike Rapoport 2018-11-11 615 * The recommended usage of the @flags is described at
> > 2370ae4b1d5aa7 Mauro Carvalho Chehab 2020-04-10 616 * :ref:`Documentation/core-api/memory-allocation.rst <memory_allocation>`
> > 7e3528c3660a2e Randy Dunlap 2013-11-22 617 *
> > 01598ba6b1a863 Mike Rapoport 2018-11-11 618 * Below is a brief outline of the most useful GFP flags
> > 7e3528c3660a2e Randy Dunlap 2013-11-22 619 *
> > 01598ba6b1a863 Mike Rapoport 2018-11-11 620 * %GFP_KERNEL
> > 01598ba6b1a863 Mike Rapoport 2018-11-11 621 * Allocate normal kernel ram. May sleep.
> > 7e3528c3660a2e Randy Dunlap 2013-11-22 622 *
> > 01598ba6b1a863 Mike Rapoport 2018-11-11 623 * %GFP_NOWAIT
> > 01598ba6b1a863 Mike Rapoport 2018-11-11 624 * Allocation will not sleep.
> > 7e3528c3660a2e Randy Dunlap 2013-11-22 625 *
> > 01598ba6b1a863 Mike Rapoport 2018-11-11 626 * %GFP_ATOMIC
> > 01598ba6b1a863 Mike Rapoport 2018-11-11 627 * Allocation will not sleep. May use emergency pools.
> > 7e3528c3660a2e Randy Dunlap 2013-11-22 628 *
> > 7e3528c3660a2e Randy Dunlap 2013-11-22 629 * Also it is possible to set different flags by OR'ing
> > 7e3528c3660a2e Randy Dunlap 2013-11-22 630 * in one or more of the following additional @flags:
> > 7e3528c3660a2e Randy Dunlap 2013-11-22 631 *
> > 838de63b101147 Vlastimil Babka 2022-11-10 632 * %__GFP_ZERO
> > 838de63b101147 Vlastimil Babka 2022-11-10 633 * Zero the allocated memory before returning. Also see kzalloc().
> > 838de63b101147 Vlastimil Babka 2022-11-10 634 *
> > 01598ba6b1a863 Mike Rapoport 2018-11-11 635 * %__GFP_HIGH
> > 01598ba6b1a863 Mike Rapoport 2018-11-11 636 * This allocation has high priority and may use emergency pools.
> > 7e3528c3660a2e Randy Dunlap 2013-11-22 637 *
> > 01598ba6b1a863 Mike Rapoport 2018-11-11 638 * %__GFP_NOFAIL
> > 01598ba6b1a863 Mike Rapoport 2018-11-11 639 * Indicate that this allocation is in no way allowed to fail
> > 7e3528c3660a2e Randy Dunlap 2013-11-22 640 * (think twice before using).
> > 7e3528c3660a2e Randy Dunlap 2013-11-22 641 *
> > 01598ba6b1a863 Mike Rapoport 2018-11-11 642 * %__GFP_NORETRY
> > 01598ba6b1a863 Mike Rapoport 2018-11-11 643 * If memory is not immediately available,
> > 7e3528c3660a2e Randy Dunlap 2013-11-22 644 * then give up at once.
> > 7e3528c3660a2e Randy Dunlap 2013-11-22 645 *
> > 01598ba6b1a863 Mike Rapoport 2018-11-11 646 * %__GFP_NOWARN
> > 01598ba6b1a863 Mike Rapoport 2018-11-11 647 * If allocation fails, don't issue any warnings.
> > 7e3528c3660a2e Randy Dunlap 2013-11-22 648 *
> > 01598ba6b1a863 Mike Rapoport 2018-11-11 649 * %__GFP_RETRY_MAYFAIL
> > 01598ba6b1a863 Mike Rapoport 2018-11-11 650 * Try really hard to succeed the allocation but fail
> > dcda9b04713c3f Michal Hocko 2017-07-12 651 * eventually.
> > f1b6eb6e6be149 Christoph Lameter 2013-09-04 652 */
> > 7bd230a26648ac Suren Baghdasaryan 2024-03-21 653 static __always_inline __alloc_size(1) void *kmalloc_noprof(size_t size, gfp_t flags)
> > f1b6eb6e6be149 Christoph Lameter 2013-09-04 654 {
> > 6fa57d78aa7f21 Kees Cook 2022-11-17 655 if (__builtin_constant_p(size) && size) {
> > cc252eae85e095 Vlastimil Babka 2018-10-26 656 unsigned int index;
> > 3bf019334fbbb5 Kees Cook 2022-11-17 657
> > f1b6eb6e6be149 Christoph Lameter 2013-09-04 658 if (size > KMALLOC_MAX_CACHE_SIZE)
> > a0a44d9175b349 Vlastimil Babka 2024-05-27 659 return __kmalloc_large_noprof(size, flags);
> > f1b6eb6e6be149 Christoph Lameter 2013-09-04 660
> > cc252eae85e095 Vlastimil Babka 2018-10-26 661 index = kmalloc_index(size);
> > a0a44d9175b349 Vlastimil Babka 2024-05-27 662 return __kmalloc_cache_noprof(
> > 3c615294058429 GONG, Ruiqi 2023-07-14 @663 kmalloc_caches[kmalloc_type(flags, _RET_IP_)][index],
> > f1b6eb6e6be149 Christoph Lameter 2013-09-04 664 flags, size);
> > f1b6eb6e6be149 Christoph Lameter 2013-09-04 665 }
> > 7bd230a26648ac Suren Baghdasaryan 2024-03-21 666 return __kmalloc_noprof(size, flags);
> > f1b6eb6e6be149 Christoph Lameter 2013-09-04 667 }
> > 7bd230a26648ac Suren Baghdasaryan 2024-03-21 668 #define kmalloc(...) alloc_hooks(kmalloc_noprof(__VA_ARGS__))
> > ce6a50263d4dde Christoph Lameter 2013-01-10 669
> >
> > :::::: The code at line 663 was first introduced by commit
> > :::::: 3c6152940584290668b35fa0800026f6a1ae05fe Randomized slab caches for kmalloc()
> >
> > :::::: TO: GONG, Ruiqi <gongruiqi@huaweicloud.com>
> > :::::: CC: Vlastimil Babka <vbabka@suse.cz>
> >
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* include/linux/slab.h:663:78: error: subscripted value is neither array nor pointer nor vector
@ 2024-07-19 20:02 kernel test robot
2024-07-22 7:14 ` Vlastimil Babka
0 siblings, 1 reply; 7+ messages in thread
From: kernel test robot @ 2024-07-19 20:02 UTC (permalink / raw)
To: Kees Cook; +Cc: oe-kbuild-all, linux-kernel, Vlastimil Babka
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 4305ca0087dd99c3c3e0e2ac8a228b7e53a21c78
commit: 72e0fe2241ce113cbba339ca8c2450b167774530 mm/slab: Introduce kmem_buckets typedef
date: 2 weeks ago
config: m68k-alldefconfig (https://download.01.org/0day-ci/archive/20240720/202407200330.Mgxnq2Dq-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240720/202407200330.Mgxnq2Dq-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202407200330.Mgxnq2Dq-lkp@intel.com/
All errors (new ones prefixed by >>):
arch/m68k/include/asm/page.h:10:25: error: 'CONFIG_PAGE_SHIFT' undeclared here (not in a function); did you mean 'CONFIG_LOG_BUF_SHIFT'?
10 | #define PAGE_SHIFT CONFIG_PAGE_SHIFT
| ^~~~~~~~~~~~~~~~~
arch/m68k/include/asm/page.h:11:40: note: in expansion of macro 'PAGE_SHIFT'
11 | #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
| ^~~~~~~~~~
arch/m68k/include/asm/thread_info.h:23:26: note: in expansion of macro 'PAGE_SIZE'
23 | #define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
| ^~~~~~~~~
include/linux/sched.h:1851:29: note: in expansion of macro 'THREAD_SIZE'
1851 | unsigned long stack[THREAD_SIZE/sizeof(long)];
| ^~~~~~~~~~~
arch/m68k/include/asm/page.h:10:25: warning: "CONFIG_PAGE_SHIFT" is not defined, evaluates to 0 [-Wundef]
10 | #define PAGE_SHIFT CONFIG_PAGE_SHIFT
| ^~~~~~~~~~~~~~~~~
arch/m68k/include/asm/page.h:11:40: note: in expansion of macro 'PAGE_SHIFT'
11 | #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
| ^~~~~~~~~~
include/linux/mm_types.h:531:6: note: in expansion of macro 'PAGE_SIZE'
531 | #if (PAGE_SIZE < PAGE_FRAG_CACHE_MAX_SIZE)
| ^~~~~~~~~
In file included from include/vdso/const.h:5,
from include/linux/const.h:4,
from include/linux/bits.h:5,
from include/linux/ratelimit_types.h:5,
from include/linux/printk.h:9,
from include/asm-generic/bug.h:22,
from arch/m68k/include/asm/bug.h:32,
from include/linux/bug.h:5,
from include/linux/thread_info.h:13:
arch/m68k/include/asm/page.h:10:25: warning: "CONFIG_PAGE_SHIFT" is not defined, evaluates to 0 [-Wundef]
10 | #define PAGE_SHIFT CONFIG_PAGE_SHIFT
| ^~~~~~~~~~~~~~~~~
include/uapi/linux/const.h:32:50: note: in definition of macro '__ALIGN_KERNEL_MASK'
32 | #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
| ^~~~
include/linux/mm_types.h:508:41: note: in expansion of macro '__ALIGN_MASK'
508 | #define PAGE_FRAG_CACHE_MAX_SIZE __ALIGN_MASK(32768, ~PAGE_MASK)
| ^~~~~~~~~~~~
arch/m68k/include/asm/page.h:11:40: note: in expansion of macro 'PAGE_SHIFT'
11 | #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
| ^~~~~~~~~~
arch/m68k/include/asm/page.h:12:28: note: in expansion of macro 'PAGE_SIZE'
12 | #define PAGE_MASK (~(PAGE_SIZE-1))
| ^~~~~~~~~
include/linux/mm_types.h:508:62: note: in expansion of macro 'PAGE_MASK'
508 | #define PAGE_FRAG_CACHE_MAX_SIZE __ALIGN_MASK(32768, ~PAGE_MASK)
| ^~~~~~~~~
include/linux/mm_types.h:531:18: note: in expansion of macro 'PAGE_FRAG_CACHE_MAX_SIZE'
531 | #if (PAGE_SIZE < PAGE_FRAG_CACHE_MAX_SIZE)
| ^~~~~~~~~~~~~~~~~~~~~~~~
arch/m68k/include/asm/page.h:10:25: warning: "CONFIG_PAGE_SHIFT" is not defined, evaluates to 0 [-Wundef]
10 | #define PAGE_SHIFT CONFIG_PAGE_SHIFT
| ^~~~~~~~~~~~~~~~~
include/uapi/linux/const.h:32:61: note: in definition of macro '__ALIGN_KERNEL_MASK'
32 | #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
| ^~~~
include/linux/mm_types.h:508:41: note: in expansion of macro '__ALIGN_MASK'
508 | #define PAGE_FRAG_CACHE_MAX_SIZE __ALIGN_MASK(32768, ~PAGE_MASK)
| ^~~~~~~~~~~~
arch/m68k/include/asm/page.h:11:40: note: in expansion of macro 'PAGE_SHIFT'
11 | #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
| ^~~~~~~~~~
arch/m68k/include/asm/page.h:12:28: note: in expansion of macro 'PAGE_SIZE'
12 | #define PAGE_MASK (~(PAGE_SIZE-1))
| ^~~~~~~~~
include/linux/mm_types.h:508:62: note: in expansion of macro 'PAGE_MASK'
508 | #define PAGE_FRAG_CACHE_MAX_SIZE __ALIGN_MASK(32768, ~PAGE_MASK)
| ^~~~~~~~~
include/linux/mm_types.h:531:18: note: in expansion of macro 'PAGE_FRAG_CACHE_MAX_SIZE'
531 | #if (PAGE_SIZE < PAGE_FRAG_CACHE_MAX_SIZE)
| ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from include/linux/init.h:5,
from include/linux/printk.h:6:
arch/m68k/include/asm/page.h:10:25: error: expression in static assertion is not an integer
10 | #define PAGE_SHIFT CONFIG_PAGE_SHIFT
| ^~~~~~~~~~~~~~~~~
include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~
include/linux/slab.h:527:1: note: in expansion of macro 'static_assert'
527 | static_assert(PAGE_SHIFT <= 20);
| ^~~~~~~~~~~~~
include/linux/slab.h:527:15: note: in expansion of macro 'PAGE_SHIFT'
527 | static_assert(PAGE_SHIFT <= 20);
| ^~~~~~~~~~
In file included from include/linux/irq.h:21,
from include/asm-generic/hardirq.h:17,
from ./arch/m68k/include/generated/asm/hardirq.h:1,
from include/linux/hardirq.h:11,
from include/linux/interrupt.h:11,
from include/linux/kernel_stat.h:9,
from arch/m68k/kernel/asm-offsets.c:16:
include/linux/slab.h:593:33: warning: 'assume_aligned' attribute argument <erroneous-expression> is not an integer constant [-Wattributes]
593 | __assume_page_alignment __alloc_size(1);
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/slab.h:596:33: warning: 'assume_aligned' attribute argument <erroneous-expression> is not an integer constant [-Wattributes]
596 | __assume_page_alignment __alloc_size(1);
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/slab.h: In function 'kmalloc_noprof':
>> include/linux/slab.h:663:78: error: subscripted value is neither array nor pointer nor vector
663 | kmalloc_caches[kmalloc_type(flags, _RET_IP_)][index],
| ^
include/linux/slab.h:656:30: warning: variable 'index' set but not used [-Wunused-but-set-variable]
656 | unsigned int index;
| ^~~~~
include/linux/slab.h: In function 'kmalloc_node_noprof':
include/linux/slab.h:680:78: error: subscripted value is neither array nor pointer nor vector
680 | kmalloc_caches[kmalloc_type(flags, _RET_IP_)][index],
| ^
include/linux/slab.h:673:30: warning: variable 'index' set but not used [-Wunused-but-set-variable]
673 | unsigned int index;
| ^~~~~
make[3]: *** [scripts/Makefile.build:117: arch/m68k/kernel/asm-offsets.s] Error 1
make[3]: Target 'prepare' not remade because of errors.
make[2]: *** [Makefile:1208: prepare0] Error 2
make[2]: Target 'prepare' not remade because of errors.
make[1]: *** [Makefile:240: __sub-make] Error 2
make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:240: __sub-make] Error 2
make: Target 'prepare' not remade because of errors.
vim +663 include/linux/slab.h
f1b6eb6e6be149 Christoph Lameter 2013-09-04 572
a0a44d9175b349 Vlastimil Babka 2024-05-27 573 /*
a0a44d9175b349 Vlastimil Babka 2024-05-27 574 * The following functions are not to be used directly and are intended only
a0a44d9175b349 Vlastimil Babka 2024-05-27 575 * for internal use from kmalloc() and kmalloc_node()
a0a44d9175b349 Vlastimil Babka 2024-05-27 576 * with the exception of kunit tests
a0a44d9175b349 Vlastimil Babka 2024-05-27 577 */
a0a44d9175b349 Vlastimil Babka 2024-05-27 578
a0a44d9175b349 Vlastimil Babka 2024-05-27 579 void *__kmalloc_noprof(size_t size, gfp_t flags)
a0a44d9175b349 Vlastimil Babka 2024-05-27 580 __assume_kmalloc_alignment __alloc_size(1);
f1b6eb6e6be149 Christoph Lameter 2013-09-04 581
a0a44d9175b349 Vlastimil Babka 2024-05-27 582 void *__kmalloc_node_noprof(size_t size, gfp_t flags, int node)
a0a44d9175b349 Vlastimil Babka 2024-05-27 583 __assume_kmalloc_alignment __alloc_size(1);
a0a44d9175b349 Vlastimil Babka 2024-05-27 584
a0a44d9175b349 Vlastimil Babka 2024-05-27 585 void *__kmalloc_cache_noprof(struct kmem_cache *s, gfp_t flags, size_t size)
a0a44d9175b349 Vlastimil Babka 2024-05-27 586 __assume_kmalloc_alignment __alloc_size(3);
7bd230a26648ac Suren Baghdasaryan 2024-03-21 587
a0a44d9175b349 Vlastimil Babka 2024-05-27 588 void *__kmalloc_cache_node_noprof(struct kmem_cache *s, gfp_t gfpflags,
a0a44d9175b349 Vlastimil Babka 2024-05-27 589 int node, size_t size)
a0a44d9175b349 Vlastimil Babka 2024-05-27 590 __assume_kmalloc_alignment __alloc_size(4);
7bd230a26648ac Suren Baghdasaryan 2024-03-21 591
a0a44d9175b349 Vlastimil Babka 2024-05-27 592 void *__kmalloc_large_noprof(size_t size, gfp_t flags)
a0a44d9175b349 Vlastimil Babka 2024-05-27 593 __assume_page_alignment __alloc_size(1);
a0c3b940023eef Hyeonggon Yoo 2022-08-17 594
a0a44d9175b349 Vlastimil Babka 2024-05-27 595 void *__kmalloc_large_node_noprof(size_t size, gfp_t flags, int node)
a0a44d9175b349 Vlastimil Babka 2024-05-27 596 __assume_page_alignment __alloc_size(1);
a0c3b940023eef Hyeonggon Yoo 2022-08-17 597
f1b6eb6e6be149 Christoph Lameter 2013-09-04 598 /**
838de63b101147 Vlastimil Babka 2022-11-10 599 * kmalloc - allocate kernel memory
f1b6eb6e6be149 Christoph Lameter 2013-09-04 600 * @size: how many bytes of memory are required.
838de63b101147 Vlastimil Babka 2022-11-10 601 * @flags: describe the allocation context
f1b6eb6e6be149 Christoph Lameter 2013-09-04 602 *
f1b6eb6e6be149 Christoph Lameter 2013-09-04 603 * kmalloc is the normal method of allocating memory
f1b6eb6e6be149 Christoph Lameter 2013-09-04 604 * for objects smaller than page size in the kernel.
7e3528c3660a2e Randy Dunlap 2013-11-22 605 *
59bb47985c1db2 Vlastimil Babka 2019-10-06 606 * The allocated object address is aligned to at least ARCH_KMALLOC_MINALIGN
59bb47985c1db2 Vlastimil Babka 2019-10-06 607 * bytes. For @size of power of two bytes, the alignment is also guaranteed
ad59baa3169591 Vlastimil Babka 2024-07-03 608 * to be at least to the size. For other sizes, the alignment is guaranteed to
ad59baa3169591 Vlastimil Babka 2024-07-03 609 * be at least the largest power-of-two divisor of @size.
59bb47985c1db2 Vlastimil Babka 2019-10-06 610 *
01598ba6b1a863 Mike Rapoport 2018-11-11 611 * The @flags argument may be one of the GFP flags defined at
e9d198f2be851f Thorsten Scherer 2023-03-12 612 * include/linux/gfp_types.h and described at
01598ba6b1a863 Mike Rapoport 2018-11-11 613 * :ref:`Documentation/core-api/mm-api.rst <mm-api-gfp-flags>`
7e3528c3660a2e Randy Dunlap 2013-11-22 614 *
01598ba6b1a863 Mike Rapoport 2018-11-11 615 * The recommended usage of the @flags is described at
2370ae4b1d5aa7 Mauro Carvalho Chehab 2020-04-10 616 * :ref:`Documentation/core-api/memory-allocation.rst <memory_allocation>`
7e3528c3660a2e Randy Dunlap 2013-11-22 617 *
01598ba6b1a863 Mike Rapoport 2018-11-11 618 * Below is a brief outline of the most useful GFP flags
7e3528c3660a2e Randy Dunlap 2013-11-22 619 *
01598ba6b1a863 Mike Rapoport 2018-11-11 620 * %GFP_KERNEL
01598ba6b1a863 Mike Rapoport 2018-11-11 621 * Allocate normal kernel ram. May sleep.
7e3528c3660a2e Randy Dunlap 2013-11-22 622 *
01598ba6b1a863 Mike Rapoport 2018-11-11 623 * %GFP_NOWAIT
01598ba6b1a863 Mike Rapoport 2018-11-11 624 * Allocation will not sleep.
7e3528c3660a2e Randy Dunlap 2013-11-22 625 *
01598ba6b1a863 Mike Rapoport 2018-11-11 626 * %GFP_ATOMIC
01598ba6b1a863 Mike Rapoport 2018-11-11 627 * Allocation will not sleep. May use emergency pools.
7e3528c3660a2e Randy Dunlap 2013-11-22 628 *
7e3528c3660a2e Randy Dunlap 2013-11-22 629 * Also it is possible to set different flags by OR'ing
7e3528c3660a2e Randy Dunlap 2013-11-22 630 * in one or more of the following additional @flags:
7e3528c3660a2e Randy Dunlap 2013-11-22 631 *
838de63b101147 Vlastimil Babka 2022-11-10 632 * %__GFP_ZERO
838de63b101147 Vlastimil Babka 2022-11-10 633 * Zero the allocated memory before returning. Also see kzalloc().
838de63b101147 Vlastimil Babka 2022-11-10 634 *
01598ba6b1a863 Mike Rapoport 2018-11-11 635 * %__GFP_HIGH
01598ba6b1a863 Mike Rapoport 2018-11-11 636 * This allocation has high priority and may use emergency pools.
7e3528c3660a2e Randy Dunlap 2013-11-22 637 *
01598ba6b1a863 Mike Rapoport 2018-11-11 638 * %__GFP_NOFAIL
01598ba6b1a863 Mike Rapoport 2018-11-11 639 * Indicate that this allocation is in no way allowed to fail
7e3528c3660a2e Randy Dunlap 2013-11-22 640 * (think twice before using).
7e3528c3660a2e Randy Dunlap 2013-11-22 641 *
01598ba6b1a863 Mike Rapoport 2018-11-11 642 * %__GFP_NORETRY
01598ba6b1a863 Mike Rapoport 2018-11-11 643 * If memory is not immediately available,
7e3528c3660a2e Randy Dunlap 2013-11-22 644 * then give up at once.
7e3528c3660a2e Randy Dunlap 2013-11-22 645 *
01598ba6b1a863 Mike Rapoport 2018-11-11 646 * %__GFP_NOWARN
01598ba6b1a863 Mike Rapoport 2018-11-11 647 * If allocation fails, don't issue any warnings.
7e3528c3660a2e Randy Dunlap 2013-11-22 648 *
01598ba6b1a863 Mike Rapoport 2018-11-11 649 * %__GFP_RETRY_MAYFAIL
01598ba6b1a863 Mike Rapoport 2018-11-11 650 * Try really hard to succeed the allocation but fail
dcda9b04713c3f Michal Hocko 2017-07-12 651 * eventually.
f1b6eb6e6be149 Christoph Lameter 2013-09-04 652 */
7bd230a26648ac Suren Baghdasaryan 2024-03-21 653 static __always_inline __alloc_size(1) void *kmalloc_noprof(size_t size, gfp_t flags)
f1b6eb6e6be149 Christoph Lameter 2013-09-04 654 {
6fa57d78aa7f21 Kees Cook 2022-11-17 655 if (__builtin_constant_p(size) && size) {
cc252eae85e095 Vlastimil Babka 2018-10-26 656 unsigned int index;
3bf019334fbbb5 Kees Cook 2022-11-17 657
f1b6eb6e6be149 Christoph Lameter 2013-09-04 658 if (size > KMALLOC_MAX_CACHE_SIZE)
a0a44d9175b349 Vlastimil Babka 2024-05-27 659 return __kmalloc_large_noprof(size, flags);
f1b6eb6e6be149 Christoph Lameter 2013-09-04 660
cc252eae85e095 Vlastimil Babka 2018-10-26 661 index = kmalloc_index(size);
a0a44d9175b349 Vlastimil Babka 2024-05-27 662 return __kmalloc_cache_noprof(
3c615294058429 GONG, Ruiqi 2023-07-14 @663 kmalloc_caches[kmalloc_type(flags, _RET_IP_)][index],
f1b6eb6e6be149 Christoph Lameter 2013-09-04 664 flags, size);
f1b6eb6e6be149 Christoph Lameter 2013-09-04 665 }
7bd230a26648ac Suren Baghdasaryan 2024-03-21 666 return __kmalloc_noprof(size, flags);
f1b6eb6e6be149 Christoph Lameter 2013-09-04 667 }
7bd230a26648ac Suren Baghdasaryan 2024-03-21 668 #define kmalloc(...) alloc_hooks(kmalloc_noprof(__VA_ARGS__))
ce6a50263d4dde Christoph Lameter 2013-01-10 669
:::::: The code at line 663 was first introduced by commit
:::::: 3c6152940584290668b35fa0800026f6a1ae05fe Randomized slab caches for kmalloc()
:::::: TO: GONG, Ruiqi <gongruiqi@huaweicloud.com>
:::::: CC: Vlastimil Babka <vbabka@suse.cz>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: include/linux/slab.h:663:78: error: subscripted value is neither array nor pointer nor vector
2024-07-19 20:02 kernel test robot
@ 2024-07-22 7:14 ` Vlastimil Babka
2024-07-22 7:48 ` Geert Uytterhoeven
0 siblings, 1 reply; 7+ messages in thread
From: Vlastimil Babka @ 2024-07-22 7:14 UTC (permalink / raw)
To: kernel test robot, Kees Cook; +Cc: oe-kbuild-all, linux-kernel
On 7/19/24 10:02 PM, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: 4305ca0087dd99c3c3e0e2ac8a228b7e53a21c78
> commit: 72e0fe2241ce113cbba339ca8c2450b167774530 mm/slab: Introduce kmem_buckets typedef
> date: 2 weeks ago
> config: m68k-alldefconfig (https://download.01.org/0day-ci/archive/20240720/202407200330.Mgxnq2Dq-lkp@intel.com/config)
> compiler: m68k-linux-gcc (GCC) 14.1.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240720/202407200330.Mgxnq2Dq-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202407200330.Mgxnq2Dq-lkp@intel.com/
>
> All errors (new ones prefixed by >>):
Hm the new error ettributed to slab seems just a consequence of the broken
PAGE_SHIFT? Although it's not listed here in the errors for some reason, I
assume without PAGE_SHIFT we don't have KMALLOC_SHIFT_HIGH thus we don't
have kmem_buckets typedef and thus kmalloc_caches is who knows what and thus
doesn't look like an array? And the broken PAGE_SHIFT has to be cause by
something else.
> arch/m68k/include/asm/page.h:10:25: error: 'CONFIG_PAGE_SHIFT' undeclared here (not in a function); did you mean 'CONFIG_LOG_BUF_SHIFT'?
> 10 | #define PAGE_SHIFT CONFIG_PAGE_SHIFT
> | ^~~~~~~~~~~~~~~~~
> arch/m68k/include/asm/page.h:11:40: note: in expansion of macro 'PAGE_SHIFT'
> 11 | #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
> | ^~~~~~~~~~
> arch/m68k/include/asm/thread_info.h:23:26: note: in expansion of macro 'PAGE_SIZE'
> 23 | #define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
> | ^~~~~~~~~
> include/linux/sched.h:1851:29: note: in expansion of macro 'THREAD_SIZE'
> 1851 | unsigned long stack[THREAD_SIZE/sizeof(long)];
> | ^~~~~~~~~~~
> arch/m68k/include/asm/page.h:10:25: warning: "CONFIG_PAGE_SHIFT" is not defined, evaluates to 0 [-Wundef]
> 10 | #define PAGE_SHIFT CONFIG_PAGE_SHIFT
> | ^~~~~~~~~~~~~~~~~
> arch/m68k/include/asm/page.h:11:40: note: in expansion of macro 'PAGE_SHIFT'
> 11 | #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
> | ^~~~~~~~~~
> include/linux/mm_types.h:531:6: note: in expansion of macro 'PAGE_SIZE'
> 531 | #if (PAGE_SIZE < PAGE_FRAG_CACHE_MAX_SIZE)
> | ^~~~~~~~~
> In file included from include/vdso/const.h:5,
> from include/linux/const.h:4,
> from include/linux/bits.h:5,
> from include/linux/ratelimit_types.h:5,
> from include/linux/printk.h:9,
> from include/asm-generic/bug.h:22,
> from arch/m68k/include/asm/bug.h:32,
> from include/linux/bug.h:5,
> from include/linux/thread_info.h:13:
> arch/m68k/include/asm/page.h:10:25: warning: "CONFIG_PAGE_SHIFT" is not defined, evaluates to 0 [-Wundef]
> 10 | #define PAGE_SHIFT CONFIG_PAGE_SHIFT
> | ^~~~~~~~~~~~~~~~~
> include/uapi/linux/const.h:32:50: note: in definition of macro '__ALIGN_KERNEL_MASK'
> 32 | #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
> | ^~~~
> include/linux/mm_types.h:508:41: note: in expansion of macro '__ALIGN_MASK'
> 508 | #define PAGE_FRAG_CACHE_MAX_SIZE __ALIGN_MASK(32768, ~PAGE_MASK)
> | ^~~~~~~~~~~~
> arch/m68k/include/asm/page.h:11:40: note: in expansion of macro 'PAGE_SHIFT'
> 11 | #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
> | ^~~~~~~~~~
> arch/m68k/include/asm/page.h:12:28: note: in expansion of macro 'PAGE_SIZE'
> 12 | #define PAGE_MASK (~(PAGE_SIZE-1))
> | ^~~~~~~~~
> include/linux/mm_types.h:508:62: note: in expansion of macro 'PAGE_MASK'
> 508 | #define PAGE_FRAG_CACHE_MAX_SIZE __ALIGN_MASK(32768, ~PAGE_MASK)
> | ^~~~~~~~~
> include/linux/mm_types.h:531:18: note: in expansion of macro 'PAGE_FRAG_CACHE_MAX_SIZE'
> 531 | #if (PAGE_SIZE < PAGE_FRAG_CACHE_MAX_SIZE)
> | ^~~~~~~~~~~~~~~~~~~~~~~~
> arch/m68k/include/asm/page.h:10:25: warning: "CONFIG_PAGE_SHIFT" is not defined, evaluates to 0 [-Wundef]
> 10 | #define PAGE_SHIFT CONFIG_PAGE_SHIFT
> | ^~~~~~~~~~~~~~~~~
> include/uapi/linux/const.h:32:61: note: in definition of macro '__ALIGN_KERNEL_MASK'
> 32 | #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
> | ^~~~
> include/linux/mm_types.h:508:41: note: in expansion of macro '__ALIGN_MASK'
> 508 | #define PAGE_FRAG_CACHE_MAX_SIZE __ALIGN_MASK(32768, ~PAGE_MASK)
> | ^~~~~~~~~~~~
> arch/m68k/include/asm/page.h:11:40: note: in expansion of macro 'PAGE_SHIFT'
> 11 | #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
> | ^~~~~~~~~~
> arch/m68k/include/asm/page.h:12:28: note: in expansion of macro 'PAGE_SIZE'
> 12 | #define PAGE_MASK (~(PAGE_SIZE-1))
> | ^~~~~~~~~
> include/linux/mm_types.h:508:62: note: in expansion of macro 'PAGE_MASK'
> 508 | #define PAGE_FRAG_CACHE_MAX_SIZE __ALIGN_MASK(32768, ~PAGE_MASK)
> | ^~~~~~~~~
> include/linux/mm_types.h:531:18: note: in expansion of macro 'PAGE_FRAG_CACHE_MAX_SIZE'
> 531 | #if (PAGE_SIZE < PAGE_FRAG_CACHE_MAX_SIZE)
> | ^~~~~~~~~~~~~~~~~~~~~~~~
> In file included from include/linux/init.h:5,
> from include/linux/printk.h:6:
> arch/m68k/include/asm/page.h:10:25: error: expression in static assertion is not an integer
> 10 | #define PAGE_SHIFT CONFIG_PAGE_SHIFT
> | ^~~~~~~~~~~~~~~~~
> include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
> 78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
> | ^~~~
> include/linux/slab.h:527:1: note: in expansion of macro 'static_assert'
> 527 | static_assert(PAGE_SHIFT <= 20);
> | ^~~~~~~~~~~~~
> include/linux/slab.h:527:15: note: in expansion of macro 'PAGE_SHIFT'
> 527 | static_assert(PAGE_SHIFT <= 20);
> | ^~~~~~~~~~
> In file included from include/linux/irq.h:21,
> from include/asm-generic/hardirq.h:17,
> from ./arch/m68k/include/generated/asm/hardirq.h:1,
> from include/linux/hardirq.h:11,
> from include/linux/interrupt.h:11,
> from include/linux/kernel_stat.h:9,
> from arch/m68k/kernel/asm-offsets.c:16:
> include/linux/slab.h:593:33: warning: 'assume_aligned' attribute argument <erroneous-expression> is not an integer constant [-Wattributes]
> 593 | __assume_page_alignment __alloc_size(1);
> | ^~~~~~~~~~~~~~~~~~~~~~~
> include/linux/slab.h:596:33: warning: 'assume_aligned' attribute argument <erroneous-expression> is not an integer constant [-Wattributes]
> 596 | __assume_page_alignment __alloc_size(1);
> | ^~~~~~~~~~~~~~~~~~~~~~~
> include/linux/slab.h: In function 'kmalloc_noprof':
>>> include/linux/slab.h:663:78: error: subscripted value is neither array nor pointer nor vector
> 663 | kmalloc_caches[kmalloc_type(flags, _RET_IP_)][index],
> | ^
> include/linux/slab.h:656:30: warning: variable 'index' set but not used [-Wunused-but-set-variable]
> 656 | unsigned int index;
> | ^~~~~
> include/linux/slab.h: In function 'kmalloc_node_noprof':
> include/linux/slab.h:680:78: error: subscripted value is neither array nor pointer nor vector
> 680 | kmalloc_caches[kmalloc_type(flags, _RET_IP_)][index],
> | ^
> include/linux/slab.h:673:30: warning: variable 'index' set but not used [-Wunused-but-set-variable]
> 673 | unsigned int index;
> | ^~~~~
> make[3]: *** [scripts/Makefile.build:117: arch/m68k/kernel/asm-offsets.s] Error 1
> make[3]: Target 'prepare' not remade because of errors.
> make[2]: *** [Makefile:1208: prepare0] Error 2
> make[2]: Target 'prepare' not remade because of errors.
> make[1]: *** [Makefile:240: __sub-make] Error 2
> make[1]: Target 'prepare' not remade because of errors.
> make: *** [Makefile:240: __sub-make] Error 2
> make: Target 'prepare' not remade because of errors.
>
>
> vim +663 include/linux/slab.h
>
> f1b6eb6e6be149 Christoph Lameter 2013-09-04 572
> a0a44d9175b349 Vlastimil Babka 2024-05-27 573 /*
> a0a44d9175b349 Vlastimil Babka 2024-05-27 574 * The following functions are not to be used directly and are intended only
> a0a44d9175b349 Vlastimil Babka 2024-05-27 575 * for internal use from kmalloc() and kmalloc_node()
> a0a44d9175b349 Vlastimil Babka 2024-05-27 576 * with the exception of kunit tests
> a0a44d9175b349 Vlastimil Babka 2024-05-27 577 */
> a0a44d9175b349 Vlastimil Babka 2024-05-27 578
> a0a44d9175b349 Vlastimil Babka 2024-05-27 579 void *__kmalloc_noprof(size_t size, gfp_t flags)
> a0a44d9175b349 Vlastimil Babka 2024-05-27 580 __assume_kmalloc_alignment __alloc_size(1);
> f1b6eb6e6be149 Christoph Lameter 2013-09-04 581
> a0a44d9175b349 Vlastimil Babka 2024-05-27 582 void *__kmalloc_node_noprof(size_t size, gfp_t flags, int node)
> a0a44d9175b349 Vlastimil Babka 2024-05-27 583 __assume_kmalloc_alignment __alloc_size(1);
> a0a44d9175b349 Vlastimil Babka 2024-05-27 584
> a0a44d9175b349 Vlastimil Babka 2024-05-27 585 void *__kmalloc_cache_noprof(struct kmem_cache *s, gfp_t flags, size_t size)
> a0a44d9175b349 Vlastimil Babka 2024-05-27 586 __assume_kmalloc_alignment __alloc_size(3);
> 7bd230a26648ac Suren Baghdasaryan 2024-03-21 587
> a0a44d9175b349 Vlastimil Babka 2024-05-27 588 void *__kmalloc_cache_node_noprof(struct kmem_cache *s, gfp_t gfpflags,
> a0a44d9175b349 Vlastimil Babka 2024-05-27 589 int node, size_t size)
> a0a44d9175b349 Vlastimil Babka 2024-05-27 590 __assume_kmalloc_alignment __alloc_size(4);
> 7bd230a26648ac Suren Baghdasaryan 2024-03-21 591
> a0a44d9175b349 Vlastimil Babka 2024-05-27 592 void *__kmalloc_large_noprof(size_t size, gfp_t flags)
> a0a44d9175b349 Vlastimil Babka 2024-05-27 593 __assume_page_alignment __alloc_size(1);
> a0c3b940023eef Hyeonggon Yoo 2022-08-17 594
> a0a44d9175b349 Vlastimil Babka 2024-05-27 595 void *__kmalloc_large_node_noprof(size_t size, gfp_t flags, int node)
> a0a44d9175b349 Vlastimil Babka 2024-05-27 596 __assume_page_alignment __alloc_size(1);
> a0c3b940023eef Hyeonggon Yoo 2022-08-17 597
> f1b6eb6e6be149 Christoph Lameter 2013-09-04 598 /**
> 838de63b101147 Vlastimil Babka 2022-11-10 599 * kmalloc - allocate kernel memory
> f1b6eb6e6be149 Christoph Lameter 2013-09-04 600 * @size: how many bytes of memory are required.
> 838de63b101147 Vlastimil Babka 2022-11-10 601 * @flags: describe the allocation context
> f1b6eb6e6be149 Christoph Lameter 2013-09-04 602 *
> f1b6eb6e6be149 Christoph Lameter 2013-09-04 603 * kmalloc is the normal method of allocating memory
> f1b6eb6e6be149 Christoph Lameter 2013-09-04 604 * for objects smaller than page size in the kernel.
> 7e3528c3660a2e Randy Dunlap 2013-11-22 605 *
> 59bb47985c1db2 Vlastimil Babka 2019-10-06 606 * The allocated object address is aligned to at least ARCH_KMALLOC_MINALIGN
> 59bb47985c1db2 Vlastimil Babka 2019-10-06 607 * bytes. For @size of power of two bytes, the alignment is also guaranteed
> ad59baa3169591 Vlastimil Babka 2024-07-03 608 * to be at least to the size. For other sizes, the alignment is guaranteed to
> ad59baa3169591 Vlastimil Babka 2024-07-03 609 * be at least the largest power-of-two divisor of @size.
> 59bb47985c1db2 Vlastimil Babka 2019-10-06 610 *
> 01598ba6b1a863 Mike Rapoport 2018-11-11 611 * The @flags argument may be one of the GFP flags defined at
> e9d198f2be851f Thorsten Scherer 2023-03-12 612 * include/linux/gfp_types.h and described at
> 01598ba6b1a863 Mike Rapoport 2018-11-11 613 * :ref:`Documentation/core-api/mm-api.rst <mm-api-gfp-flags>`
> 7e3528c3660a2e Randy Dunlap 2013-11-22 614 *
> 01598ba6b1a863 Mike Rapoport 2018-11-11 615 * The recommended usage of the @flags is described at
> 2370ae4b1d5aa7 Mauro Carvalho Chehab 2020-04-10 616 * :ref:`Documentation/core-api/memory-allocation.rst <memory_allocation>`
> 7e3528c3660a2e Randy Dunlap 2013-11-22 617 *
> 01598ba6b1a863 Mike Rapoport 2018-11-11 618 * Below is a brief outline of the most useful GFP flags
> 7e3528c3660a2e Randy Dunlap 2013-11-22 619 *
> 01598ba6b1a863 Mike Rapoport 2018-11-11 620 * %GFP_KERNEL
> 01598ba6b1a863 Mike Rapoport 2018-11-11 621 * Allocate normal kernel ram. May sleep.
> 7e3528c3660a2e Randy Dunlap 2013-11-22 622 *
> 01598ba6b1a863 Mike Rapoport 2018-11-11 623 * %GFP_NOWAIT
> 01598ba6b1a863 Mike Rapoport 2018-11-11 624 * Allocation will not sleep.
> 7e3528c3660a2e Randy Dunlap 2013-11-22 625 *
> 01598ba6b1a863 Mike Rapoport 2018-11-11 626 * %GFP_ATOMIC
> 01598ba6b1a863 Mike Rapoport 2018-11-11 627 * Allocation will not sleep. May use emergency pools.
> 7e3528c3660a2e Randy Dunlap 2013-11-22 628 *
> 7e3528c3660a2e Randy Dunlap 2013-11-22 629 * Also it is possible to set different flags by OR'ing
> 7e3528c3660a2e Randy Dunlap 2013-11-22 630 * in one or more of the following additional @flags:
> 7e3528c3660a2e Randy Dunlap 2013-11-22 631 *
> 838de63b101147 Vlastimil Babka 2022-11-10 632 * %__GFP_ZERO
> 838de63b101147 Vlastimil Babka 2022-11-10 633 * Zero the allocated memory before returning. Also see kzalloc().
> 838de63b101147 Vlastimil Babka 2022-11-10 634 *
> 01598ba6b1a863 Mike Rapoport 2018-11-11 635 * %__GFP_HIGH
> 01598ba6b1a863 Mike Rapoport 2018-11-11 636 * This allocation has high priority and may use emergency pools.
> 7e3528c3660a2e Randy Dunlap 2013-11-22 637 *
> 01598ba6b1a863 Mike Rapoport 2018-11-11 638 * %__GFP_NOFAIL
> 01598ba6b1a863 Mike Rapoport 2018-11-11 639 * Indicate that this allocation is in no way allowed to fail
> 7e3528c3660a2e Randy Dunlap 2013-11-22 640 * (think twice before using).
> 7e3528c3660a2e Randy Dunlap 2013-11-22 641 *
> 01598ba6b1a863 Mike Rapoport 2018-11-11 642 * %__GFP_NORETRY
> 01598ba6b1a863 Mike Rapoport 2018-11-11 643 * If memory is not immediately available,
> 7e3528c3660a2e Randy Dunlap 2013-11-22 644 * then give up at once.
> 7e3528c3660a2e Randy Dunlap 2013-11-22 645 *
> 01598ba6b1a863 Mike Rapoport 2018-11-11 646 * %__GFP_NOWARN
> 01598ba6b1a863 Mike Rapoport 2018-11-11 647 * If allocation fails, don't issue any warnings.
> 7e3528c3660a2e Randy Dunlap 2013-11-22 648 *
> 01598ba6b1a863 Mike Rapoport 2018-11-11 649 * %__GFP_RETRY_MAYFAIL
> 01598ba6b1a863 Mike Rapoport 2018-11-11 650 * Try really hard to succeed the allocation but fail
> dcda9b04713c3f Michal Hocko 2017-07-12 651 * eventually.
> f1b6eb6e6be149 Christoph Lameter 2013-09-04 652 */
> 7bd230a26648ac Suren Baghdasaryan 2024-03-21 653 static __always_inline __alloc_size(1) void *kmalloc_noprof(size_t size, gfp_t flags)
> f1b6eb6e6be149 Christoph Lameter 2013-09-04 654 {
> 6fa57d78aa7f21 Kees Cook 2022-11-17 655 if (__builtin_constant_p(size) && size) {
> cc252eae85e095 Vlastimil Babka 2018-10-26 656 unsigned int index;
> 3bf019334fbbb5 Kees Cook 2022-11-17 657
> f1b6eb6e6be149 Christoph Lameter 2013-09-04 658 if (size > KMALLOC_MAX_CACHE_SIZE)
> a0a44d9175b349 Vlastimil Babka 2024-05-27 659 return __kmalloc_large_noprof(size, flags);
> f1b6eb6e6be149 Christoph Lameter 2013-09-04 660
> cc252eae85e095 Vlastimil Babka 2018-10-26 661 index = kmalloc_index(size);
> a0a44d9175b349 Vlastimil Babka 2024-05-27 662 return __kmalloc_cache_noprof(
> 3c615294058429 GONG, Ruiqi 2023-07-14 @663 kmalloc_caches[kmalloc_type(flags, _RET_IP_)][index],
> f1b6eb6e6be149 Christoph Lameter 2013-09-04 664 flags, size);
> f1b6eb6e6be149 Christoph Lameter 2013-09-04 665 }
> 7bd230a26648ac Suren Baghdasaryan 2024-03-21 666 return __kmalloc_noprof(size, flags);
> f1b6eb6e6be149 Christoph Lameter 2013-09-04 667 }
> 7bd230a26648ac Suren Baghdasaryan 2024-03-21 668 #define kmalloc(...) alloc_hooks(kmalloc_noprof(__VA_ARGS__))
> ce6a50263d4dde Christoph Lameter 2013-01-10 669
>
> :::::: The code at line 663 was first introduced by commit
> :::::: 3c6152940584290668b35fa0800026f6a1ae05fe Randomized slab caches for kmalloc()
>
> :::::: TO: GONG, Ruiqi <gongruiqi@huaweicloud.com>
> :::::: CC: Vlastimil Babka <vbabka@suse.cz>
>
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: include/linux/slab.h:663:78: error: subscripted value is neither array nor pointer nor vector
2024-07-22 7:14 ` Vlastimil Babka
@ 2024-07-22 7:48 ` Geert Uytterhoeven
2024-07-22 9:22 ` Arnd Bergmann
0 siblings, 1 reply; 7+ messages in thread
From: Geert Uytterhoeven @ 2024-07-22 7:48 UTC (permalink / raw)
To: Vlastimil Babka
Cc: kernel test robot, Kees Cook, oe-kbuild-all, linux-kernel,
Arnd Bergmann
Hi Vlastimil,
On Mon, Jul 22, 2024 at 9:15 AM Vlastimil Babka <vbabka@suse.cz> wrote:
> On 7/19/24 10:02 PM, kernel test robot wrote:
> > tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > head: 4305ca0087dd99c3c3e0e2ac8a228b7e53a21c78
> > commit: 72e0fe2241ce113cbba339ca8c2450b167774530 mm/slab: Introduce kmem_buckets typedef
> > date: 2 weeks ago
> > config: m68k-alldefconfig (https://download.01.org/0day-ci/archive/20240720/202407200330.Mgxnq2Dq-lkp@intel.com/config)
> > compiler: m68k-linux-gcc (GCC) 14.1.0
> > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240720/202407200330.Mgxnq2Dq-lkp@intel.com/reproduce)
> >
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <lkp@intel.com>
> > | Closes: https://lore.kernel.org/oe-kbuild-all/202407200330.Mgxnq2Dq-lkp@intel.com/
> >
> > All errors (new ones prefixed by >>):
>
> Hm the new error ettributed to slab seems just a consequence of the broken
> PAGE_SHIFT? Although it's not listed here in the errors for some reason, I
> assume without PAGE_SHIFT we don't have KMALLOC_SHIFT_HIGH thus we don't
> have kmem_buckets typedef and thus kmalloc_caches is who knows what and thus
> doesn't look like an array? And the broken PAGE_SHIFT has to be cause by
> something else.
>
> > arch/m68k/include/asm/page.h:10:25: error: 'CONFIG_PAGE_SHIFT' undeclared here (not in a function); did you mean 'CONFIG_LOG_BUF_SHIFT'?
> > 10 | #define PAGE_SHIFT CONFIG_PAGE_SHIFT
> > | ^~~~~~~~~~~~~~~~~
It's a known issue since commit 5394f1e9b687bcf2 ("arch: define
CONFIG_PAGE_SIZE_*KB on all architectures"): m68k-alldefconfig does
not select any CPU types, hence no MMU type, and as a consequence no
page size is selected.
Arnd and I couldn't come up with a good solution to enforce a valid config,
so this is still broken...
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@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] 7+ messages in thread* Re: include/linux/slab.h:663:78: error: subscripted value is neither array nor pointer nor vector
2024-07-22 7:48 ` Geert Uytterhoeven
@ 2024-07-22 9:22 ` Arnd Bergmann
0 siblings, 0 replies; 7+ messages in thread
From: Arnd Bergmann @ 2024-07-22 9:22 UTC (permalink / raw)
To: Geert Uytterhoeven, Vlastimil Babka
Cc: kernel test robot, Kees Cook, oe-kbuild-all, linux-kernel
On Mon, Jul 22, 2024, at 09:48, Geert Uytterhoeven wrote:
> On Mon, Jul 22, 2024 at 9:15 AM Vlastimil Babka <vbabka@suse.cz> wrote:
>> On 7/19/24 10:02 PM, kernel test robot wrote:
>>
>> Hm the new error ettributed to slab seems just a consequence of the broken
>> PAGE_SHIFT? Although it's not listed here in the errors for some reason, I
>> assume without PAGE_SHIFT we don't have KMALLOC_SHIFT_HIGH thus we don't
>> have kmem_buckets typedef and thus kmalloc_caches is who knows what and thus
>> doesn't look like an array? And the broken PAGE_SHIFT has to be cause by
>> something else.
>>
>> > arch/m68k/include/asm/page.h:10:25: error: 'CONFIG_PAGE_SHIFT' undeclared here (not in a function); did you mean 'CONFIG_LOG_BUF_SHIFT'?
>> > 10 | #define PAGE_SHIFT CONFIG_PAGE_SHIFT
>> > | ^~~~~~~~~~~~~~~~~
>
> It's a known issue since commit 5394f1e9b687bcf2 ("arch: define
> CONFIG_PAGE_SIZE_*KB on all architectures"): m68k-alldefconfig does
> not select any CPU types, hence no MMU type, and as a consequence no
> page size is selected.
>
> Arnd and I couldn't come up with a good solution to enforce a valid config,
> so this is still broken...
I've tried again as this keeps coming up. Not sure if this
is a variant we have discussed before, but this way should
fix the issue. There are still two unrelated build failures
with 'alldefconfig' though:
arch/m68k/kernel/setup_mm.c:54:2: error: #warning No CPU/platform type selected, your kernel will not work! [-Werror=cpp]
54 | #warning No CPU/platform type selected, your kernel will not work!
arm-soc/kernel/irq/irqdesc.c:592:3: error: array index in initializer exceeds array bounds
592 | [0 ... NR_IRQS-1] = {
Arnd
8<---
From 4579e30445643f1def7b9a8ae2f8720ca963b973 Mon Sep 17 00:00:00 2001
From: Arnd Bergmann <arnd@arndb.de>
Date: Mon, 22 Jul 2024 10:55:57 +0200
Subject: [PATCH] m68k: move sun3 into a top-level platform option
It is possible to select an m68k MMU build but not actually
enable any of the three MMU options, which then results in a
build failure:
arch/m68k/include/asm/page.h:10:25: error: 'CONFIG_PAGE_SHIFT' undeclared here (not in a function); did you mean 'CONFIG_LOG_BUF_SHIFT'?
Change the Kconfig selection to ensure that exactly one of the
three options is always enabled whenever an MMU-enabled kernel
is built, but moving CONFIG_SUN3 into a top-level option next
to M68KCLASSIC and COLDFIRE.
All defconfig files should keep working without changes,
but alldefconfig now builds support for the classic MMU.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index cc26df907bfe..7c4f7bcc89d7 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -84,24 +84,23 @@ config MMU
support by paged memory management. If unsure, say 'Y'.
config MMU_MOTOROLA
- bool
+ def_bool MMU && M68KCLASSIC
select HAVE_PAGE_SIZE_4KB
config MMU_COLDFIRE
+ def_bool MMU && COLDFIRE
select HAVE_PAGE_SIZE_8KB
- bool
config MMU_SUN3
- bool
+ def_bool MMU && SUN3
select HAVE_PAGE_SIZE_8KB
- depends on MMU && !MMU_MOTOROLA && !MMU_COLDFIRE
config ARCH_SUPPORTS_KEXEC
- def_bool M68KCLASSIC && MMU
+ def_bool (M68KCLASSIC || SUN3) && MMU
config BOOTINFO_PROC
bool "Export bootinfo in procfs"
- depends on KEXEC && M68KCLASSIC
+ depends on KEXEC && (M68KCLASSIC || SUN3)
help
Say Y to export the bootinfo used to boot the kernel in a
"bootinfo" file in procfs. This is useful with kexec.
diff --git a/arch/m68k/Kconfig.cpu b/arch/m68k/Kconfig.cpu
index c777a129768a..a1b9e5f09e18 100644
--- a/arch/m68k/Kconfig.cpu
+++ b/arch/m68k/Kconfig.cpu
@@ -32,13 +32,23 @@ config COLDFIRE
select HAVE_LEGACY_CLK
select HAVE_PAGE_SIZE_8KB if !MMU
-endchoice
+config SUN3
+ bool "Sun3 support"
+ depends on MMU
+ select HAVE_ARCH_PFN_VALID
+ select LEGACY_TIMER_TICK
+ select NO_DMA
+ select M68020
+ help
+ This option enables support for the Sun 3 series of workstations
+ (3/50, 3/60, 3/1xx, 3/2xx systems). These use a classic 68020 CPU
+ but the custom memory management unit makes them incompatible with
+ all other classic m68k machines, including Sun 3x.
-if M68KCLASSIC
+endchoice
config M68000
- def_bool y
- depends on !MMU
+ def_bool M68KCLASSIC && !MMU
select CPU_HAS_NO_BITFIELDS
select CPU_HAS_NO_CAS
select CPU_HAS_NO_MULDIV64
@@ -56,7 +66,8 @@ config M68000
a paging MMU.
config M68020
- bool "68020 support"
+ bool "68020 support" if M68KCLASSIC
+ default !(M68030 || M68040 || M68060)
depends on MMU
select FPU
select CPU_HAS_ADDRESS_SPACES
@@ -66,9 +77,10 @@ config M68020
68851 MMU (Memory Management Unit) to run Linux/m68k, except on the
Sun 3, which provides its own version.
+if M68KCLASSIC && MMU
+
config M68030
bool "68030 support"
- depends on MMU && !MMU_SUN3
select FPU
select CPU_HAS_ADDRESS_SPACES
help
@@ -78,7 +90,6 @@ config M68030
config M68040
bool "68040 support"
- depends on MMU && !MMU_SUN3
select FPU
select CPU_HAS_ADDRESS_SPACES
help
@@ -89,13 +100,14 @@ config M68040
config M68060
bool "68060 support"
- depends on MMU && !MMU_SUN3
select FPU
select CPU_HAS_ADDRESS_SPACES
help
If you anticipate running this kernel on a computer with a MC68060
processor, say Y. Otherwise, say N.
+endif # M68KCLASSIC
+
config M68328
bool
depends on !MMU
@@ -117,8 +129,6 @@ config M68VZ328
help
Motorola 68VZ328 processor support.
-endif # M68KCLASSIC
-
if COLDFIRE
choice
diff --git a/arch/m68k/Kconfig.machine b/arch/m68k/Kconfig.machine
index d06b1c5d9b0c..de39f23b180e 100644
--- a/arch/m68k/Kconfig.machine
+++ b/arch/m68k/Kconfig.machine
@@ -6,7 +6,6 @@ if M68KCLASSIC
config AMIGA
bool "Amiga support"
depends on MMU
- select MMU_MOTOROLA if MMU
select LEGACY_TIMER_TICK
help
This option enables support for the Amiga series of computers. If
@@ -16,7 +15,6 @@ config AMIGA
config ATARI
bool "Atari support"
depends on MMU
- select MMU_MOTOROLA if MMU
select HAVE_ARCH_NVRAM_OPS
select LEGACY_TIMER_TICK
help
@@ -31,7 +29,6 @@ config ATARI_KBD_CORE
config MAC
bool "Macintosh support"
depends on MMU
- select MMU_MOTOROLA if MMU
select HAVE_ARCH_NVRAM_OPS
select HAVE_PATA_PLATFORM
select LEGACY_TIMER_TICK
@@ -44,7 +41,6 @@ config MAC
config APOLLO
bool "Apollo support"
depends on MMU
- select MMU_MOTOROLA if MMU
select LEGACY_TIMER_TICK
help
Say Y here if you want to run Linux on an MC680x0-based Apollo
@@ -53,7 +49,6 @@ config APOLLO
config VME
bool "VME (Motorola and BVM) support"
depends on MMU
- select MMU_MOTOROLA if MMU
help
Say Y here if you want to build a kernel for a 680x0 based VME
board. Boards currently supported include Motorola boards MVME147,
@@ -97,7 +92,6 @@ config BVME6000
config HP300
bool "HP9000/300 and HP9000/400 support"
depends on MMU
- select MMU_MOTOROLA if MMU
select LEGACY_TIMER_TICK
help
This option enables support for the HP9000/300 and HP9000/400 series
@@ -110,7 +104,6 @@ config SUN3X
bool "Sun3x support"
depends on MMU
select LEGACY_TIMER_TICK
- select MMU_MOTOROLA if MMU
select M68030
help
This option enables support for the Sun 3x series of workstations.
@@ -124,7 +117,6 @@ config SUN3X
config Q40
bool "Q40/Q60 support"
depends on MMU
- select MMU_MOTOROLA if MMU
select LEGACY_TIMER_TICK
help
The Q40 is a Motorola 68040-based successor to the Sinclair QL
@@ -133,22 +125,6 @@ config Q40
Q60. Select your CPU below. For 68LC060 don't forget to enable FPU
emulation.
-config SUN3
- bool "Sun3 support"
- depends on MMU
- depends on !MMU_MOTOROLA
- select MMU_SUN3 if MMU
- select LEGACY_TIMER_TICK
- select NO_DMA
- select M68020
- help
- This option enables support for the Sun 3 series of workstations
- (3/50, 3/60, 3/1xx, 3/2xx systems). Enabling this option requires
- that all other hardware types must be disabled, as Sun 3 kernels
- are incompatible with all other m68k targets (including Sun 3x!).
-
- If you don't want to compile a kernel exclusively for a Sun 3, say N.
-
config VIRT
bool "Virtual M68k Machine support"
depends on MMU
@@ -157,7 +133,6 @@ config VIRT
select GOLDFISH_TIMER
select GOLDFISH_TTY
select M68040
- select MMU_MOTOROLA if MMU
select RTC_CLASS
select RTC_DRV_GOLDFISH
select TTY
diff --git a/arch/m68k/kernel/Makefile b/arch/m68k/kernel/Makefile
index f335bf3268a1..5d1af676b508 100644
--- a/arch/m68k/kernel/Makefile
+++ b/arch/m68k/kernel/Makefile
@@ -5,16 +5,8 @@
extra-y += vmlinux.lds
-obj-$(CONFIG_AMIGA) := head.o
-obj-$(CONFIG_ATARI) := head.o
-obj-$(CONFIG_MAC) := head.o
-obj-$(CONFIG_APOLLO) := head.o
-obj-$(CONFIG_VME) := head.o
-obj-$(CONFIG_HP300) := head.o
-obj-$(CONFIG_Q40) := head.o
-obj-$(CONFIG_SUN3X) := head.o
-obj-$(CONFIG_VIRT) := head.o
-obj-$(CONFIG_SUN3) := sun3-head.o
+obj-$(CONFIG_M68KCLASSIC) := head.o
+obj-$(CONFIG_SUN3) := sun3-head.o
obj-y += entry.o irq.o module.o process.o ptrace.o
obj-y += setup.o signal.o sys_m68k.o syscalltable.o time.o traps.o
diff --git a/arch/m68k/kernel/time.c b/arch/m68k/kernel/time.c
index a97600b2af50..108debb87cfb 100644
--- a/arch/m68k/kernel/time.c
+++ b/arch/m68k/kernel/time.c
@@ -62,7 +62,7 @@ void timer_heartbeat(void)
}
#endif /* CONFIG_HEARTBEAT */
-#ifdef CONFIG_M68KCLASSIC
+#if defined(CONFIG_M68KCLASSIC) || defined(CONFIG_SUN3)
/* machine dependent timer functions */
int (*mach_hwclk) (int, struct rtc_time*);
EXPORT_SYMBOL(mach_hwclk);
@@ -149,7 +149,7 @@ static int __init rtc_init(void)
module_init(rtc_init);
#endif /* CONFIG_RTC_DRV_GENERIC */
-#endif /* CONFIG M68KCLASSIC */
+#endif /* CONFIG M68KCLASSIC || SUN3 */
void __init time_init(void)
{
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-08-06 6:33 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-03 15:04 include/linux/slab.h:663:78: error: subscripted value is neither array nor pointer nor vector kernel test robot
2024-08-05 9:10 ` Vlastimil Babka
2024-08-06 6:33 ` Philip Li
-- strict thread matches above, loose matches on Subject: below --
2024-07-19 20:02 kernel test robot
2024-07-22 7:14 ` Vlastimil Babka
2024-07-22 7:48 ` Geert Uytterhoeven
2024-07-22 9:22 ` Arnd Bergmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox