From: Alexei Starovoitov <ast@fb.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
"David S . Miller" <davem@davemloft.net>,
Ingo Molnar <mingo@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Arnaldo Carvalho de Melo <acme@infradead.org>,
Wang Nan <wangnan0@huawei.com>, Josef Bacik <jbacik@fb.com>,
Brendan Gregg <brendan.d.gregg@gmail.com>,
<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<kernel-team@fb.com>
Subject: [PATCH v2 net-next 01/10] perf: optimize perf_fetch_caller_regs
Date: Wed, 6 Apr 2016 18:43:22 -0700 [thread overview]
Message-ID: <1459993411-2754735-2-git-send-email-ast@fb.com> (raw)
In-Reply-To: <1459993411-2754735-1-git-send-email-ast@fb.com>
avoid memset in perf_fetch_caller_regs, since it's the critical path of all tracepoints.
It's called from perf_sw_event_sched, perf_event_task_sched_in and all of perf_trace_##call
with this_cpu_ptr(&__perf_regs[..]) which are zero initialized by perpcu init logic and
subsequent call to perf_arch_fetch_caller_regs initializes the same fields on all archs,
so we can safely drop memset from all of the above cases and move it into
perf_ftrace_function_call that calls it with stack allocated pt_regs.
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
---
include/linux/perf_event.h | 2 --
kernel/trace/trace_event_perf.c | 1 +
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index f291275ffd71..e89f7199c223 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -882,8 +882,6 @@ static inline void perf_arch_fetch_caller_regs(struct pt_regs *regs, unsigned lo
*/
static inline void perf_fetch_caller_regs(struct pt_regs *regs)
{
- memset(regs, 0, sizeof(*regs));
-
perf_arch_fetch_caller_regs(regs, CALLER_ADDR0);
}
diff --git a/kernel/trace/trace_event_perf.c b/kernel/trace/trace_event_perf.c
index 00df25fd86ef..7a68afca8249 100644
--- a/kernel/trace/trace_event_perf.c
+++ b/kernel/trace/trace_event_perf.c
@@ -316,6 +316,7 @@ perf_ftrace_function_call(unsigned long ip, unsigned long parent_ip,
BUILD_BUG_ON(ENTRY_SIZE > PERF_MAX_TRACE_SIZE);
+ memset(®s, 0, sizeof(regs));
perf_fetch_caller_regs(®s);
entry = perf_trace_buf_prepare(ENTRY_SIZE, TRACE_FN, NULL, &rctx);
--
2.8.0
next prev parent reply other threads:[~2016-04-07 1:46 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-07 1:43 [PATCH v2 net-next 00/10] allow bpf attach to tracepoints Alexei Starovoitov
2016-04-07 1:43 ` Alexei Starovoitov [this message]
2016-04-07 1:43 ` [PATCH v2 net-next 02/10] perf: remove unused __addr variable Alexei Starovoitov
2016-04-07 20:54 ` Peter Zijlstra
2016-04-07 1:43 ` [PATCH v2 net-next 03/10] perf: split perf_trace_buf_prepare into alloc and update parts Alexei Starovoitov
2016-04-07 20:58 ` Peter Zijlstra
2016-04-07 1:43 ` [PATCH v2 net-next 04/10] perf, bpf: allow bpf programs attach to tracepoints Alexei Starovoitov
2016-04-07 20:58 ` Peter Zijlstra
2016-04-07 1:43 ` [PATCH v2 net-next 05/10] bpf: register BPF_PROG_TYPE_TRACEPOINT program type Alexei Starovoitov
2016-04-07 1:43 ` [PATCH v2 net-next 06/10] bpf: support bpf_get_stackid() and bpf_perf_event_output() in tracepoint programs Alexei Starovoitov
2016-04-07 1:43 ` [PATCH v2 net-next 07/10] bpf: sanitize bpf tracepoint access Alexei Starovoitov
2016-04-07 1:43 ` [PATCH v2 net-next 08/10] samples/bpf: add tracepoint support to bpf loader Alexei Starovoitov
2016-04-07 1:43 ` [PATCH v2 net-next 09/10] samples/bpf: tracepoint example Alexei Starovoitov
2016-04-07 1:43 ` [PATCH v2 net-next 10/10] samples/bpf: add tracepoint vs kprobe performance tests Alexei Starovoitov
2016-04-07 20:46 ` [PATCH v2 net-next 00/10] allow bpf attach to tracepoints David Miller
2016-04-08 1:04 ` David Miller
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=1459993411-2754735-2-git-send-email-ast@fb.com \
--to=ast@fb.com \
--cc=acme@infradead.org \
--cc=brendan.d.gregg@gmail.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=jbacik@fb.com \
--cc=kernel-team@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=wangnan0@huawei.com \
/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