Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

unwind_user/fp: Use dummies instead of ifdef

This simplifies the code. unwind_user_next_fp() does not need to
return -EINVAL if config option HAVE_UNWIND_USER_FP is disabled, as
unwind_user_start() will then not select this unwind method and
unwind_user_next() will therefore not call it.

Provide (1) a dummy definition of ARCH_INIT_USER_FP_FRAME, if the unwind
user method HAVE_UNWIND_USER_FP is not enabled, (2) a common fallback
definition of unwind_user_at_function_start() which returns false, and
(3) a common dummy definition of ARCH_INIT_USER_FP_ENTRY_FRAME.

Note that enabling the config option HAVE_UNWIND_USER_FP without
defining ARCH_INIT_USER_FP_FRAME triggers a compile error, which is
helpful when implementing support for this unwind user method in an
architecture. Enabling the config option when providing an arch-
specific unwind_user_at_function_start() definition makes it necessary
to also provide an arch-specific ARCH_INIT_USER_FP_ENTRY_FRAME
definition.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20251208160352.1363040-3-jremus@linux.ibm.com

authored by

Jens Remus and committed by
Peter Zijlstra
2652f9a4 2d6ad925

+17 -6
+1
arch/x86/include/asm/unwind_user.h
··· 35 35 { 36 36 return is_uprobe_at_func_entry(regs); 37 37 } 38 + #define unwind_user_at_function_start unwind_user_at_function_start 38 39 39 40 #endif /* CONFIG_HAVE_UNWIND_USER_FP */ 40 41
+16 -2
include/linux/unwind_user.h
··· 5 5 #include <linux/unwind_user_types.h> 6 6 #include <asm/unwind_user.h> 7 7 8 - #ifndef ARCH_INIT_USER_FP_FRAME 9 - #define ARCH_INIT_USER_FP_FRAME 8 + #ifndef CONFIG_HAVE_UNWIND_USER_FP 9 + 10 + #define ARCH_INIT_USER_FP_FRAME(ws) 11 + 12 + #endif 13 + 14 + #ifndef ARCH_INIT_USER_FP_ENTRY_FRAME 15 + #define ARCH_INIT_USER_FP_ENTRY_FRAME(ws) 16 + #endif 17 + 18 + #ifndef unwind_user_at_function_start 19 + static inline bool unwind_user_at_function_start(struct pt_regs *regs) 20 + { 21 + return false; 22 + } 23 + #define unwind_user_at_function_start unwind_user_at_function_start 10 24 #endif 11 25 12 26 int unwind_user(struct unwind_stacktrace *trace, unsigned int max_entries);
-4
kernel/unwind/user.c
··· 67 67 68 68 static int unwind_user_next_fp(struct unwind_user_state *state) 69 69 { 70 - #ifdef CONFIG_HAVE_UNWIND_USER_FP 71 70 struct pt_regs *regs = task_pt_regs(current); 72 71 73 72 if (state->topmost && unwind_user_at_function_start(regs)) { ··· 80 81 ARCH_INIT_USER_FP_FRAME(state->ws) 81 82 }; 82 83 return unwind_user_next_common(state, &fp_frame); 83 - #else 84 - return -EINVAL; 85 - #endif 86 84 } 87 85 88 86 static int unwind_user_next(struct unwind_user_state *state)