diff mbox series

[03/10] x86/unwind: Compile kretprobe fixup code only if CONFIG_KRETPROBES=y

Message ID 163430227030.459050.12754362425825951410.stgit@devnote2 (mailing list archive)
State New, archived
Headers show
Series kprobes: Make KUnit and add stacktrace on kretprobe tests | expand

Commit Message

Masami Hiramatsu (Google) Oct. 15, 2021, 12:51 p.m. UTC
Compile kretprobe related stacktrace entry recovery code and
unwind_state::kr_cur field only when CONFIG_KRETPROBES=y.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 arch/x86/include/asm/unwind.h |    6 ++++++
 1 file changed, 6 insertions(+)

Comments

Masami Hiramatsu (Google) Oct. 15, 2021, 1:10 p.m. UTC | #1
On Fri, 15 Oct 2021 21:51:10 +0900
Masami Hiramatsu <mhiramat@kernel.org> wrote:

> Compile kretprobe related stacktrace entry recovery code and
> unwind_state::kr_cur field only when CONFIG_KRETPROBES=y.

Oh, this is another new patch, and is a kind of cleanup.
No functionality change, but a bit reducing memory usage
when CONFIG_KRETPROBES=n.

Thank you,

> 
> Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
> ---
>  arch/x86/include/asm/unwind.h |    6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/arch/x86/include/asm/unwind.h b/arch/x86/include/asm/unwind.h
> index fca2e783e3ce..2a1f8734416d 100644
> --- a/arch/x86/include/asm/unwind.h
> +++ b/arch/x86/include/asm/unwind.h
> @@ -16,7 +16,9 @@ struct unwind_state {
>  	unsigned long stack_mask;
>  	struct task_struct *task;
>  	int graph_idx;
> +#ifdef CONFIG_KRETPROBES
>  	struct llist_node *kr_cur;
> +#endif
>  	bool error;
>  #if defined(CONFIG_UNWINDER_ORC)
>  	bool signal, full_regs;
> @@ -105,9 +107,13 @@ static inline
>  unsigned long unwind_recover_kretprobe(struct unwind_state *state,
>  				       unsigned long addr, unsigned long *addr_p)
>  {
> +#ifdef CONFIG_KRETPROBES
>  	return is_kretprobe_trampoline(addr) ?
>  		kretprobe_find_ret_addr(state->task, addr_p, &state->kr_cur) :
>  		addr;
> +#else
> +	return addr;
> +#endif
>  }
>  
>  /* Recover the return address modified by kretprobe and ftrace_graph. */
>
diff mbox series

Patch

diff --git a/arch/x86/include/asm/unwind.h b/arch/x86/include/asm/unwind.h
index fca2e783e3ce..2a1f8734416d 100644
--- a/arch/x86/include/asm/unwind.h
+++ b/arch/x86/include/asm/unwind.h
@@ -16,7 +16,9 @@  struct unwind_state {
 	unsigned long stack_mask;
 	struct task_struct *task;
 	int graph_idx;
+#ifdef CONFIG_KRETPROBES
 	struct llist_node *kr_cur;
+#endif
 	bool error;
 #if defined(CONFIG_UNWINDER_ORC)
 	bool signal, full_regs;
@@ -105,9 +107,13 @@  static inline
 unsigned long unwind_recover_kretprobe(struct unwind_state *state,
 				       unsigned long addr, unsigned long *addr_p)
 {
+#ifdef CONFIG_KRETPROBES
 	return is_kretprobe_trampoline(addr) ?
 		kretprobe_find_ret_addr(state->task, addr_p, &state->kr_cur) :
 		addr;
+#else
+	return addr;
+#endif
 }
 
 /* Recover the return address modified by kretprobe and ftrace_graph. */