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

mpstat does not display stats of hotplugged CPUs when run with an interval inside VM #327

Closed
shaleenbathla opened this issue Jun 27, 2022 · 2 comments · Fixed by #337
Closed

Comments

@shaleenbathla
Copy link
Contributor

shaleenbathla commented Jun 27, 2022

Running mpstat with an interval (without count parameter (say) ), does not display hotplugged CPU(s) stats, unless we re-run the command after getting out of the loop.
mpstat -P ALL <interval>
Someone/Something running the command with an interval and no count will not be able to see the statistics of all CPUs and it will require getting out of the loop.

Suggestion 1 : We can add an option like "--hotplug" that will keep an eye on number of cpu/cpu hotplug (by checking get_cpu_nr() for example) after each iteration and display stats of all CPUs including the hotplugged ones in the next iteration.
OR
Suggestion 2 : Without introducing a new option and fix this in main loop code to cover all cases.

I would like to get suggestions and comments if this will be a good feature before proceeding with this.
All comments and suggestions will be greatly appreciated.

#######################################################
[root@localhost ~]# mpstat -P ALL 5
<snipped 1 line>

07:47:47 AM CPU %usr %nice %sys %iowait %irq %soft %steal
%guest %gnice %idle
07:47:52 AM all 0.00 0.00 0.20 0.80 0.00 0.20 0.00
0.00 0.00 98.80
07:47:52 AM 0 0.00 0.00 0.20 0.80 0.00 0.20 0.00
0.00 0.00 98.80

07:47:52 AM CPU %usr %nice %sys %iowait %irq %soft %steal
%guest %gnice %idle
07:47:57 AM all 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.00 0.00 100.00
07:47:57 AM 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.00 0.00 100.00

07:47:57 AM CPU %usr %nice %sys %iowait %irq %soft %steal
%guest %gnice %idle
07:48:02 AM all 0.00 0.00 0.00 0.00 0.20 0.00 0.00
0.00 0.00 99.80
07:48:02 AM 0 0.00 0.00 0.00 0.00 0.20 0.00 0.00
0.00 0.00 99.80

07:48:02 AM CPU %usr %nice %sys %iowait %irq %soft %steal
%guest %gnice %idle
07:48:07 AM all 0.00 0.00 0.00 0.00 0.00 0.20 0.00
0.00 0.00 99.80
07:48:07 AM 0 0.00 0.00 0.00 0.00 0.00 0.20 0.00
0.00 0.00 99.80
#######################################################

[root@localhost ~]# mpstat -P ALL 5
<snipped 1 line>
07:50:52 AM CPU %usr %nice %sys %iowait %irq %soft %steal
%guest %gnice %idle
07:50:57 AM all 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.00 0.00 100.00
07:50:57 AM 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.00 0.00 100.00
07:50:57 AM 1 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.00 0.00 100.00
^C

Average: CPU %usr %nice %sys %iowait %irq %soft %steal
%guest %gnice %idle
Average: all 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.00 0.00 100.00
Average: 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.00 0.00 100.00
Average: 1 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.00 0.00 100.00
#######################################################

@stevekay
Copy link
Contributor

Curious. I'm running mpstat 12.7.1 and it happily spots hot unplugging and plugging of CPUs, see below.

$ ./mpstat -V
sysstat version 12.7.1
(C) Sebastien Godard (sysstat <at> orange.fr)
$ ./mpstat -P ALL 5
Linux 5.14.0-70.13.1.el9_0.x86_64 (localhost.localdomain)       28/06/22        _x86_64_        (4 CPU)

20:10:12     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
20:10:17     all    0.05    0.00    0.10    0.00    0.15    0.05    0.00    0.00    0.00   99.65
20:10:17       0    0.00    0.00    0.20    0.00    0.00    0.00    0.00    0.00    0.00   99.80
20:10:17       1    0.20    0.00    0.00    0.00    0.20    0.20    0.00    0.00    0.00   99.40
20:10:17       2    0.00    0.00    0.00    0.00    0.20    0.00    0.00    0.00    0.00   99.80
20:10:17       3    0.00    0.00    0.20    0.00    0.20    0.00    0.00    0.00    0.00   99.60
...
20:12:17     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
20:12:22     all    0.30    0.00    0.55    0.15    0.65    0.05    0.00    0.00    0.00   98.30
20:12:22       0    0.20    0.00    0.40    0.00    0.80    0.00    0.00    0.00    0.00   98.60
20:12:22       1    0.00    0.00    0.40    0.00    0.80    0.00    0.00    0.00    0.00   98.79
20:12:22       2    0.40    0.00    0.40    0.20    0.60    0.00    0.00    0.00    0.00   98.41
20:12:22       3    0.60    0.00    1.00    0.40    0.40    0.20    0.00    0.00    0.00   97.41

