Skip to contentSkip to conversation

lockdep: minor config and documentation fixes

PATCH Applied Carlos Llamas 5 participants 11 messages Oct 24, 2024 – Dec 24, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v3 cover lockdep: minor config and documentation fixes

These are some minor follow-up patches that came up during conversation
at: https://lore.kernel.org/all/30795.1620913191@jrobl/

This v3 is based on master as commit e0ba72e3a442 ("lockdep: upper limit LOCKDEP_CHAINS_BITS") has now landed.

Cc Huang Ying <[email protected]>
Cc J. R. Okajima <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Boqun Feng <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Waiman Long <[email protected]>
Cc Will Deacon <[email protected]>
Cc Andrew Morton <[email protected]>

v3: rebased on master and collected tags
v2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/

Carlos Llamas (3):
lockdep: fix upper limit for LOCKDEP_*_BITS configs
lockdep: clarify size for LOCKDEP_*_BITS configs
lockdep: document MAX_LOCKDEP_CHAIN_HLOCKS calculation

 kernel/locking/lockdep_internals.h |  3 ++-
 lib/Kconfig.debug                  | 18 +++++++++---------
 2 files changed, 11 insertions(+), 10 deletions(-)
Signature · 1 line
2.47.0.163.g1226f6d8fa-goog
#1 lore raw

PATCH v3 1/3 lockdep: fix upper limit for LOCKDEP_*_BITS configs

Lockdep has a set of configs used to determine the size of the static arrays that it uses. However, the upper limit that was initially setup for these configs is too high (30 bit shift). This equates to several GiB of static memory for individual symbols. Using such high values leads to linker errors:

  $ make defconfig
  $ ./scripts/config -e PROVE_LOCKING --set-val LOCKDEP_BITS 30
  $ make olddefconfig all
  [...]
  ld: kernel image bigger than KERNEL_IMAGE_SIZE
  ld: section .bss VMA wraps around address space

Adjust the upper limits to the maximum values that avoid these issues. The need for anything more, likely points to a problem elsewhere. Note that LOCKDEP_CHAINS_BITS was intentionally left out as its upper limit had a different symptom and has already been fixed [1].

---
 lib/Kconfig.debug | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
lib/Kconfig.debug +4 -4
index 7312ae7c3cc5..c8b1db37abe6 100644
@@ -1524,7 +1524,7 @@ config LOCKDEP_SMALL
 config LOCKDEP_BITS
 	int "Bitsize for MAX_LOCKDEP_ENTRIES"
 	depends on LOCKDEP && !LOCKDEP_SMALL
-	range 10 30
+	range 10 24
 	default 15
 	help
 	  Try increasing this value if you hit "BUG: MAX_LOCKDEP_ENTRIES too low!" message.
@@ -1540,7 +1540,7 @@ config LOCKDEP_CHAINS_BITS
 config LOCKDEP_STACK_TRACE_BITS
 	int "Bitsize for MAX_STACK_TRACE_ENTRIES"
 	depends on LOCKDEP && !LOCKDEP_SMALL
-	range 10 30
+	range 10 26
 	default 19
 	help
 	  Try increasing this value if you hit "BUG: MAX_STACK_TRACE_ENTRIES too low!" message.
@@ -1548,7 +1548,7 @@ config LOCKDEP_STACK_TRACE_BITS
 config LOCKDEP_STACK_TRACE_HASH_BITS
 	int "Bitsize for STACK_TRACE_HASH_SIZE"
 	depends on LOCKDEP && !LOCKDEP_SMALL
-	range 10 30
+	range 10 26
 	default 14
 	help
 	  Try increasing this value if you need large STACK_TRACE_HASH_SIZE.
@@ -1556,7 +1556,7 @@ config LOCKDEP_STACK_TRACE_HASH_BITS
 config LOCKDEP_CIRCULAR_QUEUE_BITS
 	int "Bitsize for elements in circular_queue struct"
 	depends on LOCKDEP
-	range 10 30
+	range 10 26
 	default 12
 	help
 	  Try increasing this value if you hit "lockdep bfs error:-1" warning due to __cq_enqueue() failure.
Signature · 1 line
2.47.0.163.g1226f6d8fa-goog
merge bot Applied
#2 lore raw

[tip: locking/core] lockdep: Fix upper limit for LOCKDEP_*_BITS configs

The following commit has been merged into the locking/core branch of tip:

The following commit has been merged into the locking/core branch of tip:

