-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
cgroup: support config cgroup cpu.idle by systemd #23299
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
Conversation
3f2348c
to
57ab210
Compare
I don't understand what the patch does? the patch seems to add a boolean option, but your patch here adds a numeric option? so, what does this do? can you explain? please add an brief explanation of the option to man/systemd.resource-control.xml, where we document all stuff backed by cgroup stuff... |
/cc @htejun what is this? should we support this? |
I think it was from google. They wanted hierarchical idle scheduling - ie. at each level, if some cgroups have idle set, they are guaranteed to run only when no non-idle sibling is runnable. It's a niche feature that google and scheduler folks wanted. Maybe leave it be until some people really want it? |
Quoting the kernel commit message (https://lore.kernel.org/lkml/[email protected]/):
|
@wineway so is that something you actually intend to use? or something you just wanted to add support for for completeness? |
Actually I think I could make good use of this setting, sounds like it would nicely complement the Condition PSI settings for long lived services. We could even configure this in background.slice maybe? |
We don't necessarily want to expose things 1:1 exposing the raw kernel semantics. We genreally try to be friendlier than the kernel. i.e. to me this appears to be something that is boolean for now, and maybe supports more values later, but still a small number. hence maybe expose this conceptually as an enum for now, that happens to also parse a boolean value... We do that for a couple of settings, for example ProtectSystem=, which is primarily a boolean, but also takes some additional, special values. I am pretty sure exposing a raw integer is not the right approach... That all said, I'd like to understand what the usecase here is: should we really care? are there people who actually want this? I'd rather avoid adding support for this, unless there's real value for people in this. |
I think I'd use this - for short-lived tasks we now have the ConditionCPUPressure which works nicely, but for long-running services obviously that doesn't help. This could fill that gap. |
but why wouldn't |
for this kernel feature, yes, and for the systemd's implementation, for me mainly for the completeness. we intend to use this kernel feature in container environments to run a regular service and a less latency-sensitive service in one host machine before this patch merged, many other applications(like with this feature, we can use a more explicit configuration and get a better effect. since mostly container runtimes rely on and as @bluca mentioned, this feature is useful besides what is described above. |
Those are hard limits. We use them too, of course - but just like with the conditions, some tasks are of the type 'I'd like to run and use a lot of resources, but it's fine if I don't because of high-prio items'. With a fixed setting you have a hard ceiling regardless of the state of the system. |
i am not sure i grok the "hard limits" and "hard ceiling" references? As I understand the What concerns me about the |
Uhm CPUWeight takes into account current pressure? It wasn't obvious from our manpage, but maybe I'm conflating that with CPUQuota in my head |
seems the sematic we want is:
in our use case, we have two services we benched 🤔I think it might not a niche requirement, especially in cloud and container environments. |
I am not against adding this, if people actually intend to use this. |
I'm not against adding this either but the niche part comes from this being a hierarchical feature. For most use cases, setting SCHED_IDLE is enough. Maybe it'd be more convenient if that can be enforced per cgroup. What the feature implements is idle class per cgroup sibling group. There are use cases this would be useful but the intersection of needing both hierarchical control and the improvements over weight-based control isn't huge. I think we'd be better off with better weight based control (e.g. even widening the dynamic range of weights). So, I'm rather ambivalent. That said, the feature is there and so are the users, so why not? |
If we adding this, seems we should make
and since we didn't keep the value range the same as the kernel. Should we rename this option? but I can't find a name better than or we can keep both enum and integer value for it, and convert the enum value to an integer
|
My 0.02€ -- as systemd adds own abstract layer on top of kernel knobs, let's allow setting |
@Werkov In my opinion, |
I think we should support this knob in some fashion. If the kernel added this in cgroups-v2, this means pretty much means we should support it, since we generally try to provide a complete interface for cgroups-v2.
I don't think we should conflate the two. But please make this take a boolean argument in the config. We'll 'yes|no' for now, and if the kernel interface is extended, we can extend the parser. OTOH, internally and in the dbus interface, I think it's fine if we keep this an integer. If kernel allows other values, we'll want to map them 1:1 to our own values. |
man/systemd.resource-control.xml
Outdated
<listitem> | ||
<para>If set to the special string "idle", mark the cgroup for "idle scheduling", which means | ||
that it will get CPU resources only when there are no processes not marked in this way to execute in this | ||
cgroup or its siblings. This setting corresponds to the <literal>cpu.idle</literal> cgroup attribute.</para> |
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.
hmm, this indentation is particularly weird now
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.
👀 fixed here……
lgtm, but the indentation of the man page docbook XML is still a bit weird |
Signed-off-by: wineway <[email protected]>
Systemd v252 (available in CentOS Stream 9 in our CI) added support for setting cpu.idle (see [1]). The way it works is: - if CPUWeight == 0, cpu.idle is set to 1; - if CPUWeight != 0, cpu.idle is set to 0. This behavior breaks the existing test case, as described in [2]. To fix, skip the last check in the test case in case a newer systemd is used. Fixes: opencontainers#3786 [1] systemd/systemd#23299 [2] opencontainers#3786 Signed-off-by: Kir Kolyshkin <[email protected]>
Systemd v252 (available in CentOS Stream 9 in our CI) added support for setting cpu.idle (see [1]). The way it works is: - if CPUWeight == 0, cpu.idle is set to 1; - if CPUWeight != 0, cpu.idle is set to 0. This commit implements setting cpu.idle in systemd cgroup driver via a unit property. In case CPUIdle is set to non-zero value, the driver sets adds CPUWeight=0 property, which will result in systemd setting cpu.idle to 1. Unfortunately, there's no way to set cpu.idle to 0 without also changing the CPUWeight value, so the driver doesn't do anything if CPUIdle is explicitly set to 0. This case is handled by the fs driver which is always used as a followup to setting systemd unit properties. Also, handle cpu.idle set via unified map. In case it is set to non-zero value, add CPUWeight=0 property, and ignore cpu.weight (otherwise we'll get two different CPUWeight properties set). Add a unit test for new values in unified map, and an integration test case. [1] systemd/systemd#23299 [2] opencontainers#3786 Signed-off-by: Kir Kolyshkin <[email protected]>
Systemd v252 (available in CentOS Stream 9 in our CI) added support for setting cpu.idle (see [1]). The way it works is: - if CPUWeight == 0, cpu.idle is set to 1; - if CPUWeight != 0, cpu.idle is set to 0. This commit implements setting cpu.idle in systemd cgroup driver via a unit property. In case CPUIdle is set to non-zero value, the driver sets adds CPUWeight=0 property, which will result in systemd setting cpu.idle to 1. Unfortunately, there's no way to set cpu.idle to 0 without also changing the CPUWeight value, so the driver doesn't do anything if CPUIdle is explicitly set to 0. This case is handled by the fs driver which is always used as a followup to setting systemd unit properties. Also, handle cpu.idle set via unified map. In case it is set to non-zero value, add CPUWeight=0 property, and ignore cpu.weight (otherwise we'll get two different CPUWeight properties set). Add a unit test for new values in unified map, and an integration test case. [1] systemd/systemd#23299 [2] opencontainers#3786 Signed-off-by: Kir Kolyshkin <[email protected]>
Systemd v252 (available in CentOS Stream 9 in our CI) added support for setting cpu.idle (see [1]). The way it works is: - if CPUWeight == 0, cpu.idle is set to 1; - if CPUWeight != 0, cpu.idle is set to 0. This behavior breaks the existing test case, as described in [2]. To fix, skip the last check in the test case in case a newer systemd is used. Fixes: opencontainers#3786 [1] systemd/systemd#23299 [2] opencontainers#3786 Signed-off-by: Kir Kolyshkin <[email protected]>
Systemd v252 (available in CentOS Stream 9 in our CI) added support for setting cpu.idle (see [1]). The way it works is: - if CPUWeight == 0, cpu.idle is set to 1; - if CPUWeight != 0, cpu.idle is set to 0. This commit implements setting cpu.idle in systemd cgroup driver via a unit property. In case CPUIdle is set to non-zero value, the driver sets adds CPUWeight=0 property, which will result in systemd setting cpu.idle to 1. Unfortunately, there's no way to set cpu.idle to 0 without also changing the CPUWeight value, so the driver doesn't do anything if CPUIdle is explicitly set to 0. This case is handled by the fs driver which is always used as a followup to setting systemd unit properties. Also, handle cpu.idle set via unified map. In case it is set to non-zero value, add CPUWeight=0 property, and ignore cpu.weight (otherwise we'll get two different CPUWeight properties set). Add a unit test for new values in unified map, and an integration test case. [1] systemd/systemd#23299 [2] opencontainers#3786 Signed-off-by: Kir Kolyshkin <[email protected]>
Systemd v252 (available in CentOS Stream 9 in our CI) added support for setting cpu.idle (see [1]). The way it works is: - if CPUWeight == 0, cpu.idle is set to 1; - if CPUWeight != 0, cpu.idle is set to 0. This commit implements setting cpu.idle in systemd cgroup driver via a unit property. In case CPUIdle is set to non-zero value, the driver sets adds CPUWeight=0 property, which will result in systemd setting cpu.idle to 1. Unfortunately, there's no way to set cpu.idle to 0 without also changing the CPUWeight value, so the driver doesn't do anything if CPUIdle is explicitly set to 0. This case is handled by the fs driver which is always used as a followup to setting systemd unit properties. Also, handle cpu.idle set via unified map. In case it is set to non-zero value, add CPUWeight=0 property, and ignore cpu.weight (otherwise we'll get two different CPUWeight properties set). Add a unit test for new values in unified map, and an integration test case. [1] systemd/systemd#23299 [2] opencontainers#3786 Signed-off-by: Kir Kolyshkin <[email protected]>
Systemd v252 (available in CentOS Stream 9 in our CI) added support for setting cpu.idle (see [1]). The way it works is: - if CPUWeight == 0, cpu.idle is set to 1; - if CPUWeight != 0, cpu.idle is set to 0. This behavior breaks the existing test case, as described in [2]. To fix, skip the last check in the test case in case a newer systemd is used. Fixes: opencontainers#3786 [1] systemd/systemd#23299 [2] opencontainers#3786 Signed-off-by: Kir Kolyshkin <[email protected]>
Systemd v252 (available in CentOS Stream 9 in our CI) added support for setting cpu.idle (see [1]). The way it works is: - if CPUWeight == 0, cpu.idle is set to 1; - if CPUWeight != 0, cpu.idle is set to 0. This commit implements setting cpu.idle in systemd cgroup driver via a unit property. In case CPUIdle is set to non-zero value, the driver sets adds CPUWeight=0 property, which will result in systemd setting cpu.idle to 1. Unfortunately, there's no way to set cpu.idle to 0 without also changing the CPUWeight value, so the driver doesn't do anything if CPUIdle is explicitly set to 0. This case is handled by the fs driver which is always used as a followup to setting systemd unit properties. Also, handle cpu.idle set via unified map. In case it is set to non-zero value, add CPUWeight=0 property, and ignore cpu.weight (otherwise we'll get two different CPUWeight properties set). Add a unit test for new values in unified map, and an integration test case. [1] systemd/systemd#23299 [2] opencontainers#3786 Signed-off-by: Kir Kolyshkin <[email protected]>
Systemd v252 (available in CentOS Stream 9 in our CI) added support for setting cpu.idle (see [1]). The way it works is: - if CPUWeight == 0, cpu.idle is set to 1; - if CPUWeight != 0, cpu.idle is set to 0. This behavior breaks the existing test case, as described in [2]. To fix, skip the last check in the test case in case a newer systemd is used. Fixes: opencontainers#3786 [1] systemd/systemd#23299 [2] opencontainers#3786 Signed-off-by: Kir Kolyshkin <[email protected]>
Systemd v252 (available in CentOS Stream 9 in our CI) added support for setting cpu.idle (see [1]). The way it works is: - if CPUWeight == 0, cpu.idle is set to 1; - if CPUWeight != 0, cpu.idle is set to 0. This commit implements setting cpu.idle in systemd cgroup driver via a unit property. In case CPUIdle is set to non-zero value, the driver sets adds CPUWeight=0 property, which will result in systemd setting cpu.idle to 1. Unfortunately, there's no way to set cpu.idle to 0 without also changing the CPUWeight value, so the driver doesn't do anything if CPUIdle is explicitly set to 0. This case is handled by the fs driver which is always used as a followup to setting systemd unit properties. Also, handle cpu.idle set via unified map. In case it is set to non-zero value, add CPUWeight=0 property, and ignore cpu.weight (otherwise we'll get two different CPUWeight properties set). Add a unit test for new values in unified map, and an integration test case. [1] systemd/systemd#23299 [2] opencontainers#3786 Signed-off-by: Kir Kolyshkin <[email protected]>
Systemd v252 (available in CentOS Stream 9 in our CI) added support for setting cpu.idle (see [1]). The way it works is: - if CPUWeight == 0, cpu.idle is set to 1; - if CPUWeight != 0, cpu.idle is set to 0. This behavior breaks the existing test case, as described in [2]. To fix, skip the last check in the test case in case a newer systemd is used. Fixes: opencontainers#3786 [1] systemd/systemd#23299 [2] opencontainers#3786 Signed-off-by: Kir Kolyshkin <[email protected]>
Systemd v252 (available in CentOS Stream 9 in our CI) added support for setting cpu.idle (see [1]). The way it works is: - if CPUWeight == 0, cpu.idle is set to 1; - if CPUWeight != 0, cpu.idle is set to 0. This commit implements setting cpu.idle in systemd cgroup driver via a unit property. In case CPUIdle is set to non-zero value, the driver sets adds CPUWeight=0 property, which will result in systemd setting cpu.idle to 1. Unfortunately, there's no way to set cpu.idle to 0 without also changing the CPUWeight value, so the driver doesn't do anything if CPUIdle is explicitly set to 0. This case is handled by the fs driver which is always used as a followup to setting systemd unit properties. Also, handle cpu.idle set via unified map. In case it is set to non-zero value, add CPUWeight=0 property, and ignore cpu.weight (otherwise we'll get two different CPUWeight properties set). Add a unit test for new values in unified map, and an integration test case. [1] systemd/systemd#23299 [2] opencontainers#3786 Signed-off-by: Kir Kolyshkin <[email protected]>
Systemd v252 (available in CentOS Stream 9 in our CI) added support for setting cpu.idle (see [1]). The way it works is: - if CPUWeight == 0, cpu.idle is set to 1; - if CPUWeight != 0, cpu.idle is set to 0. This behavior breaks the existing test case, as described in [2]. To fix, skip the last check in the test case in case a newer systemd is used. Fixes: opencontainers#3786 [1] systemd/systemd#23299 [2] opencontainers#3786 Signed-off-by: Kir Kolyshkin <[email protected]>
Systemd v252 (available in CentOS Stream 9 in our CI) added support for setting cpu.idle (see [1]). The way it works is: - if CPUWeight == 0, cpu.idle is set to 1; - if CPUWeight != 0, cpu.idle is set to 0. This commit implements setting cpu.idle in systemd cgroup driver via a unit property. In case CPUIdle is set to non-zero value, the driver sets adds CPUWeight=0 property, which will result in systemd setting cpu.idle to 1. Unfortunately, there's no way to set cpu.idle to 0 without also changing the CPUWeight value, so the driver doesn't do anything if CPUIdle is explicitly set to 0. This case is handled by the fs driver which is always used as a followup to setting systemd unit properties. Also, handle cpu.idle set via unified map. In case it is set to non-zero value, add CPUWeight=0 property, and ignore cpu.weight (otherwise we'll get two different CPUWeight properties set). Add a unit test for new values in unified map, and an integration test case. [1] systemd/systemd#23299 [2] opencontainers#3786 Signed-off-by: Kir Kolyshkin <[email protected]>
Systemd v252 (available in CentOS Stream 9 in our CI) added support for setting cpu.idle (see [1]). The way it works is: - if CPUWeight == 0, cpu.idle is set to 1; - if CPUWeight != 0, cpu.idle is set to 0. This commit implements setting cpu.idle in systemd cgroup driver via a unit property. In case CPUIdle is set to non-zero value, the driver sets adds CPUWeight=0 property, which will result in systemd setting cpu.idle to 1. Unfortunately, there's no way to set cpu.idle to 0 without also changing the CPUWeight value, so the driver doesn't do anything if CPUIdle is explicitly set to 0. This case is handled by the fs driver which is always used as a followup to setting systemd unit properties. Also, handle cpu.idle set via unified map. In case it is set to non-zero value, add CPUWeight=0 property, and ignore cpu.weight (otherwise we'll get two different CPUWeight properties set). Add a unit test for new values in unified map, and an integration test case. [1] systemd/systemd#23299 [2] opencontainers/runc#3786 Signed-off-by: Kir Kolyshkin <[email protected]>
Systemd v252 (available in CentOS Stream 9 in our CI) added support for setting cpu.idle (see [1]). The way it works is: - if CPUWeight == 0, cpu.idle is set to 1; - if CPUWeight != 0, cpu.idle is set to 0. This commit implements setting cpu.idle in systemd cgroup driver via a unit property. In case CPUIdle is set to non-zero value, the driver sets adds CPUWeight=0 property, which will result in systemd setting cpu.idle to 1. Unfortunately, there's no way to set cpu.idle to 0 without also changing the CPUWeight value, so the driver doesn't do anything if CPUIdle is explicitly set to 0. This case is handled by the fs driver which is always used as a followup to setting systemd unit properties. Also, handle cpu.idle set via unified map. In case it is set to non-zero value, add CPUWeight=0 property, and ignore cpu.weight (otherwise we'll get two different CPUWeight properties set). Add a unit test for new values in unified map, and an integration test case. [1] systemd/systemd#23299 [2] opencontainers/runc#3786 Signed-off-by: Kir Kolyshkin <[email protected]>
Systemd v252 (available in CentOS Stream 9 in our CI) added support for setting cpu.idle (see [1]). The way it works is: - if CPUWeight == 0, cpu.idle is set to 1; - if CPUWeight != 0, cpu.idle is set to 0. This commit implements setting cpu.idle in systemd cgroup driver via a unit property. In case CPUIdle is set to non-zero value, the driver sets adds CPUWeight=0 property, which will result in systemd setting cpu.idle to 1. Unfortunately, there's no way to set cpu.idle to 0 without also changing the CPUWeight value, so the driver doesn't do anything if CPUIdle is explicitly set to 0. This case is handled by the fs driver which is always used as a followup to setting systemd unit properties. Also, handle cpu.idle set via unified map. In case it is set to non-zero value, add CPUWeight=0 property, and ignore cpu.weight (otherwise we'll get two different CPUWeight properties set). Add a unit test for new values in unified map, and an integration test case. [1] systemd/systemd#23299 [2] opencontainers/runc#3786 Signed-off-by: Kir Kolyshkin <[email protected]>
this patch introduced a new option named
cpu.idle
in cgroup/cpu, and already added to opencontainers/runtime-spec#1136, seems we should also make systemd could manage it