From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>,
Andrew Morton <akpm@linux-foundation.org>,
Frederic Weisbecker <fweisbec@gmail.com>
Subject: [PATCH 8/8] ftrace: Consolidate the function match routines for normal and mods
Date: Sat, 30 Apr 2011 11:30:48 -0400 [thread overview]
Message-ID: <20110430153212.152717553@goodmis.org> (raw)
In-Reply-To: <20110430153040.354378898@goodmis.org>
[-- 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
next prev parent reply other threads:[~2011-04-30 15:32 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` [PATCH 3/8] ftrace: Remove failures file Steven Rostedt
2011-04-30 15:30 ` [PATCH 4/8] ftrace: Remove FTRACE_FL_FAILED flag Steven Rostedt
2011-04-30 15:30 ` [PATCH 5/8] ftrace: Remove FTRACE_FL_CONVERTED flag Steven Rostedt
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 ` [PATCH 7/8] ftrace: Consolidate updating of ftrace_trace_function Steven Rostedt
2011-04-30 15:30 ` Steven Rostedt [this message]
2011-05-01 17:36 ` [PATCH 0/8] [GIT PULL][2.6.40] ftrace: cleanups Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110430153212.152717553@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®