20:12:22     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
20:12:27     all    0.07    0.00    0.20    0.00    0.40    0.07    0.00    0.00    0.00   99.26
20:12:27       1    0.20    0.00    0.40    0.00    0.80    0.00    0.00    0.00    0.00   98.59
20:12:27       2    0.00    0.00    0.20    0.00    0.20    0.00    0.00    0.00    0.00   99.60
20:12:27       3    0.00    0.00    0.00    0.00    0.20    0.20    0.00    0.00    0.00   99.60

20:12:27     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
20:12:32     all    0.00    0.00    0.21    0.00    2.74    0.14    0.00    0.00    0.00   96.91
20:12:32       1    0.00    0.00    0.22    0.00    6.29    0.22    0.00    0.00    0.00   93.26
20:12:32       2    0.00    0.00    0.20    0.00    1.22    0.20    0.00    0.00    0.00   98.37
20:12:32       3    0.00    0.00    0.20    0.00    1.02    0.00    0.00    0.00    0.00   98.77

20:12:32     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
20:12:37     all    0.10    0.00    0.31    0.00    1.87    0.10    0.00    0.00    0.00   97.61
20:12:37       2    0.21    0.00    0.42    0.00    2.76    0.00    0.00    0.00    0.00   96.60
20:12:37       3    0.00    0.00    0.20    0.00    1.01    0.20    0.00    0.00    0.00   98.58

20:12:37     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
20:12:42     all    0.20    0.00    0.41    0.00    0.81    0.20    0.00    0.00    0.00   98.38
20:12:42       3    0.20    0.00    0.41    0.00    0.81    0.20    0.00    0.00    0.00   98.38

20:12:42     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
20:12:47     all    0.17    0.00    0.34    0.00    0.84    0.34    0.00    0.00    0.00   98.32
20:12:47       2    0.00    0.00    0.00    0.00    2.02    1.01    0.00    0.00    0.00   96.97
20:12:47       3    0.20    0.00    0.40    0.00    0.60    0.20    0.00    0.00    0.00   98.59

20:12:47     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
20:12:52     all    0.00    0.00    0.30    0.00    0.30    0.10    0.00    0.00    0.00   99.30
20:12:52       2    0.00    0.00    0.20    0.00    0.20    0.00    0.00    0.00    0.00   99.60
20:12:52       3    0.00    0.00    0.40    0.00    0.40    0.20    0.00    0.00    0.00   99.00

20:12:52     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
20:12:57     all    0.10    0.00    0.10    0.00    0.20    0.10    0.00    0.00    0.00   99.50
20:12:57       2    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
20:12:57       3    0.20    0.00    0.20    0.00    0.40    0.20    0.00    0.00    0.00   99.00

20:12:57     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
20:13:02     all    0.08    0.00    0.40    0.00    0.32    0.08    0.00    0.00    0.00   99.12
20:13:02       0    0.00    0.00    0.40    0.00    0.40    0.00    0.00    0.00    0.00   99.21
20:13:02       2    0.20    0.00    0.20    0.00    0.20    0.00    0.00    0.00    0.00   99.40
20:13:02       3    0.00    0.00    0.60    0.00    0.40    0.20    0.00    0.00    0.00   98.80

20:13:02     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
20:13:07     all    0.00    0.00    0.16    0.00    1.37    0.05    0.00    0.00    0.00   98.41
20:13:07       0    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
20:13:07       1    0.00    0.00    0.30    0.00    6.87    0.30    0.00    0.00    0.00   92.54
20:13:07       2    0.00    0.00    0.20    0.00    0.20    0.00    0.00    0.00    0.00   99.60
20:13:07       3    0.00    0.00    0.20    0.00    0.20    0.00    0.00    0.00    0.00   99.60

20:13:07     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
20:13:12     all    0.00    0.00    0.10    0.00    0.20    0.05    0.00    0.00    0.00   99.65
20:13:12       0    0.00    0.00    0.00    0.00    0.20    0.00    0.00    0.00    0.00   99.80
20:13:12       1    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
20:13:12       2    0.00    0.00    0.00    0.00    0.20    0.20    0.00    0.00    0.00   99.60
20:13:12       3    0.00    0.00    0.40    0.00    0.40    0.00    0.00    0.00    0.00   99.20
^C

@shaleenbathla
Copy link
Contributor Author

Sorry for the incomplete info earlier.
The mpstat command was run inside a VM.
I used virsh command on a Host machine to do "physical" hotplug (not a logical hotplug) of 1 additional vCPU to the VM.
The command to hotplug 1 more vCPU to a live VM (having 1 vcpu) :
virsh setvcpus vm1 2 --live --config

@stevekay
In the case above, you have done a logical cpu hotplug i.e. offlining / onlining CPUs that were already present on the system.
My description of the issue was a bit confusing earlier as I did not take logical hotplug into account.
This issue should only be for VM scenarios I suppose.

@shaleenbathla shaleenbathla changed the title mpstat does not display stats of hotplugged CPUs when run with an interval mpstat does not display stats of hotplugged CPUs when run with an interval inside VM Jun 29, 2022
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