Page MenuHomeFreeBSD

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

Authored by markj on Tue, Jul 28, 12:02 AM.

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
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

markj requested review of this revision.Tue, Jul 28, 12:02 AM
markj created this revision.
markj edited the test plan for this revision. (Show Details)Tue, Jul 28, 12:04 AM
markj added reviewers: mjg, freqlabs.
freqlabs accepted this revision.Tue, Jul 28, 12:16 AM

That helps, thanks! :)

This revision is now accepted and ready to land.Tue, Jul 28, 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]
This revision was automatically updated to reflect the committed changes.