提交 982c350b 编写于 作者: S Steven Rostedt 提交者: Ingo Molnar

ftrace: fix dyn ftrace filter

Impact: correct implementation of dyn ftrace filter

The old decisions made by the filter algorithm was complex and incorrect.
This lead to inconsistent enabling or disabling of functions when
the filter was used.

This patch simplifies that code and in doing so, corrects the usage
of the filters.
Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
上级 20e5227e
...@@ -394,72 +394,62 @@ __ftrace_replace_code(struct dyn_ftrace *rec, int enable) ...@@ -394,72 +394,62 @@ __ftrace_replace_code(struct dyn_ftrace *rec, int enable)
ip = rec->ip; 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: * 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.
*/ */
fl = rec->flags & (FTRACE_FL_FILTER | FTRACE_FL_NOTRACE | fl = rec->flags & (FTRACE_FL_FILTER | FTRACE_FL_ENABLED);
FTRACE_FL_ENABLED);
if ((fl == (FTRACE_FL_FILTER | FTRACE_FL_ENABLED)) || /* Record is filtered and enabled, do nothing */
(fl == (FTRACE_FL_FILTER | FTRACE_FL_NOTRACE)) || if (fl == (FTRACE_FL_FILTER | FTRACE_FL_ENABLED))
!fl || (fl == FTRACE_FL_NOTRACE))
return 0; return 0;
/* /* Record is not filtered and is not enabled do nothing */
* If it is enabled disable it, if (!fl)
* otherwise enable it! return 0;
*/
if (fl & FTRACE_FL_ENABLED) { /* Record is not filtered but enabled, disable it */
enable = 0; if (fl == FTRACE_FL_ENABLED)
rec->flags &= ~FTRACE_FL_ENABLED; rec->flags &= ~FTRACE_FL_ENABLED;
} else { else
enable = 1; /* Otherwise record is filtered but not enabled, enable it */
rec->flags |= FTRACE_FL_ENABLED; rec->flags |= FTRACE_FL_ENABLED;
}
} else { } else {
/* Disable or not filtered */
if (enable) { if (enable) {
/* /* if record is enabled, do nothing */
* 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;
}
if (enable) {
if (rec->flags & FTRACE_FL_ENABLED) if (rec->flags & FTRACE_FL_ENABLED)
return 0; return 0;
rec->flags |= FTRACE_FL_ENABLED; rec->flags |= FTRACE_FL_ENABLED;
} else { } else {
/* if record is not enabled do nothing */
if (!(rec->flags & FTRACE_FL_ENABLED)) if (!(rec->flags & FTRACE_FL_ENABLED))
return 0; return 0;
rec->flags &= ~FTRACE_FL_ENABLED; rec->flags &= ~FTRACE_FL_ENABLED;
} }
} }
if (enable) if (rec->flags & FTRACE_FL_ENABLED)
return ftrace_make_call(rec, FTRACE_ADDR); return ftrace_make_call(rec, FTRACE_ADDR);
else else
return ftrace_make_nop(NULL, rec, FTRACE_ADDR); return ftrace_make_nop(NULL, rec, FTRACE_ADDR);
...@@ -554,8 +544,7 @@ static void ftrace_startup(void) ...@@ -554,8 +544,7 @@ static void ftrace_startup(void)
mutex_lock(&ftrace_start_lock); mutex_lock(&ftrace_start_lock);
ftrace_start_up++; ftrace_start_up++;
if (ftrace_start_up == 1) command |= FTRACE_ENABLE_CALLS;
command |= FTRACE_ENABLE_CALLS;
if (saved_ftrace_func != ftrace_trace_function) { if (saved_ftrace_func != ftrace_trace_function) {
saved_ftrace_func = ftrace_trace_function; saved_ftrace_func = ftrace_trace_function;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册