Skip to content

Commit a5dd63e

Browse files
committed
lockdep: Use "WARNING" tag on lockdep splats
This commit changes lockdep splats to begin lines with "WARNING" and to use pr_warn() instead of printk(). This change eases scripted analysis of kernel console output. Reported-by: Dmitry Vyukov <dvyukov@google.com> Reported-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Acked-by: Dmitry Vyukov <dvyukov@google.com> Reviewed-by: Josh Triplett <josh@joshtriplett.org>
1 parent 5f0d5a3 commit a5dd63e

2 files changed

Lines changed: 48 additions & 47 deletions

File tree

‎kernel/locking/lockdep.c‎

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,10 +1144,10 @@ print_circular_bug_header(struct lock_list *entry, unsigned int depth,
11441144
return 0;
11451145

11461146
printk("\n");
1147-
printk("======================================================\n");
1148-
printk("[ INFO: possible circular locking dependency detected ]\n");
1147+
pr_warn("======================================================\n");
1148+
pr_warn("WARNING: possible circular locking dependency detected\n");
11491149
print_kernel_ident();
1150-
printk("-------------------------------------------------------\n");
1150+
pr_warn("------------------------------------------------------\n");
11511151
printk("%s/%d is trying to acquire lock:\n",
11521152
curr->comm, task_pid_nr(curr));
11531153
print_lock(check_src);
@@ -1482,11 +1482,11 @@ print_bad_irq_dependency(struct task_struct *curr,
14821482
return 0;
14831483

14841484
printk("\n");
1485-
printk("======================================================\n");
1486-
printk("[ INFO: %s-safe -> %s-unsafe lock order detected ]\n",
1485+
pr_warn("=====================================================\n");
1486+
pr_warn("WARNING: %s-safe -> %s-unsafe lock order detected\n",
14871487
irqclass, irqclass);
14881488
print_kernel_ident();
1489-
printk("------------------------------------------------------\n");
1489+
pr_warn("-----------------------------------------------------\n");
14901490
printk("%s/%d [HC%u[%lu]:SC%u[%lu]:HE%u:SE%u] is trying to acquire:\n",
14911491
curr->comm, task_pid_nr(curr),
14921492
curr->hardirq_context, hardirq_count() >> HARDIRQ_SHIFT,
@@ -1711,10 +1711,10 @@ print_deadlock_bug(struct task_struct *curr, struct held_lock *prev,
17111711
return 0;
17121712

17131713
printk("\n");
1714-
printk("=============================================\n");
1715-
printk("[ INFO: possible recursive locking detected ]\n");
1714+
pr_warn("============================================\n");
1715+
pr_warn("WARNING: possible recursive locking detected\n");
17161716
print_kernel_ident();
1717-
printk("---------------------------------------------\n");
1717+
pr_warn("--------------------------------------------\n");
17181718
printk("%s/%d is trying to acquire lock:\n",
17191719
curr->comm, task_pid_nr(curr));
17201720
print_lock(next);
@@ -2061,10 +2061,10 @@ static void print_collision(struct task_struct *curr,
20612061
struct lock_chain *chain)
20622062
{
20632063
printk("\n");
2064-
printk("======================\n");
2065-
printk("[chain_key collision ]\n");
2064+
pr_warn("============================\n");
2065+
pr_warn("WARNING: chain_key collision\n");
20662066
print_kernel_ident();
2067-
printk("----------------------\n");
2067+
pr_warn("----------------------------\n");
20682068
printk("%s/%d: ", current->comm, task_pid_nr(current));
20692069
printk("Hash chain already cached but the contents don't match!\n");
20702070

@@ -2360,10 +2360,10 @@ print_usage_bug(struct task_struct *curr, struct held_lock *this,
23602360
return 0;
23612361

23622362
printk("\n");
2363-
printk("=================================\n");
2364-
printk("[ INFO: inconsistent lock state ]\n");
2363+
pr_warn("================================\n");
2364+
pr_warn("WARNING: inconsistent lock state\n");
23652365
print_kernel_ident();
2366-
printk("---------------------------------\n");
2366+
pr_warn("--------------------------------\n");
23672367

23682368
printk("inconsistent {%s} -> {%s} usage.\n",
23692369
usage_str[prev_bit], usage_str[new_bit]);
@@ -2425,10 +2425,10 @@ print_irq_inversion_bug(struct task_struct *curr,
24252425
return 0;
24262426

24272427
printk("\n");
2428-
printk("=========================================================\n");
2429-
printk("[ INFO: possible irq lock inversion dependency detected ]\n");
2428+
pr_warn("========================================================\n");
2429+
pr_warn("WARNING: possible irq lock inversion dependency detected\n");
24302430
print_kernel_ident();
2431-
printk("---------------------------------------------------------\n");
2431+
pr_warn("--------------------------------------------------------\n");
24322432
printk("%s/%d just changed the state of lock:\n",
24332433
curr->comm, task_pid_nr(curr));
24342434
print_lock(this);
@@ -3170,10 +3170,10 @@ print_lock_nested_lock_not_held(struct task_struct *curr,
31703170
return 0;
31713171

31723172
printk("\n");
3173-
printk("==================================\n");
3174-
printk("[ BUG: Nested lock was not taken ]\n");
3173+
pr_warn("==================================\n");
3174+
pr_warn("WARNING: Nested lock was not taken\n");
31753175
print_kernel_ident();
3176-
printk("----------------------------------\n");
3176+
pr_warn("----------------------------------\n");
31773177

31783178
printk("%s/%d is trying to lock:\n", curr->comm, task_pid_nr(curr));
31793179
print_lock(hlock);
@@ -3383,10 +3383,10 @@ print_unlock_imbalance_bug(struct task_struct *curr, struct lockdep_map *lock,
33833383
return 0;
33843384

33853385
printk("\n");
3386-
printk("=====================================\n");
3387-
printk("[ BUG: bad unlock balance detected! ]\n");
3386+
pr_warn("=====================================\n");
3387+
pr_warn("WARNING: bad unlock balance detected!\n");
33883388
print_kernel_ident();
3389-
printk("-------------------------------------\n");
3389+
pr_warn("-------------------------------------\n");
33903390
printk("%s/%d is trying to release lock (",
33913391
curr->comm, task_pid_nr(curr));
33923392
print_lockdep_cache(lock);
@@ -3880,10 +3880,10 @@ print_lock_contention_bug(struct task_struct *curr, struct lockdep_map *lock,
38803880
return 0;
38813881

38823882
printk("\n");
3883-
printk("=================================\n");
3884-
printk("[ BUG: bad contention detected! ]\n");
3883+
pr_warn("=================================\n");
3884+
pr_warn("WARNING: bad contention detected!\n");
38853885
print_kernel_ident();
3886-
printk("---------------------------------\n");
3886+
pr_warn("---------------------------------\n");
38873887
printk("%s/%d is trying to contend lock (",
38883888
curr->comm, task_pid_nr(curr));
38893889
print_lockdep_cache(lock);
@@ -4244,10 +4244,10 @@ print_freed_lock_bug(struct task_struct *curr, const void *mem_from,
42444244
return;
42454245

42464246
printk("\n");
4247-
printk("=========================\n");
4248-
printk("[ BUG: held lock freed! ]\n");
4247+
pr_warn("=========================\n");
4248+
pr_warn("WARNING: held lock freed!\n");
42494249
print_kernel_ident();
4250-
printk("-------------------------\n");
4250+
pr_warn("-------------------------\n");
42514251
printk("%s/%d is freeing memory %p-%p, with a lock still held there!\n",
42524252
curr->comm, task_pid_nr(curr), mem_from, mem_to-1);
42534253
print_lock(hlock);
@@ -4302,11 +4302,11 @@ static void print_held_locks_bug(void)
43024302
return;
43034303

43044304
printk("\n");
4305-
printk("=====================================\n");
4306-
printk("[ BUG: %s/%d still has locks held! ]\n",
4305+
pr_warn("====================================\n");
4306+
pr_warn("WARNING: %s/%d still has locks held!\n",
43074307
current->comm, task_pid_nr(current));
43084308
print_kernel_ident();
4309-
printk("-------------------------------------\n");
4309+
pr_warn("------------------------------------\n");
43104310
lockdep_print_held_locks(current);
43114311
printk("\nstack backtrace:\n");
43124312
dump_stack();
@@ -4371,7 +4371,7 @@ void debug_show_all_locks(void)
43714371
} while_each_thread(g, p);
43724372

43734373
printk("\n");
4374-
printk("=============================================\n\n");
4374+
pr_warn("=============================================\n\n");
43754375

43764376
if (unlock)
43774377
read_unlock(&tasklist_lock);
@@ -4401,10 +4401,10 @@ asmlinkage __visible void lockdep_sys_exit(void)
44014401
if (!debug_locks_off())
44024402
return;
44034403
printk("\n");
4404-
printk("================================================\n");
4405-
printk("[ BUG: lock held when returning to user space! ]\n");
4404+
pr_warn("================================================\n");
4405+
pr_warn("WARNING: lock held when returning to user space!\n");
44064406
print_kernel_ident();
4407-
printk("------------------------------------------------\n");
4407+
pr_warn("------------------------------------------------\n");
44084408
printk("%s/%d is leaving the kernel with locks still held!\n",
44094409
curr->comm, curr->pid);
44104410
lockdep_print_held_locks(curr);
@@ -4421,13 +4421,13 @@ void lockdep_rcu_suspicious(const char *file, const int line, const char *s)
44214421
#endif /* #ifdef CONFIG_PROVE_RCU_REPEATEDLY */
44224422
/* Note: the following can be executed concurrently, so be careful. */
44234423
printk("\n");
4424-
pr_err("===============================\n");
4425-
pr_err("[ ERR: suspicious RCU usage. ]\n");
4424+
pr_warn("=============================\n");
4425+
pr_warn("WARNING: suspicious RCU usage\n");
44264426
print_kernel_ident();
4427-
pr_err("-------------------------------\n");
4428-
pr_err("%s:%d %s!\n", file, line, s);
4429-
pr_err("\nother info that might help us debug this:\n\n");
4430-
pr_err("\n%srcu_scheduler_active = %d, debug_locks = %d\n",
4427+
pr_warn("-----------------------------\n");
4428+
printk("%s:%d %s!\n", file, line, s);
4429+
printk("\nother info that might help us debug this:\n\n");
4430+
printk("\n%srcu_scheduler_active = %d, debug_locks = %d\n",
44314431
!rcu_lockdep_current_cpu_online()
44324432
? "RCU used illegally from offline CPU!\n"
44334433
: !rcu_is_watching()

‎kernel/locking/rtmutex-debug.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,11 @@ void debug_rt_mutex_print_deadlock(struct rt_mutex_waiter *waiter)
102102
return;
103103
}
104104

105-
printk("\n============================================\n");
106-
printk( "[ BUG: circular locking deadlock detected! ]\n");
107-
printk("%s\n", print_tainted());
108-
printk( "--------------------------------------------\n");
105+
pr_warn("\n");
106+
pr_warn("============================================\n");
107+
pr_warn("WARNING: circular locking deadlock detected!\n");
108+
pr_warn("%s\n", print_tainted());
109+
pr_warn("--------------------------------------------\n");
109110
printk("%s/%d is deadlocking current task %s/%d\n\n",
110111
task->comm, task_pid_nr(task),
111112
current->comm, task_pid_nr(current));

0 commit comments

Comments
 (0)