The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] sched/ext: Use flexible array for exit backtraces
@ 2026-05-12  1:08 Rosen Penev
  0 siblings, 0 replies; only message in thread
From: Rosen Penev @ 2026-05-12  1:08 UTC (permalink / raw)
  To: sched-ext
  Cc: Tejun Heo, David Vernet, Andrea Righi, Changwoo Min, Ingo Molnar,
	Peter Zijlstra, Juri Lelli, Vincent Guittot, Dietmar Eggemann,
	Steven Rostedt, Ben Segall, Mel Gorman, Valentin Schneider,
	K Prateek Nayak, open list:SCHEDULER

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 <rosenp@gmail.com>
---
 kernel/sched/ext.c          | 6 ++----
 kernel/sched/ext_internal.h | 8 ++++----
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 1d7f206941f0..f8d18406cfa6 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -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;
 	}
diff --git a/kernel/sched/ext_internal.h b/kernel/sched/ext_internal.h
index 0ed79bd891c7..9fde7f1eee01 100644
--- a/kernel/sched/ext_internal.h
+++ b/kernel/sched/ext_internal.h
@@ -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 */
-- 
2.54.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-05-12  1:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-12  1:08 [PATCH] sched/ext: Use flexible array for exit backtraces Rosen Penev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox