RE: [PATCH v3 1/2] cacheinfo: Add function to get cacheinfo for a given (cpu, cachelevel)

From: Luck, Tony
Date: Thu Jun 06 2024 - 15:59:10 EST


> + lockdep_assert_cpus_held();
> +
>
> lkp says this breaks riscv-allnoconfig and riscv-defconfig
>
> In file included from arch/riscv/include/asm/cacheinfo.h:9:
> >> include/linux/cacheinfo.h:126:2: error: call to undeclared function 'lockdep_assert_cpus_held'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
> 126 | lockdep_assert_cpus_held();
>
> but I'm not really sure why. I added "#include <linux/cpu.h>" to <linux/cpuinfo,h> to deal with similar warning when building for x86.

Ah. The full trace from lkp explains:

In file included from io_uring/io_uring.c:45:
In file included from include/linux/syscalls.h:93:
In file included from include/trace/syscall.h:5:
In file included from include/linux/tracepoint.h:22:
In file included from include/linux/static_call.h:135:
In file included from include/linux/cpu.h:17: <<<< only part way through cpu.h, lockdep_assert_cpus_held not defined yet
In file included from include/linux/node.h:18:
In file included from include/linux/device.h:32:
In file included from include/linux/device/driver.h:21:
In file included from include/linux/module.h:19:
In file included from include/linux/elf.h:6:
In file included from arch/riscv/include/asm/elf.h:16:
In file included from arch/riscv/include/asm/cacheinfo.h:9: <<< doesn't matter that this includes cpu.h because of #ifndef _LINUX_CPU_H_

>> include/linux/cacheinfo.h:126:2: error: call to undeclared function 'lockdep_assert_cpus_held'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
126 | lockdep_assert_cpus_held();

So this is #include hell that many others have complained about.


How much do you *REALLY* want that lockdep_assert_cpus_held() to be in <linux/cacheinfo.h>

The lack of an assert did not come up when James added get_cpu_cacheinfo_id()

https://lkml.kernel.org/r/20200708163929.2783-11-james.morse@xxxxxxx

-Tony