[Devel] [VZ8 PATCH 1/3] ve/cgroup: unmark ve-root cgroups at container stop
Konstantin Khorenko
khorenko at virtuozzo.com
Thu Jan 28 11:52:33 MSK 2021
On 01/18/2021 09:08 PM, Valeriy Vdovin wrote:
> fixes: 915a1130c7ee4ffb6de3f69a5bd98c5ee42a723f
>
> Signed-off-by: Valeriy Vdovin <valeriy.vdovin at virtuozzo.com>
> Reviewed-by: Kirill Tkhai <ktkhai at virtuozzo.com>
>
> Cherry-picked from 5dceccf5dd794673ebb1b0e6840d96aa654ec33e)
> Signed-off-by: Valeriy Vdovin <valeriy.vdovin at virtuozzo.com>
Ack, i will drop one redundant copy-paste line during commit, see below.
> ---
> include/linux/cgroup.h | 1 +
> kernel/cgroup/cgroup.c | 24 ++++++++++++++++++++++++
> kernel/ve/ve.c | 3 +++
> 3 files changed, 28 insertions(+)
>
> diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
> index 4f0dd51338bf..c0a42c3d43fa 100644
> --- a/include/linux/cgroup.h
> +++ b/include/linux/cgroup.h
> @@ -867,6 +867,7 @@ int cgroup_path_ns(struct cgroup *cgrp, char *buf, size_t buflen,
>
> #ifdef CONFIG_VE
> extern void cgroup_mark_ve_root(struct ve_struct *ve);
> +void cgroup_unmark_ve_roots(struct ve_struct *ve);
> #endif
>
> #else /* !CONFIG_CGROUPS */
> diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
> index 0335a07f64e6..4488df184235 100644
> --- a/kernel/cgroup/cgroup.c
> +++ b/kernel/cgroup/cgroup.c
> @@ -1908,6 +1908,30 @@ void cgroup_mark_ve_root(struct ve_struct *ve)
> spin_unlock_irq(&css_set_lock);
> }
>
> +void cgroup_unmark_ve_roots(struct ve_struct *ve)
> +{
> + struct cgrp_cset_link *link;
> + struct css_set *cset;
> + struct cgroup *cgrp;
> +
> + spin_lock_irq(&css_set_lock);
> +
> + rcu_read_lock();
> + cset = rcu_dereference(ve->ve_ns)->cgroup_ns->root_cset;
> + if (WARN_ON(!cset))
> + goto unlock;
> +
> + list_for_each_entry(link, &cset->cgrp_links, cgrp_link) {
> + cgrp = link->cgrp;
> + clear_bit(CGRP_VE_ROOT, &cgrp->flags);
> + }
> + link_ve_root_cpu_cgroup(cset->subsys[cpu_cgrp_id]);
^^^ this line to be dropped.
> +unlock:
> + rcu_read_unlock();
> +
> + spin_unlock_irq(&css_set_lock);
> +}
> +
> struct cgroup *cgroup_get_ve_root1(struct cgroup *cgrp)
> {
> struct cgroup *ve_root = NULL;
> diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
> index 3f53641455ad..b922653acf49 100644
> --- a/kernel/ve/ve.c
> +++ b/kernel/ve/ve.c
> @@ -519,6 +519,9 @@ void ve_exit_ns(struct pid_namespace *pid_ns)
> */
> if (!ve_ns || ve_ns->pid_ns_for_children != pid_ns)
> goto unlock;
> +
> + cgroup_unmark_ve_roots(ve);
> +
> /*
> * At this point all userspace tasks in container are dead.
> */
>
More information about the Devel
mailing list