[Devel] [PATCH VZ8 v1 06/14] cgroup: exported put_css_set and get_css_set to cgroup.h
Kirill Tkhai
ktkhai at virtuozzo.com
Mon Jan 25 13:09:03 MSK 2021
On 20.01.2021 12:56, Valeriy Vdovin wrote:
> (Cherry-picked from 8222bbe47ed1e3824e0890a1404735324189c0cb)
> Signed-off-by: Valeriy.Vdovin <valeriy.vdovin at virtuozzo.com>
Reviewed-by: Kirill Tkhai <ktkhai at virtuozzo.com>
> ---
> include/linux/cgroup.h | 28 ++++++++++++++++++++++++++++
> kernel/cgroup/cgroup-internal.h | 27 ---------------------------
> kernel/cgroup/cgroup.c | 1 +
> 3 files changed, 29 insertions(+), 27 deletions(-)
>
> diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
> index 76e38ac63333..a1e6822bca8f 100644
> --- a/include/linux/cgroup.h
> +++ b/include/linux/cgroup.h
> @@ -512,6 +512,34 @@ task_get_css(struct task_struct *task, int subsys_id)
> return css;
> }
>
> +void put_css_set_locked(struct css_set *cset);
> +
> +static inline void put_css_set(struct css_set *cset)
> +{
> + unsigned long flags;
> +
> + /*
> + * Ensure that the refcount doesn't hit zero while any readers
> + * can see it. Similar to atomic_dec_and_lock(), but for an
> + * rwlock
> + */
> + if (refcount_dec_not_one(&cset->refcount))
> + return;
> +
> + spin_lock_irqsave(&css_set_lock, flags);
> + put_css_set_locked(cset);
> + spin_unlock_irqrestore(&css_set_lock, flags);
> +}
> +
> +/*
> + * refcounted get/put for css_set objects
> + */
> +static inline void get_css_set(struct css_set *cset)
> +{
> + refcount_inc(&cset->refcount);
> +}
> +
> +
> /**
> * task_css_is_root - test whether a task belongs to the root css
> * @task: the target task
> diff --git a/kernel/cgroup/cgroup-internal.h b/kernel/cgroup/cgroup-internal.h
> index ce1c1553c696..829997989c41 100644
> --- a/kernel/cgroup/cgroup-internal.h
> +++ b/kernel/cgroup/cgroup-internal.h
> @@ -159,33 +159,6 @@ static inline bool notify_on_release(const struct cgroup *cgrp)
> return test_bit(CGRP_NOTIFY_ON_RELEASE, &cgrp->flags);
> }
>
> -void put_css_set_locked(struct css_set *cset);
> -
> -static inline void put_css_set(struct css_set *cset)
> -{
> - unsigned long flags;
> -
> - /*
> - * Ensure that the refcount doesn't hit zero while any readers
> - * can see it. Similar to atomic_dec_and_lock(), but for an
> - * rwlock
> - */
> - if (refcount_dec_not_one(&cset->refcount))
> - return;
> -
> - spin_lock_irqsave(&css_set_lock, flags);
> - put_css_set_locked(cset);
> - spin_unlock_irqrestore(&css_set_lock, flags);
> -}
> -
> -/*
> - * refcounted get/put for css_set objects
> - */
> -static inline void get_css_set(struct css_set *cset)
> -{
> - refcount_inc(&cset->refcount);
> -}
> -
> bool cgroup_ssid_enabled(int ssid);
> bool cgroup_on_dfl(const struct cgroup *cgrp);
> bool cgroup_is_thread_root(struct cgroup *cgrp);
> diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
> index 447c8f003496..53a349539256 100644
> --- a/kernel/cgroup/cgroup.c
> +++ b/kernel/cgroup/cgroup.c
> @@ -58,6 +58,7 @@
> #include <linux/psi.h>
> #include <net/sock.h>
> #include <linux/ve.h>
> +#include <linux/cgroup.h>
>
> #include <linux/rh_features.h>
>
>
More information about the Devel
mailing list