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
5858 const char *
5959 ftrace_mod_address_lookup(unsigned long addr, unsigned long *size,
6060 unsigned long *off, char **modname, char *sym);
61−int ftrace_mod_get_kallsym(unsigned int symnum, unsigned long *value,
62− char *type, char *name,
63− char *module_name, int *exported);
6461 #else
6562 static inline const char *
6663 ftrace_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
6865 {
6966 return NULL;
7067 }
68+#endif
69+
70+#if defined(CONFIG_FUNCTION_TRACER) && defined(CONFIG_DYNAMIC_FTRACE)
71+int ftrace_mod_get_kallsym(unsigned int symnum, unsigned long *value,
72+ char *type, char *name,
73+ char *module_name, int *exported);
74+#else
7175 static inline int ftrace_mod_get_kallsym(unsigned int symnum, unsigned long *value,
7276 char *type, char *name,
7377 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
7680 }
7781 #endif
7882
79−
8083 #ifdef CONFIG_FUNCTION_TRACER
8184
8285 extern int ftrace_enabled;
@@ -207,6 +210,7 @@ struct ftrace_ops { · 124 unmodified lines
207210 struct ftrace_ops_hash old_hash;
208211 unsigned long trampoline;
209212 unsigned long trampoline_size;
213+ struct list_head list;
210214 #endif
211215 };
212216