mirror of
https://github.com/systemd/systemd.git
synced 2025-01-26 14:04:03 +03:00
core: map io.bfq.weight to 1..1000
Aaargh. See the comment in the code. Apparently the range is like that: $ sudo bash -c 'echo "default 1001" >/sys/fs/cgroup/user.slice/io.bfq.weight' bash: line 0: echo: write error: Numerical result out of range $ uname -r 5.11.0-0.rc4.129.fc34.x86_64
This commit is contained in:
parent
84c46fb03c
commit
29eb0eefd1
@ -1057,6 +1057,23 @@ static int cgroup_apply_devices(Unit *u) {
|
||||
return r;
|
||||
}
|
||||
|
||||
static void set_io_weight(Unit *u, const char *controller, uint64_t weight) {
|
||||
char buf[8+DECIMAL_STR_MAX(uint64_t)+1];
|
||||
const char *p;
|
||||
|
||||
p = strjoina(controller, ".weight");
|
||||
xsprintf(buf, "default %" PRIu64 "\n", weight);
|
||||
(void) set_attribute_and_warn(u, controller, p, buf);
|
||||
|
||||
/* FIXME: drop this when distro kernels properly support BFQ through "io.weight"
|
||||
* See also: https://github.com/systemd/systemd/pull/13335 and
|
||||
* https://github.com/torvalds/linux/commit/65752aef0a407e1ef17ec78a7fc31ba4e0b360f9.
|
||||
* The range is 1..1000 apparently. */
|
||||
p = strjoina(controller, ".bfq.weight");
|
||||
xsprintf(buf, "%" PRIu64 "\n", (weight + 9) / 10);
|
||||
(void) set_attribute_and_warn(u, controller, p, buf);
|
||||
}
|
||||
|
||||
static void cgroup_context_apply(
|
||||
Unit *u,
|
||||
CGroupMask apply_mask,
|
||||
@ -1143,7 +1160,6 @@ static void cgroup_context_apply(
|
||||
* controller), and in case of containers we want to leave control of these attributes to the container manager
|
||||
* (and we couldn't access that stuff anyway, even if we tried if proper delegation is used). */
|
||||
if ((apply_mask & CGROUP_MASK_IO) && !is_local_root) {
|
||||
char buf[8+DECIMAL_STR_MAX(uint64_t)+1];
|
||||
bool has_io, has_blockio;
|
||||
uint64_t weight;
|
||||
|
||||
@ -1163,13 +1179,7 @@ static void cgroup_context_apply(
|
||||
} else
|
||||
weight = CGROUP_WEIGHT_DEFAULT;
|
||||
|
||||
xsprintf(buf, "default %" PRIu64 "\n", weight);
|
||||
(void) set_attribute_and_warn(u, "io", "io.weight", buf);
|
||||
|
||||
/* FIXME: drop this when distro kernels properly support BFQ through "io.weight"
|
||||
* See also: https://github.com/systemd/systemd/pull/13335 */
|
||||
xsprintf(buf, "%" PRIu64 "\n", weight);
|
||||
(void) set_attribute_and_warn(u, "io", "io.bfq.weight", buf);
|
||||
set_io_weight(u, "io", weight);
|
||||
|
||||
if (has_io) {
|
||||
CGroupIODeviceLatency *latency;
|
||||
@ -1225,7 +1235,6 @@ static void cgroup_context_apply(
|
||||
/* Applying a 'weight' never makes sense for the host root cgroup, and for containers this should be
|
||||
* left to our container manager, too. */
|
||||
if (!is_local_root) {
|
||||
char buf[DECIMAL_STR_MAX(uint64_t)+1];
|
||||
uint64_t weight;
|
||||
|
||||
if (has_io) {
|
||||
@ -1241,13 +1250,7 @@ static void cgroup_context_apply(
|
||||
else
|
||||
weight = CGROUP_BLKIO_WEIGHT_DEFAULT;
|
||||
|
||||
xsprintf(buf, "%" PRIu64 "\n", weight);
|
||||
(void) set_attribute_and_warn(u, "blkio", "blkio.weight", buf);
|
||||
|
||||
/* FIXME: drop this when distro kernels properly support BFQ through "blkio.weight"
|
||||
* See also: https://github.com/systemd/systemd/pull/13335 */
|
||||
xsprintf(buf, "%" PRIu64 "\n", weight);
|
||||
(void) set_attribute_and_warn(u, "blkio", "blkio.bfq.weight", buf);
|
||||
set_io_weight(u, "blkio", weight);
|
||||
|
||||
if (has_io) {
|
||||
CGroupIODeviceWeight *w;
|
||||
|
Loading…
x
Reference in New Issue
Block a user