Commit-ID:     e638072e61726cae363d48812815197a2a0e097f
Gitweb:        https://git.kernel.org/tip/e638072e61726cae363d48812815197a2a0e097f
Author:        Carlos Llamas <[email protected]>
AuthorDate:    Thu, 24 Oct 2024 18:36:26 
Committer:     Boqun Feng <[email protected]>
CommitterDate: Sun, 15 Dec 2024 11:49:35 -08:00

lockdep: Fix upper limit for LOCKDEP_*_BITS configs

Lockdep has a set of configs used to determine the size of the static arrays that it uses. However, the upper limit that was initially setup for these configs is too high (30 bit shift). This equates to several GiB of static memory for individual symbols. Using such high values leads to linker errors:

  $ make defconfig
  $ ./scripts/config -e PROVE_LOCKING --set-val LOCKDEP_BITS 30
  $ make olddefconfig all
  [...]
  ld: kernel image bigger than KERNEL_IMAGE_SIZE
  ld: section .bss VMA wraps around address space

Adjust the upper limits to the maximum values that avoid these issues. The need for anything more, likely points to a problem elsewhere. Note that LOCKDEP_CHAINS_BITS was intentionally left out as its upper limit had a different symptom and has already been fixed [1].

---
 lib/Kconfig.debug | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
lib/Kconfig.debug +4 -4
index 49a3819..7635b36 100644
@@ -1504,7 +1504,7 @@ config LOCKDEP_SMALL
 config LOCKDEP_BITS
 	int "Bitsize for MAX_LOCKDEP_ENTRIES"
 	depends on LOCKDEP && !LOCKDEP_SMALL
-	range 10 30
+	range 10 24
 	default 15
 	help
 	  Try increasing this value if you hit "BUG: MAX_LOCKDEP_ENTRIES too low!" message.
@@ -1520,7 +1520,7 @@ config LOCKDEP_CHAINS_BITS
 config LOCKDEP_STACK_TRACE_BITS
 	int "Bitsize for MAX_STACK_TRACE_ENTRIES"
 	depends on LOCKDEP && !LOCKDEP_SMALL
-	range 10 30
+	range 10 26
 	default 19
 	help
 	  Try increasing this value if you hit "BUG: MAX_STACK_TRACE_ENTRIES too low!" message.
@@ -1528,7 +1528,7 @@ config LOCKDEP_STACK_TRACE_BITS
 config LOCKDEP_STACK_TRACE_HASH_BITS
 	int "Bitsize for STACK_TRACE_HASH_SIZE"
 	depends on LOCKDEP && !LOCKDEP_SMALL
-	range 10 30
+	range 10 26
 	default 14
 	help
 	  Try increasing this value if you need large STACK_TRACE_HASH_SIZE.
@@ -1536,7 +1536,7 @@ config LOCKDEP_STACK_TRACE_HASH_BITS
 config LOCKDEP_CIRCULAR_QUEUE_BITS
 	int "Bitsize for elements in circular_queue struct"
 	depends on LOCKDEP
-	range 10 30
+	range 10 26
 	default 12
 	help
 	  Try increasing this value if you hit "lockdep bfs error:-1" warning due to __cq_enqueue() failure.
#3 lore raw

PATCH v3 2/3 lockdep: clarify size for LOCKDEP_*_BITS configs

In reply to Carlos Llamas

The LOCKDEP_*_BITS configs control the size of internal structures used by lockdep. The size is calculated as a power of two of the configured value (e.g. 16 => 64KB). Update these descriptions to more accurately reflect this, as "Bitsize" can be misleading.

Cc Peter Zijlstra <[email protected]>
Cc Boqun Feng <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Waiman Long <[email protected]>
Cc Will Deacon <[email protected]>
---
 lib/Kconfig.debug | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
lib/Kconfig.debug +5 -5
index c8b1db37abe6..5a769cbf4bb2 100644
@@ -1522,7 +1522,7 @@ config LOCKDEP_SMALL
 	bool
 
 config LOCKDEP_BITS
-	int "Bitsize for MAX_LOCKDEP_ENTRIES"
+	int "Size for MAX_LOCKDEP_ENTRIES (as Nth power of 2)"
 	depends on LOCKDEP && !LOCKDEP_SMALL
 	range 10 24
 	default 15
@@ -1530,7 +1530,7 @@ config LOCKDEP_BITS
 	  Try increasing this value if you hit "BUG: MAX_LOCKDEP_ENTRIES too low!" message.
 
 config LOCKDEP_CHAINS_BITS
