* [PATCH 1/8] ftrace: Make FTRACE_WARN_ON() work in if condition
2011-04-30 15:30 [PATCH 0/8] [GIT PULL][2.6.40] ftrace: cleanups Steven Rostedt
@ 2011-04-30 15:30 ` Steven Rostedt
2011-04-30 15:30 ` [PATCH 2/8] ftrace: Remove unnecessary disabling of irqs Steven Rostedt
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Steven Rostedt @ 2011-04-30 15:30 UTC (permalink / raw)
To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker
[-- Attachment #1: 0001-ftrace-Make-FTRACE_WARN_ON-work-in-if-condition.patch --]
[-- Type: text/plain, Size: 977 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
Let FTRACE_WARN_ON() be used as a stand alone statement or
inside a conditional: if (FTRACE_WARN_ON(x))
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/ftrace.c | 16 ++++++++++------
1 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index ee24fa1..4ff6559 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -39,16 +39,20 @@
#include "trace_stat.h"
#define FTRACE_WARN_ON(cond) \
- do { \
- if (WARN_ON(cond)) \
+ ({ \
+ int ___r = cond; \
+ if (WARN_ON(___r)) \
ftrace_kill(); \
- } while (0)
+ ___r; \
+ })
#define FTRACE_WARN_ON_ONCE(cond) \
- do { \
- if (WARN_ON_ONCE(cond)) \
+ ({ \
+ int ___r = cond; \
+ if (WARN_ON_ONCE(___r)) \
ftrace_kill(); \
- } while (0)
+ ___r; \
+ })
/* hash bits for specific function selection */
#define FTRACE_HASH_BITS 7
--
1.7.2.3
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH 2/8] ftrace: Remove unnecessary disabling of irqs
2011-04-30 15:30 [PATCH 0/8] [GIT PULL][2.6.40] ftrace: cleanups Steven Rostedt
2011-04-30 15:30 ` [PATCH 1/8] ftrace: Make FTRACE_WARN_ON() work in if condition Steven Rostedt
@ 2011-04-30 15:30 ` Steven Rostedt
2011-04-30 15:30 ` [PATCH 3/8] ftrace: Remove failures file Steven Rostedt
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Steven Rostedt @ 2011-04-30 15:30 UTC (permalink / raw)
To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker
[-- Attachment #1: 0002-ftrace-Remove-unnecessary-disabling-of-irqs.patch --]
[-- Type: text/plain, Size: 1121 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
The disabling of interrupts around ftrace_update_code() was used
to protect against the evil ftrace daemon from years past. But that
daemon has long been killed. It is safe to keep interrupts enabled
while updating the initial mcount into nops.
The ftrace_mutex is also held which keeps other users at bay.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/ftrace.c | 4 ----
1 files changed, 0 insertions(+), 4 deletions(-)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 4ff6559..f199fb2 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -2707,7 +2707,6 @@ static int ftrace_process_locs(struct module *mod,
{
unsigned long *p;
unsigned long addr;
- unsigned long flags;
mutex_lock(&ftrace_lock);
p = start;
@@ -2724,10 +2723,7 @@ static int ftrace_process_locs(struct module *mod,
ftrace_record_ip(addr);
}
- /* disable interrupts to prevent kstop machine */
- local_irq_save(flags);
ftrace_update_code(mod);
- local_irq_restore(flags);
mutex_unlock(&ftrace_lock);
return 0;
--
1.7.2.3
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH 3/8] ftrace: Remove failures file
2011-04-30 15:30 [PATCH 0/8] [GIT PULL][2.6.40] ftrace: cleanups Steven Rostedt
2011-04-30 15:30 ` [PATCH 1/8] ftrace: Make FTRACE_WARN_ON() work in if condition Steven Rostedt
2011-04-30 15:30 ` [PATCH 2/8] ftrace: Remove unnecessary disabling of irqs Steven Rostedt
@ 2011-04-30 15:30 ` Steven Rostedt
2011-04-30 15:30 ` [PATCH 4/8] ftrace: Remove FTRACE_FL_FAILED flag Steven Rostedt
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Steven Rostedt @ 2011-04-30 15:30 UTC (permalink / raw)
To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker
[-- Attachment #1: 0003-ftrace-Remove-failures-file.patch --]
[-- Type: text/plain, Size: 2742 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
The failures file in the debugfs tracing directory would list the
functions that failed to convert when the old dead ftrace daemon
tried to update code but failed. Since this code is now dead along
with the daemon the failures file is useless. Remove it.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/ftrace.c | 39 ++-------------------------------------
1 files changed, 2 insertions(+), 37 deletions(-)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index f199fb2..97b30f8 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1355,9 +1355,8 @@ static int __init ftrace_dyn_table_alloc(unsigned long num_to_init)
enum {
FTRACE_ITER_FILTER = (1 << 0),
FTRACE_ITER_NOTRACE = (1 << 1),
- FTRACE_ITER_FAILURES = (1 << 2),
- FTRACE_ITER_PRINTALL = (1 << 3),
- FTRACE_ITER_HASH = (1 << 4),
+ FTRACE_ITER_PRINTALL = (1 << 2),
+ FTRACE_ITER_HASH = (1 << 3),
};
#define FTRACE_BUFF_MAX (KSYM_SYMBOL_LEN+4) /* room for wildcards */
@@ -1487,12 +1486,6 @@ t_next(struct seq_file *m, void *v, loff_t *pos)
rec = &iter->pg->records[iter->idx++];
if ((rec->flags & FTRACE_FL_FREE) ||
- (!(iter->flags & FTRACE_ITER_FAILURES) &&
- (rec->flags & FTRACE_FL_FAILED)) ||
-
- ((iter->flags & FTRACE_ITER_FAILURES) &&
- !(rec->flags & FTRACE_FL_FAILED)) ||
-
((iter->flags & FTRACE_ITER_FILTER) &&
!(rec->flags & FTRACE_FL_FILTER)) ||
@@ -1633,24 +1626,6 @@ ftrace_avail_open(struct inode *inode, struct file *file)
return ret;
}
-static int
-ftrace_failures_open(struct inode *inode, struct file *file)
-{
- int ret;
- struct seq_file *m;
- struct ftrace_iterator *iter;
-
- ret = ftrace_avail_open(inode, file);
- if (!ret) {
- m = file->private_data;
- iter = m->private;
- iter->flags = FTRACE_ITER_FAILURES;
- }
-
- return ret;
-}
-
-
static void ftrace_filter_reset(int enable)
{
struct ftrace_page *pg;
@@ -2448,13 +2423,6 @@ static const struct file_operations ftrace_avail_fops = {
.release = seq_release_private,
};
-static const struct file_operations ftrace_failures_fops = {
- .open = ftrace_failures_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = seq_release_private,
-};
-
static const struct file_operations ftrace_filter_fops = {
.open = ftrace_filter_open,
.read = seq_read,
@@ -2683,9 +2651,6 @@ static __init int ftrace_init_dyn_debugfs(struct dentry *d_tracer)
trace_create_file("available_filter_functions", 0444,
d_tracer, NULL, &ftrace_avail_fops);
- trace_create_file("failures", 0444,
- d_tracer, NULL, &ftrace_failures_fops);
-
trace_create_file("set_ftrace_filter", 0644, d_tracer,
NULL, &ftrace_filter_fops);
--
1.7.2.3
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH 4/8] ftrace: Remove FTRACE_FL_FAILED flag
2011-04-30 15:30 [PATCH 0/8] [GIT PULL][2.6.40] ftrace: cleanups Steven Rostedt
` (2 preceding siblings ...)
2011-04-30 15:30 ` [PATCH 3/8] ftrace: Remove failures file Steven Rostedt
@ 2011-04-30 15:30 ` Steven Rostedt
2011-04-30 15:30 ` [PATCH 5/8] ftrace: Remove FTRACE_FL_CONVERTED flag Steven Rostedt
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Steven Rostedt @ 2011-04-30 15:30 UTC (permalink / raw)
To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker
[-- Attachment #1: 0004-ftrace-Remove-FTRACE_FL_FAILED-flag.patch --]
[-- Type: text/plain, Size: 6845 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
Since we disable all function tracer processing if we detect
that a modification of a instruction had failed, we do not need
to track that the record has failed. No more ftrace processing
is allowed, and the FTRACE_FL_FAILED flag is pointless.
Removing this flag simplifies some of the code, but some ftrace_disabled
checks needed to be added or move around a little.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
include/linux/ftrace.h | 9 ++---
kernel/trace/ftrace.c | 76 +++++++++++++++++++++++++++++------------------
2 files changed, 51 insertions(+), 34 deletions(-)
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index ca29e03..2a195ff 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -147,11 +147,10 @@ extern int ftrace_text_reserved(void *start, void *end);
enum {
FTRACE_FL_FREE = (1 << 0),
- FTRACE_FL_FAILED = (1 << 1),
- FTRACE_FL_FILTER = (1 << 2),
- FTRACE_FL_ENABLED = (1 << 3),
- FTRACE_FL_NOTRACE = (1 << 4),
- FTRACE_FL_CONVERTED = (1 << 5),
+ FTRACE_FL_FILTER = (1 << 1),
+ FTRACE_FL_ENABLED = (1 << 2),
+ FTRACE_FL_NOTRACE = (1 << 3),
+ FTRACE_FL_CONVERTED = (1 << 4),
};
struct dyn_ftrace {
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 97b30f8..eb19fae 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1083,19 +1083,20 @@ static void ftrace_replace_code(int enable)
struct ftrace_page *pg;
int failed;
+ if (unlikely(ftrace_disabled))
+ return;
+
do_for_each_ftrace_rec(pg, rec) {
/*
* Skip over free records, records that have
* failed and not converted.
*/
if (rec->flags & FTRACE_FL_FREE ||
- rec->flags & FTRACE_FL_FAILED ||
!(rec->flags & FTRACE_FL_CONVERTED))
continue;
failed = __ftrace_replace_code(rec, enable);
if (failed) {
- rec->flags |= FTRACE_FL_FAILED;
ftrace_bug(failed, rec->ip);
/* Stop processing */
return;
@@ -1111,10 +1112,12 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
ip = rec->ip;
+ if (unlikely(ftrace_disabled))
+ return 0;
+
ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
if (ret) {
ftrace_bug(ret, ip);
- rec->flags |= FTRACE_FL_FAILED;
return 0;
}
return 1;
@@ -1466,6 +1469,9 @@ t_next(struct seq_file *m, void *v, loff_t *pos)
struct ftrace_iterator *iter = m->private;
struct dyn_ftrace *rec = NULL;
+ if (unlikely(ftrace_disabled))
+ return NULL;
+
if (iter->flags & FTRACE_ITER_HASH)
return t_hash_next(m, pos);
@@ -1518,6 +1524,10 @@ static void *t_start(struct seq_file *m, loff_t *pos)
loff_t l;
mutex_lock(&ftrace_lock);
+
+ if (unlikely(ftrace_disabled))
+ return NULL;
+
/*
* If an lseek was done, then reset and start from beginning.
*/
@@ -1636,8 +1646,6 @@ static void ftrace_filter_reset(int enable)
if (enable)
ftrace_filtered = 0;
do_for_each_ftrace_rec(pg, rec) {
- if (rec->flags & FTRACE_FL_FAILED)
- continue;
rec->flags &= ~type;
} while_for_each_ftrace_rec();
mutex_unlock(&ftrace_lock);
@@ -1767,9 +1775,6 @@ static int ftrace_match_records(char *buff, int len, int enable)
mutex_lock(&ftrace_lock);
do_for_each_ftrace_rec(pg, rec) {
- if (rec->flags & FTRACE_FL_FAILED)
- continue;
-
if (ftrace_match_record(rec, search, search_len, type)) {
if (not)
rec->flags &= ~flag;
@@ -1837,10 +1842,11 @@ static int ftrace_match_module_records(char *buff, char *mod, int enable)
}
mutex_lock(&ftrace_lock);
- do_for_each_ftrace_rec(pg, rec) {
- if (rec->flags & FTRACE_FL_FAILED)
- continue;
+ if (unlikely(ftrace_disabled))
+ goto out_unlock;
+
+ do_for_each_ftrace_rec(pg, rec) {
if (ftrace_match_module_record(rec, mod,
search, search_len, type)) {
@@ -1854,6 +1860,7 @@ static int ftrace_match_module_records(char *buff, char *mod, int enable)
ftrace_filtered = 1;
} while_for_each_ftrace_rec();
+ out_unlock:
mutex_unlock(&ftrace_lock);
return found;
@@ -2008,10 +2015,11 @@ register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
return -EINVAL;
mutex_lock(&ftrace_lock);
- do_for_each_ftrace_rec(pg, rec) {
- if (rec->flags & FTRACE_FL_FAILED)
- continue;
+ if (unlikely(ftrace_disabled))
+ goto out_unlock;
+
+ do_for_each_ftrace_rec(pg, rec) {
if (!ftrace_match_record(rec, search, len, type))
continue;
@@ -2218,6 +2226,10 @@ ftrace_regex_write(struct file *file, const char __user *ubuf,
mutex_lock(&ftrace_regex_lock);
+ ret = -ENODEV;
+ if (unlikely(ftrace_disabled))
+ goto out_unlock;
+
if (file->f_mode & FMODE_READ) {
struct seq_file *m = file->private_data;
iter = m->private;
@@ -2545,9 +2557,6 @@ ftrace_set_func(unsigned long *array, int *idx, char *buffer)
bool exists;
int i;
- if (ftrace_disabled)
- return -ENODEV;
-
/* decode regex */
type = filter_parse_regex(buffer, strlen(buffer), &search, ¬);
if (!not && *idx >= FTRACE_GRAPH_MAX_FUNCS)
@@ -2556,9 +2565,15 @@ ftrace_set_func(unsigned long *array, int *idx, char *buffer)
search_len = strlen(search);
mutex_lock(&ftrace_lock);
+
+ if (unlikely(ftrace_disabled)) {
+ mutex_unlock(&ftrace_lock);
+ return -ENODEV;
+ }
+
do_for_each_ftrace_rec(pg, rec) {
- if (rec->flags & (FTRACE_FL_FAILED | FTRACE_FL_FREE))
+ if (rec->flags & FTRACE_FL_FREE)
continue;
if (ftrace_match_record(rec, search, search_len, type)) {
@@ -2700,10 +2715,11 @@ void ftrace_release_mod(struct module *mod)
struct dyn_ftrace *rec;
struct ftrace_page *pg;
+ mutex_lock(&ftrace_lock);
+
if (ftrace_disabled)
- return;
+ goto out_unlock;
- mutex_lock(&ftrace_lock);
do_for_each_ftrace_rec(pg, rec) {
if (within_module_core(rec->ip, mod)) {
/*
@@ -2714,6 +2730,7 @@ void ftrace_release_mod(struct module *mod)
ftrace_free_rec(rec);
}
} while_for_each_ftrace_rec();
+ out_unlock:
mutex_unlock(&ftrace_lock);
}
@@ -3108,16 +3125,17 @@ void ftrace_kill(void)
*/
int register_ftrace_function(struct ftrace_ops *ops)
{
- int ret;
-
- if (unlikely(ftrace_disabled))
- return -1;
+ int ret = -1;
mutex_lock(&ftrace_lock);
+ if (unlikely(ftrace_disabled))
+ goto out_unlock;
+
ret = __register_ftrace_function(ops);
ftrace_startup(0);
+ out_unlock:
mutex_unlock(&ftrace_lock);
return ret;
}
@@ -3145,14 +3163,14 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp,
loff_t *ppos)
{
- int ret;
-
- if (unlikely(ftrace_disabled))
- return -ENODEV;
+ int ret = -ENODEV;
mutex_lock(&ftrace_lock);
- ret = proc_dointvec(table, write, buffer, lenp, ppos);
+ if (unlikely(ftrace_disabled))
+ goto out;
+
+ ret = proc_dointvec(table, write, buffer, lenp, ppos);
if (ret || !write || (last_ftrace_enabled == !!ftrace_enabled))
goto out;
--
1.7.2.3
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH 5/8] ftrace: Remove FTRACE_FL_CONVERTED flag
2011-04-30 15:30 [PATCH 0/8] [GIT PULL][2.6.40] ftrace: cleanups Steven Rostedt
` (3 preceding siblings ...)
2011-04-30 15:30 ` [PATCH 4/8] ftrace: Remove FTRACE_FL_FAILED flag Steven Rostedt
@ 2011-04-30 15:30 ` Steven Rostedt
2011-04-30 15:30 ` [PATCH 6/8] ftrace: Move record update for normal and modules into a separate function Steven Rostedt
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Steven Rostedt @ 2011-04-30 15:30 UTC (permalink / raw)
To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker
[-- Attachment #1: 0005-ftrace-Remove-FTRACE_FL_CONVERTED-flag.patch --]
[-- Type: text/plain, Size: 1830 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
Since we disable all function tracer processing if we detect
that a modification of a instruction had failed, we do not need
to track that the record has failed. No more ftrace processing
is allowed, and the FTRACE_FL_CONVERTED flag is pointless.
The FTRACE_FL_CONVERTED flag was used to denote records that were
successfully converted from mcount calls into nops. But if a single
record fails, all of ftrace is disabled.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
include/linux/ftrace.h | 1 -
kernel/trace/ftrace.c | 12 ++++--------
2 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 2a195ff..3204744 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -150,7 +150,6 @@ enum {
FTRACE_FL_FILTER = (1 << 1),
FTRACE_FL_ENABLED = (1 << 2),
FTRACE_FL_NOTRACE = (1 << 3),
- FTRACE_FL_CONVERTED = (1 << 4),
};
struct dyn_ftrace {
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index eb19fae..9abaaf4 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1087,12 +1087,8 @@ static void ftrace_replace_code(int enable)
return;
do_for_each_ftrace_rec(pg, rec) {
- /*
- * Skip over free records, records that have
- * failed and not converted.
- */
- if (rec->flags & FTRACE_FL_FREE ||
- !(rec->flags & FTRACE_FL_CONVERTED))
+ /* Skip over free records */
+ if (rec->flags & FTRACE_FL_FREE)
continue;
failed = __ftrace_replace_code(rec, enable);
@@ -1280,10 +1276,10 @@ static int ftrace_update_code(struct module *mod)
*/
if (!ftrace_code_disable(mod, p)) {
ftrace_free_rec(p);
- continue;
+ /* Game over */
+ break;
}
- p->flags |= FTRACE_FL_CONVERTED;
ftrace_update_cnt++;
/*
--
1.7.2.3
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH 6/8] ftrace: Move record update for normal and modules into a separate function
2011-04-30 15:30 [PATCH 0/8] [GIT PULL][2.6.40] ftrace: cleanups Steven Rostedt
` (4 preceding siblings ...)
2011-04-30 15:30 ` [PATCH 5/8] ftrace: Remove FTRACE_FL_CONVERTED flag Steven Rostedt
@ 2011-04-30 15:30 ` Steven Rostedt
2011-04-30 15:30 ` [PATCH 7/8] ftrace: Consolidate updating of ftrace_trace_function Steven Rostedt
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Steven Rostedt @ 2011-04-30 15:30 UTC (permalink / raw)
To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker
[-- Attachment #1: 0006-ftrace-Move-record-update-for-normal-and-modules-int.patch --]
[-- Type: text/plain, Size: 1724 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
The updating of a function record is moved to a single function. This will allow
us to add specific changes in one location for both modules and kernel
functions.
Later patches will determine if the function record itself needs to be updated
(which enables the mcount caller), or just the ftrace_ops needs the update.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/ftrace.c | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 9abaaf4..5b758ea 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1743,6 +1743,15 @@ static int ftrace_match(char *str, char *regex, int len, int type)
return matched;
}
+static void
+update_record(struct dyn_ftrace *rec, unsigned long flag, int not)
+{
+ if (not)
+ rec->flags &= ~flag;
+ else
+ rec->flags |= flag;
+}
+
static int
ftrace_match_record(struct dyn_ftrace *rec, char *regex, int len, int type)
{
@@ -1772,10 +1781,7 @@ static int ftrace_match_records(char *buff, int len, int enable)
do_for_each_ftrace_rec(pg, rec) {
if (ftrace_match_record(rec, search, search_len, type)) {
- if (not)
- rec->flags &= ~flag;
- else
- rec->flags |= flag;
+ update_record(rec, flag, not);
found = 1;
}
/*
@@ -1846,10 +1852,7 @@ static int ftrace_match_module_records(char *buff, char *mod, int enable)
if (ftrace_match_module_record(rec, mod,
search, search_len, type)) {
- if (not)
- rec->flags &= ~flag;
- else
- rec->flags |= flag;
+ update_record(rec, flag, not);
found = 1;
}
if (enable && (rec->flags & FTRACE_FL_FILTER))
--
1.7.2.3
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH 7/8] ftrace: Consolidate updating of ftrace_trace_function
2011-04-30 15:30 [PATCH 0/8] [GIT PULL][2.6.40] ftrace: cleanups Steven Rostedt
` (5 preceding siblings ...)
2011-04-30 15:30 ` [PATCH 6/8] ftrace: Move record update for normal and modules into a separate function Steven Rostedt
@ 2011-04-30 15:30 ` Steven Rostedt
2011-04-30 15:30 ` [PATCH 8/8] ftrace: Consolidate the function match routines for normal and mods Steven Rostedt
2011-05-01 17:36 ` [PATCH 0/8] [GIT PULL][2.6.40] ftrace: cleanups Ingo Molnar
8 siblings, 0 replies; 10+ messages in thread
From: Steven Rostedt @ 2011-04-30 15:30 UTC (permalink / raw)
To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker
[-- Attachment #1: 0007-ftrace-Consolidate-updating-of-ftrace_trace_function.patch --]
[-- Type: text/plain, Size: 3597 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
There are three locations that perform almost identical functions in order
to update the ftrace_trace_function (the ftrace function variable that gets
called by mcount).
Consolidate these into a single function called update_ftrace_function().
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/ftrace.c | 95 +++++++++++++++++-------------------------------
1 files changed, 34 insertions(+), 61 deletions(-)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 5b758ea..33bcc71 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -151,6 +151,34 @@ static void ftrace_test_stop_func(unsigned long ip, unsigned long parent_ip)
}
#endif
+static void update_ftrace_function(void)
+{
+ ftrace_func_t func;
+
+ /*
+ * If there's only one function registered, then call that
+ * function directly. Otherwise, we need to iterate over the
+ * registered callers.
+ */
+ if (ftrace_list == &ftrace_list_end ||
+ ftrace_list->next == &ftrace_list_end)
+ func = ftrace_list->func;
+ else
+ func = ftrace_list_func;
+
+ /* If we filter on pids, update to use the pid function */
+ if (!list_empty(&ftrace_pids)) {
+ set_ftrace_pid_function(func);
+ func = ftrace_pid_func;
+ }
+#ifdef CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST
+ ftrace_trace_function = func;
+#else
+ __ftrace_trace_function = func;
+ ftrace_trace_function = ftrace_test_stop_func;
+#endif
+}
+
static int __register_ftrace_function(struct ftrace_ops *ops)
{
ops->next = ftrace_list;
@@ -162,30 +190,8 @@ static int __register_ftrace_function(struct ftrace_ops *ops)
*/
rcu_assign_pointer(ftrace_list, ops);
- if (ftrace_enabled) {
- ftrace_func_t func;
-
- if (ops->next == &ftrace_list_end)
- func = ops->func;
- else
- func = ftrace_list_func;
-
- if (!list_empty(&ftrace_pids)) {
- set_ftrace_pid_function(func);
- func = ftrace_pid_func;
- }
-
- /*
- * For one func, simply call it directly.
- * For more than one func, call the chain.
- */
-#ifdef CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST
- ftrace_trace_function = func;
-#else
- __ftrace_trace_function = func;
- ftrace_trace_function = ftrace_test_stop_func;
-#endif
- }
+ if (ftrace_enabled)
+ update_ftrace_function();
return 0;
}
@@ -213,52 +219,19 @@ static int __unregister_ftrace_function(struct ftrace_ops *ops)
*p = (*p)->next;
- if (ftrace_enabled) {
- /* If we only have one func left, then call that directly */
- if (ftrace_list->next == &ftrace_list_end) {
- ftrace_func_t func = ftrace_list->func;
-
- if (!list_empty(&ftrace_pids)) {
- set_ftrace_pid_function(func);
- func = ftrace_pid_func;
- }
-#ifdef CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST
- ftrace_trace_function = func;
-#else
- __ftrace_trace_function = func;
-#endif
- }
- }
+ if (ftrace_enabled)
+ update_ftrace_function();
return 0;
}
static void ftrace_update_pid_func(void)
{
- ftrace_func_t func;
-
+ /* Only do something if we are tracing something */
if (ftrace_trace_function == ftrace_stub)
return;
-#ifdef CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST
- func = ftrace_trace_function;
-#else
- func = __ftrace_trace_function;
-#endif
-
- if (!list_empty(&ftrace_pids)) {
- set_ftrace_pid_function(func);
- func = ftrace_pid_func;
- } else {
- if (func == ftrace_pid_func)
- func = ftrace_pid_function;
- }
-
-#ifdef CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST
- ftrace_trace_function = func;
-#else
- __ftrace_trace_function = func;
-#endif
+ update_ftrace_function();
}
#ifdef CONFIG_FUNCTION_PROFILER
--
1.7.2.3
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH 8/8] ftrace: Consolidate the function match routines for normal and mods
2011-04-30 15:30 [PATCH 0/8] [GIT PULL][2.6.40] ftrace: cleanups Steven Rostedt
` (6 preceding siblings ...)
2011-04-30 15:30 ` [PATCH 7/8] ftrace: Consolidate updating of ftrace_trace_function Steven Rostedt
@ 2011-04-30 15:30 ` Steven Rostedt
2011-05-01 17:36 ` [PATCH 0/8] [GIT PULL][2.6.40] ftrace: cleanups Ingo Molnar
8 siblings, 0 replies; 10+ messages in thread
From: Steven Rostedt @ 2011-04-30 15:30 UTC (permalink / raw)
To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker
[-- Attachment #1: 0008-ftrace-Consolidate-the-function-match-routines-for-n.patch --]
[-- Type: text/plain, Size: 4870 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
The code used for matching functions is almost identical between normal
selecting of functions and using the :mod: feature of set_ftrace_notrace.
Consolidate the two users into one function.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/ftrace.c | 98 ++++++++++++++++++-------------------------------
1 files changed, 36 insertions(+), 62 deletions(-)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 33bcc71..4f19dbb 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1726,34 +1726,52 @@ update_record(struct dyn_ftrace *rec, unsigned long flag, int not)
}
static int
-ftrace_match_record(struct dyn_ftrace *rec, char *regex, int len, int type)
+ftrace_match_record(struct dyn_ftrace *rec, char *mod,
+ char *regex, int len, int type)
{
char str[KSYM_SYMBOL_LEN];
+ char *modname;
+
+ kallsyms_lookup(rec->ip, NULL, NULL, &modname, str);
+
+ if (mod) {
+ /* module lookup requires matching the module */
+ if (!modname || strcmp(modname, mod))
+ return 0;
+
+ /* blank search means to match all funcs in the mod */
+ if (!len)
+ return 1;
+ }
- kallsyms_lookup(rec->ip, NULL, NULL, NULL, str);
return ftrace_match(str, regex, len, type);
}
-static int ftrace_match_records(char *buff, int len, int enable)
+static int match_records(char *buff, int len, char *mod, int enable, int not)
{
- unsigned int search_len;
+ unsigned search_len = 0;
struct ftrace_page *pg;
struct dyn_ftrace *rec;
+ int type = MATCH_FULL;
+ char *search = buff;
unsigned long flag;
- char *search;
- int type;
- int not;
int found = 0;
- flag = enable ? FTRACE_FL_FILTER : FTRACE_FL_NOTRACE;
- type = filter_parse_regex(buff, len, &search, ¬);
+ if (len) {
+ type = filter_parse_regex(buff, len, &search, ¬);
+ search_len = strlen(search);
+ }
- search_len = strlen(search);
+ flag = enable ? FTRACE_FL_FILTER : FTRACE_FL_NOTRACE;
mutex_lock(&ftrace_lock);
+
+ if (unlikely(ftrace_disabled))
+ goto out_unlock;
+
do_for_each_ftrace_rec(pg, rec) {
- if (ftrace_match_record(rec, search, search_len, type)) {
+ if (ftrace_match_record(rec, mod, search, search_len, type)) {
update_record(rec, flag, not);
found = 1;
}
@@ -1763,43 +1781,23 @@ static int ftrace_match_records(char *buff, int len, int enable)
*/
if (enable && (rec->flags & FTRACE_FL_FILTER))
ftrace_filtered = 1;
+
} while_for_each_ftrace_rec();
+ out_unlock:
mutex_unlock(&ftrace_lock);
return found;
}
static int
-ftrace_match_module_record(struct dyn_ftrace *rec, char *mod,
- char *regex, int len, int type)
+ftrace_match_records(char *buff, int len, int enable)
{
- char str[KSYM_SYMBOL_LEN];
- char *modname;
-
- kallsyms_lookup(rec->ip, NULL, NULL, &modname, str);
-
- if (!modname || strcmp(modname, mod))
- return 0;
-
- /* blank search means to match all funcs in the mod */
- if (len)
- return ftrace_match(str, regex, len, type);
- else
- return 1;
+ return match_records(buff, len, NULL, enable, 0);
}
static int ftrace_match_module_records(char *buff, char *mod, int enable)
{
- unsigned search_len = 0;
- struct ftrace_page *pg;
- struct dyn_ftrace *rec;
- int type = MATCH_FULL;
- char *search = buff;
- unsigned long flag;
int not = 0;
- int found = 0;
-
- flag = enable ? FTRACE_FL_FILTER : FTRACE_FL_NOTRACE;
/* blank or '*' mean the same */
if (strcmp(buff, "*") == 0)
@@ -1811,31 +1809,7 @@ static int ftrace_match_module_records(char *buff, char *mod, int enable)
not = 1;
}
- if (strlen(buff)) {
- type = filter_parse_regex(buff, strlen(buff), &search, ¬);
- search_len = strlen(search);
- }
-
- mutex_lock(&ftrace_lock);
-
- if (unlikely(ftrace_disabled))
- goto out_unlock;
-
- do_for_each_ftrace_rec(pg, rec) {
-
- if (ftrace_match_module_record(rec, mod,
- search, search_len, type)) {
- update_record(rec, flag, not);
- found = 1;
- }
- if (enable && (rec->flags & FTRACE_FL_FILTER))
- ftrace_filtered = 1;
-
- } while_for_each_ftrace_rec();
- out_unlock:
- mutex_unlock(&ftrace_lock);
-
- return found;
+ return match_records(buff, strlen(buff), mod, enable, not);
}
/*
@@ -1993,7 +1967,7 @@ register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
do_for_each_ftrace_rec(pg, rec) {
- if (!ftrace_match_record(rec, search, len, type))
+ if (!ftrace_match_record(rec, NULL, search, len, type))
continue;
entry = kmalloc(sizeof(*entry), GFP_KERNEL);
@@ -2548,7 +2522,7 @@ ftrace_set_func(unsigned long *array, int *idx, char *buffer)
if (rec->flags & FTRACE_FL_FREE)
continue;
- if (ftrace_match_record(rec, search, search_len, type)) {
+ if (ftrace_match_record(rec, NULL, search, search_len, type)) {
/* if it is in the array */
exists = false;
for (i = 0; i < *idx; i++) {
--
1.7.2.3
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH 0/8] [GIT PULL][2.6.40] ftrace: cleanups
2011-04-30 15:30 [PATCH 0/8] [GIT PULL][2.6.40] ftrace: cleanups Steven Rostedt
` (7 preceding siblings ...)
2011-04-30 15:30 ` [PATCH 8/8] ftrace: Consolidate the function match routines for normal and mods Steven Rostedt
@ 2011-05-01 17:36 ` Ingo Molnar
8 siblings, 0 replies; 10+ messages in thread
From: Ingo Molnar @ 2011-05-01 17:36 UTC (permalink / raw)
To: Steven Rostedt; +Cc: linux-kernel, Andrew Morton, Frederic Weisbecker
* Steven Rostedt <rostedt@goodmis.org> wrote:
> Ingo,
>
> I'm still working on the accounting of ftrace function tracer to be able
> to have multiple users that do not conflict with each other in selecting
> functions to trace. It's going well and is almost done.
>
> But in doing this, there were several cleanups that had to be made first.
> This patch series contains those cleanups and I've already run my tests
> on them and wanted to get them out now, instead of sending them with
> the major changes. This will let reviews focus on the major changes
> and not have to worry about these cleanups. Reviewers can examine these
> cleanups now if they want.
>
> One nice thing about this patch set is the stats:
> 141 insertions(+), 214 deletions(-)
>
> Please pull the latest tip/perf/core tree, which can be found at:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
> tip/perf/core
>
>
> Steven Rostedt (8):
> ftrace: Make FTRACE_WARN_ON() work in if condition
> ftrace: Remove unnecessary disabling of irqs
> ftrace: Remove failures file
> ftrace: Remove FTRACE_FL_FAILED flag
> ftrace: Remove FTRACE_FL_CONVERTED flag
> ftrace: Move record update for normal and modules into a separate function
> ftrace: Consolidate updating of ftrace_trace_function
> ftrace: Consolidate the function match routines for normal and mods
>
> ----
> include/linux/ftrace.h | 8 +-
> kernel/trace/ftrace.c | 347 +++++++++++++++++++-----------------------------
> 2 files changed, 141 insertions(+), 214 deletions(-)
Pulled, thanks Steve!
Ingo
^ permalink raw reply [flat|nested] 10+ messages in thread