Bug 850718

Summary: RFE: Reduce the depth of libvirt cgroup hierarchy
Product: Red Hat Enterprise Linux 7 Reporter: Daniel Berrangé <berrange>
Component: libvirtAssignee: Daniel Berrangé <berrange>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.0CC: ajia, cwei, dfediuck, dyuan, jeder, mzhan, perfbz, ydu
Target Milestone: rcKeywords: FutureFeature
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-1.0.5 Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-06-13 11:58:27 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 797489    

Description Daniel Berrangé 2012-08-22 08:42:42 UTC
Description of problem:
The depth of the cgroup heirarchy can have performance implications. Libvirt currently creates a hierarchy 3 to 4 levels deep below the cgroup that libvirtd itself is placed in.

  libvirt/$DRIVERNAME/$VMNAME/$VCPUNUM

The first level is potentially redundant if systemd is already placing libvirtd in a private cgroup. The second and third levels could be optionally combined into '$DRIVERNAME-$VMNAME' 

There could be back compatibility issues with changing this, and potentially different scenarios will need different arrangements. Thus the layout probably ought to be made configuration, using placeholders eg

 1. Match current hardcoded layout:

    cgroup_layout="::PROCESS::/libvirt/::DRIVER::/::VMNAME::" 

 2. Remove first level when used with systemd:

    cgroup_layout="::PROCESS::/::DRIVER::/::VMNAME::" 

 3. Ignore current libvirtd placement completely and create in the root:

    cgroup_layout="/libvirt/::DRIVER::/::VMNAME::"

 4. Combine 2nd and 3rd levels

    cgroup_layout="/libvirt/::DRIVER::-::VMNAME::"

 5. Combine 2nd and 3rd levels, but use UUID instead of VM name

    cgroup_layout="/libvirt/::DRIVER::-::VMUUID::"

etc

Comment 1 Daniel Berrangé 2013-07-02 14:25:01 UTC
Resolved with the introduction of the new cgroups layout in libvirt

http://libvirt.org/cgroups.html

Comment 2 yanbing du 2013-11-11 09:16:02 UTC
# rpm -q libvirt
libvirt-1.1.1-11.el7.x86_64

Start 2 guests(named: virt-tests-vm and test), then check the cgroup layout:

# lscgroup 
cpuset:/
cpuset:/machine.slice
cpuset:/machine.slice/machine-qemu\x2dtest.scope
cpuset:/machine.slice/machine-qemu\x2dtest.scope/emulator
cpuset:/machine.slice/machine-qemu\x2dtest.scope/vcpu0
cpuset:/machine.slice/machine-qemu\x2dvirt\x2dtests\x2dvm.scope
cpuset:/machine.slice/machine-qemu\x2dvirt\x2dtests\x2dvm.scope/emulator
cpuset:/machine.slice/machine-qemu\x2dvirt\x2dtests\x2dvm.scope/vcpu0
cpu,cpuacct:/
cpu,cpuacct:/machine.slice
cpu,cpuacct:/machine.slice/machine-qemu\x2dtest.scope
cpu,cpuacct:/machine.slice/machine-qemu\x2dtest.scope/emulator
cpu,cpuacct:/machine.slice/machine-qemu\x2dtest.scope/vcpu0
cpu,cpuacct:/machine.slice/machine-qemu\x2dvirt\x2dtests\x2dvm.scope
cpu,cpuacct:/machine.slice/machine-qemu\x2dvirt\x2dtests\x2dvm.scope/emulator
cpu,cpuacct:/machine.slice/machine-qemu\x2dvirt\x2dtests\x2dvm.scope/vcpu0
memory:/
memory:/machine.slice
memory:/machine.slice/machine-qemu\x2dtest.scope
memory:/machine.slice/machine-qemu\x2dvirt\x2dtests\x2dvm.scope
devices:/
devices:/machine.slice
devices:/machine.slice/machine-qemu\x2dtest.scope
devices:/machine.slice/machine-qemu\x2dvirt\x2dtests\x2dvm.scope
freezer:/
freezer:/machine.slice
freezer:/machine.slice/machine-qemu\x2dtest.scope
freezer:/machine.slice/machine-qemu\x2dvirt\x2dtests\x2dvm.scope
net_cls:/
net_cls:/machine.slice
net_cls:/machine.slice/machine-qemu\x2dtest.scope
net_cls:/machine.slice/machine-qemu\x2dvirt\x2dtests\x2dvm.scope
blkio:/
blkio:/machine.slice
blkio:/machine.slice/machine-qemu\x2dtest.scope
blkio:/machine.slice/machine-qemu\x2dvirt\x2dtests\x2dvm.scope
perf_event:/
perf_event:/machine.slice
perf_event:/machine.slice/machine-qemu\x2dtest.scope
perf_event:/machine.slice/machine-qemu\x2dvirt\x2dtests\x2dvm.scope
hugetlb:/


# ll /sys/fs/cgroup/systemd/
total 0
-rw-r--r--.  1 root root 0 Nov  6 14:59 cgroup.clone_children
--w--w--w-.  1 root root 0 Nov  6 14:59 cgroup.event_control
-rw-r--r--.  1 root root 0 Nov  6 14:59 cgroup.procs
-r--r--r--.  1 root root 0 Nov  6 14:59 cgroup.sane_behavior
drwxr-xr-x.  4 root root 0 Nov 11 16:23 machine.slice
-rw-r--r--.  1 root root 0 Nov  6 14:59 notify_on_release
-rw-r--r--.  1 root root 0 Nov  6 14:59 release_agent
drwxr-xr-x. 78 root root 0 Nov 11 16:50 system.slice
-rw-r--r--.  1 root root 0 Nov  6 14:59 tasks
drwxr-xr-x.  3 root root 0 Nov  6 14:59 user.slice

# ll /sys/fs/cgroup/systemd/machine.slice/
total 0
-rw-r--r--. 1 root root 0 Nov  6 15:10 cgroup.clone_children
--w--w--w-. 1 root root 0 Nov  6 15:10 cgroup.event_control
-rw-r--r--. 1 root root 0 Nov  6 15:10 cgroup.procs
drwxr-xr-x. 2 root root 0 Nov 11 17:12 machine-qemu\x2dtest.scope
drwxr-xr-x. 2 root root 0 Nov 11 16:24 machine-qemu\x2dvirt\x2dtests\x2dvm.scope
-rw-r--r--. 1 root root 0 Nov  6 15:10 notify_on_release
-rw-r--r--. 1 root root 0 Nov  6 15:10 tasks

Comment 3 Ludek Smid 2014-06-13 11:58:27 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.