Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not convert blkio weight value using blkio->io conversion scheme #2786

Merged
merged 1 commit into from
Feb 24, 2021

Conversation

dqminh
Copy link
Contributor

@dqminh dqminh commented Feb 3, 2021

bfq weight controller (i.e. io.bfq.weight if present) is still using the
same bfq weight scheme (i.e 1->1000, see [1].) Unfortunaly the
documentation for this was wrong, and only fixed recently [2].

Therefore, if we map blkio weight to io.bfq.weight, there's no need to
do any conversion.

[1] https://github.com/torvalds/linux/blob/master/Documentation/block/bfq-iosched.rst
[2] torvalds/linux@65752ae

@dqminh
Copy link
Contributor Author

dqminh commented Feb 3, 2021

This will also need to be fixed in crun and systemd among other things afair @giuseppe

@AkihiroSuda AkihiroSuda added this to the 1.0.0-rc94 milestone Feb 3, 2021
giuseppe added a commit to giuseppe/crun that referenced this pull request Feb 3, 2021
More details here: opencontainers/runc#2786

Signed-off-by: Giuseppe Scrivano <[email protected]>
@giuseppe
Copy link
Member

giuseppe commented Feb 3, 2021

This will also need to be fixed in crun and systemd among other things afair @giuseppe

thanks for letting me know! I've opened a PR for crun as well: containers/crun#584

@giuseppe
Copy link
Member

giuseppe commented Feb 3, 2021

@keszybz FYI

@dqminh
Copy link
Contributor Author

dqminh commented Feb 3, 2021

Updated to add a test so we can try to catch this in the future. I'm not sure if there's movement to merge io.weight and io.bfq.weight at the moment, at which point we need to fix the inconsistency between 2 interface.

kolyshkin
kolyshkin previously approved these changes Feb 3, 2021
Copy link
Contributor

@kolyshkin kolyshkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kolyshkin
Copy link
Contributor

CI failure on Fedora is a glitch (of download.fedoraproject.org) -- created #2787 to address.

CI restared.

@@ -190,6 +190,22 @@ function setup() {
[[ "$output" == *'invalid configuration'* ]]
}

