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:
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 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?
(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 ?
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
hit this on s390x with libvirt 9.0 rebase check
Still on recent RHEL 9
(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/>