ps -Hl shows 0 in the CPU# column for every thread. It should show the correct CPU#. Fix: Patch attached with submission follows: How-To-Repeat: observe the output of ps -axHl
Responsible Changed From-To: freebsd-bugs->gavin I'll grab this one
Hi Gavin, I have a patch against HEAD that applies cleanly. Is there any chance this can be committed? Regards, Glen -- Glen Barber | gjb@FreeBSD.org FreeBSD Documentation Project Index: ps/keyword.c =================================================================== --- ps/keyword.c (revision 227541) +++ ps/keyword.c (working copy) @@ -76,7 +76,7 @@ {"comm", "COMMAND", NULL, LJUST, ucomm, 0, CHAR, NULL, 0}, {"command", "COMMAND", NULL, COMM|LJUST|USER, command, 0, CHAR, NULL, 0}, - {"cpu", "CPU", NULL, 0, kvar, KOFF(ki_estcpu), UINT, "d", 0}, + {"cpu", "CPU", NULL, 0, kvar, KOFF(ki_lastcpu), CHAR, "d", 0}, {"cputime", "", "time", 0, NULL, 0, CHAR, NULL, 0}, {"egid", "", "gid", 0, NULL, 0, CHAR, NULL, 0}, {"egroup", "", "group", 0, NULL, 0, CHAR, NULL, 0},
For bugs matching the following criteria: Status: In Progress Changed: (is less than) 2014-06-01 Reset to default assignee and clear in-progress tags. Mail being skipped
I don't think that the patch is correct. My main disagreement with it is the replacing of ki_estcpu with ki_lastcpu, which would render a part of the manual page definitely incorrect. It seems to me that the intention of the keyword "cpu" really is "short-term CPU usage factor (for scheduling)" as the manual page puts it. I believe that it isn't meant to show the CPU on which the process is running. Therefore, I think, the way forward is to add another keyword to do what you expected of the keyword "cpu". My patch calls it "cpu#" and is currently under review at https://reviews.freebsd.org/D25377
I've changed my mind. Currently, "cpu" is based on a sched_4bsd-specific value, so I don't want to keep it. I just updated the diff review and also added more details.
A commit references this bug: Author: pstef Date: Sat Jun 27 19:09:34 UTC 2020 New revision: 362705 URL: https://svnweb.freebsd.org/changeset/base/362705 Log: ps(1): reuse keyword "cpu" to show CPU number This flag will now 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 (cpu#) 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 the code and manual changes were borrowed from top(1). PR: 129965 Reported by: Nikola Kne?evi? MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D25377 Changes: head/bin/ps/extern.h head/bin/ps/keyword.c head/bin/ps/print.c head/bin/ps/ps.1 head/bin/ps/ps.c