@test "runc run (blkio weight)" {
requires root cgroups_v2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't require root?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AkihiroSuda once #2818 is merged we will be able to enable it (rm root, add [[ "$ROOTLESS" -ne 0 ]] && requires rootless_cgroup)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...because currently runc exec test_cgroups_unified sh -c 'cat /sys/fs/cgroup/io.bfq.weight' is not working

set_cgroups_path "$BUSYBOX_BUNDLE"
update_config '.linux.resources.blockIO |= {"weight": 750}' "${BUSYBOX_BUNDLE}"

runc run -d --console-socket "$CONSOLE_SOCKET" test_cgroups_v2_blkio
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you add a new container name you need to add it to the teardown() hook at the start -- teardown_running_container.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed it, too, but did not comment because I am fixing all this soon (after #2757 is merged).


runc exec test_cgroups_v2_blkio sh -c 'cat /sys/fs/cgroup/io.bfq.weight'
[ "$status" -eq 0 ]
echo "$output"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be necessary? runc is a function which prints the output to the bats log (I'm also pretty sure a naked echo doesn't work which is why runc redirects to stderr):

# Wrapper for runc.
function runc() {
	run __runc "$@"

	# Some debug information to make life easier. bats will only print it if the
	# test failed, in which case the output is useful.
	echo "runc $@ (status=$status):" >&2
	echo "$output" >&2
}

# Raw wrapper for runc.
function __runc() {
	"$RUNC" ${RUNC_USE_SYSTEMD+--systemd-cgroup} --root "$ROOT" "$@"
}

Copy link
Member

@cyphar cyphar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test needs to be cleaned up.

@keszybz
Copy link

keszybz commented Feb 4, 2021

@giuseppe thanks for the ping.

This will also need to be fixed in crun and systemd among other things afair

Do I get this right that io.bfq.weight wants a value that is in the range 1..1000, while io.weight wants a value in the range 1..10000? systemd treats the cgroupv2 range as the input value, so we'd need to add a conversion io.bfq.weight = (io.weight + 9) / 10.

@keszybz
Copy link

keszybz commented Feb 4, 2021

^ @paolo-github

@keszybz
Copy link

keszybz commented Feb 4, 2021

systemd/systemd#18467

@dqminh
Copy link
Contributor Author

dqminh commented Feb 4, 2021

@keszybz yes, i think that is correct.

Which then also raises more questions:

  1. Do we want to set both interface ( like what systemd is doing ) ? In our case, since the spec is saying that the allowed range is 0-1000, and i assume that we don't want breaking changes, we still have to do the conversion to write to io.weight
  2. I don't think runc's systemd v2 is setting IOWeight, is that right ? I tried to do a quick search and can't find any.

In general, io.weight iocost interface is also more likely to be available everywhere (is it ?, see containers/podman#8737), so maybe doing 1) makes sense.

Copy link
Contributor

@kolyshkin kolyshkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, the io.bfq.weight range is 1-1000, but io.weight range is 1-10000. runc is not currently setting io.weight.

@paolo-github
Copy link

paolo-github commented Feb 5, 2021 via email

@kolyshkin
Copy link
Contributor

kolyshkin commented Feb 23, 2021

Took a liberty to

kolyshkin
kolyshkin previously approved these changes Feb 23, 2021
Copy link
Contributor

@kolyshkin kolyshkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kolyshkin
Copy link
Contributor

@AkihiroSuda PTAL

@kolyshkin
Copy link
Contributor

The test case is not working under rootless on Fedora:

not ok 10 runc run (blkio weight)
# (in test file /vagrant/tests/integration/cgroups.bats, line 203)
#   `[ "$status" -eq 0 ]' failed
# runc spec --rootless (status=0):
# 
# runc run -d --console-socket /tmp/console.sock test_cgroups_unified (status=0):
# 
# runc exec test_cgroups_unified sh -c cat /sys/fs/cgroup/io.bfq.weight (status=1):
# cat: can't open '/sys/fs/cgroup/io.bfq.weight': No such file or directory

Apparently the problem is, rootless containers somehow do no honor cgroupns. Instead of "just this container" we see everything in container's view of /sys/fs/cgroup.

Looking...

@kolyshkin
Copy link
Contributor

Normal container's cgroup2 mount:

[kir@kir-rhat runc]$ cat /proc/2474364/mountinfo | grep cgroup
1956 1955 0:27 /user.slice/user-1000.slice/[email protected]/x453 /sys/fs/cgroup ro,nosuid,nodev,noexec,relatime - cgroup2 cgroup rw,seclabel

rootless container cgroup2 mount:

[kir@kir-rhat runc]$ cat /proc/2475909/mountinfo | grep cgroup
30 23 0:27 / /sys/fs/cgroup rw,nosuid,nodev,noexec,relatime shared:4 - cgroup2 cgroup2 rw,seclabel

Ah, so it is caused by #2158. Hmmm.

@dqminh
Copy link
Contributor Author

dqminh commented Feb 23, 2021

@kolyshkin sorry for the delay. yes i indeed hit this along the removal of root for the test so it wasn't done, and i forgot to put a comment on that.

@kolyshkin
Copy link
Contributor

@dqminh your patch is fine (note that I pushed into your branch though), the rootless cgroup mount is a separate issue I'm going to address.

bfq weight controller (i.e. io.bfq.weight if present) is still using the
same bfq weight scheme (i.e 1->1000, see [1].) Unfortunately the
documentation for this was wrong, and only fixed recently [2].

Therefore, if we map blkio weight to io.bfq.weight, there's no need to
do any conversion. Otherwise, we will try to write invalid value which
results in error such as:

```
time="2021-02-03T14:55:30Z" level=error msg="container_linux.go:367: starting container process caused: process_linux.go:495: container init caused: process_linux.go:458: setting cgroup config for procHooks process caused: failed to write \"7475\": write /sys/fs/cgroup/runc-cgroups-integration-test/test-cgroup/io.bfq.weight: numerical result out of range"
```

[1] https://github.com/torvalds/linux/blob/master/Documentation/block/bfq-iosched.rst
[2] torvalds/linux@65752ae

Signed-off-by: Daniel Dao <[email protected]>
Copy link
Contributor

@kolyshkin kolyshkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kolyshkin
Copy link
Contributor

@AkihiroSuda PTAL

@kolyshkin
Copy link
Contributor

@cyphar PTAL (you requested changes and thus merging is blocked until you approve). Seems your review comments are now addressed.

Copy link
Member

@cyphar cyphar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. As an aside, feel free to dismiss my old reviews if they are clearly no longer applicable. (I wish GitHub did this already, because it treats approvals as something that can go stale but "request changes" reviews aren't treated as stale.)

@cyphar cyphar closed this in c153261 Feb 24, 2021
@cyphar cyphar merged commit c153261 into opencontainers:master Feb 24, 2021
bergwolf pushed a commit to bergwolf/kata-containers that referenced this pull request Feb 25, 2021
BFQ weight controller is using the same BFQ weight scheme (i.e 1->1000).
Therefore, there is no need to do the conversion.

More details here: opencontainers/runc#2786

Fixes: kata-containers#1440

Signed-off-by: Manabu Sugimoto <[email protected]>
bergwolf pushed a commit to bergwolf/kata-containers that referenced this pull request Mar 17, 2021
BFQ weight controller is using the same BFQ weight scheme (i.e 1->1000).
Therefore, there is no need to do the conversion.

More details here: opencontainers/runc#2786

Fixes: kata-containers#1440

Signed-off-by: Manabu Sugimoto <[email protected]>
avagin pushed a commit to google/gvisor that referenced this pull request May 4, 2021
The way libcontainer and lots of other runtime deals with blockio
setting in cgroupv2 is buggy, see [1]

For now, we disable BlockIO until a fix can land in libcontainer.

[1] opencontainers/runc#2786

Signed-off-by: Daniel Dao <[email protected]>
avagin pushed a commit to google/gvisor that referenced this pull request May 5, 2021
The way libcontainer and lots of other runtime deals with blockio
setting in cgroupv2 is buggy, see [1]

For now, we disable BlockIO until a fix can land in libcontainer.

[1] opencontainers/runc#2786

Signed-off-by: Daniel Dao <[email protected]>
avagin pushed a commit to google/gvisor that referenced this pull request May 12, 2021
The way libcontainer and lots of other runtime deals with blockio
setting in cgroupv2 is buggy, see [1]

For now, we disable BlockIO until a fix can land in libcontainer.

[1] opencontainers/runc#2786

Signed-off-by: Daniel Dao <[email protected]>
avagin pushed a commit to google/gvisor that referenced this pull request May 14, 2021
The way libcontainer and lots of other runtime deals with blockio
setting in cgroupv2 is buggy, see [1]

For now, we disable BlockIO until a fix can land in libcontainer.

[1] opencontainers/runc#2786

Signed-off-by: Daniel Dao <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants