History

ftrace: Add symbols for ftrace trampolines

Symbols are needed for tools to describe instruction addresses. Pages allocated for ftrace's purposes need symbols to be created for them. Add such symbols to be visible via /proc/kallsyms. Example on x86 with CONFIG_DYNAMIC_FTRACE=y # echo function > /sys/kernel/debug/tracing/current_tracer # cat /proc/kallsyms | grep '\[__builtin__ftrace\]' ffffffffc0238000 t ftrace_trampoline [__builtin__ftrace] Note: This patch adds "__builtin__ftrace" as a module name in /proc/kallsyms for symbols for pages allocated for ftrace's purposes, even though "__builtin__ftrace" is not a module.

Adrian Hunter committed 6 years ago

Commit fc0ea791 parent 3e46bb43 files · +88 −6Browse files

Showing the changes to include/linux (1 of 3 files). Show all

Unified · Split

include/linux/ftrace.h+8−4
@@ -58,9 +58,6 @@ struct ftrace_direct_func; · 57 unmodified lines
58const char *58const char *
59ftrace_mod_address_lookup(unsigned long addr, unsigned long *size,59ftrace_mod_address_lookup(unsigned long addr, unsigned long *size,
60 unsigned long *off, char **modname, char *sym);60 unsigned long *off, char **modname, char *sym);
61int ftrace_mod_get_kallsym(unsigned int symnum, unsigned long *value,
62 char *type, char *name,
63 char *module_name, int *exported);
64#else61#else
65static inline const char *62static inline const char *
66ftrace_mod_address_lookup(unsigned long addr, unsigned long *size,63ftrace_mod_address_lookup(unsigned long addr, unsigned long *size,
@@ -68,6 +65,13 @@ ftrace_mod_address_lookup(unsigned long addr, unsigned long *size, · 1 unmodified line
68{65{
69 return NULL;66 return NULL;
70}67}
68#endif
69
70#if defined(CONFIG_FUNCTION_TRACER) && defined(CONFIG_DYNAMIC_FTRACE)
71int ftrace_mod_get_kallsym(unsigned int symnum, unsigned long *value,
72 char *type, char *name,
73 char *module_name, int *exported);
74#else
71static inline int ftrace_mod_get_kallsym(unsigned int symnum, unsigned long *value,75static inline int ftrace_mod_get_kallsym(unsigned int symnum, unsigned long *value,
72 char *type, char *name,76 char *type, char *name,
73 char *module_name, int *exported)77 char *module_name, int *exported)
@@ -76,7 +80,6 @@ static inline int ftrace_mod_get_kallsym(unsigned int symnum, unsigned long *val · 2 unmodified lines
76}80}
77#endif81#endif
78 82
79
80#ifdef CONFIG_FUNCTION_TRACER83#ifdef CONFIG_FUNCTION_TRACER
81 84
82extern int ftrace_enabled;85extern int ftrace_enabled;
@@ -207,6 +210,7 @@ struct ftrace_ops { · 124 unmodified lines
207 struct ftrace_ops_hash old_hash;210 struct ftrace_ops_hash old_hash;
208 unsigned long trampoline;211 unsigned long trampoline;
209 unsigned long trampoline_size;212 unsigned long trampoline_size;
213 struct list_head list;
210#endif214#endif
211};215};
212 216