Re: [PATCH] lockdep: Fix static memory detection even more

From: Peter Zijlstra
Date: Mon Aug 14 2023 - 10:18:09 EST


On Mon, Aug 14, 2023 at 09:40:42PM +0800, kernel test robot wrote:
>
>
> Hello,
>
> kernel test robot noticed "BUG:key#has_not_been_registered" on:
>
> commit: 94d4413e506da48ea18f1cc982202874d35c76b1 ("[PATCH] lockdep: Fix static memory detection even more")
> url: https://github.com/intel-lab-lkp/linux/commits/Helge-Deller/lockdep-Fix-static-memory-detection-even-more/20230812-235022
> base: https://git.kernel.org/cgit/linux/kernel/git/akpm/mm.git mm-everything
> patch link: https://lore.kernel.org/all/ZNep5EcYskP9HtGD@p100/
> patch subject: [PATCH] lockdep: Fix static memory detection even more
>
> in testcase: boot
>
> compiler: gcc-12
> test machine: qemu-system-x86_64 -enable-kvm -cpu SandyBridge -smp 2 -m 16G
>
> (please refer to attached dmesg/kmsg for entire log/backtrace)
>
>
>
> 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 <oliver.sang@xxxxxxxxx>
> | Closes: https://lore.kernel.org/oe-lkp/202308141646.d3160c77-oliver.sang@xxxxxxxxx
>
>
>
> [ 0.575811][ T1] BUG: key b35c282c has not been registered!
> [ 0.576580][ T1] ------------[ cut here ]------------
> [ 0.577216][ T1] DEBUG_LOCKS_WARN_ON(1)
> [ 0.577236][ T1] WARNING: CPU: 0 PID: 1 at kernel/locking/lockdep.c:4888 lockdep_init_map_type+0x155/0x250
> [ 0.578389][ T1] Modules linked in:
> [ 0.578856][ T1] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.5.0-rc4-00587-g94d4413e506d #2

> [ 0.595653][ T1] __kernfs_create_file+0x6a/0xe0
> [ 0.596244][ T1] sysfs_add_bin_file_mode_ns+0x4e/0xc0
> [ 0.596891][ T1] sysfs_create_bin_file+0x5c/0x90
> [ 0.597496][ T1] ? nsproxy_cache_init+0x30/0x30
> [ 0.598090][ T1] ksysfs_init+0x5c/0x90

Problem seems to be __ro_after_init. Your patch only considers
is_kernel_core_data(), which seems to not include these other fancy data
sections we have.