Skip to contentSkip to conversation

lib/sys_info: avoid showing locks info twice in __sys_info

PATCH In review Leon Hwang 3 participants 3 messages Nov 13 – Nov 16 Library code

lore
Share & tools
lore

Leon Hwang

author
#0 lore raw

PATCH 1/1 lib/sys_info: avoid showing locks info twice in __sys_info

In __sys_info(), if the si_mask has both SYS_INFO_TASKS and SYS_INFO_LOCKS, the locks info will be printed twice: debug_show_all_locks() is also called inner show_state().

Since commit
8b2b9b4f6f4f ("hung_task: add hung_task_sys_info sysctl to dump sys info on task-hung"), hung_task will print locks info twice when
sysctl -w kernel.hung_task_sys_info="tasks,locks".

[ 4658.894440]
               Showing all locks held in the system:
[ 4658.894445] locks held by khungtaskd/119: 1, last CPU#7:
[ 4658.894449]  #0: ffffffff9159cd00 (rcu_read_lock){....}-{1:3}, at: debug_show_all_locks+0x3b/0x1f0
[ 4658.894468] locks held by cat/674: 1, on CPU#8:
[ 4658.894472]  #0: ffffffffc01681a0 (dummy_mutex){+.+.}-{4:4}, at: read_dummy_mutex+0x34/0x80 [hung_task_tests]
[ 4658.894487] locks held by cat/676: 1, on CPU#8:
[ 4658.894490]  #0: ffffffffc01681a0 (dummy_mutex){+.+.}-{4:4}, at: read_dummy_mutex+0x34/0x80 [hung_task_tests]
[ 4658.894504] locks held by dmesg/677: 5, last CPU#8:
[ 4658.894507]  #0: ff426e3f828ee0a0 (&tty->ldisc_sem){++++}-{0:0}, at: ldsem_down_read+0x34/0x40
[ 4658.894521]  #1: ff426e3f828ee128 (&tty->atomic_write_lock){+.+.}-{4:4}, at: file_tty_write.isra.0+0xaa/0x360
[ 4658.894535]  #2: ff426e3f828ee2c8 (&tty->termios_rwsem){++++}-{4:4}, at: n_tty_write+0x9d/0x4c0
[ 4658.894549]  #3: ff4fe07e82c57370 (&ldata->output_lock){+.+.}-{4:4}, at: remove_wait_queue+0x1b/0x60
[ 4658.894563]  #4: ffffffff927b1278 (&port_lock_key){-.-.}-{3:3}, at: uart_write_room+0x4e/0x230
[ 4658.894581] =============================================
[ 4658.894583]
               Showing all locks held in the system:
[ 4658.894586] locks held by khungtaskd/119: 1, last CPU#7:
[ 4658.894589]  #0: ffffffff9159cd00 (rcu_read_lock){....}-{1:3}, at: debug_show_all_locks+0x3b/0x1f0
[ 4658.894604] locks held by cat/674: 1, on CPU#8:
[ 4658.894607]  #0: ffffffffc01681a0 (dummy_mutex){+.+.}-{4:4}, at: read_dummy_mutex+0x34/0x80 [hung_task_tests]
[ 4658.894622] locks held by cat/676: 1, on CPU#8:
[ 4658.894625]  #0: ffffffffc01681a0 (dummy_mutex){+.+.}-{4:4}, at: read_dummy_mutex+0x34/0x80 [hung_task_tests]
[ 4658.894639] locks held by dmesg/677: 5, last CPU#8:
[ 4658.894642]  #0: ff426e3f828ee0a0 (&tty->ldisc_sem){++++}-{0:0}, at: ldsem_down_read+0x34/0x40
[ 4658.894655]  #1: ff426e3f828ee128 (&tty->atomic_write_lock){+.+.}-{4:4}, at: file_tty_write.isra.0+0xaa/0x360
[ 4658.894669]  #2: ff426e3f828ee2c8 (&tty->termios_rwsem){++++}-{4:4}, at: n_tty_write+0x9d/0x4c0
[ 4658.894683]  #3: ff4fe07e82c57370 (&ldata->output_lock){+.+.}-{4:4}, at: n_tty_write+0x190/0x4c0
[ 4658.894697]  #4: ffffffff927b1278 (&port_lock_key){-.-.}-{3:3}, at: uart_write_room+0x4e/0x230
[ 4658.894713] =============================================

To avoid showing locks info again, check '!(si_mask & SYS_INFO_TASKS)' when checking 'si_mask & SYS_INFO_LOCKS' in __sys_info().

---
 lib/sys_info.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/sys_info.c +1 -1
index f32a06ec9ed4..750803012f43 100644
@@ -147,7 +147,7 @@ static void __sys_info(unsigned long si_mask)
 	if (si_mask & SYS_INFO_TIMERS)
 		sysrq_timer_list_show();
 
