Easy way to know, which command/process is sleeping and in which kernel function using WCHAN?..

I quite oftenly use below command to know the same..

# ps -eopid,tt,user,fname,tmout,f,wchan

The important bit here is “WCHAN” field and the “COMMAND” field.. “WCHAN” points to the “sleeping function” in kernel mode..

WCHAN : address of the kernel function where the process is sleeping (use wchan if you want the kernel
                           function name). Running tasks will display a dash (‘-‘) in this column.

[root@humbles-lap ~]$ ps -eopid,tt,user,fname,tmout,f,wchan
  PID TT       USER     COMMAND  TMOUT F WCHAN
1 ?        root     systemd      – 4 epoll_wait
2 ?        root     kthreadd     – 1 kthreadd
3 ?        root     ksoftirq     – 1 run_ksoftirqd
6 ?        root     migratio     – 1 cpu_stopper_thread
7 ?        root     watchdog     – 5 watchdog
21 ?        root     cpuset       – 1 rescuer_thread
22 ?        root     khelper      – 1 rescuer_thread
23 ?        root     kdevtmpf     – 5 devtmpfsd
24 ?        root     netns        – 1 rescuer_thread
25 ?        root     sync_sup     – 1 bdi_sync_supers
26 ?        root     bdi-defa     – 1 bdi_forker_thread
27 ?        root     kintegri     – 1 rescuer_thread
28 ?        root     kblockd      – 1 rescuer_thread
29 ?        root     ata_sff      – 1 rescuer_thread
30 ?        root     khubd        – 1 hub_thread
31 ?        root     md           – 1 rescuer_thread
55 ?        root     kswapd0      – 1 kswapd
56 ?        root     ksmd         – 1 ksm_scan_thread
57 ?        root     khugepag     – 1 khugepaged_alloc_sleep
58 ?        root     fsnotify     – 1 fsnotify_mark_destroy
59 ?        root     crypto       – 1 rescuer_thread
65 ?        root     kthrotld     – 1 rescuer_thread
66 ?        root     scsi_eh_     – 1 scsi_error_handler
67 ?        root     scsi_eh_     – 1 scsi_error_handler
68 ?        root     scsi_eh_     – 1 scsi_error_handler
69 ?        root     scsi_eh_     – 1 scsi_error_handler
70 ?        root     scsi_eh_     – 1 scsi_error_handler
71 ?        root     scsi_eh_     – 1 scsi_error_handler
79 ?        root     kpsmouse     – 1 rescuer_thread
130 ?        root     ttm_swap     – 1 rescuer_thread
311 ?        root     kdmflush     – 1 rescuer_thread
320 ?        root     jbd2/dm-     – 1 kjournald2
321 ?        root     ext4-dio     – 1 rescuer_thread
355 ?        root     kauditd      – 1 kauditd_thread
357 ?        root     udevd        – 4 poll_schedule_timeout
378 ?        root     systemd-     – 4 epoll_wait
391 ?        root     kvm-irqf     – 1 rescuer_thread
640 ?        root     ips-adju     – 1 ips_adjust
641 ?        root     ips-moni     – 1 ips_monitor
648 ?        root     cfg80211     – 1 rescuer_thread
661 ?        root     hci0         – 1 rescuer_thread
671 ?        root     iwlwifi      – 1 rescuer_thread
688 ?        root     hd-audio     – 1 rescuer_thread
736 ?        root     hd-audio     – 1 rescuer_thread
772 ?        root     flush-25     – 1 bdi_writeback_thread
775 ?        root     kdmflush     – 1 rescuer_thread
802 ?        root     kjournal     – 1 kjournald
811 ?        root     jbd2/sda     – 1 kjournald2
812 ?        root     ext4-dio     – 1 rescuer_thread
829 ?        root     bluetoot     – 4 poll_schedule_timeout
841 ?        avahi    avahi-da     – 4 poll_schedule_timeout
859 ?        root     abrtd        – 0 poll_schedule_timeout
862 ?        avahi    avahi-da     – 1 unix_stream_recvmsg
890 ?        root     gpm          – 5 hrtimer_nanosleep
893 ?        root     NetworkM     – 4 poll_schedule_timeout
895 ?        root     mcelog       – 4 poll_schedule_timeout

*********** Truncated

Hope this helps!!