Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 119233
b: refs/heads/master
c: 3246477
h: refs/heads/master
i:
  119231: d6869e3
v: v3
  • Loading branch information
Steven Rostedt authored and Steven Rostedt committed Nov 19, 2008
1 parent 5045f4e commit 909ee97
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 59 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: 820432783190b4096499e38a4a4d7095c511913d
refs/heads/master: 32464779a1b8c15e9aa9aa0306b2f735080df9d8
108 changes: 50 additions & 58 deletions trunk/kernel/trace/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,96 +327,89 @@ ftrace_record_ip(unsigned long ip)

static int
__ftrace_replace_code(struct dyn_ftrace *rec,
unsigned char *old, unsigned char *new, int enable)
unsigned char *nop, int enable)
{
unsigned long ip, fl;
unsigned char *call, *old, *new;

ip = rec->ip;

if (ftrace_filtered && enable) {
/*
* If this record is not to be traced and
* it is not enabled then do nothing.
*
* If this record is not to be traced and
* it is enabled then disabled it.
*
*/
if (rec->flags & FTRACE_FL_NOTRACE) {
if (rec->flags & FTRACE_FL_ENABLED)
rec->flags &= ~FTRACE_FL_ENABLED;
else
return 0;

} else if (ftrace_filtered && enable) {
/*
* If filtering is on:
*
* If this record is set to be filtered and
* is enabled then do nothing.
*
* If this record is set to be filtered and
* it is not enabled, enable it.
*
* If this record is not set to be filtered
* and it is not enabled do nothing.
*
* If this record is set not to trace then
* do nothing.
*
* If this record is set not to trace and
* it is enabled then disable it.
*
* If this record is not set to be filtered and
* it is enabled, disable it.
* Filtering is on:
*/

fl = rec->flags & (FTRACE_FL_FILTER | FTRACE_FL_NOTRACE |
FTRACE_FL_ENABLED);
fl = rec->flags & (FTRACE_FL_FILTER | FTRACE_FL_ENABLED);

if ((fl == (FTRACE_FL_FILTER | FTRACE_FL_ENABLED)) ||
(fl == (FTRACE_FL_FILTER | FTRACE_FL_NOTRACE)) ||
!fl || (fl == FTRACE_FL_NOTRACE))
/* Record is filtered and enabled, do nothing */
if (fl == (FTRACE_FL_FILTER | FTRACE_FL_ENABLED))
return 0;

/*
* If it is enabled disable it,
* otherwise enable it!
*/
if (fl & FTRACE_FL_ENABLED) {
/* swap new and old */
new = old;
old = ftrace_call_replace(ip, FTRACE_ADDR);
/* Record is not filtered and is not enabled do nothing */
if (!fl)
return 0;

/* Record is not filtered but enabled, disable it */
if (fl == FTRACE_FL_ENABLED)
rec->flags &= ~FTRACE_FL_ENABLED;
} else {
new = ftrace_call_replace(ip, FTRACE_ADDR);
else
/* Otherwise record is filtered but not enabled, enable it */
rec->flags |= FTRACE_FL_ENABLED;
}
} else {
/* Disable or not filtered */

if (enable) {
/*
* If this record is set not to trace and is
* not enabled, do nothing.
*/
fl = rec->flags & (FTRACE_FL_NOTRACE | FTRACE_FL_ENABLED);
if (fl == FTRACE_FL_NOTRACE)
return 0;

new = ftrace_call_replace(ip, FTRACE_ADDR);
} else
old = ftrace_call_replace(ip, FTRACE_ADDR);

if (enable) {
/* if record is enabled, do nothing */
if (rec->flags & FTRACE_FL_ENABLED)
return 0;

rec->flags |= FTRACE_FL_ENABLED;

} else {

/* if record is not enabled do nothing */
if (!(rec->flags & FTRACE_FL_ENABLED))
return 0;

rec->flags &= ~FTRACE_FL_ENABLED;
}
}

call = ftrace_call_replace(ip, FTRACE_ADDR);

if (rec->flags & FTRACE_FL_ENABLED) {
old = nop;
new = call;
} else {
old = call;
new = nop;
}

return ftrace_modify_code(ip, old, new);
}

static void ftrace_replace_code(int enable)
{
int i, failed;
unsigned char *new = NULL, *old = NULL;
unsigned char *nop = NULL;
struct dyn_ftrace *rec;
struct ftrace_page *pg;

if (enable)
old = ftrace_nop_replace();
else
new = ftrace_nop_replace();
nop = ftrace_nop_replace();

for (pg = ftrace_pages_start; pg; pg = pg->next) {
for (i = 0; i < pg->index; i++) {
Expand All @@ -434,7 +427,7 @@ static void ftrace_replace_code(int enable)
unfreeze_record(rec);
}

failed = __ftrace_replace_code(rec, old, new, enable);
failed = __ftrace_replace_code(rec, nop, enable);
if (failed && (rec->flags & FTRACE_FL_CONVERTED)) {
rec->flags |= FTRACE_FL_FAILED;
if ((system_state == SYSTEM_BOOTING) ||
Expand Down Expand Up @@ -538,8 +531,7 @@ static void ftrace_startup(void)

mutex_lock(&ftrace_start_lock);
ftrace_start++;
if (ftrace_start == 1)
command |= FTRACE_ENABLE_CALLS;
command |= FTRACE_ENABLE_CALLS;

if (saved_ftrace_func != ftrace_trace_function) {
saved_ftrace_func = ftrace_trace_function;
Expand Down

0 comments on commit 909ee97

Please sign in to comment.