-	if (si_mask & SYS_INFO_LOCKS)
+	if ((si_mask & SYS_INFO_LOCKS) && !(si_mask & SYS_INFO_TASKS))
 		debug_show_all_locks();
 
 	if (si_mask & SYS_INFO_FTRACE)
Signature · 1 line
2.55.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Leon Hwang

In __sys_info(), if the si_mask has both SYS_INFO_TASKS and SYS_INFO_LOCKS, the locks info will be printed twice: debug_show_all_locks() is also called inner show_state().

Good catch!

Quoted 52 lines

Since commit
8b2b9b4f6f4f ("hung_task: add hung_task_sys_info sysctl to dump sys info on task-hung"), hung_task will print locks info twice when
sysctl -w kernel.hung_task_sys_info="tasks,locks".

[ 4658.894440]
              Showing all locks held in the system:
[ 4658.894445] locks held by khungtaskd/119: 1, last CPU#7:
[ 4658.894449]  #0: ffffffff9159cd00 (rcu_read_lock){....}-{1:3}, at: debug_show_all_locks+0x3b/0x1f0
[ 4658.894468] locks held by cat/674: 1, on CPU#8:
[ 4658.894472]  #0: ffffffffc01681a0 (dummy_mutex){+.+.}-{4:4}, at: read_dummy_mutex+0x34/0x80 [hung_task_tests]
[ 4658.894487] locks held by cat/676: 1, on CPU#8:
[ 4658.894490]  #0: ffffffffc01681a0 (dummy_mutex){+.+.}-{4:4}, at: read_dummy_mutex+0x34/0x80 [hung_task_tests]
[ 4658.894504] locks held by dmesg/677: 5, last CPU#8:
[ 4658.894507]  #0: ff426e3f828ee0a0 (&tty->ldisc_sem){++++}-{0:0}, at: ldsem_down_read+0x34/0x40
[ 4658.894521]  #1: ff426e3f828ee128 (&tty->atomic_write_lock){+.+.}-{4:4}, at: file_tty_write.isra.0+0xaa/0x360
[ 4658.894535]  #2: ff426e3f828ee2c8 (&tty->termios_rwsem){++++}-{4:4}, at: n_tty_write+0x9d/0x4c0
[ 4658.894549]  #3: ff4fe07e82c57370 (&ldata->output_lock){+.+.}-{4:4}, at: remove_wait_queue+0x1b/0x60
[ 4658.894563]  #4: ffffffff927b1278 (&port_lock_key){-.-.}-{3:3}, at: uart_write_room+0x4e/0x230
[ 4658.894581] =============================================
[ 4658.894583]
              Showing all locks held in the system:
[ 4658.894586] locks held by khungtaskd/119: 1, last CPU#7:
[ 4658.894589]  #0: ffffffff9159cd00 (rcu_read_lock){....}-{1:3}, at: debug_show_all_locks+0x3b/0x1f0
[ 4658.894604] locks held by cat/674: 1, on CPU#8:
[ 4658.894607]  #0: ffffffffc01681a0 (dummy_mutex){+.+.}-{4:4}, at: read_dummy_mutex+0x34/0x80 [hung_task_tests]
[ 4658.894622] locks held by cat/676: 1, on CPU#8:
[ 4658.894625]  #0: ffffffffc01681a0 (dummy_mutex){+.+.}-{4:4}, at: read_dummy_mutex+0x34/0x80 [hung_task_tests]
[ 4658.894639] locks held by dmesg/677: 5, last CPU#8:
[ 4658.894642]  #0: ff426e3f828ee0a0 (&tty->ldisc_sem){++++}-{0:0}, at: ldsem_down_read+0x34/0x40
[ 4658.894655]  #1: ff426e3f828ee128 (&tty->atomic_write_lock){+.+.}-{4:4}, at: file_tty_write.isra.0+0xaa/0x360
[ 4658.894669]  #2: ff426e3f828ee2c8 (&tty->termios_rwsem){++++}-{4:4}, at: n_tty_write+0x9d/0x4c0
[ 4658.894683]  #3: ff4fe07e82c57370 (&ldata->output_lock){+.+.}-{4:4}, at: n_tty_write+0x190/0x4c0
[ 4658.894697]  #4: ffffffff927b1278 (&port_lock_key){-.-.}-{3:3}, at: uart_write_room+0x4e/0x230
[ 4658.894713] =============================================

To avoid showing locks info again, check '!(si_mask & SYS_INFO_TASKS)' when checking 'si_mask & SYS_INFO_LOCKS' in __sys_info().

---
lib/sys_info.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
lib/sys_info.c +0 -0
index f32a06ec9ed4..750803012f43 100644

lib/sys_info.c static void __sys_info(unsigned long si_mask) · line 151

Quoted 6 lines
lib/sys_info.c +1 -1
@@ -147,7 +147,7 @@ static void __sys_info(unsigned long si_mask)
 	if (si_mask & SYS_INFO_TIMERS)
 		sysrq_timer_list_show();
 
