2020-11-09 05:23:58 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
2019-08-01 13:14:45 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#include "cgroup-util.h"
|
|
|
|
|
|
|
|
bool cg_is_unified_wanted(void);
|
|
|
|
bool cg_is_legacy_wanted(void);
|
|
|
|
bool cg_is_hybrid_wanted(void);
|
|
|
|
|
|
|
|
int cg_weight_parse(const char *s, uint64_t *ret);
|
|
|
|
int cg_cpu_shares_parse(const char *s, uint64_t *ret);
|
|
|
|
int cg_blkio_weight_parse(const char *s, uint64_t *ret);
|
|
|
|
|
|
|
|
int cg_trim(const char *controller, const char *path, bool delete_root);
|
|
|
|
|
|
|
|
int cg_create(const char *controller, const char *path);
|
|
|
|
int cg_attach(const char *controller, const char *path, pid_t pid);
|
|
|
|
int cg_attach_fallback(const char *controller, const char *path, pid_t pid);
|
|
|
|
int cg_create_and_attach(const char *controller, const char *path, pid_t pid);
|
|
|
|
|
|
|
|
int cg_migrate(const char *cfrom, const char *pfrom, const char *cto, const char *pto, CGroupFlags flags);
|
|
|
|
int cg_migrate_recursive(const char *cfrom, const char *pfrom, const char *cto, const char *pto, CGroupFlags flags);
|
|
|
|
int cg_migrate_recursive_fallback(const char *cfrom, const char *pfrom, const char *cto, const char *pto, CGroupFlags flags);
|
|
|
|
|
|
|
|
int cg_create_everywhere(CGroupMask supported, CGroupMask mask, const char *path);
|
|
|
|
int cg_attach_everywhere(CGroupMask supported, const char *path, pid_t pid, cg_migrate_callback_t callback, void *userdata);
|
cgroup: Swap cgroup v1 deletion and migration
When we are about to derealize a controller on v1 cgroup, we first
attempt to delete the controller cgroup and migrate afterwards. This
doesn't work in practice because populated cgroup cannot be deleted.
Furthermore, we leave out slices from migration completely, so
(un)setting a control value on them won't realize their controller
cgroup.
Rework actual realization, unit_create_cgroup() becomes
unit_update_cgroup() and make sure that controller hierarchies are
reduced when given controller cgroup ceased to be needed.
Note that with this we introduce slight deviation between v1 and v2 code
-- when a descendant unit turns off a delegated controller, we attempt
to disable it in ancestor slices. On v2 this may fail (kernel enforced,
because of child cgroups using the controller), on v1 we'll migrate
whole subtree and trim the subhierachy. (Previously, we wouldn't take
away delegated controller, however, derealization was broken anyway.)
Fixes: #14149
2020-05-01 14:00:42 +02:00
|
|
|
int cg_migrate_v1_controllers(CGroupMask supported, CGroupMask mask, const char *from, cg_migrate_callback_t to_callback, void *userdata);
|
2019-08-01 13:14:45 +02:00
|
|
|
int cg_trim_everywhere(CGroupMask supported, const char *path, bool delete_root);
|
cgroup: Swap cgroup v1 deletion and migration
When we are about to derealize a controller on v1 cgroup, we first
attempt to delete the controller cgroup and migrate afterwards. This
doesn't work in practice because populated cgroup cannot be deleted.
Furthermore, we leave out slices from migration completely, so
(un)setting a control value on them won't realize their controller
cgroup.
Rework actual realization, unit_create_cgroup() becomes
unit_update_cgroup() and make sure that controller hierarchies are
reduced when given controller cgroup ceased to be needed.
Note that with this we introduce slight deviation between v1 and v2 code
-- when a descendant unit turns off a delegated controller, we attempt
to disable it in ancestor slices. On v2 this may fail (kernel enforced,
because of child cgroups using the controller), on v1 we'll migrate
whole subtree and trim the subhierachy. (Previously, we wouldn't take
away delegated controller, however, derealization was broken anyway.)
Fixes: #14149
2020-05-01 14:00:42 +02:00
|
|
|
int cg_trim_v1_controllers(CGroupMask supported, CGroupMask mask, const char *path, bool delete_root);
|
2019-08-01 13:14:45 +02:00
|
|
|
int cg_enable_everywhere(CGroupMask supported, CGroupMask mask, const char *p, CGroupMask *ret_result_mask);
|