Page MenuHomeFreeBSD

ps(1): Fix formatting of the "command" field for kernel threads.
ClosedPublic

Authored by markj on Jul 28 2020, 12:02 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Dec 21, 10:38 AM
Unknown Object (File)
Mon, Dec 16, 9:13 AM
Unknown Object (File)
Tue, Dec 3, 8:08 AM
Unknown Object (File)
Nov 22 2024, 8:16 AM
Unknown Object (File)
Nov 6 2024, 10:41 PM
Unknown Object (File)
Oct 22 2024, 1:16 PM
Unknown Object (File)
Oct 3 2024, 8:08 PM
Unknown Object (File)
Sep 26 2024, 5:42 PM
Subscribers

Details

Summary

When -H is specified, for kernel threads the command is formatted as
"<proc name>/<td name>" and truncated to MAXCOMLEN. But each of the
proc name and td name may be up to MAXCOMLEN bytes in length.

Also handle the ki_moretdname hack to ensure that the full thread name
gets printed. This is already handled correctly when formatting for
"-o tdname".

Test Plan

Before:

markj@biggie> ps auxH | grep laund
root     49   0.0  0.0     0    80  -  DL   17:32     0:00.00 [pagedaemon/laundry:]
root     49   0.0  0.0     0    80  -  DL   17:32     0:00.00 [pagedaemon/laundry:]

After:

markj@biggie> ps auxH | grep laund
root     49   0.0  0.0     0    80  -  DL   17:32     0:00.00 [pagedaemon/laundry: dom0]
root     49   0.0  0.0     0    80  -  DL   17:32     0:00.00 [pagedaemon/laundry: dom1]

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj created this revision.
markj added reviewers: mjg, freqlabs.
This revision is now accepted and ready to land.Jul 28 2020, 12:16 AM

Here's how it looks with https://github.com/openzfs/zfs/pull/10630 which is what brought this to my attention:

Before:

$ ps axH | grep zfskern
   54  -  SL       0:00.02 [zfskern/arc_evict]
   54  -  SL       0:00.01 [zfskern/arc_reap]
   54  -  SL       0:00.92 [zfskern/dbuf_evict_]
   54  -  SL       0:00.00 [zfskern/l2arc_feed_]
   54  -  IL       0:00.00 [zfskern/sysevent]
   54  -  SL       0:00.01 [zfskern/txg_thread_]
   54  -  SL       0:00.29 [zfskern/txg_thread_]
   54  -  SL       0:00.01 [zfskern/mmp_thread_]
   54  -  IL       0:00.00 [zfskern/z_indirect_]
   54  -  IL       0:00.00 [zfskern/z_livelist_]
   54  -  IL       0:00.00 [zfskern/z_livelist_]
   54  -  IL       0:00.00 [zfskern/z_checkpoin]
   54  -  SL       0:00.05 [zfskern/txg_thread_]
   54  -  SL       0:00.47 [zfskern/txg_thread_]
   54  -  SL       0:00.01 [zfskern/mmp_thread_]
   54  -  IL       0:00.00 [zfskern/z_indirect_]
   54  -  IL       0:00.00 [zfskern/z_livelist_]
   54  -  IL       0:00.00 [zfskern/z_livelist_]
   54  -  IL       0:00.00 [zfskern/z_checkpoin]
   54  -  SL       0:00.04 [zfskern/vdev_autotr]
   54  -  SL       0:00.05 [zfskern/vdev_autotr]
   54  -  SL       0:00.04 [zfskern/vdev_autotr]
   54  -  SL       0:00.05 [zfskern/vdev_autotr]
   54  -  SL       0:00.04 [zfskern/vdev_autotr]

After:

$ ps axH | grep zfskern
   54  -  SL       0:00.02 [zfskern/arc_evict]
   54  -  SL       0:00.01 [zfskern/arc_reap]
   54  -  SL       0:00.88 [zfskern/dbuf_evict_thread]
   54  -  SL       0:00.00 [zfskern/l2arc_feed_thread]
   54  -  IL       0:00.00 [zfskern/sysevent]
   54  -  SL       0:00.01 [zfskern/txg_thread_enter]
   54  -  SL       0:00.27 [zfskern/txg_thread_enter]
   54  -  SL       0:00.01 [zfskern/mmp_thread_enter]
   54  -  IL       0:00.00 [zfskern/z_indirect_condense]
   54  -  IL       0:00.00 [zfskern/z_livelist_destroy]
   54  -  IL       0:00.00 [zfskern/z_livelist_condense]
   54  -  IL       0:00.00 [zfskern/z_checkpoint_discar]
   54  -  SL       0:00.05 [zfskern/txg_thread_enter]
   54  -  SL       0:00.45 [zfskern/txg_thread_enter]
   54  -  SL       0:00.01 [zfskern/mmp_thread_enter]
   54  -  IL       0:00.00 [zfskern/z_indirect_condense]
   54  -  IL       0:00.00 [zfskern/z_livelist_destroy]
   54  -  IL       0:00.00 [zfskern/z_livelist_condense]
   54  -  IL       0:00.00 [zfskern/z_checkpoint_discar]
   54  -  SL       0:00.04 [zfskern/vdev_autotrim_threa]
   54  -  SL       0:00.04 [zfskern/vdev_autotrim_threa]
   54  -  SL       0:00.04 [zfskern/vdev_autotrim_threa]
   54  -  SL       0:00.04 [zfskern/vdev_autotrim_threa]
   54  -  SL       0:00.04 [zfskern/vdev_autotrim_threa]