sched/ext: Use flexible array for exit backtraces
Subsystems (2)
PATCH 1/1 sched/ext: Use flexible array for exit backtraces
Store the fixed-size exit backtrace buffer in the sched_ext exit info allocation instead of allocating it separately.
This ties the backtrace buffer lifetime directly to the exit info object and removes a separate allocation failure path.
Assisted-by Codex:GPT-5.5
Signed-off-by Rosen Penev <[email protected]>
--- kernel/sched/ext.c | 6 ++---- kernel/sched/ext_internal.h | 8 ++++---- 2 files changed, 6 insertions(+), 8 deletions(-)
kernel/sched/ext.c +2 -4
@@ -5628,7 +5628,6 @@ static void free_exit_info(struct scx_exit_info *ei) {kvfree (ei->dump);kfree (ei->msg); -kfree (ei->bt);kfree (ei); }
@@ -5636,16 +5635,15 @@ static struct scx_exit_info *alloc_exit_info(size_t exit_dump_len) {struct scx_exit_info *ei; - ei =kzalloc_obj (*ei); + ei =kzalloc_flex (*ei, bt,SCX_EXIT_BT_LEN );if (!ei)return NULL ; ei->exit_cpu =-1 ; - ei->bt =kzalloc_objs (ei->bt[0 ],SCX_EXIT_BT_LEN ); ei->msg =kzalloc (SCX_EXIT_MSG_LEN ,GFP_KERNEL ); ei->dump =kvzalloc (exit_dump_len,GFP_KERNEL ); -if (!ei->bt || !ei->msg || !ei->dump) { +if (!ei->msg || !ei->dump) {free_exit_info (ei);return NULL ; }
kernel/sched/ext_internal.h +4 -4
@@ -80,15 +80,15 @@ struct scx_exit_info {/* textual representation of the above */ const char *reason; -/* backtrace if exiting due to an error */ -unsigned long *bt; -u32 bt_len; -/* informational message */ char *msg;/* debug dump */ char *dump; + +/* backtrace if exiting due to an error */ +u32 bt_len; +unsigned long bt[]; };/* sched_ext_ops.flags */
Signature · 1 line
2.54.0