public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* LOCKDEP customizable numbers upper limit
@ 2021-05-13 13:39 J. R. Okajima
  2021-05-13 14:27 ` Tetsuo Handa
  0 siblings, 1 reply; 10+ messages in thread
From: J. R. Okajima @ 2021-05-13 13:39 UTC (permalink / raw)
  To: peterz, penguin-kernel; +Cc: linux-kernel

Hello,

According to the commit in v5.13-rc1,
	5dc33592e9553 2021-04-05 lockdep: Allow tuning tracing capacity constants.
several lockdep numbers have their own range as 10--30.
But if we set all 30s, we got a compilation error.

kernel/locking/lockdep.c:3536:2: note: in expansion of macro 'BUILD_BUG_ON'
  BUILD_BUG_ON((1UL << 24) <= ARRAY_SIZE(chain_hlocks));

kernel/locking/lockdep.c
----------------------------------------
static u16 chain_hlocks[MAX_LOCKDEP_CHAIN_HLOCKS];
	:::
	BUILD_BUG_ON((1UL << 24) <= ARRAY_SIZE(chain_hlocks));
	:::
----------------------------------------

MAX_LOCKDEP_CHAIN_HLOCKS is defined in kernel/locking/lockdep_internal.h
as this.

#define MAX_LOCKDEP_CHAINS_BITS		CONFIG_LOCKDEP_CHAINS_BITS
#define MAX_LOCKDEP_CHAINS		(1UL << MAX_LOCKDEP_CHAINS_BITS)
#define MAX_LOCKDEP_CHAIN_HLOCKS	(MAX_LOCKDEP_CHAINS*5)

I don't know what this 'multiply by 5' means and why
ARRAY_SIZE(chain_hlocks) is limited to (1UL << 24), but setting 30 to
CONFIG_LOCKDEP_CHAINS_BITS obviously causes BUILD_BUG.
'*5' is more than 2 bits shift, so CONFIG_LOCKDEP_CHAINS_BITS has to be
less than (24-2), limited to the range 10--21.

Hmm, I tried.

CONFIG_LOCKDEP_BITS=30
CONFIG_LOCKDEP_CHAINS_BITS=21
CONFIG_LOCKDEP_STACK_TRACE_BITS=30
CONFIG_LOCKDEP_STACK_TRACE_HASH_BITS=30
CONFIG_LOCKDEP_CIRCULAR_QUEUE_BITS=30

Arg, LD failed.
ld: kernel/locking/lockdep.o: in function `lockdep_hlock_class':
lockdep.c:(.text+0x84f): relocation truncated to fit: R_X86_64_PC32 against `.bss'

I am afraid these LOCKDEP configurations need some sort of balancing.


J. R. Okajima

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

end of thread, other threads:[~2024-08-06  1:05 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-13 13:39 LOCKDEP customizable numbers upper limit J. R. Okajima
2021-05-13 14:27 ` Tetsuo Handa
2021-05-14 18:22   ` PATCH: " hooanon05g
2021-05-14 22:41     ` Tetsuo Handa
2024-07-23 16:40       ` [PATCH v2] lockdep: upper limit LOCKDEP_CHAINS_BITS Carlos Llamas
2024-07-31 23:48         ` Andrew Morton
2024-08-01 16:25           ` Carlos Llamas
2024-08-01 23:51             ` J. R. Okajima
2024-08-05 19:58           ` Carlos Llamas
2024-08-06  1:05             ` Carlos Llamas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox