Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bcc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
bcc
Commits
ac297c1e
Commit
ac297c1e
authored
Oct 18, 2016
by
Brendan Gregg
Committed by
4ast
Oct 18, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix profile.py page_offset_base breakage (#768)
parent
5845ef9c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
26 deletions
+25
-26
man/man8/profile.8
man/man8/profile.8
+6
-10
tools/profile.py
tools/profile.py
+19
-16
No files found.
man/man8/profile.8
View file @
ac297c1e
...
@@ -18,20 +18,16 @@ kernel context, rather than passing each stack to user space for frequency
...
@@ -18,20 +18,16 @@ kernel context, rather than passing each stack to user space for frequency
counting there. Only the unique stacks and counts are passed to user space
counting there. Only the unique stacks and counts are passed to user space
at the end of the profile, greatly reducing the kernel<->user transfer.
at the end of the profile, greatly reducing the kernel<->user transfer.
Note: if another perf-based sampling session is active, the output may become
Note: if another perf-based sampling or tracing session is active, the output
polluted with their events. On older kernels, the ouptut may also become
may become polluted with their events. This will be fixed for Linux 4.9.
polluted with tracing sessions (when the kprobe is used instead of the
tracepoint). This may be filtered in a future version if it becomes a problem.
.SH REQUIREMENTS
.SH REQUIREMENTS
CONFIG_BPF and bcc.
CONFIG_BPF and bcc.
This also requires Linux 4.6+ (BPF_MAP_TYPE_STACK_TRACE support), and the
This also requires Linux 4.6+ (BPF_MAP_TYPE_STACK_TRACE support), and the
perf:perf_hrtimer tracepoint (currently a kernel patch). If the latter is
perf_misc_flags() function symbol to exist. The latter may or may not
unavailable, this will try to use kprobes as a fallback (of perf_misc_flags()),
exist depending on your kernel build, and if it doesn't exist, this tool
which may work or
will not work. Linux 4.9 provides a proper solution to this (this tool will
may not, depending on your kernel build. If the kprobe doesn't work, this tool
be updated).
will either error on instrumentation, or, instrument successfully but
generate no output.
.SH OPTIONS
.SH OPTIONS
.TP
.TP
\-h
\-h
...
...
tools/profile.py
View file @
ac297c1e
...
@@ -24,9 +24,9 @@
...
@@ -24,9 +24,9 @@
# tracepoint). If this becomes a problem, logic can be added to filter events.
# tracepoint). If this becomes a problem, logic can be added to filter events.
#
#
# REQUIRES: Linux 4.6+ (BPF_MAP_TYPE_STACK_TRACE support), and the
# REQUIRES: Linux 4.6+ (BPF_MAP_TYPE_STACK_TRACE support), and the
# perf
:perf_hrtimer tracepoint (currently a kernel patch). If the latter is
# perf
_misc_flags() function symbol to exist. The latter may or may not
#
unavailable, this will try to use kprobes as a fallback, which may work or
#
exist depending on your kernel build. Linux 4.9 provides a proper solution
#
may instrument nothing, depending on your kernel build
.
#
to this (this tool will be updated)
.
#
#
# Copyright 2016 Netflix, Inc.
# Copyright 2016 Netflix, Inc.
# Licensed under the Apache License, Version 2.0 (the "License")
# Licensed under the Apache License, Version 2.0 (the "License")
...
@@ -162,8 +162,13 @@ PERF_TRACE_EVENT {
...
@@ -162,8 +162,13 @@ PERF_TRACE_EVENT {
struct pt_regs regs = {};
struct pt_regs regs = {};
bpf_probe_read(®s, sizeof(regs), (void *)REGS_LOCATION);
bpf_probe_read(®s, sizeof(regs), (void *)REGS_LOCATION);
u64 ip = PT_REGS_IP(®s);
u64 ip = PT_REGS_IP(®s);
// if ip isn't sane, leave key ips as zero for later checking
// if ip isn't sane, leave key ips as zero for later checking
#ifdef CONFIG_RANDOMIZE_MEMORY
if (ip > __PAGE_OFFSET_BASE) {
#else
if (ip > PAGE_OFFSET) {
if (ip > PAGE_OFFSET) {
#endif
key.kernel_ip = ip;
key.kernel_ip = ip;
if (DO_KERNEL_RIP) {
if (DO_KERNEL_RIP) {
/*
/*
...
@@ -232,23 +237,21 @@ if not args.folded:
...
@@ -232,23 +237,21 @@ if not args.folded:
else
:
else
:
print
(
"... Hit Ctrl-C to end."
)
print
(
"... Hit Ctrl-C to end."
)
# use perf tracepoint if it exists, else kprobe
# kprobe perf_misc_flags()
if
os
.
path
.
exists
(
"/sys/kernel/debug/tracing/events/perf/perf_hrtimer"
):
bpf_text
=
bpf_text
.
replace
(
'PERF_TRACE_EVENT'
,
bpf_text
=
bpf_text
.
replace
(
'PERF_TRACE_EVENT'
,
'int kprobe__perf_misc_flags(struct pt_regs *args)'
)
'TRACEPOINT_PROBE(perf, perf_hrtimer)'
)
bpf_text
=
bpf_text
.
replace
(
'REGS_LOCATION'
,
'PT_REGS_PARM1(args)'
)
bpf_text
=
bpf_text
.
replace
(
'REGS_LOCATION'
,
'args->regs'
)
else
:
if
not
args
.
folded
:
print
(
"Tracepoint perf:perf_hrtimer missing. "
"Trying kprobe of perf_misc_flags()..."
)
bpf_text
=
bpf_text
.
replace
(
'PERF_TRACE_EVENT'
,
'int kprobe__perf_misc_flags(struct pt_regs *args)'
)
bpf_text
=
bpf_text
.
replace
(
'REGS_LOCATION'
,
'PT_REGS_PARM1(args)'
)
if
debug
:
if
debug
:
print
(
bpf_text
)
print
(
bpf_text
)
# initialize BPF
# initialize BPF
b
=
BPF
(
text
=
bpf_text
)
try
:
b
=
BPF
(
text
=
bpf_text
)
except
:
print
(
"BPF initialization failed. perf_misc_flags() may be inlined in "
+
"your kernel build.
\
n
This tool will be updated in the future to "
+
"support Linux 4.9, which has reliable profiling support. Exiting."
)
exit
()
# signal handler
# signal handler
def
signal_ignore
(
signal
,
frame
):
def
signal_ignore
(
signal
,
frame
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment