[PATCH v2] cgroup: remove the superfluous judgment

Shida Zhang posted 1 patch 3 years, 11 months ago
kernel/cgroup/cgroup.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH v2] cgroup: remove the superfluous judgment
Posted by Shida Zhang 3 years, 11 months ago
Remove the superfluous judgment since the function is
never called for a root cgroup, as suggested by Tejun.

Suggested-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Shida Zhang <zhangshida@kylinos.cn>
---
 Changes from v1:
 - Just remove the superfluous judgment instead.

 kernel/cgroup/cgroup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index adb820e98f24..7d8a463c461b 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -5685,7 +5685,7 @@ static int cgroup_destroy_locked(struct cgroup *cgrp)
 	css_clear_dir(&cgrp->self);
 	kernfs_remove(cgrp->kn);
 
-	if (parent && cgroup_is_threaded(cgrp))
+	if (cgroup_is_threaded(cgrp))
 		parent->nr_threaded_children--;
 
 	spin_lock_irq(&css_set_lock);
-- 
2.25.1
Re: [PATCH v2] cgroup: remove the superfluous judgment
Posted by Tejun Heo 3 years, 11 months ago
On Wed, May 18, 2022 at 09:36:47AM +0800, Shida Zhang wrote:
> Remove the superfluous judgment since the function is
> never called for a root cgroup, as suggested by Tejun.
> 
> Suggested-by: Tejun Heo <tj@kernel.org>
> Signed-off-by: Shida Zhang <zhangshida@kylinos.cn>

Applied to cgroup/for-5.19.

Thanks.

-- 
tejun
Re: [PATCH v2] cgroup: remove the superfluous judgment
Posted by Michal Koutný 3 years, 11 months ago
On Wed, May 18, 2022 at 09:36:47AM +0800, Shida Zhang <starzhangzsd@gmail.com> wrote:
>  kernel/cgroup/cgroup.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Michal Koutný <mkoutny@suse.com>

(Note to self, css_clear_dir() on root cgroup is not needed thanks to
kernfs_destroy_root()->kernfs_remove().)