sched_ext: Expose exit_cpu to BPF and userspace

Extend struct user_exit_info with an exit_cpu field so BPF schedulers
and the userspace report path can see the CPU that triggered the exit,
matching the kernel-side dump.

UEI_RECORD() defaults the field to -1 before the CO-RE-gated copy so
that running against an older kernel without exit_cpu stays
distinguishable from "exit happened on CPU 0".

UEI_REPORT() appends "on CPU N" to the EXIT line when the value is
valid, surfacing the most diagnostically useful piece of exit info to
any sched_ext userspace tool without needing to crack open the debug
dump.

Signed-off-by: Changwoo Min <changwoo@igalia.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
Changwoo Min 2026-04-29 17:23:18 +09:00 committed by Tejun Heo
parent 78683079ca
commit ee8391ba11
3 changed files with 10 additions and 0 deletions

View File

@ -32,6 +32,9 @@
__uei_name##_dump_len, (__ei)->dump); \
if (bpf_core_field_exists((__ei)->exit_code)) \
__uei_name.exit_code = (__ei)->exit_code; \
__uei_name.exit_cpu = -1; \
if (bpf_core_field_exists((__ei)->exit_cpu)) \
__uei_name.exit_cpu = (__ei)->exit_cpu; \
/* use __sync to force memory barrier */ \
__sync_val_compare_and_swap(&__uei_name.kind, __uei_name.kind, \
(__ei)->kind); \

View File

@ -39,6 +39,8 @@
fprintf(stderr, "EXIT: %s", __uei->reason); \
if (__uei->msg[0] != '\0') \
fprintf(stderr, " (%s)", __uei->msg); \
if (__uei->exit_cpu >= 0) \
fprintf(stderr, " on CPU %d", __uei->exit_cpu); \
fputs("\n", stderr); \
__uei->exit_code; \
})

View File

@ -22,6 +22,11 @@ enum uei_sizes {
struct user_exit_info {
int kind;
/*
* CPU that triggered the exit, or -1 if unset (e.g. running on an
* older kernel that does not expose this field).
*/
s32 exit_cpu;
s64 exit_code;
char reason[UEI_REASON_LEN];
char msg[UEI_MSG_LEN];