[ Pobierz całość w formacie PDF ]

~]# cat /cgroup/net_cls/red/net_cls.classid
1048577
Refer to the man page for tc to learn how to configure the traffic controller to use the handles that the
net_cls adds to network packets.
3.9. net_prio
The Network Priority (net_prio) subsystem provides a way to dynamically set the priority of network
traffic per each network interface for applications within various cgroups. A network's priority is a number
assigned to network traffic and used internally by the system and network devices. Network priority is
used to differentiate packets that are sent, queued, or dropped. The tc command may be used to set a
network's priority (setting the network priority via the tc command is outside the scope of this guide; for
more information, refer to the tc man page).
54
Chapter 3. Subsystems and Tunable Parameters
Typically, an application sets the priority of its traffic via the SO_PRIORITY socket option. However,
applications are often not coded to set the priority value, or the application's traffic is site-specific and
does not provide a defined priority.
Using the net_prio subsystem in a cgroup allows an administrator to assign a process to a specific
cgroup which defines the priority of outgoing traffic on a given network interface.
net_prio.prioidx
a read-only file which contains a unique integer value that the kernel uses as an internal
representation of this cgroup.
net_prio.ifpriomap
contains a map of priorities assigned to traffic originating from processes in this group and
leaving the system on various interfaces. This map is represented by a list of pairs in the form
:
~]# cat /cgroup/net_prio/iscsi/net_prio.ifpriomap
eth0 5
eth1 4
eth2 6
Contents of the net_prio.ifpriomap file can be modified by echoing a string into the file
using the above format, for example:
~]# echo "eth0 5" > /cgroup/net_prio/iscsi/net_prio.ifpriomap
The above command forces any traffic originating from processes belonging to the iscsi
net_prio cgroup, and with traffic outgoing on the eth0 network interface, to have the priority
set to the value 5. The parent cgroup also has a writable net_prio.ifpriomap file that can
be used to set a system default priority.
3.10. ns
The ns subsystem provides a way to group processes into separate namespaces. Within a particular
namespace, processes can interact with each other but are isolated from processes running in other
namespaces. These separate namespaces are sometimes referred to as containers when used for
operating-system-level virtualization.
3.11. perf_event
When the perf_event subsystem is attached to a hierarchy, all cgroups in that hierarchy can be used
to group processes and threads which can then be monitored with the perf tool, as opposed to
monitoring each process or thread separately or per-CPU. Cgroups which use the perf_event
subsystem do not contain any special tunable parameters other than the common parameters listed in
Section 3.12,  Common Tunable Parameters .
For additional information on how tasks in a cgroup can be monitored using the perf tool, refer to the
Red Hat Enterprise Linux Developer Guide, available from
http://access.redhat.com/site/documentation/Red_Hat_Enterprise_Linux/.
55
Red Hat Enterprise Linux 6 Resource Management Guide
3.12. Common Tunable Parameters
The following parameters are present in every created cgroup, regardless of the subsystem that the
cgroup is using:
tasks
contains a list of processes, represented by their PIDs, that are running in a cgroup. The list of
PIDs is not guaranteed to be ordered or unique (that is, it may contain duplicate entries). Writing
a PID into the tasks file of a cgroup moves that process into that cgroup.
cgroup.procs
contains a list of thread groups, represented by their TGIDs, that are running in a cgroup. The
list of TGIDs is not guaranteed to be ordered or unique (that is, it may contain duplicate
entries). Writing a TGID into the cgroup.procs file of a cgroup moves that thread group into
that cgroup.
cgroup.event_control
along with the cgroup notification API, allows notifications to be sent about a changing status of
a cgroup.
notify_on_release
contains a Boolean value, 1 or 0, that either enables or disables the execution of the release
agent. If the notify_on_release is enabled, the kernel executes the contents of the
release_agent file when a cgroup no longer contains any tasks (that is, the cgroup's tasks
file contained some PIDs and those PIDs were removed, leaving the file empty). A path to the
empty cgroup is provided as an argument to the release agent.
The default value of the notify_on_release parameter in the root cgroup is 0. All non-root
cgroups inherit the value in notify_on_release from their parent cgroup.
release_agent (present in the root cgroup only)
contains a command to be executed when a  notify on release is triggered. Once a cgroup is
emptied of all processes, and the notify_on_release flag is enabled, the kernel runs the
command in the release_agent file and supplies it with a relative path (relative to the root
cgroup) to the emptied cgroup as an argument. The release agent can be used, for example, to
automatically remove empty cgroups; for more information, see Example 3.4,  Automatically
removing empty cgroups .
56
Chapter 3. Subsystems and Tunable Parameters
Example 3.4 . Automatically removing empty cgroups
Follow these steps to configure automatic removal of any emptied cgroup from the cpu
cgroup:
1. Create a shell script that removes empty cpu cgroups, place it in, for example,
/usr/local/bin, and make it executable.
~]# cat /usr/local/bin/remove-empty-cpu-cgroup.sh
#!/bin/sh
rmdir /cgroup/cpu/$1
~]# chmod +x /usr/local/bin/remove-empty-cpu-cgroup.sh
The $1 variable contains a relative path to the emptied cgroup.
2. In the cpu cgroup, enable the notify_on_release flag:
~]# echo 1 > /cgroup/cpu/notify_on_release
3. In the cpu cgroup, specify a release agent to be used:
~]# echo "/usr/local/bin/remove-empty-cpu-cgroup.sh" >
/cgroup/cpu/release_agent
4. Test your configuration to make sure emptied cgroups are properly removed:
cpu]# pwd; ls
/cgroup/cpu
cgroup.event_control cgroup.procs cpu.cfs_period_us
cpu.cfs_quota_us cpu.rt_period_us cpu.rt_runtime_us cpu.shares
cpu.stat libvirt notify_on_release release_agent tasks
cpu]# cat notify_on_release
1
cpu]# cat release_agent
/usr/local/bin/remove-empty-cpu-cgroup.sh
cpu]# mkdir blue; ls
blue cgroup.event_control cgroup.procs cpu.cfs_period_us
cpu.cfs_quota_us cpu.rt_period_us cpu.rt_runtime_us cpu.shares
cpu.stat libvirt notify_on_release release_agent tasks
cpu]# cat blue/notify_on_release
1
cpu]# cgexec -g cpu:blue dd if=/dev/zero of=/dev/null bs=1024k &
[1] 8623
cpu]# cat blue/tasks
8623
cpu]# kill -9 8623
cpu]# ls
cgroup.event_control cgroup.procs cpu.cfs_period_us
cpu.cfs_quota_us cpu.rt_period_us cpu.rt_runtime_us cpu.shares
cpu.stat libvirt notify_on_release release_agent tasks
3.13. Additional Resources
Subsystem-Specific Kernel Documentation
57
Red Hat Enterprise Linux 6 Resource Management Guide
All of the following files are located under the /usr/share/doc/kernel-
doc-/Documentation/cgroups/ directory (provided by the kernel-doc
package).
blkio subsystem  blkio-controller.txt
cpuacct subsystem  cpuacct.txt
cpuset subsystem  cpusets.txt
devices subsystem  devices.txt
freezer subsystem  freezer-subsystem.txt
memory subsystem  memory.txt
net_prio subsystem  net_prio.txt
Additionally, refer to the following files on further information about the cpu subsystem:
Real-Time scheduling  /usr/share/doc/kernel-
doc-/Documentation/scheduler/sched-rt-group.txt
CFS scheduling  /usr/share/doc/kernel-
doc-/Documentation/scheduler/sched-bwc.txt
[5] So urce co d e p ro vid ed b y Red Hat Eng ineer Frantiaek Hrb ata.
[6 ] So urce co d e p ro vid ed b y Red Hat Eng ineer Frantiaek Hrb ata.
58
Chapter 4. Control Group Application Examples
Chapter 4. Control Group Application Examples
This chapter provides application examples that take advantage of the cgroup functionality.
4.1. Prioritizing Database I/O [ Pobierz całość w formacie PDF ]
  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • arachnea.htw.pl