]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
sched/ext: Use tg_cgroup() to elieminate duplicate code
authorZhang Qiao <zhangqiao22@huawei.com>
Thu, 26 Sep 2024 02:15:05 +0000 (10:15 +0800)
committerTejun Heo <tj@kernel.org>
Fri, 27 Sep 2024 21:06:28 +0000 (11:06 -1000)
Use tg_cgroup() to eliminate duplicate code patterns
in scx_bpf_task_cgroup().

Signed-off-by: Zhang Qiao <zhangqiao22@huawei.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/sched/ext.c

index 0e8eac19daa40ee2f7ec42d304587e42efcd4bf4..fe8acae35166b401d11dfd5907fad68305f2ebe1 100644 (file)
@@ -7130,15 +7130,8 @@ __bpf_kfunc struct cgroup *scx_bpf_task_cgroup(struct task_struct *p)
        if (!scx_kf_allowed_on_arg_tasks(__SCX_KF_RQ_LOCKED, p))
                goto out;
 
-       /*
-        * A task_group may either be a cgroup or an autogroup. In the latter
-        * case, @tg->css.cgroup is %NULL. A task_group can't become the other
-        * kind once created.
-        */
-       if (tg && tg->css.cgroup)
-               cgrp = tg->css.cgroup;
-       else
-               cgrp = &cgrp_dfl_root.cgrp;
+       cgrp = tg_cgrp(tg);
+
 out:
        cgroup_get(cgrp);
        return cgrp;