-	int "Bitsize for MAX_LOCKDEP_CHAINS"
+	int "Size for MAX_LOCKDEP_CHAINS (as Nth power of 2)"
 	depends on LOCKDEP && !LOCKDEP_SMALL
 	range 10 21
 	default 16
@@ -1538,7 +1538,7 @@ config LOCKDEP_CHAINS_BITS
 	  Try increasing this value if you hit "BUG: MAX_LOCKDEP_CHAINS too low!" message.
 
 config LOCKDEP_STACK_TRACE_BITS
-	int "Bitsize for MAX_STACK_TRACE_ENTRIES"
+	int "Size for MAX_STACK_TRACE_ENTRIES (as Nth power of 2)"
 	depends on LOCKDEP && !LOCKDEP_SMALL
 	range 10 26
 	default 19
@@ -1546,7 +1546,7 @@ config LOCKDEP_STACK_TRACE_BITS
 	  Try increasing this value if you hit "BUG: MAX_STACK_TRACE_ENTRIES too low!" message.
 
 config LOCKDEP_STACK_TRACE_HASH_BITS
-	int "Bitsize for STACK_TRACE_HASH_SIZE"
+	int "Size for STACK_TRACE_HASH_SIZE (as Nth power of 2)"
 	depends on LOCKDEP && !LOCKDEP_SMALL
 	range 10 26
 	default 14
@@ -1554,7 +1554,7 @@ config LOCKDEP_STACK_TRACE_HASH_BITS
 	  Try increasing this value if you need large STACK_TRACE_HASH_SIZE.
 
 config LOCKDEP_CIRCULAR_QUEUE_BITS
-	int "Bitsize for elements in circular_queue struct"
+	int "Size for elements in circular_queue struct (as Nth power of 2)"
 	depends on LOCKDEP
 	range 10 26
 	default 12
Signature · 1 line
2.47.0.163.g1226f6d8fa-goog
Acked-by on v3 2/3
#4 lore raw

Re: [PATCH v3 2/3] lockdep: clarify size for LOCKDEP_*_BITS configs

Quoted 57 lines · Carlos Llamas

The LOCKDEP_*_BITS configs control the size of internal structures used by lockdep. The size is calculated as a power of two of the configured value (e.g. 16 => 64KB). Update these descriptions to more accurately reflect this, as "Bitsize" can be misleading.

Cc Peter Zijlstra <[email protected]>
Cc Boqun Feng <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Waiman Long <[email protected]>
Cc Will Deacon <[email protected]>
---
  lib/Kconfig.debug | 10 +++++-----
  1 file changed, 5 insertions(+), 5 deletions(-)
lib/Kconfig.debug +4 -4
index c8b1db37abe6..5a769cbf4bb2 100644
@@ -1522,7 +1522,7 @@ config LOCKDEP_SMALL
  	bool
 
  config LOCKDEP_BITS
-	int "Bitsize for MAX_LOCKDEP_ENTRIES"
+	int "Size for MAX_LOCKDEP_ENTRIES (as Nth power of 2)"
  	depends on LOCKDEP && !LOCKDEP_SMALL
  	range 10 24
  	default 15
@@ -1530,7 +1530,7 @@ config LOCKDEP_BITS
  	  Try increasing this value if you hit "BUG: MAX_LOCKDEP_ENTRIES too low!" message.
 
  config LOCKDEP_CHAINS_BITS
-	int "Bitsize for MAX_LOCKDEP_CHAINS"
+	int "Size for MAX_LOCKDEP_CHAINS (as Nth power of 2)"
  	depends on LOCKDEP && !LOCKDEP_SMALL
  	range 10 21
  	default 16
@@ -1538,7 +1538,7 @@ config LOCKDEP_CHAINS_BITS
  	  Try increasing this value if you hit "BUG: MAX_LOCKDEP_CHAINS too low!" message.
 
  config LOCKDEP_STACK_TRACE_BITS
-	int "Bitsize for MAX_STACK_TRACE_ENTRIES"
+	int "Size for MAX_STACK_TRACE_ENTRIES (as Nth power of 2)"
  	depends on LOCKDEP && !LOCKDEP_SMALL
  	range 10 26
  	default 19
@@ -1546,7 +1546,7 @@ config LOCKDEP_STACK_TRACE_BITS
  	  Try increasing this value if you hit "BUG: MAX_STACK_TRACE_ENTRIES too low!" message.
 
  config LOCKDEP_STACK_TRACE_HASH_BITS
