Skip to content

Commit

Permalink
ftrace: Add a ftrace_free_mem() function for modules to use
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Steven Rostedt (VMware) committed Oct 4, 2017
1 parent 5819ead commit 6cafbe1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions include/linux/ftrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,10 @@ struct ftrace_ops_hash {
};

void ftrace_free_init_mem(void);
void ftrace_free_mem(void *start, void *end);
#else
static inline void ftrace_free_init_mem(void) { }
static inline void ftrace_free_mem(void *start, void *end) { }
#endif

/*
Expand Down
14 changes: 11 additions & 3 deletions kernel/trace/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -5868,10 +5868,10 @@ void ftrace_module_init(struct module *mod)
}
#endif /* CONFIG_MODULES */

void __init ftrace_free_init_mem(void)
void ftrace_free_mem(void *start_ptr, void *end_ptr)
{
unsigned long start = (unsigned long)(&__init_begin);
unsigned long end = (unsigned long)(&__init_end);
unsigned long start = (unsigned long)(start_ptr);
unsigned long end = (unsigned long)(end_ptr);
struct ftrace_page **last_pg = &ftrace_pages_start;
struct ftrace_page *pg;
struct dyn_ftrace *rec;
Expand Down Expand Up @@ -5913,6 +5913,14 @@ void __init ftrace_free_init_mem(void)
mutex_unlock(&ftrace_lock);
}

void __init ftrace_free_init_mem(void)
{
void *start = (void *)(&__init_begin);
void *end = (void *)(&__init_end);

ftrace_free_mem(start, end);
}

void __init ftrace_init(void)
{
extern unsigned long __start_mcount_loc[];
Expand Down

0 comments on commit 6cafbe1

Please sign in to comment.