Skip to content

Commit

Permalink
sched/ext: Use tg_cgroup() to elieminate duplicate code
Browse files Browse the repository at this point in the history
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>
(cherry picked from commit 161853a78bb2f304eb16f025ea08bd1bbe61516c)
  • Loading branch information
Zhang Qiao authored and htejun committed Sep 30, 2024
1 parent d90bdfb commit d9a53e1
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions kernel/sched/ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -7170,15 +7170,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;
Expand Down

0 comments on commit d9a53e1

Please sign in to comment.