-	int "Bitsize for STACK_TRACE_HASH_SIZE"
+	int "Size for STACK_TRACE_HASH_SIZE (as Nth power of 2)"
  	depends on LOCKDEP && !LOCKDEP_SMALL
  	range 10 26
  	default 14

lib/Kconfig.debug config LOCKDEP_STACK_TRACE_HASH_BITS · line 1560

Quoted 8 lines
lib/Kconfig.debug +1 -1
@@ -1554,7 +1554,7 @@ config LOCKDEP_STACK_TRACE_HASH_BITS
  	  Try increasing this value if you need large STACK_TRACE_HASH_SIZE.
 
  config LOCKDEP_CIRCULAR_QUEUE_BITS
-	int "Bitsize for elements in circular_queue struct"
+	int "Size for elements in circular_queue struct (as Nth power of 2)"
  	depends on LOCKDEP
  	range 10 26
  	default 12
merge bot Applied
#5 lore raw

[tip: locking/core] lockdep: Clarify size for LOCKDEP_*_BITS configs

In reply to Carlos Llamas
The following commit has been merged into the locking/core branch of tip:

The following commit has been merged into the locking/core branch of tip:

Commit-ID:     88a79e88a97cb9309bb48a472be2bf1316d40adc
Gitweb:        https://git.kernel.org/tip/88a79e88a97cb9309bb48a472be2bf1316d40adc
Author:        Carlos Llamas <[email protected]>
AuthorDate:    Thu, 24 Oct 2024 18:36:27 
Committer:     Boqun Feng <[email protected]>
CommitterDate: Sun, 15 Dec 2024 11:49:35 -08:00

lockdep: Clarify size for LOCKDEP_*_BITS configs

The LOCKDEP_*_BITS configs control the size of internal structures used by lockdep. The size is calculated as a power of two of the configured value (e.g. 16 => 64KB). Update these descriptions to more accurately reflect this, as "Bitsize" can be misleading.

---
 lib/Kconfig.debug | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
lib/Kconfig.debug +5 -5
index 7635b36..cf2a41d 100644
@@ -1502,7 +1502,7 @@ config LOCKDEP_SMALL
 	bool
 
 config LOCKDEP_BITS
-	int "Bitsize for MAX_LOCKDEP_ENTRIES"
+	int "Size for MAX_LOCKDEP_ENTRIES (as Nth power of 2)"
 	depends on LOCKDEP && !LOCKDEP_SMALL
 	range 10 24
 	default 15
@@ -1510,7 +1510,7 @@ config LOCKDEP_BITS
 	  Try increasing this value if you hit "BUG: MAX_LOCKDEP_ENTRIES too low!" message.
 
 config LOCKDEP_CHAINS_BITS
-	int "Bitsize for MAX_LOCKDEP_CHAINS"
+	int "Size for MAX_LOCKDEP_CHAINS (as Nth power of 2)"
 	depends on LOCKDEP && !LOCKDEP_SMALL
 	range 10 21
 	default 16
@@ -1518,7 +1518,7 @@ config LOCKDEP_CHAINS_BITS
 	  Try increasing this value if you hit "BUG: MAX_LOCKDEP_CHAINS too low!" message.
 
 config LOCKDEP_STACK_TRACE_BITS
-	int "Bitsize for MAX_STACK_TRACE_ENTRIES"
+	int "Size for MAX_STACK_TRACE_ENTRIES (as Nth power of 2)"
 	depends on LOCKDEP && !LOCKDEP_SMALL
 	range 10 26
 	default 19
@@ -1526,7 +1526,7 @@ config LOCKDEP_STACK_TRACE_BITS
 	  Try increasing this value if you hit "BUG: MAX_STACK_TRACE_ENTRIES too low!" message.
 
 config LOCKDEP_STACK_TRACE_HASH_BITS
-	int "Bitsize for STACK_TRACE_HASH_SIZE"
+	int "Size for STACK_TRACE_HASH_SIZE (as Nth power of 2)"
 	depends on LOCKDEP && !LOCKDEP_SMALL
 	range 10 26
 	default 14
@@ -1534,7 +1534,7 @@ config LOCKDEP_STACK_TRACE_HASH_BITS
 	  Try increasing this value if you need large STACK_TRACE_HASH_SIZE.
 
 config LOCKDEP_CIRCULAR_QUEUE_BITS
-	int "Bitsize for elements in circular_queue struct"
+	int "Size for elements in circular_queue struct (as Nth power of 2)"
 	depends on LOCKDEP
 	range 10 26
 	default 12
