Page MenuHomeFreeBSD

ps(1): reuse keyword "cpu" to show CPU number
ClosedPublic

Authored by pstef on Jun 20 2020, 7:30 PM.

Details

Summary

This flag will now obtain and show the processor number on which a process is running.

This change was inspired by PR129965. Initially I didn't think that the patch attached to it was correct -- it sacrificed ki_estcpu use in "cpu" for ki_lastcpu and I thought that the old functionality should be kept and the new one added to it. But I've since discovered that ki_estcpu is sched_4bsd-specific. What's worse, it represents the same thing as ki_pctcpu, except ki_pctcpu is universal -- so "%cpu" has been using it successfully. Therefore, I've decided to replace information based on ki_estcpu with information based on ki_oncpu/ki_lastcpu.

Key parts of code and manual were borrowed from top(1).

# ps -ocomm,cpu,%cpu
COMMAND C %CPU
getty   3  0.0
getty   3  0.0
getty   0  0.0
getty   3  0.0
getty   0  0.0
getty   1  0.0
getty   3  0.0
getty   0  0.0
ps      3  0.0
su      0  0.0
csh     0  0.0

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

pstef requested review of this revision.Jun 20 2020, 7:30 PM
pstef created this revision.
pstef edited the summary of this revision. (Show Details)
pstef edited the summary of this revision. (Show Details)
pstef edited the summary of this revision. (Show Details)

Changed my mind, the new functionality will replace the old one.

pstef retitled this revision from ps(1): add a cpu# flag to ps(1): reuse keyword "cpu" to show CPU number.Jun 20 2020, 10:56 PM
pstef edited the summary of this revision. (Show Details)

Don't make keyword descriptions even less sorted than they are now.

This revision was not accepted when it landed; it landed in state Needs Review.Jun 27 2020, 7:09 PM
This revision was automatically updated to reflect the committed changes.