Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 116575
b: refs/heads/master
c: 68bf21a
h: refs/heads/master
i:
  116573: c42eca6
  116571: ae6e9bc
  116567: 6389787
  116559: 255161b
  116543: d8d9784
v: v3
  • Loading branch information
Steven Rostedt authored and Ingo Molnar committed Oct 14, 2008
1 parent af11fde commit ea8c225
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 44 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: 8da3821ba5634497da63d58a69e24a97697c4a2b
refs/heads/master: 68bf21aa15c85d2e9b623dcda2b1ed8893275fa1
10 changes: 10 additions & 0 deletions trunk/include/asm-x86/ftrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@

#ifndef __ASSEMBLY__
extern void mcount(void);

static inline unsigned long ftrace_call_adjust(unsigned long addr)
{
/*
* call mcount is "e8 <4 byte offset>"
* The addr points to the 4 byte offset and the caller of this
* function wants the pointer to e8. Simply subtract one.
*/
return addr - 1;
}
#endif

#endif /* CONFIG_FTRACE */
Expand Down
6 changes: 6 additions & 0 deletions trunk/include/linux/ftrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,10 @@ static inline void
ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) { }
#endif

#ifdef CONFIG_FTRACE_MCOUNT_RECORD
extern void ftrace_init(void);
#else
static inline void ftrace_init(void) { }
#endif

#endif /* _LINUX_FTRACE_H */
3 changes: 3 additions & 0 deletions trunk/init/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
#include <linux/sched.h>
#include <linux/signal.h>
#include <linux/idr.h>
#include <linux/ftrace.h>

#include <asm/io.h>
#include <asm/bugs.h>
Expand Down Expand Up @@ -687,6 +688,8 @@ asmlinkage void __init start_kernel(void)

acpi_early_init(); /* before LAPIC and SMP init */

ftrace_init();

/* Do the rest non-__init'ed, we're now alive */
rest_init();
}
Expand Down
148 changes: 105 additions & 43 deletions trunk/kernel/trace/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -792,47 +792,7 @@ static int ftrace_update_code(void)
return 1;
}

static int ftraced(void *ignore)
{
unsigned long usecs;

while (!kthread_should_stop()) {

set_current_state(TASK_INTERRUPTIBLE);

/* check once a second */
schedule_timeout(HZ);

if (unlikely(ftrace_disabled))
continue;

mutex_lock(&ftrace_sysctl_lock);
mutex_lock(&ftraced_lock);
if (!ftraced_suspend && !ftraced_stop &&
ftrace_update_code()) {
usecs = nsecs_to_usecs(ftrace_update_time);
if (ftrace_update_tot_cnt > 100000) {
ftrace_update_tot_cnt = 0;
pr_info("hm, dftrace overflow: %lu change%s"
" (%lu total) in %lu usec%s\n",
ftrace_update_cnt,
ftrace_update_cnt != 1 ? "s" : "",
ftrace_update_tot_cnt,
usecs, usecs != 1 ? "s" : "");
ftrace_disabled = 1;
WARN_ON_ONCE(1);
}
}
mutex_unlock(&ftraced_lock);
mutex_unlock(&ftrace_sysctl_lock);

ftrace_shutdown_replenish();
}
__set_current_state(TASK_RUNNING);
return 0;
}

static int __init ftrace_dyn_table_alloc(void)
static int __init ftrace_dyn_table_alloc(unsigned long num_to_init)
{
struct ftrace_page *pg;
int cnt;
Expand All @@ -859,7 +819,9 @@ static int __init ftrace_dyn_table_alloc(void)

pg = ftrace_pages = ftrace_pages_start;

cnt = NR_TO_INIT / ENTRIES_PER_PAGE;
cnt = num_to_init / ENTRIES_PER_PAGE;
pr_info("ftrace: allocating %ld hash entries in %d pages\n",
num_to_init, cnt);

for (i = 0; i < cnt; i++) {
pg->next = (void *)get_zeroed_page(GFP_KERNEL);
Expand Down Expand Up @@ -1556,6 +1518,104 @@ static __init int ftrace_init_debugfs(void)

fs_initcall(ftrace_init_debugfs);

#ifdef CONFIG_FTRACE_MCOUNT_RECORD
static int ftrace_convert_nops(unsigned long *start,
unsigned long *end)
{
unsigned long *p;
unsigned long addr;
unsigned long flags;

p = start;
while (p < end) {
addr = ftrace_call_adjust(*p++);
ftrace_record_ip(addr);
ftrace_shutdown_replenish();
}

/* p is ignored */
local_irq_save(flags);
__ftrace_update_code(p);
local_irq_restore(flags);

return 0;
}

extern unsigned long __start_mcount_loc[];
extern unsigned long __stop_mcount_loc[];

void __init ftrace_init(void)
{
unsigned long count, addr, flags;
int ret;

/* Keep the ftrace pointer to the stub */
addr = (unsigned long)ftrace_stub;

local_irq_save(flags);
ftrace_dyn_arch_init(&addr);
local_irq_restore(flags);

/* ftrace_dyn_arch_init places the return code in addr */
if (addr)
goto failed;

count = __stop_mcount_loc - __start_mcount_loc;

ret = ftrace_dyn_table_alloc(count);
if (ret)
goto failed;

last_ftrace_enabled = ftrace_enabled = 1;

ret = ftrace_convert_nops(__start_mcount_loc,
__stop_mcount_loc);

return;
failed:
ftrace_disabled = 1;
}
#else /* CONFIG_FTRACE_MCOUNT_RECORD */
static int ftraced(void *ignore)
{
unsigned long usecs;

while (!kthread_should_stop()) {

set_current_state(TASK_INTERRUPTIBLE);

/* check once a second */
schedule_timeout(HZ);

if (unlikely(ftrace_disabled))
continue;

mutex_lock(&ftrace_sysctl_lock);
mutex_lock(&ftraced_lock);
if (!ftraced_suspend && !ftraced_stop &&
ftrace_update_code()) {
usecs = nsecs_to_usecs(ftrace_update_time);
if (ftrace_update_tot_cnt > 100000) {
ftrace_update_tot_cnt = 0;
pr_info("hm, dftrace overflow: %lu change%s"
" (%lu total) in %lu usec%s\n",
ftrace_update_cnt,
ftrace_update_cnt != 1 ? "s" : "",
ftrace_update_tot_cnt,
usecs, usecs != 1 ? "s" : "");
ftrace_disabled = 1;
WARN_ON_ONCE(1);
}
}
mutex_unlock(&ftraced_lock);
mutex_unlock(&ftrace_sysctl_lock);

ftrace_shutdown_replenish();
}
__set_current_state(TASK_RUNNING);
return 0;
}

static int __init ftrace_dynamic_init(void)
{
struct task_struct *p;
Expand All @@ -1572,7 +1632,7 @@ static int __init ftrace_dynamic_init(void)
goto failed;
}

ret = ftrace_dyn_table_alloc();
ret = ftrace_dyn_table_alloc(NR_TO_INIT);
if (ret)
goto failed;

Expand All @@ -1593,6 +1653,8 @@ static int __init ftrace_dynamic_init(void)
}

core_initcall(ftrace_dynamic_init);
#endif /* CONFIG_FTRACE_MCOUNT_RECORD */

#else
# define ftrace_startup() do { } while (0)
# define ftrace_shutdown() do { } while (0)
Expand Down

0 comments on commit ea8c225

Please sign in to comment.