Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 116583
b: refs/heads/master
c: fed1939
h: refs/heads/master
i:
  116581: b335025
  116579: aabd184
  116575: ea8c225
v: v3
  • Loading branch information
Steven Rostedt authored and Ingo Molnar committed Oct 14, 2008
1 parent cc7072a commit cd5be15
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 28614889bcb2558a47d02d52394b7fd9795a9547
refs/heads/master: fed1939c64d2288938fdc1c367d49082da65e195
2 changes: 2 additions & 0 deletions trunk/include/linux/ftrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,12 @@ ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) { }
#ifdef CONFIG_FTRACE_MCOUNT_RECORD
extern void ftrace_init(void);
extern void ftrace_init_module(unsigned long *start, unsigned long *end);
extern void ftrace_release(void *start, unsigned long size);
#else
static inline void ftrace_init(void) { }
static inline void
ftrace_init_module(unsigned long *start, unsigned long *end) { }
static inline void ftrace_release(void *start, unsigned long size) { }
#endif

#endif /* _LINUX_FTRACE_H */
2 changes: 1 addition & 1 deletion trunk/include/linux/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

/* These are for everybody (although not all archs will actually
discard it in modules) */
#define __init __section(.init.text) __cold
#define __init __section(.init.text) __cold notrace
#define __initdata __section(.init.data)
#define __initconst __section(.init.rodata)
#define __exitdata __section(.exit.data)
Expand Down
12 changes: 8 additions & 4 deletions trunk/kernel/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -1431,6 +1431,9 @@ static void free_module(struct module *mod)
/* Module unload stuff */
module_unload_free(mod);

/* release any pointers to mcount in this module */
ftrace_release(mod->module_core, mod->core_size);

/* This may be NULL, but that's OK */
module_free(mod, mod->module_init);
kfree(mod->args);
Expand Down Expand Up @@ -1839,6 +1842,7 @@ static noinline struct module *load_module(void __user *umod,
struct module *mod;
long err = 0;
void *percpu = NULL, *ptr = NULL; /* Stops spurious gcc warning */
void *mseg;
struct exception_table_entry *extable;
mm_segment_t old_fs;

Expand Down Expand Up @@ -2190,10 +2194,9 @@ static noinline struct module *load_module(void __user *umod,
#endif
}

if (mcountindex) {
void *mseg = (void *)sechdrs[mcountindex].sh_addr;
ftrace_init_module(mseg, mseg + sechdrs[mcountindex].sh_size);
}
/* sechdrs[0].sh_size is always zero */
mseg = (void *)sechdrs[mcountindex].sh_addr;
ftrace_init_module(mseg, mseg + sechdrs[mcountindex].sh_size);

err = module_finalize(hdr, sechdrs, mod);
if (err < 0)
Expand Down Expand Up @@ -2264,6 +2267,7 @@ static noinline struct module *load_module(void __user *umod,
cleanup:
kobject_del(&mod->mkobj.kobj);
kobject_put(&mod->mkobj.kobj);
ftrace_release(mod->module_core, mod->core_size);
free_unload:
module_unload_free(mod);
module_free(mod, mod->module_init);
Expand Down
32 changes: 30 additions & 2 deletions trunk/kernel/trace/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,37 @@ static inline void ftrace_del_hash(struct dyn_ftrace *node)

static void ftrace_free_rec(struct dyn_ftrace *rec)
{
/* no locking, only called from kstop_machine */

rec->ip = (unsigned long)ftrace_free_records;
ftrace_free_records = rec;
rec->flags |= FTRACE_FL_FREE;
}

void ftrace_release(void *start, unsigned long size)
{
struct dyn_ftrace *rec;
struct ftrace_page *pg;
unsigned long s = (unsigned long)start;
unsigned long e = s + size;
int i;

if (!start)
return;

/* No interrupt should call this */
spin_lock(&ftrace_lock);

for (pg = ftrace_pages_start; pg; pg = pg->next) {
for (i = 0; i < pg->index; i++) {
rec = &pg->records[i];

if ((rec->ip >= s) && (rec->ip < e))
ftrace_free_rec(rec);
}
}
spin_unlock(&ftrace_lock);

}

static struct dyn_ftrace *ftrace_alloc_dyn_node(unsigned long ip)
{
struct dyn_ftrace *rec;
Expand Down Expand Up @@ -1527,7 +1551,9 @@ static int ftrace_convert_nops(unsigned long *start,
p = start;
while (p < end) {
addr = ftrace_call_adjust(*p++);
spin_lock(&ftrace_lock);
ftrace_record_ip(addr);
spin_unlock(&ftrace_lock);
ftrace_shutdown_replenish();
}

Expand All @@ -1541,6 +1567,8 @@ static int ftrace_convert_nops(unsigned long *start,

void ftrace_init_module(unsigned long *start, unsigned long *end)
{
if (start == end)
return;
ftrace_convert_nops(start, end);
}

Expand Down

0 comments on commit cd5be15

Please sign in to comment.