#6 lore raw

PATCH v3 3/3 lockdep: document MAX_LOCKDEP_CHAIN_HLOCKS calculation

In reply to Carlos Llamas

Define a macro AVG_LOCKDEP_CHAIN_DEPTH to document the magic number '5' used in the calculation of MAX_LOCKDEP_CHAIN_HLOCKS. The number represents the estimated average depth (number of locks held) of a lock chain. The calculation of MAX_LOCKDEP_CHAIN_HLOCKS was first added in commit 443cd507ce7f ("lockdep: add lock_class information to lock_chain and output it").

Cc Huang Ying <[email protected]>
Cc J. R. Okajima <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Boqun Feng <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Will Deacon <[email protected]>

---
v3: collect tags
v2: switched the comment for a macro as suggested by Waiman Long.

 kernel/locking/lockdep_internals.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/locking/lockdep_internals.h +2 -1
index bbe9000260d0..20f9ef58d3d0 100644
@@ -119,7 +119,8 @@ static const unsigned long LOCKF_USED_IN_IRQ_READ =
 
 #define MAX_LOCKDEP_CHAINS	(1UL << MAX_LOCKDEP_CHAINS_BITS)
 
-#define MAX_LOCKDEP_CHAIN_HLOCKS (MAX_LOCKDEP_CHAINS*5)
+#define AVG_LOCKDEP_CHAIN_DEPTH		5
+#define MAX_LOCKDEP_CHAIN_HLOCKS (MAX_LOCKDEP_CHAINS * AVG_LOCKDEP_CHAIN_DEPTH)
 
 extern struct lock_chain lock_chains[];
 
Signature · 1 line
2.47.0.163.g1226f6d8fa-goog
Acked-by on v3 3/3
#7 lore raw

Re: [PATCH v3 3/3] lockdep: document MAX_LOCKDEP_CHAIN_HLOCKS calculation

Quoted 28 lines · Carlos Llamas

Define a macro AVG_LOCKDEP_CHAIN_DEPTH to document the magic number '5' used in the calculation of MAX_LOCKDEP_CHAIN_HLOCKS. The number represents the estimated average depth (number of locks held) of a lock chain. The calculation of MAX_LOCKDEP_CHAIN_HLOCKS was first added in commit 443cd507ce7f ("lockdep: add lock_class information to lock_chain and output it").

Cc Huang Ying <[email protected]>
Cc J. R. Okajima <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Boqun Feng <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Will Deacon <[email protected]>

---
v3: collect tags
v2: switched the comment for a macro as suggested by Waiman Long.

  kernel/locking/lockdep_internals.h | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
kernel/locking/lockdep_internals.h +0 -0
index bbe9000260d0..20f9ef58d3d0 100644

kernel/locking/lockdep_internals.h static const unsigned long LOCKF_USED_IN_IRQ_READ = · line 126

Quoted 9 lines
kernel/locking/lockdep_internals.h +2 -1
@@ -119,7 +119,8 @@ static const unsigned long LOCKF_USED_IN_IRQ_READ =
 
  #define MAX_LOCKDEP_CHAINS	(1UL << MAX_LOCKDEP_CHAINS_BITS)
 
-#define MAX_LOCKDEP_CHAIN_HLOCKS (MAX_LOCKDEP_CHAINS*5)
+#define AVG_LOCKDEP_CHAIN_DEPTH		5
+#define MAX_LOCKDEP_CHAIN_HLOCKS (MAX_LOCKDEP_CHAINS * AVG_LOCKDEP_CHAIN_DEPTH)
 
  extern struct lock_chain lock_chains[];
 
Acked-by on v3 3/3
#8 lore raw

Re: [PATCH v3 3/3] lockdep: document MAX_LOCKDEP_CHAIN_HLOCKS calculation

In reply to Carlos Llamas
Quoted 7 lines · Carlos Llamas

Define a macro AVG_LOCKDEP_CHAIN_DEPTH to document the magic number '5' used in the calculation of MAX_LOCKDEP_CHAIN_HLOCKS. The number represents the estimated average depth (number of locks held) of a lock chain. The calculation of MAX_LOCKDEP_CHAIN_HLOCKS was first added in commit 443cd507ce7f ("lockdep: add lock_class information to lock_chain and output it").

Quoted 9 lines
Cc Huang Ying <[email protected]>
Cc J. R. Okajima <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Boqun Feng <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Will Deacon <[email protected]>

