Bug 1796543 - virsh cpu-stats does not work with cgroup v2.
Summary: virsh cpu-stats does not work with cgroup v2.
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libvirt
Version: unspecified
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Libvirt Maintainers
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks: 2015763
TreeView+ depends on / blocked
 
Reported: 2020-01-30 16:43 UTC by Ramkumar
Modified: 2024-04-02 10:27 UTC (History)
9 users (show)

Fixed In Version:
Clone Of:
: 2015763 (view as bug list)
Environment:
Last Closed: 2024-04-02 10:26:46 UTC
Embargoed:


Attachments (Terms of Use)

Description Ramkumar 2020-01-30 16:43:48 UTC
Description of problem: 'virsh cpu-stats ...' does not work with cgroup v2. The command fails with the error 'operation 'getCpuacctPercpuUsage' not supported'. On further analysis I see that a function 'getCpuacctPercpuUsage' is not registered in the backend 'virCgroupV2Backend'.


Version-Release number of selected component (if applicable):5.6.0


How reproducible:


Steps to Reproduce:
1. Bring up VMs through QEMU
2. Issue a 'virsh cpu-stats <domain-name>'


Actual results: operation 'getCpuacctPercpuUsage' not supported'


Expected results: Display the CPU-stats per cpu.


Additional info:

Comment 1 Pavel Hrdina 2020-01-30 17:35:37 UTC
Unfortunately there is nothing we can do to provide the per-CPU stats.

With cgroups v1 there was cpuacct.usage_percpu file where we could get the data from but with cgroups v2 there is no such interface.
The latest kernel documentation for CPU controller <https://www.kernel.org/doc/html/v5.5/admin-guide/cgroup-v2.html#cpu>.

The only think we can do is to not call that function and return CPU usage stats for all CPUs which we can get from cgroups v2

Comment 2 Ramkumar 2020-01-30 17:45:17 UTC
I understand and agree that it would be good to prevent calling the PercpuUsage function and just call the usage stats for all the CPUs. Could this be taken up in a future release?

Comment 3 Daniel Berrangé 2020-02-03 11:34:21 UTC
(In reply to Pavel Hrdina from comment #1)
> Unfortunately there is nothing we can do to provide the per-CPU stats.
> 
> With cgroups v1 there was cpuacct.usage_percpu file where we could get the
> data from but with cgroups v2 there is no such interface.
> The latest kernel documentation for CPU controller
> <https://www.kernel.org/doc/html/v5.5/admin-guide/cgroup-v2.html#cpu>.
> 
> The only think we can do is to not call that function and return CPU usage
> stats for all CPUs which we can get from cgroups v2

I wonder what the kernel maintainers recommend as a replacement for this lost functionality, if any ?  eg is there perhaps a non-cgroups based way of getting what we want, or have they decided this info can never be provided to apps ?

Comment 4 Satheesh Rajendran 2020-02-14 12:22:08 UTC
Am hitting the same issue too, just adding the env details.

Host kernel: 5.5.0-g7e7c42aa3
Libvirt: libvirt-6.1.0-1.fc31.ppc64le(compiled against, c246cfc4869096b773b697f5af899dbfd776fde7)

Regards,
-Satheesh

Comment 6 bfu 2023-01-31 08:37:56 UTC
hit this on s390x with libvirt 9.0 rebase check

Comment 7 smitterl 2024-03-06 17:00:47 UTC
Still on recent RHEL 9

Comment 8 Pavel Hrdina 2024-04-02 10:23:17 UTC
(In reply to Daniel Berrangé from comment #3)
> (In reply to Pavel Hrdina from comment #1)
> > Unfortunately there is nothing we can do to provide the per-CPU stats.
> > 
> > With cgroups v1 there was cpuacct.usage_percpu file where we could get the
> > data from but with cgroups v2 there is no such interface.
> > The latest kernel documentation for CPU controller
> > <https://www.kernel.org/doc/html/v5.5/admin-guide/cgroup-v2.html#cpu>.
> > 
> > The only think we can do is to not call that function and return CPU usage
> > stats for all CPUs which we can get from cgroups v2
> 
> I wonder what the kernel maintainers recommend as a replacement for this
> lost functionality, if any ?  eg is there perhaps a non-cgroups based way of
> getting what we want, or have they decided this info can never be provided
> to apps ?

There is no alternative recommended. The commit message [1] simply mentions this:

  Note that cpuacct.usage_percpu is currently not included in
  "cpu.stat".  If this information is actually called for, it can be
  added later.

[1] <https://lore.kernel.org/lkml/1438641689-14655-4-git-send-email-tj@kernel.org/>


Note You need to log in before you can comment on or make changes to this bug.