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
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.
Note: if another perf-based sampling session is active, the output may become
polluted with their events. On older kernels, the ouptut may also become
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.
Note: if another perf-based sampling or tracing session is active, the output
may become polluted with their events. This will be fixed for Linux 4.9.
.SH REQUIREMENTS
CONFIG_BPF and bcc.
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
unavailable, this will try to use kprobes as a fallback (of perf_misc_flags()),
which may work or
may not, depending on your kernel build. If the kprobe doesn't work, this tool
will either error on instrumentation, or, instrument successfully but
generate no output.
perf_misc_flags() function symbol to exist. The latter may or may not
exist depending on your kernel build, and if it doesn't exist, this tool
will not work. Linux 4.9 provides a proper solution to this (this tool will
be updated).
.SH OPTIONS
.TP
\-h
...
...
tools/profile.py
View file @
ac297c1e
...
...
@@ -24,9 +24,9 @@
# 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
# perf
:perf_hrtimer tracepoint (currently a kernel patch). If the latter is
#
unavailable, this will try to use kprobes as a fallback, which may work or
#
may instrument nothing, depending on your kernel build
.
# perf
_misc_flags() function symbol to exist. The latter may or may not
#
exist depending on your kernel build. Linux 4.9 provides a proper solution
#
to this (this tool will be updated)
.
#
# Copyright 2016 Netflix, Inc.
# Licensed under the Apache License, Version 2.0 (the "License")
...
...
@@ -162,8 +162,13 @@ PERF_TRACE_EVENT {
struct pt_regs regs = {};
bpf_probe_read(®s, sizeof(regs), (void *)REGS_LOCATION);
u64 ip = PT_REGS_IP(®s);
// 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) {
#endif
key.kernel_ip = ip;
if (DO_KERNEL_RIP) {
/*
...
...
@@ -232,23 +237,21 @@ if not args.folded:
else
:
print
(
"... Hit Ctrl-C to end."
)
# use perf tracepoint if it exists, else kprobe
if
os
.
path
.
exists
(
"/sys/kernel/debug/tracing/events/perf/perf_hrtimer"
):
bpf_text
=
bpf_text
.
replace
(
'PERF_TRACE_EVENT'
,
'TRACEPOINT_PROBE(perf, perf_hrtimer)'
)
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)'
)
# kprobe 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
:
print
(
bpf_text
)
# 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
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