public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH v2] lockdep: Add header and footer to surround warning reports
       [not found] <20251215072640.2580384-1-tzungbi@kernel.org>
@ 2025-12-16  1:03 ` Tzung-Bi Shih
       [not found] ` <0ae3277b-bea5-40ce-8eaa-10bb8b47c46a@redhat.com>
  1 sibling, 0 replies; 4+ messages in thread
From: Tzung-Bi Shih @ 2025-12-16  1:03 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng
  Cc: Waiman Long, linux-kernel

On Mon, Dec 15, 2025 at 07:26:40AM +0000, Tzung-Bi Shih wrote:
> Add header and footer to improve log parsing and automated analysis.
> This makes lockdep output easier to interpret.
> 
> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>

Oops, for some reason, I failed to cc lkml.  Cc lkml.

> ---
> v2:
> - asm/bugs.h -> linux/bug.h.
> 
> v1: https://lore.kernel.org/all/20251114062730.1828416-1-tzungbi@kernel.org/
> 
>  kernel/locking/lockdep.c | 34 ++++++++++++++++++++++++++++++++++
>  1 file changed, 34 insertions(+)
> 
> diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
> index 2d4c5bab5af8..adbc44c3808d 100644
> --- a/kernel/locking/lockdep.c
> +++ b/kernel/locking/lockdep.c
> @@ -58,6 +58,7 @@
>  #include <linux/context_tracking.h>
>  #include <linux/console.h>
>  #include <linux/kasan.h>
> +#include <linux/bug.h>
>  
>  #include <asm/sections.h>
>  
> @@ -110,6 +111,11 @@ static __init int kernel_lockdep_sysctls_init(void)
>  late_initcall(kernel_lockdep_sysctls_init);
>  #endif /* CONFIG_SYSCTL */
>  
> +static void print_footer(void)
> +{
> +	pr_warn("---[ end trace %016llx ]---\n", 0ULL);
> +}
> +
>  DEFINE_PER_CPU(unsigned int, lockdep_recursion);
>  EXPORT_PER_CPU_SYMBOL_GPL(lockdep_recursion);
>  
> @@ -1958,6 +1964,7 @@ print_circular_bug_header(struct lock_list *entry, unsigned int depth,
>  		return;
>  
>  	pr_warn("\n");
> +	pr_warn(CUT_HERE);
>  	pr_warn("======================================================\n");
>  	pr_warn("WARNING: possible circular locking dependency detected\n");
>  	print_kernel_ident();
> @@ -2041,6 +2048,7 @@ static noinline void print_circular_bug(struct lock_list *this,
>  
>  	printk("\nstack backtrace:\n");
>  	dump_stack();
> +	print_footer();
>  
>  	nbcon_cpu_emergency_exit();
>  }
> @@ -2561,6 +2569,7 @@ print_bad_irq_dependency(struct task_struct *curr,
>  	nbcon_cpu_emergency_enter();
>  
>  	pr_warn("\n");
> +	pr_warn(CUT_HERE);
>  	pr_warn("=====================================================\n");
>  	pr_warn("WARNING: %s-safe -> %s-unsafe lock order detected\n",
>  		irqclass, irqclass);
> @@ -2614,6 +2623,7 @@ print_bad_irq_dependency(struct task_struct *curr,
>  
>  	pr_warn("\nstack backtrace:\n");
>  	dump_stack();
> +	print_footer();
>  out:
>  	nbcon_cpu_emergency_exit();
>  }
> @@ -3018,6 +3028,7 @@ print_deadlock_bug(struct task_struct *curr, struct held_lock *prev,
>  	nbcon_cpu_emergency_enter();
>  
>  	pr_warn("\n");
> +	pr_warn(CUT_HERE);
>  	pr_warn("============================================\n");
>  	pr_warn("WARNING: possible recursive locking detected\n");
>  	print_kernel_ident();
> @@ -3039,6 +3050,7 @@ print_deadlock_bug(struct task_struct *curr, struct held_lock *prev,
>  
>  	pr_warn("\nstack backtrace:\n");
>  	dump_stack();
> +	print_footer();
>  
>  	nbcon_cpu_emergency_exit();
>  }
> @@ -3641,6 +3653,7 @@ static void print_collision(struct task_struct *curr,
>  	nbcon_cpu_emergency_enter();
>  
>  	pr_warn("\n");
> +	pr_warn(CUT_HERE);
>  	pr_warn("============================\n");
>  	pr_warn("WARNING: chain_key collision\n");
>  	print_kernel_ident();
> @@ -3656,6 +3669,7 @@ static void print_collision(struct task_struct *curr,
>  
>  	pr_warn("\nstack backtrace:\n");
>  	dump_stack();
> +	print_footer();
>  
>  	nbcon_cpu_emergency_exit();
>  }
> @@ -4013,6 +4027,7 @@ print_usage_bug(struct task_struct *curr, struct held_lock *this,
>  	nbcon_cpu_emergency_enter();
>  
>  	pr_warn("\n");
> +	pr_warn(CUT_HERE);
>  	pr_warn("================================\n");
>  	pr_warn("WARNING: inconsistent lock state\n");
>  	print_kernel_ident();
> @@ -4040,6 +4055,7 @@ print_usage_bug(struct task_struct *curr, struct held_lock *this,
>  
>  	pr_warn("\nstack backtrace:\n");
>  	dump_stack();
> +	print_footer();
>  
>  	nbcon_cpu_emergency_exit();
>  }
> @@ -4079,6 +4095,7 @@ print_irq_inversion_bug(struct task_struct *curr,
>  	nbcon_cpu_emergency_enter();
>  
>  	pr_warn("\n");
> +	pr_warn(CUT_HERE);
>  	pr_warn("========================================================\n");
>  	pr_warn("WARNING: possible irq lock inversion dependency detected\n");
>  	print_kernel_ident();
> @@ -4123,6 +4140,7 @@ print_irq_inversion_bug(struct task_struct *curr,
>  
>  	pr_warn("\nstack backtrace:\n");
>  	dump_stack();
> +	print_footer();
>  out:
>  	nbcon_cpu_emergency_exit();
>  }
> @@ -4811,6 +4829,7 @@ print_lock_invalid_wait_context(struct task_struct *curr,
>  	nbcon_cpu_emergency_enter();
>  
>  	pr_warn("\n");
> +	pr_warn(CUT_HERE);
>  	pr_warn("=============================\n");
>  	pr_warn("[ BUG: Invalid wait context ]\n");
>  	print_kernel_ident();
> @@ -4828,6 +4847,7 @@ print_lock_invalid_wait_context(struct task_struct *curr,
>  
>  	pr_warn("stack backtrace:\n");
>  	dump_stack();
> +	print_footer();
>  
>  	nbcon_cpu_emergency_exit();
>  
> @@ -5041,6 +5061,7 @@ print_lock_nested_lock_not_held(struct task_struct *curr,
>  	nbcon_cpu_emergency_enter();
>  
>  	pr_warn("\n");
> +	pr_warn(CUT_HERE);
>  	pr_warn("==================================\n");
>  	pr_warn("WARNING: Nested lock was not taken\n");
>  	print_kernel_ident();
> @@ -5060,6 +5081,7 @@ print_lock_nested_lock_not_held(struct task_struct *curr,
>  
>  	pr_warn("\nstack backtrace:\n");
>  	dump_stack();
> +	print_footer();
>  
>  	nbcon_cpu_emergency_exit();
>  }
> @@ -5281,6 +5303,7 @@ static void print_unlock_imbalance_bug(struct task_struct *curr,
>  	nbcon_cpu_emergency_enter();
>  
>  	pr_warn("\n");
> +	pr_warn(CUT_HERE);
>  	pr_warn("=====================================\n");
>  	pr_warn("WARNING: bad unlock balance detected!\n");
>  	print_kernel_ident();
> @@ -5296,6 +5319,7 @@ static void print_unlock_imbalance_bug(struct task_struct *curr,
>  
>  	pr_warn("\nstack backtrace:\n");
>  	dump_stack();
> +	print_footer();
>  
>  	nbcon_cpu_emergency_exit();
>  }
> @@ -6013,6 +6037,7 @@ static void print_lock_contention_bug(struct task_struct *curr,
>  	nbcon_cpu_emergency_enter();
>  
>  	pr_warn("\n");
> +	pr_warn(CUT_HERE);
>  	pr_warn("=================================\n");
>  	pr_warn("WARNING: bad contention detected!\n");
>  	print_kernel_ident();
> @@ -6028,6 +6053,7 @@ static void print_lock_contention_bug(struct task_struct *curr,
>  
>  	pr_warn("\nstack backtrace:\n");
>  	dump_stack();
> +	print_footer();
>  
>  	nbcon_cpu_emergency_exit();
>  }
> @@ -6680,6 +6706,7 @@ print_freed_lock_bug(struct task_struct *curr, const void *mem_from,
>  	nbcon_cpu_emergency_enter();
>  
>  	pr_warn("\n");
> +	pr_warn(CUT_HERE);
>  	pr_warn("=========================\n");
>  	pr_warn("WARNING: held lock freed!\n");
>  	print_kernel_ident();
> @@ -6691,6 +6718,7 @@ print_freed_lock_bug(struct task_struct *curr, const void *mem_from,
>  
>  	pr_warn("\nstack backtrace:\n");
>  	dump_stack();
> +	print_footer();
>  
>  	nbcon_cpu_emergency_exit();
>  }
> @@ -6742,6 +6770,7 @@ static void print_held_locks_bug(void)
>  	nbcon_cpu_emergency_enter();
>  
>  	pr_warn("\n");
> +	pr_warn(CUT_HERE);
>  	pr_warn("====================================\n");
>  	pr_warn("WARNING: %s/%d still has locks held!\n",
>  	       current->comm, task_pid_nr(current));
> @@ -6750,6 +6779,7 @@ static void print_held_locks_bug(void)
>  	lockdep_print_held_locks(current);
>  	pr_warn("\nstack backtrace:\n");
>  	dump_stack();
> +	print_footer();
>  
>  	nbcon_cpu_emergency_exit();
>  }
> @@ -6811,6 +6841,7 @@ asmlinkage __visible void lockdep_sys_exit(void)
>  			return;
>  		nbcon_cpu_emergency_enter();
>  		pr_warn("\n");
> +		pr_warn(CUT_HERE);
>  		pr_warn("================================================\n");
>  		pr_warn("WARNING: lock held when returning to user space!\n");
>  		print_kernel_ident();
> @@ -6818,6 +6849,7 @@ asmlinkage __visible void lockdep_sys_exit(void)
>  		pr_warn("%s/%d is leaving the kernel with locks still held!\n",
>  				curr->comm, curr->pid);
>  		lockdep_print_held_locks(curr);
> +		print_footer();
>  		nbcon_cpu_emergency_exit();
>  	}
>  
> @@ -6837,6 +6869,7 @@ void lockdep_rcu_suspicious(const char *file, const int line, const char *s)
>  	/* Note: the following can be executed concurrently, so be careful. */
>  	nbcon_cpu_emergency_enter();
>  	pr_warn("\n");
> +	pr_warn(CUT_HERE);
>  	pr_warn("=============================\n");
>  	pr_warn("WARNING: suspicious RCU usage\n");
>  	print_kernel_ident();
> @@ -6874,6 +6907,7 @@ void lockdep_rcu_suspicious(const char *file, const int line, const char *s)
>  	lockdep_print_held_locks(curr);
>  	pr_warn("\nstack backtrace:\n");
>  	dump_stack();
> +	print_footer();
>  	nbcon_cpu_emergency_exit();
>  	warn_rcu_exit(rcu);
>  }
> -- 
> 2.52.0.305.g3fc767764a-goog
> 

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

* Re: [PATCH v2] lockdep: Add header and footer to surround warning reports
       [not found] ` <0ae3277b-bea5-40ce-8eaa-10bb8b47c46a@redhat.com>
@ 2025-12-17  0:31   ` Tzung-Bi Shih
  2025-12-17  2:57     ` Waiman Long
  0 siblings, 1 reply; 4+ messages in thread
From: Tzung-Bi Shih @ 2025-12-17  0:31 UTC (permalink / raw)
  To: Waiman Long
  Cc: Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng,
	linux-kernel

On Tue, Dec 16, 2025 at 11:20:45AM -0500, Waiman Long wrote:
> On 12/15/25 2:26 AM, Tzung-Bi Shih wrote:
> > Add header and footer to improve log parsing and automated analysis.
> > This makes lockdep output easier to interpret.
> > 
> > Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
> > ---
> > v2:
> > - asm/bugs.h -> linux/bug.h.
> > 
> > v1: https://lore.kernel.org/all/20251114062730.1828416-1-tzungbi@kernel.org/
> > 
> >   kernel/locking/lockdep.c | 34 ++++++++++++++++++++++++++++++++++
> >   1 file changed, 34 insertions(+)
> > 
> > diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
> > index 2d4c5bab5af8..adbc44c3808d 100644
> > --- a/kernel/locking/lockdep.c
> > +++ b/kernel/locking/lockdep.c
> > @@ -58,6 +58,7 @@
> >   #include <linux/context_tracking.h>
> >   #include <linux/console.h>
> >   #include <linux/kasan.h>
> > +#include <linux/bug.h>
> >   #include <asm/sections.h>
> > @@ -110,6 +111,11 @@ static __init int kernel_lockdep_sysctls_init(void)
> >   late_initcall(kernel_lockdep_sysctls_init);
> >   #endif /* CONFIG_SYSCTL */
> > +static void print_footer(void)
> > +{
> > +	pr_warn("---[ end trace %016llx ]---\n", 0ULL);
> 
> What is the purpose of putting 16 '0' in this "end trace" line? Is it
> related to how your parsing script works?

Mostly wanted to align to print_oops_end_marker() in kernel/panic.c.  Before
e83a4472bf9f ("panic: remove oops_id"), it was an oops ID.  My parsing script
doesn't rely on the 16 '0's but existing parsers might.

I have no strong opinion.  Should we just remove the 16 '0's here?

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

* Re: [PATCH v2] lockdep: Add header and footer to surround warning reports
  2025-12-17  0:31   ` Tzung-Bi Shih
@ 2025-12-17  2:57     ` Waiman Long
  2025-12-17  5:26       ` Tzung-Bi Shih
  0 siblings, 1 reply; 4+ messages in thread
From: Waiman Long @ 2025-12-17  2:57 UTC (permalink / raw)
  To: Tzung-Bi Shih, Waiman Long
  Cc: Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng,
	linux-kernel

On 12/16/25 7:31 PM, Tzung-Bi Shih wrote:
> On Tue, Dec 16, 2025 at 11:20:45AM -0500, Waiman Long wrote:
>> On 12/15/25 2:26 AM, Tzung-Bi Shih wrote:
>>> Add header and footer to improve log parsing and automated analysis.
>>> This makes lockdep output easier to interpret.
>>>
>>> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
>>> ---
>>> v2:
>>> - asm/bugs.h -> linux/bug.h.
>>>
>>> v1: https://lore.kernel.org/all/20251114062730.1828416-1-tzungbi@kernel.org/
>>>
>>>    kernel/locking/lockdep.c | 34 ++++++++++++++++++++++++++++++++++
>>>    1 file changed, 34 insertions(+)
>>>
>>> diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
>>> index 2d4c5bab5af8..adbc44c3808d 100644
>>> --- a/kernel/locking/lockdep.c
>>> +++ b/kernel/locking/lockdep.c
>>> @@ -58,6 +58,7 @@
>>>    #include <linux/context_tracking.h>
>>>    #include <linux/console.h>
>>>    #include <linux/kasan.h>
>>> +#include <linux/bug.h>
>>>    #include <asm/sections.h>
>>> @@ -110,6 +111,11 @@ static __init int kernel_lockdep_sysctls_init(void)
>>>    late_initcall(kernel_lockdep_sysctls_init);
>>>    #endif /* CONFIG_SYSCTL */
>>> +static void print_footer(void)
>>> +{
>>> +	pr_warn("---[ end trace %016llx ]---\n", 0ULL);
>> What is the purpose of putting 16 '0' in this "end trace" line? Is it
>> related to how your parsing script works?
> Mostly wanted to align to print_oops_end_marker() in kernel/panic.c.  Before
> e83a4472bf9f ("panic: remove oops_id"), it was an oops ID.  My parsing script
> doesn't rely on the 16 '0's but existing parsers might.
>
> I have no strong opinion.  Should we just remove the 16 '0's here?

These are warning messages, not panic. So I would prefer not to have 
them if they serve no useful purpose and can cause confusion.

Cheers,
Longman

>


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

* Re: [PATCH v2] lockdep: Add header and footer to surround warning reports
  2025-12-17  2:57     ` Waiman Long
@ 2025-12-17  5:26       ` Tzung-Bi Shih
  0 siblings, 0 replies; 4+ messages in thread
From: Tzung-Bi Shih @ 2025-12-17  5:26 UTC (permalink / raw)
  To: Waiman Long
  Cc: Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng,
	linux-kernel

On Tue, Dec 16, 2025 at 09:57:30PM -0500, Waiman Long wrote:
> On 12/16/25 7:31 PM, Tzung-Bi Shih wrote:
> > On Tue, Dec 16, 2025 at 11:20:45AM -0500, Waiman Long wrote:
> > > On 12/15/25 2:26 AM, Tzung-Bi Shih wrote:
> > > > @@ -110,6 +111,11 @@ static __init int kernel_lockdep_sysctls_init(void)
> > > >    late_initcall(kernel_lockdep_sysctls_init);
> > > >    #endif /* CONFIG_SYSCTL */
> > > > +static void print_footer(void)
> > > > +{
> > > > +	pr_warn("---[ end trace %016llx ]---\n", 0ULL);
> > > What is the purpose of putting 16 '0' in this "end trace" line? Is it
> > > related to how your parsing script works?
> > Mostly wanted to align to print_oops_end_marker() in kernel/panic.c.  Before
> > e83a4472bf9f ("panic: remove oops_id"), it was an oops ID.  My parsing script
> > doesn't rely on the 16 '0's but existing parsers might.
> > 
> > I have no strong opinion.  Should we just remove the 16 '0's here?
> 
> These are warning messages, not panic. So I would prefer not to have them if
> they serve no useful purpose and can cause confusion.

Ack, fixed in v3[1].

[1] https://lore.kernel.org/all/20251217052353.1489154-1-tzungbi@kernel.org/T/#u

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

end of thread, other threads:[~2025-12-17  5:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20251215072640.2580384-1-tzungbi@kernel.org>
2025-12-16  1:03 ` [PATCH v2] lockdep: Add header and footer to surround warning reports Tzung-Bi Shih
     [not found] ` <0ae3277b-bea5-40ce-8eaa-10bb8b47c46a@redhat.com>
2025-12-17  0:31   ` Tzung-Bi Shih
2025-12-17  2:57     ` Waiman Long
2025-12-17  5:26       ` Tzung-Bi Shih

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