Add a comment to document the magic number '5' used in the calculation
of MAX_LOCKDEP_CHAIN_HLOCKS. This number represents the estimated
average depth (number of locks held) of a lock chain. This definition
was added in commit 443cd507ce7f ("lockdep: add lock_class information
to lock_chain and output it").
Cc: Huang Ying <ying.huang@intel.com>
Cc: J. R. Okajima <hooanon05g@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Waiman Long <longman@redhat.com>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Carlos Llamas <cmllamas@google.com>
---
kernel/locking/lockdep_internals.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/kernel/locking/lockdep_internals.h b/kernel/locking/lockdep_internals.h
index bbe9000260d0..2b429ed103a8 100644
--- a/kernel/locking/lockdep_internals.h
+++ b/kernel/locking/lockdep_internals.h
@@ -119,6 +119,7 @@ static const unsigned long LOCKF_USED_IN_IRQ_READ =
#define MAX_LOCKDEP_CHAINS (1UL << MAX_LOCKDEP_CHAINS_BITS)
+/* We estimate that a chain holds 5 locks on average. */
#define MAX_LOCKDEP_CHAIN_HLOCKS (MAX_LOCKDEP_CHAINS*5)
extern struct lock_chain lock_chains[];
--
2.46.0.rc2.264.g509ed76dc8-goog
On 8/5/24 21:01, Carlos Llamas wrote:
> Add a comment to document the magic number '5' used in the calculation
> of MAX_LOCKDEP_CHAIN_HLOCKS. This number represents the estimated
> average depth (number of locks held) of a lock chain. This definition
> was added in commit 443cd507ce7f ("lockdep: add lock_class information
> to lock_chain and output it").
>
> Cc: Huang Ying <ying.huang@intel.com>
> Cc: J. R. Okajima <hooanon05g@gmail.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Boqun Feng <boqun.feng@gmail.com>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Waiman Long <longman@redhat.com>
> Cc: Will Deacon <will@kernel.org>
> Signed-off-by: Carlos Llamas <cmllamas@google.com>
> ---
> kernel/locking/lockdep_internals.h | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/kernel/locking/lockdep_internals.h b/kernel/locking/lockdep_internals.h
> index bbe9000260d0..2b429ed103a8 100644
> --- a/kernel/locking/lockdep_internals.h
> +++ b/kernel/locking/lockdep_internals.h
> @@ -119,6 +119,7 @@ static const unsigned long LOCKF_USED_IN_IRQ_READ =
>
> #define MAX_LOCKDEP_CHAINS (1UL << MAX_LOCKDEP_CHAINS_BITS)
>
> +/* We estimate that a chain holds 5 locks on average. */
> #define MAX_LOCKDEP_CHAIN_HLOCKS (MAX_LOCKDEP_CHAINS*5)
>
> extern struct lock_chain lock_chains[];
I think it is better to define another macro like
diff --git a/kernel/locking/lockdep_internals.h
b/kernel/locking/lockdep_internals.h
index bbe9000260d0..8805122cc9f1 100644
--- a/kernel/locking/lockdep_internals.h
+++ b/kernel/locking/lockdep_internals.h
@@ -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[];
Cheers,
Longman
On Mon, Aug 05, 2024 at 09:27:52PM -0400, Waiman Long wrote: > > I think it is better to define another macro like > > diff --git a/kernel/locking/lockdep_internals.h > b/kernel/locking/lockdep_internals.h > index bbe9000260d0..8805122cc9f1 100644 > --- a/kernel/locking/lockdep_internals.h > +++ b/kernel/locking/lockdep_internals.h > @@ -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[]; > > Cheers, > Longman Sounds good, I'll add your suggestion for v2. Thanks!
© 2016 - 2025 Red Hat, Inc.