[PATCH cgroup/for-next 2/3] cgroup: add css_free helper

Chen Ridong posted 3 patches 1 month, 1 week ago
[PATCH cgroup/for-next 2/3] cgroup: add css_free helper
Posted by Chen Ridong 1 month, 1 week ago
From: Chen Ridong <chenridong@huawei.com>

The cgroup_destroy_wq has been split into three separate workqueues:
cgroup_offline_wq, cgroup_release_wq, and cgroup_free_wq. The cgroup
destroy work is now enqueued sequentially into these queues. To clarify
the three distinct stages of the destruction process, it will introduce
helper functions or rename existing ones accordingly. The resulting
structure is as follows:

work		workqueue		work_fn
css_offline	cgroup_offline_wq	css_offline_work_fn
css_release	cgroup_release_wq	css_release_work_fn
css_free	cgroup_free_wq		css_free_rwork_fn

This patch is to add css_free helper.

Signed-off-by: Chen Ridong <chenridong@huawei.com>
---
 kernel/cgroup/cgroup.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 5eb747a038f7..ad1f6a59a27b 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -5517,6 +5517,12 @@ static void css_free_rwork_fn(struct work_struct *work)
 	}
 }
 
+static void css_free(struct cgroup_subsys_state *css)
+{
+	INIT_RCU_WORK(&css->destroy_rwork, css_free_rwork_fn);
+	queue_rcu_work(cgroup_free_wq, &css->destroy_rwork);
+}
+
 static void css_release_work_fn(struct work_struct *work)
 {
 	struct cgroup_subsys_state *css =
@@ -5580,8 +5586,7 @@ static void css_release_work_fn(struct work_struct *work)
 
 	cgroup_unlock();
 
-	INIT_RCU_WORK(&css->destroy_rwork, css_free_rwork_fn);
-	queue_rcu_work(cgroup_free_wq, &css->destroy_rwork);
+	css_free(css);
 }
 
 static void css_release(struct percpu_ref *ref)
@@ -5718,8 +5723,7 @@ static struct cgroup_subsys_state *css_create(struct cgroup *cgrp,
 err_list_del:
 	list_del_rcu(&css->sibling);
 err_free_css:
-	INIT_RCU_WORK(&css->destroy_rwork, css_free_rwork_fn);
-	queue_rcu_work(cgroup_free_wq, &css->destroy_rwork);
+	css_free(css);
 	return ERR_PTR(err);
 }
 
-- 
2.34.1