cgroup blkio throttle does not work on root group

Bug #1760375 reported by Neil
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
linux (Ubuntu)
Confirmed
Medium
Unassigned

Bug Description

from kernel document, https://www.kernel.org/doc/Documentation/cgroup-v1/blkio-controller.txt
```
Throttling/Upper Limit policy
-----------------------------
- Enable Block IO controller
 CONFIG_BLK_CGROUP=y

- Enable throttling in block layer
 CONFIG_BLK_DEV_THROTTLING=y

- Mount blkio controller (see cgroups.txt, Why are cgroups needed?)
        mount -t cgroup -o blkio none /sys/fs/cgroup/blkio

- Specify a bandwidth rate on particular device for root group. The format
  for policy is "<major>:<minor> <bytes_per_second>".

        echo "8:16 1048576" > /sys/fs/cgroup/blkio/blkio.throttle.read_bps_device

  Above will put a limit of 1MB/second on reads happening for root group
  on device having major/minor number 8:16.

- Run dd to read a file and see if rate is throttled to 1MB/s or not.

        # dd iflag=direct if=/mnt/common/zerofile of=/dev/null bs=4K count=1024
        1024+0 records in
        1024+0 records out
        4194304 bytes (4.2 MB) copied, 4.0001 s, 1.0 MB/s

 Limits for writes can be put using blkio.throttle.write_bps_device file.
```

tested with ubuntu 16.04(xenial) and seems throttle not working, but on my virtual machine, ubuntu 14.04(trusty) works.

```
ubuntu16.04(xenial)

root@i-x3mn8m8i:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 253:0 0 20G 0 disk
`-vda1 253:1 0 20G 0 part /
vdb 253:16 0 1G 0 disk [SWAP]
root@i-x3mn8m8i:~# dd if=/dev/zero of=test.img bs=4k oflag=direct
^C16246+0 records in
16246+0 records out
66543616 bytes (67 MB, 63 MiB) copied, 3.15081 s, 21.1 MB/s

root@i-x3mn8m8i:~# echo 253:0 1000 > /sys/fs/cgroup/blkio/blkio.throttle.write_iops_device
root@i-x3mn8m8i:~# dd if=/dev/zero of=test.img bs=4k oflag=direct
^C26702+0 records in
26702+0 records out
109371392 bytes (109 MB, 104 MiB) copied, 5.2413 s, 20.9 MB/s

ubuntu14.04(trusty)

root@i-ulhx27oo:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 253:0 0 20G 0 disk
`-vda1 253:1 0 20G 0 part /
vdb 253:16 0 1G 0 disk [SWAP]

root@i-ulhx27oo:~# dd if=/dev/zero of=test.img bs=4k oflag=direct
^C27679+0 records in
27679+0 records out
113373184 bytes (113 MB) copied, 5.43766 s, 20.8 MB/s

root@i-ulhx27oo:~# echo 253:0 1000 > /sys/fs/cgroup/blkio/blkio.throttle.write_iops_device
root@i-ulhx27oo:~# dd if=/dev/zero of=test.img bs=4k oflag=direct
^C7553+0 records in
7553+0 records out
30937088 bytes (31 MB) copied, 7.60268 s, 4.1 MB/s
```

Revision history for this message
Ubuntu Kernel Bot (ubuntu-kernel-bot) wrote : Missing required logs.

This bug is missing log files that will aid in diagnosing the problem. While running an Ubuntu kernel (not a mainline or third-party kernel) please enter the following command in a terminal window:

apport-collect 1760375

and then change the status of the bug to 'Confirmed'.

If, due to the nature of the issue you have encountered, you are unable to run this command, please add a comment stating that fact and change the bug status to 'Confirmed'.

This change has been made by an automated script, maintained by the Ubuntu Kernel Team.

Changed in linux (Ubuntu):
status: New → Incomplete
Revision history for this message
Neil (loyou) wrote :

it's easy to reproduce, no log needed.

Changed in linux (Ubuntu):
status: Incomplete → Confirmed
Revision history for this message
Joseph Salisbury (jsalisbury) wrote :

Would it be possible for you to test the latest upstream kernel? Refer to https://wiki.ubuntu.com/KernelMainlineBuilds . Please test the latest v4.16 kernel[0].

If this bug is fixed in the mainline kernel, please add the following tag 'kernel-fixed-upstream'.

If the mainline kernel does not fix this bug, please add the tag: 'kernel-bug-exists-upstream'.

Once testing of the upstream kernel is complete, please mark this bug as "Confirmed".

Thanks in advance.

[0] http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.16

Changed in linux (Ubuntu):
importance: Undecided → Medium
tags: added: kernel-da-key xenial
Changed in linux (Ubuntu):
status: Confirmed → Incomplete
Revision history for this message
Neil (loyou) wrote :

same phenomenon after update latest v4.16 kernel.
this should have concern with systemd-logind.service, tasks have been added into session cgroup.

root@i-dztv2guv:~# cat /proc/$(pidof dd)/cgroup | grep blkio
6:blkio:/user.slice/user-0.slice/session-1.scope

I can throttle for this single session, but it is impossible to throttle for all sessions, is there anyway to disable it?

Changed in linux (Ubuntu):
status: Incomplete → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related questions

Remote bug watches

Bug watches keep track of this bug in other bug trackers.