Skip to content

Commit 6cafbe1

Browse files
committed
ftrace: Add a ftrace_free_mem() function for modules to use
In order to be able to trace module init functions, the module code needs to tell ftrace what is being freed when the init sections are freed. Use the code that the main init calls to tell ftrace to free the main init sections. This requires passing in a start and end address to free. Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
1 parent 5819ead commit 6cafbe1

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

include/linux/ftrace.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,10 @@ struct ftrace_ops_hash {
151151
};
152152

153153
void ftrace_free_init_mem(void);
154+
void ftrace_free_mem(void *start, void *end);
154155
#else
155156
static inline void ftrace_free_init_mem(void) { }
157+
static inline void ftrace_free_mem(void *start, void *end) { }
156158
#endif
157159

158160
/*

kernel/trace/ftrace.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5868,10 +5868,10 @@ void ftrace_module_init(struct module *mod)
58685868
}
58695869
#endif /* CONFIG_MODULES */
58705870

5871-
void __init ftrace_free_init_mem(void)
5871+
void ftrace_free_mem(void *start_ptr, void *end_ptr)
58725872
{
5873-
unsigned long start = (unsigned long)(&__init_begin);
5874-
unsigned long end = (unsigned long)(&__init_end);
5873+
unsigned long start = (unsigned long)(start_ptr);
5874+
unsigned long end = (unsigned long)(end_ptr);
58755875
struct ftrace_page **last_pg = &ftrace_pages_start;
58765876
struct ftrace_page *pg;
58775877
struct dyn_ftrace *rec;
@@ -5913,6 +5913,14 @@ void __init ftrace_free_init_mem(void)
59135913
mutex_unlock(&ftrace_lock);
59145914
}
59155915

5916+
void __init ftrace_free_init_mem(void)
5917+
{
5918+
void *start = (void *)(&__init_begin);
5919+
void *end = (void *)(&__init_end);
5920+
5921+
ftrace_free_mem(start, end);
5922+
}
5923+
59165924
void __init ftrace_init(void)
59175925
{
59185926
extern unsigned long __start_mcount_loc[];

0 commit comments

Comments
 (0)