[Devel] [PATCH VZ8 v1 14/14] cgroup: relaxed lockdep assertion for cset_cgroup_from_root

Kirill Tkhai ktkhai at virtuozzo.com
Fri Jan 29 18:07:21 MSK 2021


I don't understand this patch without explanation.

On 20.01.2021 12:56, Valeriy Vdovin wrote:
> Signed-off-by: Valeriy Vdovin <valeriy.vdovin at virtuozzo.com>
> ---
>  kernel/cgroup/cgroup-internal.h |  3 ++-
>  kernel/cgroup/cgroup-v1.c       |  3 ++-
>  kernel/cgroup/cgroup.c          | 15 +++++++++------
>  3 files changed, 13 insertions(+), 8 deletions(-)
> 
> diff --git a/kernel/cgroup/cgroup-internal.h b/kernel/cgroup/cgroup-internal.h
> index 112bd917e99d..e1ce16e77bb4 100644
> --- a/kernel/cgroup/cgroup-internal.h
> +++ b/kernel/cgroup/cgroup-internal.h
> @@ -161,7 +161,8 @@ static inline bool notify_on_release(const struct cgroup *cgrp)
>  }
>  
>  struct cgroup *cset_cgroup_from_root(struct css_set *cset,
> -					    struct cgroup_root *root);
> +					    struct cgroup_root *root,
> +					    bool assert_locks_strict);
>  
>  bool cgroup_ssid_enabled(int ssid);
>  bool cgroup_on_dfl(const struct cgroup *cgrp);
> diff --git a/kernel/cgroup/cgroup-v1.c b/kernel/cgroup/cgroup-v1.c
> index 46be2f688503..57d36cf69aea 100644
> --- a/kernel/cgroup/cgroup-v1.c
> +++ b/kernel/cgroup/cgroup-v1.c
> @@ -1022,7 +1022,8 @@ static int cgroup1_show_options(struct seq_file *seq, struct kernfs_root *kf_roo
>  				spin_lock_irq(&css_set_lock);
>  				cset = ve_ns->cgroup_ns->root_cset;
>  				BUG_ON(!cset);
> -				root_cgrp = cset_cgroup_from_root(cset, root);
> +				root_cgrp = cset_cgroup_from_root(cset, root,
> +					false);
>  				spin_unlock_irq(&css_set_lock);
>  			}
>  		}
> diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
> index 34e049361611..aac04a729535 100644
> --- a/kernel/cgroup/cgroup.c
> +++ b/kernel/cgroup/cgroup.c
> @@ -1437,11 +1437,13 @@ current_cgns_cgroup_from_root(struct cgroup_root *root)
>  
>  /* look up cgroup associated with given css_set on the specified hierarchy */
>  struct cgroup *cset_cgroup_from_root(struct css_set *cset,
> -					    struct cgroup_root *root)
> +					    struct cgroup_root *root,
> +					    bool assert_locks_strict)
>  {
>  	struct cgroup *res = NULL;
>  
> -	lockdep_assert_held(&cgroup_mutex);
> +	if (assert_locks_strict)
> +		lockdep_assert_held(&cgroup_mutex);
>  	lockdep_assert_held(&css_set_lock);
>  
>  	if (cset == &init_css_set) {
> @@ -1476,7 +1478,7 @@ struct cgroup *task_cgroup_from_root(struct task_struct *task,
>  	 * No need to lock the task - since we hold css_set_lock the
>  	 * task can't change groups.
>  	 */
> -	return cset_cgroup_from_root(task_css_set(task), root);
> +	return cset_cgroup_from_root(task_css_set(task), root, true);
>  }
>  
>  /*
> @@ -2284,7 +2286,7 @@ struct dentry *cgroup_do_mount(struct file_system_type *fs_type, int flags,
>  		mutex_lock(&cgroup_mutex);
>  		spin_lock_irq(&css_set_lock);
>  
> -		cgrp = cset_cgroup_from_root(ns->root_cset, root);
> +		cgrp = cset_cgroup_from_root(ns->root_cset, root, true);
>  
>  		spin_unlock_irq(&css_set_lock);
>  		mutex_unlock(&cgroup_mutex);
> @@ -2380,7 +2382,8 @@ static struct file_system_type cgroup2_fs_type = {
>  int cgroup_path_ns_locked(struct cgroup *cgrp, char *buf, size_t buflen,
>  			  struct cgroup_namespace *ns)
>  {
> -	struct cgroup *root = cset_cgroup_from_root(ns->root_cset, cgrp->root);
> +	struct cgroup *root = cset_cgroup_from_root(ns->root_cset, cgrp->root,
> +		true);
>  
>  	return kernfs_path_from_node(cgrp->kn, root->kn, buf, buflen);
>  }
> @@ -2749,7 +2752,7 @@ void cgroup_migrate_add_src(struct css_set *src_cset,
>  	if (src_cset->dead)
>  		return;
>  
> -	src_cgrp = cset_cgroup_from_root(src_cset, dst_cgrp->root);
> +	src_cgrp = cset_cgroup_from_root(src_cset, dst_cgrp->root, true);
>  
>  	if (!list_empty(&src_cset->mg_preload_node))
>  		return;
> 



More information about the Devel mailing list