X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Fcgroup.c;h=9248cb523b685f117d520e81f4c489c4ccd3d890;hb=f461c8073dee9cd10bfae5ae3586e785ec8a5d07;hp=db8b4d7705c053c66e73cffb078de29a6f84bbf1;hpb=0d8c31ff7237149b505290652864b4e7e866b2a7;p=elogind.git diff --git a/src/core/cgroup.c b/src/core/cgroup.c index db8b4d770..9248cb523 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -41,7 +41,7 @@ void cgroup_context_init(CGroupContext *c) { c->blockio_weight = (unsigned long) -1; c->startup_blockio_weight = (unsigned long) -1; - c->cpu_quota_per_sec_usec = (usec_t) -1; + c->cpu_quota_per_sec_usec = USEC_INFINITY; } void cgroup_context_free_device_allow(CGroupContext *c, CGroupDeviceAllow *a) { @@ -200,7 +200,7 @@ static int whitelist_device(const char *path, const char *node, const char *acc) r = cg_set_attribute("devices", path, "devices.allow", buf); if (r < 0) - log_warning("Failed to set devices.allow on %s: %s", path, strerror(-r)); + log_full(r == -ENOENT ? LOG_DEBUG : LOG_WARNING, "Failed to set devices.allow on %s: %s", path, strerror(-r)); return r; } @@ -272,7 +272,7 @@ static int whitelist_major(const char *path, const char *name, char type, const r = cg_set_attribute("devices", path, "devices.allow", buf); if (r < 0) - log_warning("Failed to set devices.allow on %s: %s", path, strerror(-r)); + log_full(r == -ENOENT ? LOG_DEBUG : LOG_WARNING, "Failed to set devices.allow on %s: %s", path, strerror(-r)); } return 0; @@ -304,20 +304,20 @@ void cgroup_context_apply(CGroupContext *c, CGroupControllerMask mask, const cha c->cpu_shares != (unsigned long) -1 ? c->cpu_shares : 1024); r = cg_set_attribute("cpu", path, "cpu.shares", buf); if (r < 0) - log_warning("Failed to set cpu.shares on %s: %s", path, strerror(-r)); + log_full(r == -ENOENT ? LOG_DEBUG : LOG_WARNING, "Failed to set cpu.shares on %s: %s", path, strerror(-r)); sprintf(buf, USEC_FMT "\n", CGROUP_CPU_QUOTA_PERIOD_USEC); r = cg_set_attribute("cpu", path, "cpu.cfs_period_us", buf); if (r < 0) - log_warning("Failed to set cpu.cfs_period_us on %s: %s", path, strerror(-r)); + log_full(r == -ENOENT ? LOG_DEBUG : LOG_WARNING, "Failed to set cpu.cfs_period_us on %s: %s", path, strerror(-r)); - if (c->cpu_quota_per_sec_usec != (usec_t) -1) { + if (c->cpu_quota_per_sec_usec != USEC_INFINITY) { sprintf(buf, USEC_FMT "\n", c->cpu_quota_per_sec_usec * CGROUP_CPU_QUOTA_PERIOD_USEC / USEC_PER_SEC); r = cg_set_attribute("cpu", path, "cpu.cfs_quota_us", buf); } else r = cg_set_attribute("cpu", path, "cpu.cfs_quota_us", "-1"); if (r < 0) - log_warning("Failed to set cpu.cfs_quota_us on %s: %s", path, strerror(-r)); + log_full(r == -ENOENT ? LOG_DEBUG : LOG_WARNING, "Failed to set cpu.cfs_quota_us on %s: %s", path, strerror(-r)); } if (mask & CGROUP_BLKIO) { @@ -332,7 +332,7 @@ void cgroup_context_apply(CGroupContext *c, CGroupControllerMask mask, const cha c->blockio_weight != (unsigned long) -1 ? c->blockio_weight : 1000); r = cg_set_attribute("blkio", path, "blkio.weight", buf); if (r < 0) - log_warning("Failed to set blkio.weight on %s: %s", path, strerror(-r)); + log_full(r == -ENOENT ? LOG_DEBUG : LOG_WARNING, "Failed to set blkio.weight on %s: %s", path, strerror(-r)); /* FIXME: no way to reset this list */ LIST_FOREACH(device_weights, w, c->blockio_device_weights) { @@ -345,7 +345,7 @@ void cgroup_context_apply(CGroupContext *c, CGroupControllerMask mask, const cha sprintf(buf, "%u:%u %lu", major(dev), minor(dev), w->weight); r = cg_set_attribute("blkio", path, "blkio.weight_device", buf); if (r < 0) - log_error("Failed to set blkio.weight_device on %s: %s", path, strerror(-r)); + log_full(r == -ENOENT ? LOG_DEBUG : LOG_WARNING, "Failed to set blkio.weight_device on %s: %s", path, strerror(-r)); } } @@ -363,7 +363,7 @@ void cgroup_context_apply(CGroupContext *c, CGroupControllerMask mask, const cha sprintf(buf, "%u:%u %" PRIu64 "\n", major(dev), minor(dev), b->bandwidth); r = cg_set_attribute("blkio", path, a, buf); if (r < 0) - log_error("Failed to set %s on %s: %s", a, path, strerror(-r)); + log_full(r == -ENOENT ? LOG_DEBUG : LOG_WARNING, "Failed to set %s on %s: %s", a, path, strerror(-r)); } } @@ -377,7 +377,7 @@ void cgroup_context_apply(CGroupContext *c, CGroupControllerMask mask, const cha r = cg_set_attribute("memory", path, "memory.limit_in_bytes", "-1"); if (r < 0) - log_error("Failed to set memory.limit_in_bytes on %s: %s", path, strerror(-r)); + log_full(r == -ENOENT ? LOG_DEBUG : LOG_WARNING, "Failed to set memory.limit_in_bytes on %s: %s", path, strerror(-r)); } if ((mask & CGROUP_DEVICE) && !is_root) { @@ -388,7 +388,7 @@ void cgroup_context_apply(CGroupContext *c, CGroupControllerMask mask, const cha else r = cg_set_attribute("devices", path, "devices.allow", "a"); if (r < 0) - log_warning("Failed to reset devices.list on %s: %s", path, strerror(-r)); + log_full(r == -ENOENT ? LOG_DEBUG : LOG_WARNING, "Failed to reset devices.list on %s: %s", path, strerror(-r)); if (c->device_policy == CGROUP_CLOSED || (c->device_policy == CGROUP_AUTO && c->device_allow)) { @@ -447,7 +447,7 @@ CGroupControllerMask cgroup_context_get_mask(CGroupContext *c) { if (c->cpu_accounting || c->cpu_shares != (unsigned long) -1 || c->startup_cpu_shares != (unsigned long) -1 || - c->cpu_quota_per_sec_usec != (usec_t) -1) + c->cpu_quota_per_sec_usec != USEC_INFINITY) mask |= CGROUP_CPUACCT | CGROUP_CPU; if (c->blockio_accounting ||