On 17.07.2025 04:06, Josh Poimboeuf wrote: > On Thu, Jul 10, 2025 at 06:35:18PM +0200, Jens Remus wrote: >> @@ -66,12 +73,20 @@ static int unwind_user_next(struct unwind_user_state >> *state) >> /* sframe expects the frame to be local storage */ >> frame = &_frame; >> if (sframe_find(state->ip, frame, topmost)) { >> - if (!IS_ENABLED(CONFIG_HAVE_UNWIND_USER_FP)) >> - goto done; >> - frame = &fp_frame; >> + if (IS_ENABLED(CONFIG_HAVE_UNWIND_USER_FP)) { >> + frame = &fp_frame; >> + } else if >> (IS_ENABLED(CONFIG_HAVE_UNWIND_USER_BACKCHAIN)) { >> + if (unwind_user_backchain_next(state)) >> + goto done; >> + goto done_backchain; >> + } >> } >> } else if (fp_state(state)) { >> frame = &fp_frame; >> + } else if (backchain_state(state)) { >> + if (unwind_user_backchain_next(state)) >> + goto done; >> + goto done_backchain; >> } else { >> goto done; >> } >> @@ -153,6 +168,7 @@ static int unwind_user_next(struct unwind_user_state >> *state) >> >> arch_unwind_user_next(state); >> >> +done_backchain: >> state->topmost = false; >> return 0; > > This feels very grafted on, is there not some way to make it more > generic, i.e., to just work with CONFIG_HAVE_UNWIND_USER_FP?
I agree. It could probably be made to compute the cfa_off and ra.offset or ra.regnum. Let me explore that, provided there would be any acceptance for unwind user backchain at all. Note that Power is using backchain as well, so they may want to build on that as well. > Also, if distros aren't even compiling with -mbackchain, I wonder if we > can just not do this altogether :-) My original intent was to use unwind user's for_each_user_frame() to replace the exiting stack tracing logic in arch_stack_walk_user_common() in arch/s390/kernel/stacktrace.c, which currently supports backchain. Given that for_each_user_frame() was made private in the latest unwind user series version hinders me. The use was also low, because the currentl arch_stack_walk_user_common() implementation does not support page faults, so that the attempt to use unwind user sframe would always fail and fallback to unwind user backchain. My hope was that somebody with more Kernel skills could give me a few hints at how it could be made to support deferred unwind. :-) Regards, Jens -- Jens Remus Linux on Z Development (D3303) +49-7031-16-1128 Office jre...@de.ibm.com IBM IBM Deutschland Research & Development GmbH; Vorsitzender des Aufsichtsrats: Wolfgang Wendt; Geschäftsführung: David Faller; Sitz der Gesellschaft: Böblingen; Registergericht: Amtsgericht Stuttgart, HRB 243294 IBM Data Privacy Statement: https://www.ibm.com/privacy/