xref: /OK3568_Linux_fs/kernel/Documentation/admin-guide/cgroup-v1/net_prio.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun=======================
2*4882a593SmuzhiyunNetwork priority cgroup
3*4882a593Smuzhiyun=======================
4*4882a593Smuzhiyun
5*4882a593SmuzhiyunThe Network priority cgroup provides an interface to allow an administrator to
6*4882a593Smuzhiyundynamically set the priority of network traffic generated by various
7*4882a593Smuzhiyunapplications
8*4882a593Smuzhiyun
9*4882a593SmuzhiyunNominally, an application would set the priority of its traffic via the
10*4882a593SmuzhiyunSO_PRIORITY socket option.  This however, is not always possible because:
11*4882a593Smuzhiyun
12*4882a593Smuzhiyun1) The application may not have been coded to set this value
13*4882a593Smuzhiyun2) The priority of application traffic is often a site-specific administrative
14*4882a593Smuzhiyun   decision rather than an application defined one.
15*4882a593Smuzhiyun
16*4882a593SmuzhiyunThis cgroup allows an administrator to assign a process to a group which defines
17*4882a593Smuzhiyunthe priority of egress traffic on a given interface. Network priority groups can
18*4882a593Smuzhiyunbe created by first mounting the cgroup filesystem::
19*4882a593Smuzhiyun
20*4882a593Smuzhiyun	# mount -t cgroup -onet_prio none /sys/fs/cgroup/net_prio
21*4882a593Smuzhiyun
22*4882a593SmuzhiyunWith the above step, the initial group acting as the parent accounting group
23*4882a593Smuzhiyunbecomes visible at '/sys/fs/cgroup/net_prio'.  This group includes all tasks in
24*4882a593Smuzhiyunthe system. '/sys/fs/cgroup/net_prio/tasks' lists the tasks in this cgroup.
25*4882a593Smuzhiyun
26*4882a593SmuzhiyunEach net_prio cgroup contains two files that are subsystem specific
27*4882a593Smuzhiyun
28*4882a593Smuzhiyunnet_prio.prioidx
29*4882a593Smuzhiyun  This file is read-only, and is simply informative.  It contains a unique
30*4882a593Smuzhiyun  integer value that the kernel uses as an internal representation of this
31*4882a593Smuzhiyun  cgroup.
32*4882a593Smuzhiyun
33*4882a593Smuzhiyunnet_prio.ifpriomap
34*4882a593Smuzhiyun  This file contains a map of the priorities assigned to traffic originating
35*4882a593Smuzhiyun  from processes in this group and egressing the system on various interfaces.
36*4882a593Smuzhiyun  It contains a list of tuples in the form <ifname priority>.  Contents of this
37*4882a593Smuzhiyun  file can be modified by echoing a string into the file using the same tuple
38*4882a593Smuzhiyun  format. For example::
39*4882a593Smuzhiyun
40*4882a593Smuzhiyun	echo "eth0 5" > /sys/fs/cgroups/net_prio/iscsi/net_prio.ifpriomap
41*4882a593Smuzhiyun
42*4882a593SmuzhiyunThis command would force any traffic originating from processes belonging to the
43*4882a593Smuzhiyuniscsi net_prio cgroup and egressing on interface eth0 to have the priority of
44*4882a593Smuzhiyunsaid traffic set to the value 5. The parent accounting group also has a
45*4882a593Smuzhiyunwriteable 'net_prio.ifpriomap' file that can be used to set a system default
46*4882a593Smuzhiyunpriority.
47*4882a593Smuzhiyun
48*4882a593SmuzhiyunPriorities are set immediately prior to queueing a frame to the device
49*4882a593Smuzhiyunqueueing discipline (qdisc) so priorities will be assigned prior to the hardware
50*4882a593Smuzhiyunqueue selection being made.
51*4882a593Smuzhiyun
52*4882a593SmuzhiyunOne usage for the net_prio cgroup is with mqprio qdisc allowing application
53*4882a593Smuzhiyuntraffic to be steered to hardware/driver based traffic classes. These mappings
54*4882a593Smuzhiyuncan then be managed by administrators or other networking protocols such as
55*4882a593SmuzhiyunDCBX.
56*4882a593Smuzhiyun
57*4882a593SmuzhiyunA new net_prio cgroup inherits the parent's configuration.
58