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>,
Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
"H. Peter Anvin" <hpa@zytor.com>
Subject: [PATCH 2/9][RFC] ftrace: Remove extra helper functions
Date: Wed, 02 May 2012 15:24:20 -0400 [thread overview]
Message-ID: <20120502193236.324199805@goodmis.org> (raw)
In-Reply-To: <20120502192418.024103772@goodmis.org>
[-- Attachment #1: 0002-ftrace-Remove-extra-helper-functions.patch --]
[-- Type: text/plain, Size: 3279 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
The ftrace_record_ip() and ftrace_alloc_dyn_node() were from the
time of the ftrace daemon. Although they were still used, they
still make things a bit more complex than necessary.
Move the code into the one function that uses it, and remove the
helper functions.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/ftrace.c | 61 +++++++++++++++++++------------------------------
1 file changed, 24 insertions(+), 37 deletions(-)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 6a19e81..4e608f8 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1520,35 +1520,6 @@ static void ftrace_hash_rec_enable(struct ftrace_ops *ops,
__ftrace_hash_rec_update(ops, filter_hash, 1);
}
-static struct dyn_ftrace *ftrace_alloc_dyn_node(unsigned long ip)
-{
- if (ftrace_pages->index == ftrace_pages->size) {
- /* We should have allocated enough */
- if (WARN_ON(!ftrace_pages->next))
- return NULL;
- ftrace_pages = ftrace_pages->next;
- }
-
- return &ftrace_pages->records[ftrace_pages->index++];
-}
-
-static struct dyn_ftrace *
-ftrace_record_ip(unsigned long ip)
-{
- struct dyn_ftrace *rec;
-
- if (ftrace_disabled)
- return NULL;
-
- rec = ftrace_alloc_dyn_node(ip);
- if (!rec)
- return NULL;
-
- rec->ip = ip;
-
- return rec;
-}
-
static void print_ip_ins(const char *fmt, unsigned char *p)
{
int i;
@@ -3715,7 +3686,9 @@ static int ftrace_process_locs(struct module *mod,
unsigned long *start,
unsigned long *end)
{
+ struct ftrace_page *start_pg;
struct ftrace_page *pg;
+ struct dyn_ftrace *rec;
unsigned long count;
unsigned long *p;
unsigned long addr;
@@ -3730,8 +3703,8 @@ static int ftrace_process_locs(struct module *mod,
sort(start, count, sizeof(*start),
ftrace_cmp_ips, ftrace_swap_ips);
- pg = ftrace_allocate_pages(count);
- if (!pg)
+ start_pg = ftrace_allocate_pages(count);
+ if (!start_pg)
return -ENOMEM;
mutex_lock(&ftrace_lock);
@@ -3744,7 +3717,7 @@ static int ftrace_process_locs(struct module *mod,
if (!mod) {
WARN_ON(ftrace_pages || ftrace_pages_start);
/* First initialization */
- ftrace_pages = ftrace_pages_start = pg;
+ ftrace_pages = ftrace_pages_start = start_pg;
} else {
if (!ftrace_pages)
goto out;
@@ -3755,11 +3728,11 @@ static int ftrace_process_locs(struct module *mod,
ftrace_pages = ftrace_pages->next;
}
- ftrace_pages->next = pg;
- ftrace_pages = pg;
+ ftrace_pages->next = start_pg;
}
p = start;
+ pg = start_pg;
while (p < end) {
addr = ftrace_call_adjust(*p++);
/*
@@ -3770,12 +3743,26 @@ static int ftrace_process_locs(struct module *mod,
*/
if (!addr)
continue;
- if (!ftrace_record_ip(addr))
- break;
+
+ if (pg->index == pg->size) {
+ /* We should have allocated enough */
+ if (WARN_ON(!pg->next))
+ break;
+ pg = pg->next;
+ }
+
+ rec = &pg->records[pg->index++];
+ rec->ip = addr;
}
+ /* We should have used all pages */
+ WARN_ON(pg->next);
+
+ /* Assign the last page to ftrace_pages */
+ ftrace_pages = pg;
+
/* These new locations need to be initialized */
- ftrace_new_pgs = pg;
+ ftrace_new_pgs = start_pg;
/*
* We only need to disable interrupts on start up
--
1.7.9.5
next prev parent reply other threads:[~2012-05-02 19:32 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-02 19:24 [PATCH 0/9][RFC] ftrace: ftrace location lookup speedup, and clean ups Steven Rostedt
2012-05-02 19:24 ` [PATCH 1/9][RFC] ftrace: Sort all function addresses, not just per page Steven Rostedt
2012-05-02 19:24 ` Steven Rostedt [this message]
2012-05-02 19:24 ` [PATCH 3/9][RFC] ftrace: Speed up search by skipping pages by address Steven Rostedt
2012-05-02 19:24 ` [PATCH 4/9][RFC] ftrace: Consolidate ftrace_location() and ftrace_text_reserved() Steven Rostedt
2012-05-02 19:24 ` [PATCH 5/9][RFC] ftrace: Return record ip addr for ftrace_location() Steven Rostedt
2012-05-02 19:24 ` [PATCH 6/9][RFC] kprobes: Allow probe on ftrace reserved text (but move it) Steven Rostedt
2012-05-02 20:40 ` Frank Ch. Eigler
2012-05-02 23:40 ` Steven Rostedt
2012-05-07 11:37 ` Masami Hiramatsu
2012-05-07 11:59 ` Masami Hiramatsu
2012-05-07 12:44 ` Steven Rostedt
2012-05-07 12:51 ` Steven Rostedt
2012-05-07 12:43 ` Steven Rostedt
2012-05-08 3:08 ` Masami Hiramatsu
2012-05-08 13:04 ` Steven Rostedt
2012-05-09 5:53 ` Masami Hiramatsu
2012-05-09 8:12 ` Masami Hiramatsu
2012-05-09 9:02 ` Masami Hiramatsu
2012-05-09 14:50 ` Steven Rostedt
2012-05-10 11:54 ` [RFC PATCH -tip ] x86/kprobes: kprobes call optimization Masami Hiramatsu
2012-05-11 8:29 ` Masami Hiramatsu
2012-05-02 19:24 ` [PATCH 7/9][RFC] ftrace: Make ftrace_modify_all_code() global for archs to use Steven Rostedt
2012-05-02 19:24 ` [PATCH 8/9][RFC] ftrace/x86: Have x86 ftrace use the ftrace_modify_all_code() Steven Rostedt
2012-05-02 19:24 ` [PATCH 9/9][RFC] ftrace: Remove selecting FRAME_POINTER with FUNCTION_TRACER Steven Rostedt
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=20120502193236.324199805@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=fweisbec@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--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
Powered by JetHome