[ Sasha's backport helper bot ]
Hi,
The upstream commit SHA1 provided is correct: d23b5c577715892c87533b13923306acc6243f93
WARNING: Author mismatch between patch and upstream commit: Backport author: Siddh Raman Pant siddh.raman.pant@oracle.com Commit author: Yafang Shao laoar.shao@gmail.com
Status in newer kernel trees: 6.12.y | Present (exact SHA1) 6.11.y | Present (exact SHA1) 6.6.y | Present (different SHA1: dd9542ae7c7c) 6.1.y | Present (different SHA1: f5b7a9792041) 5.15.y | Present (different SHA1: de77545c72c4) 5.10.y | Present (different SHA1: 45a81667e0e8) 5.4.y | Not found
Note: The patch differs from the upstream commit: --- 1: d23b5c5777158 ! 1: ab0b59573d9f9 cgroup: Make operations on the cgroup root_list RCU safe @@ Metadata ## Commit message ## cgroup: Make operations on the cgroup root_list RCU safe
+ commit d23b5c577715892c87533b13923306acc6243f93 upstream. + At present, when we perform operations on the cgroup root_list, we must hold the cgroup_mutex, which is a relatively heavyweight lock. In reality, we can make operations on this list RCU-safe, eliminating the need to hold @@ Commit message
Signed-off-by: Yafang Shao laoar.shao@gmail.com Signed-off-by: Tejun Heo tj@kernel.org + [fp: adapt to 5.10 mainly because of changes made by e210a89f5b07 + ("cgroup.c: add helper __cset_cgroup_from_root to cleanup duplicated + codes")] + Signed-off-by: Fedor Pchelkin pchelkin@ispras.ru + [Shivani: Modified to apply on v5.4.y] + Signed-off-by: Shivani Agarwal shivani.agarwal@broadcom.com + Reviewed-by: Siddh Raman Pant siddh.raman.pant@oracle.com + Signed-off-by: Siddh Raman Pant siddh.raman.pant@oracle.com
## include/linux/cgroup-defs.h ## @@ include/linux/cgroup-defs.h: struct cgroup_root { @@ kernel/cgroup/cgroup-internal.h: extern struct list_head cgroup_roots; * for_each_subsys - iterate all enabled cgroup subsystems
## kernel/cgroup/cgroup.c ## -@@ kernel/cgroup/cgroup.c: static void cgroup_exit_root_id(struct cgroup_root *root) - - void cgroup_free_root(struct cgroup_root *root) +@@ kernel/cgroup/cgroup.c: void cgroup_free_root(struct cgroup_root *root) { -- kfree(root); -+ kfree_rcu(root, rcu); + if (root) { + idr_destroy(&root->cgroup_idr); +- kfree(root); ++ kfree_rcu(root, rcu); + } }
- static void cgroup_destroy_root(struct cgroup_root *root) @@ kernel/cgroup/cgroup.c: static void cgroup_destroy_root(struct cgroup_root *root) spin_unlock_irq(&css_set_lock);
- WARN_ON_ONCE(list_empty(&root->root_list)); -- list_del(&root->root_list); -+ list_del_rcu(&root->root_list); - cgroup_root_count--; + if (!list_empty(&root->root_list)) { +- list_del(&root->root_list); ++ list_del_rcu(&root->root_list); + cgroup_root_count--; + }
- if (!have_favordynmods) -@@ kernel/cgroup/cgroup.c: static inline struct cgroup *__cset_cgroup_from_root(struct css_set *cset, +@@ kernel/cgroup/cgroup.c: static struct cgroup *cset_cgroup_from_root(struct css_set *cset, + { + struct cgroup *res = NULL; + +- lockdep_assert_held(&cgroup_mutex); + lockdep_assert_held(&css_set_lock); + + if (cset == &init_css_set) { +@@ kernel/cgroup/cgroup.c: static struct cgroup *cset_cgroup_from_root(struct css_set *cset, } }
-- BUG_ON(!res_cgroup); +- BUG_ON(!res); + /* + * If cgroup_mutex is not held, the cgrp_cset_link will be freed + * before we remove the cgroup root from the root_list. Consequently, @@ kernel/cgroup/cgroup.c: static inline struct cgroup *__cset_cgroup_from_root(str + * If we don't hold cgroup_mutex in the caller, we must do the NULL + * check. + */ - return res_cgroup; + return res; }
-@@ kernel/cgroup/cgroup.c: static struct cgroup *current_cgns_cgroup_dfl(void) - static struct cgroup *cset_cgroup_from_root(struct css_set *cset, - struct cgroup_root *root) - { -- lockdep_assert_held(&cgroup_mutex); - lockdep_assert_held(&css_set_lock); - - return __cset_cgroup_from_root(cset, root); -@@ kernel/cgroup/cgroup.c: static struct cgroup *cset_cgroup_from_root(struct css_set *cset, - /* * Return the cgroup for "task" from the given hierarchy. Must be - * called with cgroup_mutex and css_set_lock held. ---
Results of testing on various branches:
| Branch | Patch Apply | Build Test | |---------------------------|-------------|------------| | stable/linux-5.4.y | Success | Success |