mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-07-27 12:28:27 +00:00
cgroups: fix cgroup settings sorting
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
parent
8ab50a9bfc
commit
bca286f2d7
@ -2703,6 +2703,32 @@ static int cg_legacy_set_data(struct cgroup_ops *ops, const char *filename,
|
||||
return lxc_write_openat(h->path_lim, filename, value, strlen(value));
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the list of cgroup_settings sorted according to the following rules
|
||||
* 1. Put memory.limit_in_bytes before memory.memsw.limit_in_bytes
|
||||
*/
|
||||
static void sort_cgroup_settings(struct lxc_conf *conf)
|
||||
{
|
||||
LIST_HEAD(memsw_list);
|
||||
struct lxc_cgroup *cgroup, *ncgroup;
|
||||
|
||||
/* Iterate over the cgroup settings and copy them to the output list. */
|
||||
list_for_each_entry_safe(cgroup, ncgroup, &conf->cgroup, head) {
|
||||
if (!strequal(cgroup->subsystem, "memory.memsw.limit_in_bytes"))
|
||||
continue;
|
||||
|
||||
/* Move the memsw entry from the cgroup settings list. */
|
||||
list_move_tail(&cgroup->head, &memsw_list);
|
||||
}
|
||||
|
||||
/*
|
||||
* Append all the memsw entries to the end of the cgroup settings list
|
||||
* to make sure they are applied after all memory limit settings.
|
||||
*/
|
||||
list_splice_tail(&memsw_list, &conf->cgroup);
|
||||
|
||||
}
|
||||
|
||||
__cgfsng_ops static bool cgfsng_setup_limits_legacy(struct cgroup_ops *ops,
|
||||
struct lxc_conf *conf,
|
||||
bool do_devices)
|
||||
|
@ -5679,29 +5679,6 @@ void suggest_default_idmap(void)
|
||||
ERROR("lxc.idmap = g 0 %u %u", gid, grange);
|
||||
}
|
||||
|
||||
/* Return the list of cgroup_settings sorted according to the following rules
|
||||
* 1. Put memory.limit_in_bytes before memory.memsw.limit_in_bytes
|
||||
*/
|
||||
void sort_cgroup_settings(struct lxc_conf *conf)
|
||||
{
|
||||
struct lxc_cgroup *cgroup, *memsw_limit, *ncgroup;
|
||||
|
||||
/* Iterate over the cgroup settings and copy them to the output list. */
|
||||
list_for_each_entry_safe(cgroup, ncgroup, &conf->cgroup, head) {
|
||||
if (strequal(cgroup->subsystem, "memory.memsw.limit_in_bytes")) {
|
||||
/* Store the memsw_limit location */
|
||||
memsw_limit = cgroup;
|
||||
} else if (memsw_limit && strequal(cgroup->subsystem, "memory.limit_in_bytes")) {
|
||||
/*
|
||||
* lxc.cgroup.memory.memsw.limit_in_bytes is found
|
||||
* before lxc.cgroup.memory.limit_in_bytes, swap these
|
||||
* two items.
|
||||
*/
|
||||
list_swap(&memsw_limit->head, &cgroup->head);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int lxc_set_environment(const struct lxc_conf *conf)
|
||||
{
|
||||
struct environment_entry *env;
|
||||
|
@ -568,7 +568,6 @@ __hidden extern int parse_mount_attrs(struct lxc_mount_options *opts, const char
|
||||
__hidden extern void tmp_proc_unmount(struct lxc_conf *lxc_conf);
|
||||
__hidden extern void suggest_default_idmap(void);
|
||||
__hidden extern FILE *make_anonymous_mount_file(struct lxc_list *mount, bool include_nesting_helpers);
|
||||
__hidden extern void sort_cgroup_settings(struct lxc_conf *conf);
|
||||
__hidden extern int run_script(const char *name, const char *section, const char *script, ...);
|
||||
__hidden extern int run_script_argv(const char *name, unsigned int hook_version, const char *section,
|
||||
const char *script, const char *hookname, char **argsin);
|
||||
|
Loading…
Reference in New Issue
Block a user