]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
sched_ext: Replace naked scx_root dereferences in kobject callbacks
authorzhidao su <suzhidao@xiaomi.com>
Mon, 2 Mar 2026 09:14:40 +0000 (17:14 +0800)
committerTejun Heo <tj@kernel.org>
Mon, 2 Mar 2026 17:23:09 +0000 (07:23 -1000)
commit494eaf4651975127d34d5ae6555c72dedba092c9
tree88b0d0dee62b74c90b3238651c89fc1efc83d804
parent9adfcef334bf9c6ef68eaecfca5f45d18614efe0
sched_ext: Replace naked scx_root dereferences in kobject callbacks

scx_attr_ops_show() and scx_uevent() access scx_root->ops.name directly.
This is problematic for two reasons:

1. The file-level comment explicitly identifies naked scx_root
   dereferences as a temporary measure that needs to be replaced
   with proper per-instance access.

2. scx_attr_events_show(), the neighboring sysfs show function in
   the same group, already uses the correct pattern:

       struct scx_sched *sch = container_of(kobj, struct scx_sched, kobj);

   Having inconsistent access patterns in the same sysfs/uevent
   group is error-prone.

The kobject embedded in struct scx_sched is initialized as:

    kobject_init_and_add(&sch->kobj, &scx_ktype, NULL, "root");

so container_of(kobj, struct scx_sched, kobj) correctly retrieves
the owning scx_sched instance in both callbacks.

Replace the naked scx_root dereferences with container_of()-based
access, consistent with scx_attr_events_show() and in preparation
for proper multi-instance scx_sched support.

Signed-off-by: zhidao su <suzhidao@xiaomi.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/sched/ext.c