Page MenuHomeFreeBSD

top(8): fix process state sorting
ClosedPublic

Authored by kib on Jun 19 2023, 4:04 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 6, 10:49 AM
Unknown Object (File)
Sat, Nov 2, 7:25 AM
Unknown Object (File)
Fri, Nov 1, 9:42 PM
Unknown Object (File)
Fri, Oct 18, 6:36 AM
Unknown Object (File)
Oct 2 2024, 12:49 PM
Unknown Object (File)
Sep 29 2024, 9:26 PM
Unknown Object (File)
Sep 27 2024, 11:12 AM
Unknown Object (File)
Sep 26 2024, 7:23 AM

Details

Summary
top(8): designate the sorted_state[] array as constant
top(8): use designated initializers for sorted_state[]
top(8): document the actual sort order for process sorting
    top(8): add missed SLOCK state to the sorted_state[]
    
    Put it near/after the sleep state.
    
    Noted by:       Mark Millard <marklmi@yahoo.com>
`

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib requested review of this revision.Jun 19 2023, 4:04 PM
kib edited the summary of this revision. (Show Details)
kevans added inline comments.
usr.bin/top/machine.c
1272

With designated initializers we could just drop the unused 0 now, no? Holes get filled in with 0 anyways, and I'm not sure the documentation of it as unused is necessarily useful.

1293

I wonder if we should drop some assertions here to catch a ki_stat >= nitems(sorted_state) rather than relying on the out of bounds access to be caught in some other fashion, but I don't insist...

This revision is now accepted and ready to land.Jun 19 2023, 4:14 PM
kib marked an inline comment as done.

Drop [0] initializer.

This revision now requires review to proceed.Jun 19 2023, 4:40 PM
usr.bin/top/machine.c
1293

My HPoV there is that the asserts abruptly stopping the utility are worse then accessing random memory and sorting processes less precisely. I do not believe that compilers can turn this UB into rm -rf (yet). Having random user visible failure for something that is just a display is annoying.

kevans added inline comments.
usr.bin/top/machine.c
1293

Reasonable

This revision is now accepted and ready to land.Jun 19 2023, 4:53 PM
markmi_dsl-only.net added inline comments.
usr.bin/top/machine.c
1278

The comments only seem to make sense for:
[SZOMB] <=> zombie
[SLOCK] <=> blocked on lock.
Those comments do not add as much now, given the new notation.

But things like:
[SRUN] <=> interrupt wait
just seem misleading.

kib marked an inline comment as done.

Update comments for the state descriptions.

This revision now requires review to proceed.Jun 20 2023, 3:54 AM
netchild added inline comments.
usr.bin/top/machine.c
1293

Printing a one time warning instead of an assert?

It's not uncommon that the output of top is garbled by whatever reason in real-world usage, and I use ctrl-l to fix the messed up display when it happens. As such I would not mind if it is a simple one-time printf, but can understand if someone would consider this too ugly.