Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sched_ext: Add SCX_EFLAG_INITIALIZED to indicate successful ops.init()

ops.exit() may be called even if the loading failed before ops.init()
finishes successfully. This is because ops.exit() allows rich exit info
communication. Add SCX_EFLAG_INITIALIZED flag to scx_exit_info.flags to
indicate whether ops.init() finished successfully.

This enables BPF schedulers to distinguish between exit scenarios and
handle cleanup appropriately based on initialization state.

Acked-by: Andrea Righi <arighi@nvidia.com>
Signed-off-by: Tejun Heo <tj@kernel.org>

Tejun Heo f3aec2ad c7e73974

+14
+1
kernel/sched/ext.c
··· 4554 4554 scx_error(sch, "ops.init() failed (%d)", ret); 4555 4555 goto err_disable; 4556 4556 } 4557 + sch->exit_info->flags |= SCX_EFLAG_INITIALIZED; 4557 4558 } 4558 4559 4559 4560 for (i = SCX_OPI_CPU_HOTPLUG_BEGIN; i < SCX_OPI_CPU_HOTPLUG_END; i++)
+13
kernel/sched/ext_internal.h
··· 62 62 SCX_ECODE_ACT_RESTART = 1LLU << 48, 63 63 }; 64 64 65 + enum scx_exit_flags { 66 + /* 67 + * ops.exit() may be called even if the loading failed before ops.init() 68 + * finishes successfully. This is because ops.exit() allows rich exit 69 + * info communication. The following flag indicates whether ops.init() 70 + * finished successfully. 71 + */ 72 + SCX_EFLAG_INITIALIZED, 73 + }; 74 + 65 75 /* 66 76 * scx_exit_info is passed to ops.exit() to describe why the BPF scheduler is 67 77 * being disabled. ··· 82 72 83 73 /* exit code if gracefully exiting */ 84 74 s64 exit_code; 75 + 76 + /* %SCX_EFLAG_* */ 77 + u64 flags; 85 78 86 79 /* textual representation of the above */ 87 80 const char *reason;