LGTM, Thanks! Feel free to add

in the future versions.

Quoted 20 lines

---
v3: collect tags
v2: switched the comment for a macro as suggested by Waiman Long.

 kernel/locking/lockdep_internals.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/locking/lockdep_internals.h +2 -1
index bbe9000260d0..20f9ef58d3d0 100644
@@ -119,7 +119,8 @@ static const unsigned long LOCKF_USED_IN_IRQ_READ =
 
 #define MAX_LOCKDEP_CHAINS	(1UL << MAX_LOCKDEP_CHAINS_BITS)
 
-#define MAX_LOCKDEP_CHAIN_HLOCKS (MAX_LOCKDEP_CHAINS*5)
+#define AVG_LOCKDEP_CHAIN_DEPTH		5
+#define MAX_LOCKDEP_CHAIN_HLOCKS (MAX_LOCKDEP_CHAINS * AVG_LOCKDEP_CHAIN_DEPTH)
 
 extern struct lock_chain lock_chains[];
merge bot Applied
#9 lore raw

[tip: locking/core] lockdep: Document MAX_LOCKDEP_CHAIN_HLOCKS calculation

In reply to Carlos Llamas
The following commit has been merged into the locking/core branch of tip:

The following commit has been merged into the locking/core branch of tip:

Commit-ID:     bd7b5ae26618ad2bd6f6264e2cb6c5815d323e75
Gitweb:        https://git.kernel.org/tip/bd7b5ae26618ad2bd6f6264e2cb6c5815d323e75
Author:        Carlos Llamas <[email protected]>
AuthorDate:    Thu, 24 Oct 2024 18:36:28 
Committer:     Boqun Feng <[email protected]>
CommitterDate: Sun, 15 Dec 2024 11:49:35 -08:00

lockdep: Document MAX_LOCKDEP_CHAIN_HLOCKS calculation

Define a macro AVG_LOCKDEP_CHAIN_DEPTH to document the magic number '5' used in the calculation of MAX_LOCKDEP_CHAIN_HLOCKS. The number represents the estimated average depth (number of locks held) of a lock chain. The calculation of MAX_LOCKDEP_CHAIN_HLOCKS was first added in commit 443cd507ce7f ("lockdep: add lock_class information to lock_chain and output it").

---
 kernel/locking/lockdep_internals.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/locking/lockdep_internals.h +2 -1
index bbe9000..20f9ef5 100644
@@ -119,7 +119,8 @@ static const unsigned long LOCKF_USED_IN_IRQ_READ =
 
 #define MAX_LOCKDEP_CHAINS	(1UL << MAX_LOCKDEP_CHAINS_BITS)
 
-#define MAX_LOCKDEP_CHAIN_HLOCKS (MAX_LOCKDEP_CHAINS*5)
+#define AVG_LOCKDEP_CHAIN_DEPTH		5
+#define MAX_LOCKDEP_CHAIN_HLOCKS (MAX_LOCKDEP_CHAINS * AVG_LOCKDEP_CHAIN_DEPTH)
 
 extern struct lock_chain lock_chains[];
 
#10 lore raw
In reply to Carlos Llamas
Quoted 6 lines · Carlos Llamas

These are some minor follow-up patches that came up during conversation
at: https://lore.kernel.org/all/30795.1620913191@jrobl/

This v3 is based on master as commit e0ba72e3a442 ("lockdep: upper limit LOCKDEP_CHAINS_BITS") has now landed.

Quoted 9 lines
Cc Huang Ying <[email protected]>
Cc J. R. Okajima <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Boqun Feng <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Waiman Long <[email protected]>
Cc Will Deacon <[email protected]>
Cc Andrew Morton <[email protected]>

Queued into lockdep-for-tip for future tests and reviews, if all goes well, this will be merged in tip during v6.13 and in mainline during v6.14 merge window.

Thanks!

Regards,
Boqun

Quoted 16 lines

v3: rebased on master and collected tags
v2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/

Carlos Llamas (3):
lockdep: fix upper limit for LOCKDEP_*_BITS configs
lockdep: clarify size for LOCKDEP_*_BITS configs
lockdep: document MAX_LOCKDEP_CHAIN_HLOCKS calculation

 kernel/locking/lockdep_internals.h |  3 ++-
 lib/Kconfig.debug                  | 18 +++++++++---------
 2 files changed, 11 insertions(+), 10 deletions(-)
Signature · 1 line
2.47.0.163.g1226f6d8fa-goog