-	if (si_mask & SYS_INFO_LOCKS)
+	if ((si_mask & SYS_INFO_LOCKS) && !(si_mask & SYS_INFO_TASKS))
 		debug_show_all_locks();

LGTM, thanks!

Quoted 6 lines
lib/sys_info.c +0 -0
 	if (si_mask & SYS_INFO_FTRACE)
Signature · 1 line
2.55.0
Reviewed-by on v1 1/1
#2 lore raw
In reply to Leon Hwang
Quoted 41 lines · Leon Hwang

In __sys_info(), if the si_mask has both SYS_INFO_TASKS and SYS_INFO_LOCKS, the locks info will be printed twice: debug_show_all_locks() is also called inner show_state().

Since commit
8b2b9b4f6f4f ("hung_task: add hung_task_sys_info sysctl to dump sys info on task-hung"), hung_task will print locks info twice when
sysctl -w kernel.hung_task_sys_info="tasks,locks".

[ 4658.894440]
               Showing all locks held in the system:
[ 4658.894445] locks held by khungtaskd/119: 1, last CPU#7:
[ 4658.894449]  #0: ffffffff9159cd00 (rcu_read_lock){....}-{1:3}, at: debug_show_all_locks+0x3b/0x1f0
[ 4658.894468] locks held by cat/674: 1, on CPU#8:
[ 4658.894472]  #0: ffffffffc01681a0 (dummy_mutex){+.+.}-{4:4}, at: read_dummy_mutex+0x34/0x80 [hung_task_tests]
[ 4658.894487] locks held by cat/676: 1, on CPU#8:
[ 4658.894490]  #0: ffffffffc01681a0 (dummy_mutex){+.+.}-{4:4}, at: read_dummy_mutex+0x34/0x80 [hung_task_tests]
[ 4658.894504] locks held by dmesg/677: 5, last CPU#8:
[ 4658.894507]  #0: ff426e3f828ee0a0 (&tty->ldisc_sem){++++}-{0:0}, at: ldsem_down_read+0x34/0x40
[ 4658.894521]  #1: ff426e3f828ee128 (&tty->atomic_write_lock){+.+.}-{4:4}, at: file_tty_write.isra.0+0xaa/0x360
[ 4658.894535]  #2: ff426e3f828ee2c8 (&tty->termios_rwsem){++++}-{4:4}, at: n_tty_write+0x9d/0x4c0
[ 4658.894549]  #3: ff4fe07e82c57370 (&ldata->output_lock){+.+.}-{4:4}, at: remove_wait_queue+0x1b/0x60
[ 4658.894563]  #4: ffffffff927b1278 (&port_lock_key){-.-.}-{3:3}, at: uart_write_room+0x4e/0x230
[ 4658.894581] =============================================
[ 4658.894583]
               Showing all locks held in the system:
[ 4658.894586] locks held by khungtaskd/119: 1, last CPU#7:
[ 4658.894589]  #0: ffffffff9159cd00 (rcu_read_lock){....}-{1:3}, at: debug_show_all_locks+0x3b/0x1f0
[ 4658.894604] locks held by cat/674: 1, on CPU#8:
[ 4658.894607]  #0: ffffffffc01681a0 (dummy_mutex){+.+.}-{4:4}, at: read_dummy_mutex+0x34/0x80 [hung_task_tests]
[ 4658.894622] locks held by cat/676: 1, on CPU#8:
[ 4658.894625]  #0: ffffffffc01681a0 (dummy_mutex){+.+.}-{4:4}, at: read_dummy_mutex+0x34/0x80 [hung_task_tests]
[ 4658.894639] locks held by dmesg/677: 5, last CPU#8:
[ 4658.894642]  #0: ff426e3f828ee0a0 (&tty->ldisc_sem){++++}-{0:0}, at: ldsem_down_read+0x34/0x40
[ 4658.894655]  #1: ff426e3f828ee128 (&tty->atomic_write_lock){+.+.}-{4:4}, at: file_tty_write.isra.0+0xaa/0x360
[ 4658.894669]  #2: ff426e3f828ee2c8 (&tty->termios_rwsem){++++}-{4:4}, at: n_tty_write+0x9d/0x4c0
[ 4658.894683]  #3: ff4fe07e82c57370 (&ldata->output_lock){+.+.}-{4:4}, at: n_tty_write+0x190/0x4c0
[ 4658.894697]  #4: ffffffff927b1278 (&port_lock_key){-.-.}-{3:3}, at: uart_write_room+0x4e/0x230
Quoted 4 lines
[ 4658.894713] =============================================

To avoid showing locks info again, check '!(si_mask & SYS_INFO_TASKS)' when checking 'si_mask & SYS_INFO_LOCKS' in __sys_info().

Thanks for the fix!