-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Faster Intel RDT init if the feature is unavailable #3306
Conversation
@marquiz @xiaochenshen @Creatone PTAL (I don't even have hardware to test this) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @kolyshkin, good improvement. I can verify this patch on a system with RDT support
libcontainer/intelrdt/intelrdt.go
Outdated
rootOnce.Do(func() { | ||
f, err := os.Open("/proc/self/mountinfo") | ||
if err != nil { | ||
intelRdtRootErr = err | ||
return | ||
} | ||
root, err := findIntelRdtMountpointDir(f) | ||
f.Close() | ||
if err != nil { | ||
intelRdtRootErr = err | ||
return | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have to take into account that resctrl
might get mounted after the first check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so. If we do, we have to re-read /proc/self/mountinfo over and over (assuming it's some long-lived daemon that imports libcontainer/intelrdt, such as kubelet; for runc itself it's not a issue, since it's a short-lived binary).
I suppose that resctrl is mounted during system init, and it should be mounted by the time we start runc or e.g. kubernetes. If not, it's a configuration issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
K, fair enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose that resctrl is mounted during system init, and it should be mounted by the time we start runc or e.g. kubernetes. If not, it's a configuration issue.
Are there specific systemd targets to take this into account and that should be recommended for that? I know containerd has local-fs.target
, does that cover this as well?
After=network.target local-fs.target
@kolyshkin Thank you for working on this improvement. FYI - Actually on Intel RDT enabled platforms, we don't have to mount resctrl filesystem into directory
In this case, we have to call So in my opinion, checking existence of |
Sorry, this was my intention indeed I switched to other work and then back, and published a WIP patch as a result. Will fix and let you know. |
In case resctrl filesystem can not be found in /proc/self/mountinfo (which is pretty common on non-server or non-x86 hardware), subsequent calls to Root() will result in parsing it again and again. Use sync.Once to avoid it. Make unit tests call it so that Root() won't actually parse mountinfo in tests. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This test was written back in the day when findIntelRdtMountpointDir was using its own mountinfo parser. Commit f1c1fdf changed that, and thus this test is actually testing moby/sys/mountinfo parser, which does not make much sense. Remove the test, and drop the io.Reader argument since we no longer need to parse a custom file. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
In a (quite common) case RDT is not supported by the kernel/hardware, it does not make sense to parse /proc/cpuinfo and /proc/self/mountinfo, and yet the current code does it (on every runc exec, for example). Fortunately, there is a quick way to check whether RDT is available -- if so, kernel creates /sys/fs/resctrl directory. Check its existence, and skip all the other initialization if it's not present. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
OK this is how I intended it -- do NOTE we could skip parsing mountinfo entirely by doing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
As this modifies |
@AkihiroSuda @cyphar @thaJeztah PTAL 🙏🏻 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
libcontainer/intelrdt/intelrdt.go
Outdated
rootOnce.Do(func() { | ||
f, err := os.Open("/proc/self/mountinfo") | ||
if err != nil { | ||
intelRdtRootErr = err | ||
return | ||
} | ||
root, err := findIntelRdtMountpointDir(f) | ||
f.Close() | ||
if err != nil { | ||
intelRdtRootErr = err | ||
return | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose that resctrl is mounted during system init, and it should be mounted by the time we start runc or e.g. kubernetes. If not, it's a configuration issue.
Are there specific systemd targets to take this into account and that should be recommended for that? I know containerd has local-fs.target
, does that cover this as well?
After=network.target local-fs.target
intelRdtRootErr = err | ||
return | ||
} | ||
root, err := findIntelRdtMountpointDir(f) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess technically we wouldn't need the intermediate root
and err
variables (no need to change)
41 18 0:16 / /sys/fs/resctrl rw,relatime shared:24 - resctrl resctrl rw,mba_MBps | ||
42 20 0:36 / /dev/hugepages rw,relatime shared:25 - hugetlbfs hugetlbfs rw | ||
43 19 0:37 / /proc/sys/fs/binfmt_misc rw,relatime shared:26 - autofs systemd-1 rw,fd=32,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=35492 | ||
44 20 0:15 / /dev/mqueue rw,relatime shared:27 - mqueue mqueue rw |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any test-case here that we're not covering yet in the https://github.com/moby/sys repository?
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
In a (quite common) case RDT is not supported by the kernel/hardware,
it does not make sense to parse /proc/cpuinfo and /proc/self/mountinfo,
and yet the current code does it (on every runc exec, for example).
Fortunately, there is a quick way to check whether RDT is available --
if so, kernel creates /sys/fs/resctrl directory. Check its existence,
and skip all the other initialization if it's not present.
(plus some cleanups)