[Devel] [PATCH] cgroups: fix set command with beancounters upstream

Kir Kolyshkin kir at openvz.org
Tue Apr 30 02:48:38 PDT 2013


On 04/29/2013 10:12 PM, Glauber Costa wrote:
> The kernel memory controller cannot flip states from unlimited to limited if
> there are already tasks in it.  Therefore, we always have to run with *some*
> value of kmem enabled. If we don't do it, we can't start unlimited and then use
> the set command to set any beancounters. We write the maximum amount minus two
> pages, which should effectively mean "accounting turned on, but unlimited"

Alternatively, we can require CT restart for the change to take effect.
We do that for a few options, see check_set_mode().

But this is probably OK too.

>
> Signed-off-by: Glauber Costa <glommer at openvz.org>
> ---
>   src/lib/cgroup.c | 13 +++++++++++++
>   1 file changed, 13 insertions(+)
>
> diff --git a/src/lib/cgroup.c b/src/lib/cgroup.c
> index 9185d46..ae7fe5c 100644
> --- a/src/lib/cgroup.c
> +++ b/src/lib/cgroup.c
> @@ -56,6 +56,19 @@ static int controller_apply_config(struct cgroup *ct, struct cgroup *parent,
>   	} else if (!strcmp("memory", name)) {
>   		if ((ret = cgroup_set_value_string(controller, "memory.use_hierarchy", "1")))
>   			return ret;
> +		/*
> +		 * The kernel memory controller cannot flip states from
> +		 * unlimited to limited if there are already tasks in it.
> +		 * Therefore, we always have to run with *some* value of kmem
> +		 * enabled. If we don't do it, we can't start unlimited and
> +		 * then use the set command to set any beancounters. We write
> +		 * The maximum amount minus two pages, which should effectively
> +		 * mean "accounting turned on, but unlimited". This will fail
> +		 * if the kmem controller is not present, but that is okay.
> +		 */
> +		cgroup_set_value_string(controller, "memory.kmem.limit_in_bytes",
> +					"9223372036854767712");
> +
>   	} else if (!strcmp("devices", name)) {
>   		if ((ret = cgroup_set_value_string(controller, "devices.deny", "a")))
>   			return ret;




More information about the Devel mailing list