Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
linux
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
2
Pull requests
0
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
cedd361
Documentation
LICENSES
arch
block
certs
crypto
drivers
fs
include
init
ipc
kernel
lib
mm
net
samples
scripts
security
sound
tools
accounting
arch
bootconfig
bpf
build
cgroup
counter
debugging
edid
firewire
firmware
gpio
hv
iio
include
io_uring
kvm
laptop
leds
lib
memory-model
objtool
pci
pcmcia
perf
Documentation
arch
bench
dlfilters
examples
include
jvmti
pmu-events
python
scripts
tests
trace
ui
util
arm-spe-decoder
bpf_skel
c++
cs-etm-decoder
include
intel-pt-decoder
libunwind
scripting-engines
Build
PERF-VERSION-GEN
affinity.c
affinity.h
amd-sample-raw.c
annotate.c
annotate.h
archinsn.h
arm-spe.c
arm-spe.h
arm64-frame-pointer-unwind-support.c
arm64-frame-pointer-unwind-support.h
auxtrace.c
auxtrace.h
block-info.c
block-info.h
block-range.c
block-range.h
bpf-event.c
bpf-event.h
bpf-loader.c
bpf-loader.h
bpf-prologue.c
bpf-prologue.h
bpf-utils.c
bpf-utils.h
bpf_counter.c
bpf_counter.h
bpf_counter_cgroup.c
bpf_ftrace.c
bpf_map.c
bpf_map.h
branch.c
branch.h
build-id.c
build-id.h
cache.h
cacheline.c
cacheline.h
call-path.c
call-path.h
callchain.c
callchain.h
cap.c
cap.h
cgroup.c
cgroup.h
clockid.c
clockid.h
cloexec.c
cloexec.h
color.c
color.h
color_config.c
comm.c
comm.h
compress.h
config.c
config.h
copyfile.c
copyfile.h
counts.c
counts.h
cpu-set-sched.h
cpumap.c
cpumap.h
cputopo.c
cputopo.h
cs-etm.c
cs-etm.h
data-convert-bt.c
data-convert-json.c
data-convert.h
data.c
data.h
db-export.c
db-export.h
debug.c
debug.h
demangle-java.c
demangle-java.h
demangle-ocaml.c
demangle-ocaml.h
demangle-rust.c
demangle-rust.h
dlfilter.c
dlfilter.h
dso.c
dso.h
dsos.c
dsos.h
dump-insn.c
dump-insn.h
dwarf-aux.c
dwarf-aux.h
dwarf-regs.c
env.c
env.h
event.c
event.h
events_stats.h
evlist-hybrid.c
evlist-hybrid.h
evlist.c
evlist.h
evsel.c
evsel.h
evsel_config.h
evsel_fprintf.c
evsel_fprintf.h
evswitch.c
evswitch.h
expr.c
expr.h
expr.l
expr.y
find-map.c
fncache.c
fncache.h
ftrace.h
genelf.c
genelf.h
genelf_debug.c
generate-cmdlist.sh
get_current_dir_name.c
get_current_dir_name.h
hashmap.c
hashmap.h
header.c
header.h
help-unknown-cmd.c
help-unknown-cmd.h
hist.c
hist.h
intel-bts.c
intel-bts.h
intel-pt.c
intel-pt.h
intlist.c
intlist.h
iostat.c
iostat.h
jit.h
jitdump.c
jitdump.h
kvm-stat.h
levenshtein.c
levenshtein.h
llvm-utils.c
llvm-utils.h
lzma.c
machine.c
machine.h
map.c
map.h
map_symbol.h
maps.h
mem-events.c
mem-events.h
mem2node.c
mem2node.h
memswap.c
memswap.h
metricgroup.c
metricgroup.h
mmap.c
mmap.h
namespaces.c
namespaces.h
ordered-events.c
ordered-events.h
parse-branch-options.c
parse-branch-options.h
parse-events-hybrid.c
parse-events-hybrid.h
parse-events.c
parse-events.h
parse-events.l
parse-events.y
parse-regs-options.c
parse-regs-options.h
parse-sublevel-options.c
parse-sublevel-options.h
path.c
path.h
perf-hooks-list.h
perf-hooks.c
perf-hooks.h
perf_api_probe.c
perf_api_probe.h
perf_event_attr_fprintf.c
perf_regs.c
perf_regs.h
pfm.c
pfm.h
pmu-hybrid.c
pmu-hybrid.h
pmu.c
pmu.h
pmu.l
pmu.y
print_binary.c
print_binary.h
probe-event.c
probe-event.h
probe-file.c
probe-file.h
probe-finder.c
probe-finder.h
pstack.c
pstack.h
python-ext-sources
python.c
rb_resort.h
rblist.c
rblist.h
record.c
record.h
rlimit.c
rlimit.h
rwsem.c
rwsem.h
s390-cpumcf-kernel.h
s390-cpumsf-kernel.h
s390-cpumsf.c
s390-cpumsf.h
s390-sample-raw.c
sample-raw.c
sample-raw.h
session.c
session.h
setns.c
setup.py
sideband_evlist.c
smt.c
smt.h
sort.c
sort.h
spark.c
spark.h
srccode.c
srccode.h
srcline.c
srcline.h
stat-display.c
stat-shadow.c
stat.c
stat.h
strbuf.c
strbuf.h
stream.c
stream.h
strfilter.c
strfilter.h
string.c
string2.h
strlist.c
strlist.h
svghelper.c
svghelper.h
symbol-elf.c
symbol-minimal.c
symbol.c
symbol.h
symbol_conf.h
symbol_fprintf.c
symsrc.h
synthetic-events.c
synthetic-events.h
syscalltbl.c
syscalltbl.h
target.c
target.h
term.c
term.h
thread-stack.c
thread-stack.h
thread.c
thread.h
thread_map.c
thread_map.h
time-utils.c
time-utils.h
tool.h
top.c
top.h
topdown.c
topdown.h
trace-event-info.c
trace-event-parse.c
trace-event-read.c
trace-event-scripting.c
trace-event.c
trace-event.h
trigger.h
tsc.c
tsc.h
units.c
units.h
unwind-libdw.c
unwind-libdw.h
unwind-libunwind-local.c
unwind-libunwind.c
unwind.h
usage.c
util.c
util.h
values.c
values.h
vdso.c
vdso.h
zlib.c
zstd.c
.gitignore
Build
CREDITS
MANIFEST
Makefile
Makefile.config
Makefile.perf
builtin-annotate.c
builtin-bench.c
builtin-buildid-cache.c
builtin-buildid-list.c
builtin-c2c.c
builtin-config.c
builtin-daemon.c
builtin-data.c
builtin-diff.c
builtin-evlist.c
builtin-ftrace.c
builtin-help.c
builtin-inject.c
builtin-kallsyms.c
builtin-kmem.c
builtin-kvm.c
builtin-list.c
builtin-lock.c
builtin-mem.c
builtin-probe.c
builtin-record.c
builtin-report.c
builtin-sched.c
builtin-script.c
builtin-stat.c
builtin-timechart.c
builtin-top.c
builtin-trace.c
builtin-version.c
builtin.h
check-headers.sh
command-list.txt
design.txt
perf-archive.sh
perf-completion.sh
perf-iostat.sh
perf-read-vdso.c
perf-sys.h
perf-with-kcore.sh
perf.c
perf.h
power
rcu
scripts
spi
testing
thermal
time
tracing
usb
virtio
vm
wmi
Makefile
usr
virt
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README
Breadcrumbs
linux
/
tools
/
perf
/
util
/
branch.c
Copy path
Blame
Blame
Latest commit
History
History
148 lines (117 loc) · 2.93 KB
Breadcrumbs
linux
/
tools
/
perf
/
util
/
branch.c
Top
File metadata and controls
Code
Blame
148 lines (117 loc) · 2.93 KB
Raw
#include "util/map_symbol.h" #include "util/branch.h" #include <linux/kernel.h> static bool cross_area(u64 addr1, u64 addr2, int size) { u64 align1, align2; align1 = addr1 & ~(size - 1); align2 = addr2 & ~(size - 1); return (align1 != align2) ? true : false; } #define AREA_4K 4096 #define AREA_2M (2 * 1024 * 1024) void branch_type_count(struct branch_type_stat *st, struct branch_flags *flags, u64 from, u64 to) { if (flags->type == PERF_BR_UNKNOWN || from == 0) return; st->counts[flags->type]++; if (flags->type == PERF_BR_COND) { if (to > from) st->cond_fwd++; else st->cond_bwd++; } if (cross_area(from, to, AREA_2M)) st->cross_2m++; else if (cross_area(from, to, AREA_4K)) st->cross_4k++; } const char *branch_type_name(int type) { const char *branch_names[PERF_BR_MAX] = { "N/A", "COND", "UNCOND", "IND", "CALL", "IND_CALL", "RET", "SYSCALL", "SYSRET", "COND_CALL", "COND_RET", "ERET", "IRQ" }; if (type >= 0 && type < PERF_BR_MAX) return branch_names[type]; return NULL; } void branch_type_stat_display(FILE *fp, struct branch_type_stat *st) { u64 total = 0; int i; for (i = 0; i < PERF_BR_MAX; i++) total += st->counts[i]; if (total == 0) return; fprintf(fp, "\n#"); fprintf(fp, "\n# Branch Statistics:"); fprintf(fp, "\n#"); if (st->cond_fwd > 0) { fprintf(fp, "\n%8s: %5.1f%%", "COND_FWD", 100.0 * (double)st->cond_fwd / (double)total); } if (st->cond_bwd > 0) { fprintf(fp, "\n%8s: %5.1f%%", "COND_BWD", 100.0 * (double)st->cond_bwd / (double)total); } if (st->cross_4k > 0) { fprintf(fp, "\n%8s: %5.1f%%", "CROSS_4K", 100.0 * (double)st->cross_4k / (double)total); } if (st->cross_2m > 0) { fprintf(fp, "\n%8s: %5.1f%%", "CROSS_2M", 100.0 * (double)st->cross_2m / (double)total); } for (i = 0; i < PERF_BR_MAX; i++) { if (st->counts[i] > 0) fprintf(fp, "\n%8s: %5.1f%%", branch_type_name(i), 100.0 * (double)st->counts[i] / (double)total); } } static int count_str_scnprintf(int idx, const char *str, char *bf, int size) { return scnprintf(bf, size, "%s%s", (idx) ? " " : " (", str); } int branch_type_str(struct branch_type_stat *st, char *bf, int size) { int i, j = 0, printed = 0; u64 total = 0; for (i = 0; i < PERF_BR_MAX; i++) total += st->counts[i]; if (total == 0) return 0; if (st->cond_fwd > 0) printed += count_str_scnprintf(j++, "COND_FWD", bf + printed, size - printed); if (st->cond_bwd > 0) printed += count_str_scnprintf(j++, "COND_BWD", bf + printed, size - printed); for (i = 0; i < PERF_BR_MAX; i++) { if (i == PERF_BR_COND) continue; if (st->counts[i] > 0) printed += count_str_scnprintf(j++, branch_type_name(i), bf + printed, size - printed); } if (st->cross_4k > 0) printed += count_str_scnprintf(j++, "CROSS_4K", bf + printed, size - printed); if (st->cross_2m > 0) printed += count_str_scnprintf(j++, "CROSS_2M", bf + printed, size - printed); return printed; }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
You can’t perform that action at this time.