Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some CPU metrics in pmstat output #2006

Closed
myllynen opened this issue Jul 3, 2024 · 6 comments · Fixed by #2011
Closed

Add some CPU metrics in pmstat output #2006

myllynen opened this issue Jul 3, 2024 · 6 comments · Fixed by #2011

Comments

@myllynen
Copy link
Contributor

myllynen commented Jul 3, 2024

Recent versions of vmstat(8) report CPU wait, steal, and guest time that have become available in Linux kernel during the past few years. It could be nice if pmstat(1) would also report these additional CPU metrics as well. Thanks.

@natoscott
Copy link
Member

@myllynen is this different to the -x option?

$ pmstat --help 2>&1 | grep -- -x
  -x, --xcpu            extended CPU statistics reporting

@myllynen
Copy link
Contributor Author

myllynen commented Jul 4, 2024

D'oh, I somehow completely missed that!

But the extended metrics do not include guest time so I think that could be added.

Thanks.

@natoscott
Copy link
Member

Yep, missing & will be nice to have - thanks for checking. I'll queue it up but hopefully someone else drops in and fixes it in the meantime.

@myllynen
Copy link
Contributor Author

myllynen commented Jul 4, 2024

This looks pretty straightforward but for the record few things I noticed:

  1. src/pmstat/pmstat.pmlogger and src/pmlogconf/tools/pmstat are slightly different, the outcome should be the same but not sure should these be unified

  2. While at it perhaps the output could include guest_nice as well, it's not part of vmstat(8) output but this would make pmstat output more complete. However I'm not sure does this provide any real value for pmstat(1) users.

  3. Would the calculation of totals be stil like this or should guest time(s) be added as well:

user = s->val[cpu_nice].ull + s->val[cpu_user].ull;
kernel = s->val[cpu_intr].ull + s->val[cpu_sys].ull + s->val[cpu_steal].ull;
idle = s->val[cpu_idle].ull + s->val[cpu_wait].ull;

This is a bit unclear as in /proc/pid/stat utime includes guest_time according to the man page but nothing is stated for /proc/stat and guest times there so it's not entirely clear to me whether stolen time includes or is different from guest / guest_nice time?

Thanks.

@natoscott
Copy link
Member

Have a look at the way Mark setup the pmchart CPU and vCPU views are setup in terms of metrics used to answer this (note also vuser and vnice).
And yeah, definitely some updates needed to those two configs, esp. when this addition is made to pmstat.

@myllynen
Copy link
Contributor Author

myllynen commented Jul 8, 2024

I checked the kernel sources and the related git log:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/kernel/sched/cputime.c
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/kernel/sched/cputime.c

It looks like guest time is included in the user time since, at least since a couple of years ago. So this makes me think the above pasted calculations can be left as-is. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants