From 740e382f12bc1425a304bc8ff1af53bb84a28710 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Thu, 25 Jan 2024 08:49:16 -1000 Subject: [PATCH] user_exit_info: Print out debug dump if available Signed-off-by: Tejun Heo --- scheds/include/scx/user_exit_info.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scheds/include/scx/user_exit_info.h b/scheds/include/scx/user_exit_info.h index f0e45bf3c..e65e28120 100644 --- a/scheds/include/scx/user_exit_info.h +++ b/scheds/include/scx/user_exit_info.h @@ -14,6 +14,7 @@ struct user_exit_info { int kind; char reason[128]; char msg[1024]; + char dump[32768]; }; #ifdef __bpf__ @@ -26,6 +27,7 @@ static inline void uei_record(struct user_exit_info *uei, { bpf_probe_read_kernel_str(uei->reason, sizeof(uei->reason), ei->reason); bpf_probe_read_kernel_str(uei->msg, sizeof(uei->msg), ei->msg); + bpf_probe_read_kernel_str(uei->dump, sizeof(uei->dump), ei->dump); /* use __sync to force memory barrier */ __sync_val_compare_and_swap(&uei->kind, uei->kind, ei->kind); } @@ -40,6 +42,12 @@ static inline bool uei_exited(struct user_exit_info *uei) static inline void uei_print(const struct user_exit_info *uei) { + if (uei->dump[0] != '\0') { + fputs("\nDEBUG DUMP\n", stderr); + fputs("================================================================================\n\n", stderr); + fputs(uei->dump, stderr); + fputs("\n================================================================================\n\n", stderr); + } fprintf(stderr, "EXIT: %s", uei->reason); if (uei->msg[0] != '\0') fprintf(stderr, " (%s)", uei->msg);