License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 21:07:57 +07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2011-02-04 18:45:46 +07:00
|
|
|
#ifndef __PERF_ANNOTATE_H
|
|
|
|
#define __PERF_ANNOTATE_H
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
2012-04-26 00:16:03 +07:00
|
|
|
#include <stdint.h>
|
2014-04-26 02:31:02 +07:00
|
|
|
#include <linux/types.h>
|
2011-02-04 18:45:46 +07:00
|
|
|
#include "symbol.h"
|
2012-11-02 12:50:05 +07:00
|
|
|
#include "hist.h"
|
2013-02-07 16:02:08 +07:00
|
|
|
#include "sort.h"
|
2011-02-04 18:45:46 +07:00
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/rbtree.h>
|
2012-09-08 07:43:19 +07:00
|
|
|
#include <pthread.h>
|
2011-02-04 18:45:46 +07:00
|
|
|
|
2016-11-24 21:16:06 +07:00
|
|
|
struct ins_ops;
|
|
|
|
|
|
|
|
struct ins {
|
|
|
|
const char *name;
|
|
|
|
struct ins_ops *ops;
|
|
|
|
};
|
2012-04-19 20:16:27 +07:00
|
|
|
|
2012-04-21 00:38:46 +07:00
|
|
|
struct ins_operands {
|
|
|
|
char *raw;
|
2012-04-25 18:00:23 +07:00
|
|
|
struct {
|
2012-05-12 02:48:49 +07:00
|
|
|
char *raw;
|
2012-04-25 18:00:23 +07:00
|
|
|
char *name;
|
2018-03-02 21:59:36 +07:00
|
|
|
struct symbol *sym;
|
2012-04-25 18:00:23 +07:00
|
|
|
u64 addr;
|
perf annotate: Fix jump target outside of function address range
If jump target is outside of function range, perf is not handling it
correctly. Especially when target address is lesser than function start
address, target offset will be negative. But, target address declared to
be unsigned, converts negative number into 2's complement. See below
example. Here target of 'jumpq' instruction at 34cf8 is 34ac0 which is
lesser than function start address(34cf0).
34ac0 - 34cf0 = -0x230 = 0xfffffffffffffdd0
Objdump output:
0000000000034cf0 <__sigaction>:
__GI___sigaction():
34cf0: lea -0x20(%rdi),%eax
34cf3: cmp -bashx1,%eax
34cf6: jbe 34d00 <__sigaction+0x10>
34cf8: jmpq 34ac0 <__GI___libc_sigaction>
34cfd: nopl (%rax)
34d00: mov 0x386161(%rip),%rax # 3bae68 <_DYNAMIC+0x2e8>
34d07: movl -bashx16,%fs:(%rax)
34d0e: mov -bashxffffffff,%eax
34d13: retq
perf annotate before applying patch:
__GI___sigaction /usr/lib64/libc-2.22.so
lea -0x20(%rdi),%eax
cmp -bashx1,%eax
v jbe 10
v jmpq fffffffffffffdd0
nop
10: mov _DYNAMIC+0x2e8,%rax
movl -bashx16,%fs:(%rax)
mov -bashxffffffff,%eax
retq
perf annotate after applying patch:
__GI___sigaction /usr/lib64/libc-2.22.so
lea -0x20(%rdi),%eax
cmp -bashx1,%eax
v jbe 10
^ jmpq 34ac0 <__GI___libc_sigaction>
nop
10: mov _DYNAMIC+0x2e8,%rax
movl -bashx16,%fs:(%rax)
mov -bashxffffffff,%eax
retq
Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Chris Riyder <chris.ryder@arm.com>
Cc: Kim Phillips <kim.phillips@arm.com>
Cc: Markus Trippelsdorf <markus@trippelsdorf.de>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Taeung Song <treeze.taeung@gmail.com>
Cc: linuxppc-dev@lists.ozlabs.org
Link: http://lkml.kernel.org/r/1480953407-7605-3-git-send-email-ravi.bangoria@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-12-05 22:56:47 +07:00
|
|
|
s64 offset;
|
|
|
|
bool offset_avail;
|
2018-03-21 03:20:43 +07:00
|
|
|
bool outside;
|
2012-04-25 18:00:23 +07:00
|
|
|
} target;
|
2012-05-12 23:15:34 +07:00
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
char *raw;
|
|
|
|
char *name;
|
|
|
|
u64 addr;
|
|
|
|
} source;
|
|
|
|
struct {
|
2016-11-24 21:16:06 +07:00
|
|
|
struct ins ins;
|
2012-05-12 23:15:34 +07:00
|
|
|
struct ins_operands *ops;
|
|
|
|
} locked;
|
|
|
|
};
|
2012-04-21 00:38:46 +07:00
|
|
|
};
|
|
|
|
|
2016-11-17 01:39:50 +07:00
|
|
|
struct arch;
|
|
|
|
|
2012-04-18 23:58:34 +07:00
|
|
|
struct ins_ops {
|
2012-05-12 23:26:20 +07:00
|
|
|
void (*free)(struct ins_operands *ops);
|
2018-03-21 02:19:08 +07:00
|
|
|
int (*parse)(struct arch *arch, struct ins_operands *ops, struct map_symbol *ms);
|
2012-04-19 20:16:27 +07:00
|
|
|
int (*scnprintf)(struct ins *ins, char *bf, size_t size,
|
2012-05-08 04:54:16 +07:00
|
|
|
struct ins_operands *ops);
|
2012-04-18 23:58:34 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
bool ins__is_jump(const struct ins *ins);
|
2012-04-19 02:07:38 +07:00
|
|
|
bool ins__is_call(const struct ins *ins);
|
2016-06-24 18:53:58 +07:00
|
|
|
bool ins__is_ret(const struct ins *ins);
|
2017-07-07 12:06:35 +07:00
|
|
|
bool ins__is_lock(const struct ins *ins);
|
2012-05-08 04:54:16 +07:00
|
|
|
int ins__scnprintf(struct ins *ins, char *bf, size_t size, struct ins_operands *ops);
|
perf annotate: Check for fused instructions
Macro fusion merges two instructions to a single micro-op. Intel core
platform performs this hardware optimization under limited
circumstances.
For example, CMP + JCC can be "fused" and executed /retired together.
While with sampling this can result in the sample sometimes being on the
JCC and sometimes on the CMP. So for the fused instruction pair, they
could be considered together.
On Nehalem, fused instruction pairs:
cmp/test + jcc.
On other new CPU:
cmp/test/add/sub/and/inc/dec + jcc.
This patch adds an x86-specific function which checks if 2 instructions
are in a "fused" pair. For non-x86 arch, the function is just NULL.
Changelog:
v4: Move the CPU model checking to symbol__disassemble and save the CPU
family/model in arch structure.
It avoids checking every time when jump arrow printed.
v3: Add checking for Nehalem (CMP, TEST). For other newer Intel CPUs
just check it by default (CMP, TEST, ADD, SUB, AND, INC, DEC).
v2: Remove the original weak function. Arnaldo points out that doing it
as a weak function that will be overridden by the host arch doesn't
work. So now it's implemented as an arch-specific function.
Committer fix:
Do not access evsel->evlist->env->cpuid, ->env can be null, introduce
perf_evsel__env_cpuid(), just like perf_evsel__env_arch(), also used in
this function call.
The original patch was segfaulting 'perf top' + annotation.
But this essentially disables this fused instructions augmentation in
'perf top', the right thing is to get the cpuid from the running kernel,
left for a later patch tho.
Signed-off-by: Yao Jin <yao.jin@linux.intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1499403995-19857-2-git-send-email-yao.jin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2017-07-07 12:06:34 +07:00
|
|
|
bool ins__is_fused(struct arch *arch, const char *ins1, const char *ins2);
|
2012-04-18 23:58:34 +07:00
|
|
|
|
2018-03-15 20:26:17 +07:00
|
|
|
#define ANNOTATION__IPC_WIDTH 6
|
|
|
|
#define ANNOTATION__CYCLES_WIDTH 6
|
perf annotate: Create hotkey 'c' to show min/max cycles
In the 'perf annotate' view, a new hotkey 'c' is created for showing the
min/max cycles.
For example, when press 'c', the annotate view is:
Percent│ IPC Cycle(min/max)
│
│
│ Disassembly of section .text:
│
│ 000000000003aab0 <random@@GLIBC_2.2.5>:
8.22 │3.92 sub $0x18,%rsp
│3.92 mov $0x1,%esi
│3.92 xor %eax,%eax
│3.92 cmpl $0x0,argp_program_version_hook@@G
│3.92 1(2/1) ↓ je 20
│ lock cmpxchg %esi,__abort_msg@@GLIBC_P
│ ↓ jne 29
│ ↓ jmp 43
│1.10 20: cmpxchg %esi,__abort_msg@@GLIBC_PRIVATE+
8.93 │1.10 1(5/1) ↓ je 43
When press 'c' again, the annotate view is switched back:
Percent│ IPC Cycle
│
│
│ Disassembly of section .text:
│
│ 000000000003aab0 <random@@GLIBC_2.2.5>:
8.22 │3.92 sub $0x18,%rsp
│3.92 mov $0x1,%esi
│3.92 xor %eax,%eax
│3.92 cmpl $0x0,argp_program_version_hook@@GLIBC_2.2.5+0x
│3.92 1 ↓ je 20
│ lock cmpxchg %esi,__abort_msg@@GLIBC_PRIVATE+0x8a0
│ ↓ jne 29
│ ↓ jmp 43
│1.10 20: cmpxchg %esi,__abort_msg@@GLIBC_PRIVATE+0x8a0
8.93 │1.10 1 ↓ je 43
Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1526569118-14217-3-git-send-email-yao.jin@linux.intel.com
[ Rename all maxmin to minmax ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2018-05-17 21:58:38 +07:00
|
|
|
#define ANNOTATION__MINMAX_CYCLES_WIDTH 19
|
2018-03-15 20:26:17 +07:00
|
|
|
|
2018-03-15 20:03:34 +07:00
|
|
|
struct annotation_options {
|
|
|
|
bool hide_src_code,
|
|
|
|
use_offset,
|
|
|
|
jump_arrows,
|
2018-05-26 03:28:37 +07:00
|
|
|
print_lines,
|
|
|
|
full_path,
|
2018-03-15 20:03:34 +07:00
|
|
|
show_linenr,
|
|
|
|
show_nr_jumps,
|
|
|
|
show_nr_samples,
|
perf annotate: Create hotkey 'c' to show min/max cycles
In the 'perf annotate' view, a new hotkey 'c' is created for showing the
min/max cycles.
For example, when press 'c', the annotate view is:
Percent│ IPC Cycle(min/max)
│
│
│ Disassembly of section .text:
│
│ 000000000003aab0 <random@@GLIBC_2.2.5>:
8.22 │3.92 sub $0x18,%rsp
│3.92 mov $0x1,%esi
│3.92 xor %eax,%eax
│3.92 cmpl $0x0,argp_program_version_hook@@G
│3.92 1(2/1) ↓ je 20
│ lock cmpxchg %esi,__abort_msg@@GLIBC_P
│ ↓ jne 29
│ ↓ jmp 43
│1.10 20: cmpxchg %esi,__abort_msg@@GLIBC_PRIVATE+
8.93 │1.10 1(5/1) ↓ je 43
When press 'c' again, the annotate view is switched back:
Percent│ IPC Cycle
│
│
│ Disassembly of section .text:
│
│ 000000000003aab0 <random@@GLIBC_2.2.5>:
8.22 │3.92 sub $0x18,%rsp
│3.92 mov $0x1,%esi
│3.92 xor %eax,%eax
│3.92 cmpl $0x0,argp_program_version_hook@@GLIBC_2.2.5+0x
│3.92 1 ↓ je 20
│ lock cmpxchg %esi,__abort_msg@@GLIBC_PRIVATE+0x8a0
│ ↓ jne 29
│ ↓ jmp 43
│1.10 20: cmpxchg %esi,__abort_msg@@GLIBC_PRIVATE+0x8a0
8.93 │1.10 1 ↓ je 43
Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1526569118-14217-3-git-send-email-yao.jin@linux.intel.com
[ Rename all maxmin to minmax ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2018-05-17 21:58:38 +07:00
|
|
|
show_total_period,
|
2018-05-28 21:42:59 +07:00
|
|
|
show_minmax_cycle,
|
|
|
|
show_asm_raw,
|
|
|
|
annotate_src;
|
2018-04-11 20:30:03 +07:00
|
|
|
u8 offset_level;
|
2018-05-26 03:28:37 +07:00
|
|
|
int min_pcnt;
|
|
|
|
int max_lines;
|
|
|
|
int context;
|
2018-05-29 00:24:45 +07:00
|
|
|
const char *objdump_path;
|
2018-05-28 21:50:21 +07:00
|
|
|
const char *disassembler_style;
|
2018-08-04 20:05:13 +07:00
|
|
|
unsigned int percent_type;
|
2018-03-15 20:03:34 +07:00
|
|
|
};
|
|
|
|
|
2018-04-11 20:30:03 +07:00
|
|
|
enum {
|
|
|
|
ANNOTATION__OFFSET_JUMP_TARGETS = 1,
|
|
|
|
ANNOTATION__OFFSET_CALL,
|
|
|
|
ANNOTATION__MAX_OFFSET_LEVEL,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define ANNOTATION__MIN_OFFSET_LEVEL ANNOTATION__OFFSET_JUMP_TARGETS
|
|
|
|
|
2018-03-17 00:33:38 +07:00
|
|
|
extern struct annotation_options annotation__default_options;
|
|
|
|
|
2013-03-05 12:53:30 +07:00
|
|
|
struct annotation;
|
|
|
|
|
2017-10-11 22:01:39 +07:00
|
|
|
struct sym_hist_entry {
|
|
|
|
u64 nr_samples;
|
|
|
|
u64 period;
|
|
|
|
};
|
|
|
|
|
2018-08-04 20:05:09 +07:00
|
|
|
enum {
|
|
|
|
PERCENT_HITS_LOCAL,
|
2018-08-04 20:05:10 +07:00
|
|
|
PERCENT_HITS_GLOBAL,
|
2018-08-04 20:05:11 +07:00
|
|
|
PERCENT_PERIOD_LOCAL,
|
2018-08-04 20:05:12 +07:00
|
|
|
PERCENT_PERIOD_GLOBAL,
|
2018-08-04 20:05:09 +07:00
|
|
|
PERCENT_MAX,
|
|
|
|
};
|
|
|
|
|
2017-10-11 22:01:39 +07:00
|
|
|
struct annotation_data {
|
2018-08-04 20:05:09 +07:00
|
|
|
double percent[PERCENT_MAX];
|
2017-10-11 22:01:41 +07:00
|
|
|
double percent_sum;
|
2017-10-11 22:01:39 +07:00
|
|
|
struct sym_hist_entry he;
|
|
|
|
};
|
|
|
|
|
2017-10-11 22:01:25 +07:00
|
|
|
struct annotation_line {
|
|
|
|
struct list_head node;
|
2017-10-11 22:01:36 +07:00
|
|
|
struct rb_node rb_node;
|
2017-10-11 22:01:26 +07:00
|
|
|
s64 offset;
|
|
|
|
char *line;
|
|
|
|
int line_nr;
|
2018-03-16 01:31:56 +07:00
|
|
|
int jump_sources;
|
2017-10-11 22:01:27 +07:00
|
|
|
float ipc;
|
|
|
|
u64 cycles;
|
2018-05-17 21:58:37 +07:00
|
|
|
u64 cycles_max;
|
|
|
|
u64 cycles_min;
|
2017-10-11 22:01:37 +07:00
|
|
|
size_t privsize;
|
2017-10-11 22:01:41 +07:00
|
|
|
char *path;
|
2018-03-16 01:43:18 +07:00
|
|
|
u32 idx;
|
|
|
|
int idx_asm;
|
2018-08-04 20:05:05 +07:00
|
|
|
int data_nr;
|
|
|
|
struct annotation_data data[0];
|
2017-10-11 22:01:25 +07:00
|
|
|
};
|
|
|
|
|
2012-04-16 01:24:39 +07:00
|
|
|
struct disasm_line {
|
2017-10-11 22:01:25 +07:00
|
|
|
struct ins ins;
|
|
|
|
struct ins_operands ops;
|
2017-10-11 22:01:37 +07:00
|
|
|
|
|
|
|
/* This needs to be at the end. */
|
|
|
|
struct annotation_line al;
|
2011-02-04 18:45:46 +07:00
|
|
|
};
|
|
|
|
|
2018-08-04 20:05:09 +07:00
|
|
|
static inline double annotation_data__percent(struct annotation_data *data,
|
|
|
|
unsigned int which)
|
|
|
|
{
|
|
|
|
return which < PERCENT_MAX ? data->percent[which] : -1;
|
|
|
|
}
|
|
|
|
|
2017-10-11 22:01:37 +07:00
|
|
|
static inline struct disasm_line *disasm_line(struct annotation_line *al)
|
|
|
|
{
|
|
|
|
return al ? container_of(al, struct disasm_line, al) : NULL;
|
|
|
|
}
|
|
|
|
|
perf annotate: Add "_local" to jump/offset validation routines
Because they all really check if we can access data structures/visual
constructs where a "jump" instruction targets code in the same function,
i.e. things like:
__pthread_mutex_lock /usr/lib64/libpthread-2.26.so
1.95 │ mov __pthread_force_elision,%ecx
│ ┌──test %ecx,%ecx
0.07 │ ├──je 60
│ │ test $0x300,%esi
│ │↓ jne 60
│ │ or $0x100,%esi
│ │ mov %esi,0x10(%rdi)
│ 42:│ mov %esi,%edx
│ │ lea 0x16(%r8),%rsi
│ │ mov %r8,%rdi
│ │ and $0x80,%edx
│ │ add $0x8,%rsp
│ │→ jmpq __lll_lock_elision
│ │ nop
0.29 │ 60:└─→and $0x80,%esi
0.07 │ mov $0x1,%edi
0.29 │ xor %eax,%eax
2.53 │ lock cmpxchg %edi,(%r8)
And not things like that "jmpq __lll_lock_elision", that instead should behave
like a "call" instruction and "jump" to the disassembly of "___lll_lock_elision".
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-3cwx39u3h66dfw9xjrlt7ca2@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2018-03-23 20:12:33 +07:00
|
|
|
/*
|
|
|
|
* Is this offset in the same function as the line it is used?
|
|
|
|
* asm functions jump to other functions, for instance.
|
|
|
|
*/
|
|
|
|
static inline bool disasm_line__has_local_offset(const struct disasm_line *dl)
|
2012-04-26 00:16:03 +07:00
|
|
|
{
|
perf annotate: Add "_local" to jump/offset validation routines
Because they all really check if we can access data structures/visual
constructs where a "jump" instruction targets code in the same function,
i.e. things like:
__pthread_mutex_lock /usr/lib64/libpthread-2.26.so
1.95 │ mov __pthread_force_elision,%ecx
│ ┌──test %ecx,%ecx
0.07 │ ├──je 60
│ │ test $0x300,%esi
│ │↓ jne 60
│ │ or $0x100,%esi
│ │ mov %esi,0x10(%rdi)
│ 42:│ mov %esi,%edx
│ │ lea 0x16(%r8),%rsi
│ │ mov %r8,%rdi
│ │ and $0x80,%edx
│ │ add $0x8,%rsp
│ │→ jmpq __lll_lock_elision
│ │ nop
0.29 │ 60:└─→and $0x80,%esi
0.07 │ mov $0x1,%edi
0.29 │ xor %eax,%eax
2.53 │ lock cmpxchg %edi,(%r8)
And not things like that "jmpq __lll_lock_elision", that instead should behave
like a "call" instruction and "jump" to the disassembly of "___lll_lock_elision".
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-3cwx39u3h66dfw9xjrlt7ca2@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2018-03-23 20:12:33 +07:00
|
|
|
return dl->ops.target.offset_avail && !dl->ops.target.outside;
|
2012-04-26 00:16:03 +07:00
|
|
|
}
|
|
|
|
|
perf annotate: Add "_local" to jump/offset validation routines
Because they all really check if we can access data structures/visual
constructs where a "jump" instruction targets code in the same function,
i.e. things like:
__pthread_mutex_lock /usr/lib64/libpthread-2.26.so
1.95 │ mov __pthread_force_elision,%ecx
│ ┌──test %ecx,%ecx
0.07 │ ├──je 60
│ │ test $0x300,%esi
│ │↓ jne 60
│ │ or $0x100,%esi
│ │ mov %esi,0x10(%rdi)
│ 42:│ mov %esi,%edx
│ │ lea 0x16(%r8),%rsi
│ │ mov %r8,%rdi
│ │ and $0x80,%edx
│ │ add $0x8,%rsp
│ │→ jmpq __lll_lock_elision
│ │ nop
0.29 │ 60:└─→and $0x80,%esi
0.07 │ mov $0x1,%edi
0.29 │ xor %eax,%eax
2.53 │ lock cmpxchg %edi,(%r8)
And not things like that "jmpq __lll_lock_elision", that instead should behave
like a "call" instruction and "jump" to the disassembly of "___lll_lock_elision".
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-3cwx39u3h66dfw9xjrlt7ca2@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2018-03-23 20:12:33 +07:00
|
|
|
/*
|
|
|
|
* Can we draw an arrow from the jump to its target, for instance? I.e.
|
|
|
|
* is the jump and its target in the same function?
|
|
|
|
*/
|
|
|
|
bool disasm_line__is_valid_local_jump(struct disasm_line *dl, struct symbol *sym);
|
2018-03-16 01:31:56 +07:00
|
|
|
|
2012-04-16 01:24:39 +07:00
|
|
|
void disasm_line__free(struct disasm_line *dl);
|
2017-10-11 22:01:34 +07:00
|
|
|
struct annotation_line *
|
|
|
|
annotation_line__next(struct annotation_line *pos, struct list_head *head);
|
2018-03-16 03:04:53 +07:00
|
|
|
|
2018-03-16 09:14:51 +07:00
|
|
|
struct annotation_write_ops {
|
|
|
|
bool first_line, current_entry, change_color;
|
|
|
|
int width;
|
|
|
|
void *obj;
|
|
|
|
int (*set_color)(void *obj, int color);
|
|
|
|
void (*set_percent_color)(void *obj, double percent, bool current);
|
|
|
|
int (*set_jumps_percent_color)(void *obj, int nr, bool current);
|
|
|
|
void (*printf)(void *obj, const char *fmt, ...);
|
|
|
|
void (*write_graph)(void *obj, int graph);
|
|
|
|
};
|
|
|
|
|
2018-03-16 05:12:39 +07:00
|
|
|
void annotation_line__write(struct annotation_line *al, struct annotation *notes,
|
2018-03-16 09:14:51 +07:00
|
|
|
struct annotation_write_ops *ops);
|
2018-03-16 03:04:53 +07:00
|
|
|
|
2018-04-04 01:19:47 +07:00
|
|
|
int __annotation__scnprintf_samples_period(struct annotation *notes,
|
|
|
|
char *bf, size_t size,
|
|
|
|
struct perf_evsel *evsel,
|
|
|
|
bool show_freq);
|
|
|
|
|
2012-05-08 04:54:16 +07:00
|
|
|
int disasm_line__scnprintf(struct disasm_line *dl, char *bf, size_t size, bool raw);
|
2012-04-16 01:52:18 +07:00
|
|
|
size_t disasm__fprintf(struct list_head *head, FILE *fp);
|
2017-11-15 18:05:59 +07:00
|
|
|
void symbol__calc_percent(struct symbol *sym, struct perf_evsel *evsel);
|
2011-02-04 18:45:46 +07:00
|
|
|
|
|
|
|
struct sym_hist {
|
2017-07-20 04:36:51 +07:00
|
|
|
u64 nr_samples;
|
2017-07-21 03:18:05 +07:00
|
|
|
u64 period;
|
2017-07-20 04:36:45 +07:00
|
|
|
struct sym_hist_entry addr[0];
|
2011-02-04 18:45:46 +07:00
|
|
|
};
|
|
|
|
|
2015-07-18 22:24:48 +07:00
|
|
|
struct cyc_hist {
|
|
|
|
u64 start;
|
|
|
|
u64 cycles;
|
|
|
|
u64 cycles_aggr;
|
2018-05-17 21:58:37 +07:00
|
|
|
u64 cycles_max;
|
|
|
|
u64 cycles_min;
|
2015-07-18 22:24:48 +07:00
|
|
|
u32 num;
|
|
|
|
u32 num_aggr;
|
|
|
|
u8 have_start;
|
|
|
|
/* 1 byte padding */
|
|
|
|
u16 reset;
|
|
|
|
};
|
|
|
|
|
2011-02-08 22:27:39 +07:00
|
|
|
/** struct annotated_source - symbols with hits have this attached as in sannotation
|
2011-02-04 22:43:24 +07:00
|
|
|
*
|
2018-05-25 01:31:40 +07:00
|
|
|
* @histograms: Array of addr hit histograms per event being monitored
|
perf annotate: Add comment about annotated_src->nr_histograms
When we have multiple groups in an evlist, say:
$ perf stat -e '{cycles,instructions},{cache-references,cache-misses}' sleep 1
Performance counter stats for 'sleep 1':
343,134 cycles:u
249,292 instructions:u # 0.73 insn per cycle
15,556 cache-references:u
8,925 cache-misses:u # 57.373 % of all cache refs
1.000957550 seconds time elapsed
$
Then the perf_evsel instances for the two group leaders ("cycles" and
"cache-references") will have evsel->nr_members set to 2, while all the
evsel->evlist->nr_entries will be set to 4, so we can't use
evsel->evlist->nr_entries everywhere, as event groups need to be taken
into account.
But this probably requires us to audit at least the forced-group code,
where we want all of the events to be in a "group", to see them all in
the screen, one column for each, even knowing that they were not
necessarily scheduled to count at the same time by the kernel perf
subsystem.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-2g0vwqnc49wl4ttjk8dvpgcc@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2018-05-25 21:27:38 +07:00
|
|
|
* nr_histograms: This may not be the same as evsel->evlist->nr_entries if
|
|
|
|
* we have more than a group in a evlist, where we will want
|
|
|
|
* to see each group separately, that is why symbol__annotate2()
|
|
|
|
* sets src->nr_histograms to evsel->nr_members.
|
2011-02-08 22:27:39 +07:00
|
|
|
* @lines: If 'print_lines' is specified, per source code line percentages
|
2012-04-16 01:24:39 +07:00
|
|
|
* @source: source parsed from a disassembler like objdump -dS
|
2015-07-18 22:24:48 +07:00
|
|
|
* @cyc_hist: Average cycles per basic block
|
2011-02-04 22:43:24 +07:00
|
|
|
*
|
2011-02-08 22:27:39 +07:00
|
|
|
* lines is allocated, percentages calculated and all sorted by percentage
|
2011-02-04 22:43:24 +07:00
|
|
|
* when the annotation is about to be presented, so the percentages are for
|
|
|
|
* one of the entries in the histogram array, i.e. for the event/counter being
|
|
|
|
* presented. It is deallocated right after symbol__{tui,tty,etc}_annotate
|
|
|
|
* returns.
|
|
|
|
*/
|
2011-02-08 22:27:39 +07:00
|
|
|
struct annotated_source {
|
|
|
|
struct list_head source;
|
2011-02-06 23:54:44 +07:00
|
|
|
int nr_histograms;
|
2015-10-06 01:06:03 +07:00
|
|
|
size_t sizeof_sym_hist;
|
2015-07-18 22:24:48 +07:00
|
|
|
struct cyc_hist *cycles_hist;
|
2018-05-25 01:31:40 +07:00
|
|
|
struct sym_hist *histograms;
|
2011-02-08 22:27:39 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct annotation {
|
|
|
|
pthread_mutex_t lock;
|
perf annotate: Add branch stack / basic block
I wanted to know the hottest path through a function and figured the
branch-stack (LBR) information should be able to help out with that.
The below uses the branch-stack to create basic blocks and generate
statistics from them.
from to branch_i
* ----> *
|
| block
v
* ----> *
from to branch_i+1
The blocks are broken down into non-overlapping ranges, while tracking
if the start of each range is an entry point and/or the end of a range
is a branch.
Each block iterates all ranges it covers (while splitting where required
to exactly match the block) and increments the 'coverage' count.
For the range including the branch we increment the taken counter, as
well as the pred counter if flags.predicted.
Using these number we can find if an instruction:
- had coverage; given by:
br->coverage / br->sym->max_coverage
This metric ensures each symbol has a 100% spot, which reflects the
observation that each symbol must have a most covered/hottest
block.
- is a branch target: br->is_target && br->start == add
- for targets, how much of a branch's coverages comes from it:
target->entry / branch->coverage
- is a branch: br->is_branch && br->end == addr
- for branches, how often it was taken:
br->taken / br->coverage
after all, all execution that didn't take the branch would have
incremented the coverage and continued onward to a later branch.
- for branches, how often it was predicted:
br->pred / br->taken
The coverage percentage is used to color the address and asm sections;
for low (<1%) coverage we use NORMAL (uncolored), indicating that these
instructions are not 'important'. For high coverage (>75%) we color the
address RED.
For each branch, we add an asm comment after the instruction with
information on how often it was taken and predicted.
Output looks like (sans color, which does loose a lot of the
information :/)
$ perf record --branch-filter u,any -e cycles:p ./branches 27
$ perf annotate branches
Percent | Source code & Disassembly of branches for cycles:pu (217 samples)
---------------------------------------------------------------------------------
: branches():
0.00 : 40057a: push %rbp
0.00 : 40057b: mov %rsp,%rbp
0.00 : 40057e: sub $0x20,%rsp
0.00 : 400582: mov %rdi,-0x18(%rbp)
0.00 : 400586: mov %rsi,-0x20(%rbp)
0.00 : 40058a: mov -0x18(%rbp),%rax
0.00 : 40058e: mov %rax,-0x10(%rbp)
0.00 : 400592: movq $0x0,-0x8(%rbp)
0.00 : 40059a: jmpq 400656 <branches+0xdc>
1.84 : 40059f: mov -0x10(%rbp),%rax # +100.00%
3.23 : 4005a3: and $0x1,%eax
1.84 : 4005a6: test %rax,%rax
0.00 : 4005a9: je 4005bf <branches+0x45> # -54.50% (p:42.00%)
0.46 : 4005ab: mov 0x200bbe(%rip),%rax # 601170 <acc>
12.90 : 4005b2: add $0x1,%rax
2.30 : 4005b6: mov %rax,0x200bb3(%rip) # 601170 <acc>
0.46 : 4005bd: jmp 4005d1 <branches+0x57> # -100.00% (p:100.00%)
0.92 : 4005bf: mov 0x200baa(%rip),%rax # 601170 <acc> # +49.54%
13.82 : 4005c6: sub $0x1,%rax
0.46 : 4005ca: mov %rax,0x200b9f(%rip) # 601170 <acc>
2.30 : 4005d1: mov -0x10(%rbp),%rax # +50.46%
0.46 : 4005d5: mov %rax,%rdi
0.46 : 4005d8: callq 400526 <lfsr> # -100.00% (p:100.00%)
0.00 : 4005dd: mov %rax,-0x10(%rbp) # +100.00%
0.92 : 4005e1: mov -0x18(%rbp),%rax
0.00 : 4005e5: and $0x1,%eax
0.00 : 4005e8: test %rax,%rax
0.00 : 4005eb: je 4005ff <branches+0x85> # -100.00% (p:100.00%)
0.00 : 4005ed: mov 0x200b7c(%rip),%rax # 601170 <acc>
0.00 : 4005f4: shr $0x2,%rax
0.00 : 4005f8: mov %rax,0x200b71(%rip) # 601170 <acc>
0.00 : 4005ff: mov -0x10(%rbp),%rax # +100.00%
7.37 : 400603: and $0x1,%eax
3.69 : 400606: test %rax,%rax
0.00 : 400609: jne 400612 <branches+0x98> # -59.25% (p:42.99%)
1.84 : 40060b: mov $0x1,%eax
14.29 : 400610: jmp 400617 <branches+0x9d> # -100.00% (p:100.00%)
1.38 : 400612: mov $0x0,%eax # +57.65%
10.14 : 400617: test %al,%al # +42.35%
0.00 : 400619: je 40062f <branches+0xb5> # -57.65% (p:100.00%)
0.46 : 40061b: mov 0x200b4e(%rip),%rax # 601170 <acc>
2.76 : 400622: sub $0x1,%rax
0.00 : 400626: mov %rax,0x200b43(%rip) # 601170 <acc>
0.46 : 40062d: jmp 400641 <branches+0xc7> # -100.00% (p:100.00%)
0.92 : 40062f: mov 0x200b3a(%rip),%rax # 601170 <acc> # +56.13%
2.30 : 400636: add $0x1,%rax
0.92 : 40063a: mov %rax,0x200b2f(%rip) # 601170 <acc>
0.92 : 400641: mov -0x10(%rbp),%rax # +43.87%
2.30 : 400645: mov %rax,%rdi
0.00 : 400648: callq 400526 <lfsr> # -100.00% (p:100.00%)
0.00 : 40064d: mov %rax,-0x10(%rbp) # +100.00%
1.84 : 400651: addq $0x1,-0x8(%rbp)
0.92 : 400656: mov -0x8(%rbp),%rax
5.07 : 40065a: cmp -0x20(%rbp),%rax
0.00 : 40065e: jb 40059f <branches+0x25> # -100.00% (p:100.00%)
0.00 : 400664: nop
0.00 : 400665: leaveq
0.00 : 400666: retq
(Note: the --branch-filter u,any was used to avoid spurious target and
branch points due to interrupts/faults, they show up as very small -/+
annotations on 'weird' locations)
Committer note:
Please take a look at:
http://vger.kernel.org/~acme/perf/annotate_basic_blocks.png
To see the colors.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Anshuman Khandual <khandual@linux.vnet.ibm.com>
Cc: David Carrillo-Cisneros <davidcc@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
[ Moved sym->max_coverage to 'struct annotate', aka symbol__annotate(sym) ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-09-06 02:08:12 +07:00
|
|
|
u64 max_coverage;
|
2018-03-16 01:46:22 +07:00
|
|
|
u64 start;
|
2018-03-15 22:33:56 +07:00
|
|
|
struct annotation_options *options;
|
2018-03-15 20:47:54 +07:00
|
|
|
struct annotation_line **offsets;
|
2018-03-15 21:52:32 +07:00
|
|
|
int nr_events;
|
2018-03-16 01:20:12 +07:00
|
|
|
int nr_jumps;
|
2018-03-16 01:10:28 +07:00
|
|
|
int max_jump_sources;
|
2018-03-16 01:52:33 +07:00
|
|
|
int nr_entries;
|
|
|
|
int nr_asm_entries;
|
2018-03-16 01:59:01 +07:00
|
|
|
u16 max_line_len;
|
2018-03-16 02:18:21 +07:00
|
|
|
struct {
|
|
|
|
u8 addr;
|
|
|
|
u8 jumps;
|
|
|
|
u8 target;
|
|
|
|
u8 min_addr;
|
|
|
|
u8 max_addr;
|
|
|
|
} widths;
|
2018-03-15 20:35:04 +07:00
|
|
|
bool have_cycles;
|
2011-02-08 22:27:39 +07:00
|
|
|
struct annotated_source *src;
|
2011-02-04 18:45:46 +07:00
|
|
|
};
|
|
|
|
|
2018-03-15 20:35:04 +07:00
|
|
|
static inline int annotation__cycles_width(struct annotation *notes)
|
|
|
|
{
|
perf annotate: Create hotkey 'c' to show min/max cycles
In the 'perf annotate' view, a new hotkey 'c' is created for showing the
min/max cycles.
For example, when press 'c', the annotate view is:
Percent│ IPC Cycle(min/max)
│
│
│ Disassembly of section .text:
│
│ 000000000003aab0 <random@@GLIBC_2.2.5>:
8.22 │3.92 sub $0x18,%rsp
│3.92 mov $0x1,%esi
│3.92 xor %eax,%eax
│3.92 cmpl $0x0,argp_program_version_hook@@G
│3.92 1(2/1) ↓ je 20
│ lock cmpxchg %esi,__abort_msg@@GLIBC_P
│ ↓ jne 29
│ ↓ jmp 43
│1.10 20: cmpxchg %esi,__abort_msg@@GLIBC_PRIVATE+
8.93 │1.10 1(5/1) ↓ je 43
When press 'c' again, the annotate view is switched back:
Percent│ IPC Cycle
│
│
│ Disassembly of section .text:
│
│ 000000000003aab0 <random@@GLIBC_2.2.5>:
8.22 │3.92 sub $0x18,%rsp
│3.92 mov $0x1,%esi
│3.92 xor %eax,%eax
│3.92 cmpl $0x0,argp_program_version_hook@@GLIBC_2.2.5+0x
│3.92 1 ↓ je 20
│ lock cmpxchg %esi,__abort_msg@@GLIBC_PRIVATE+0x8a0
│ ↓ jne 29
│ ↓ jmp 43
│1.10 20: cmpxchg %esi,__abort_msg@@GLIBC_PRIVATE+0x8a0
8.93 │1.10 1 ↓ je 43
Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1526569118-14217-3-git-send-email-yao.jin@linux.intel.com
[ Rename all maxmin to minmax ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2018-05-17 21:58:38 +07:00
|
|
|
if (notes->have_cycles && notes->options->show_minmax_cycle)
|
|
|
|
return ANNOTATION__IPC_WIDTH + ANNOTATION__MINMAX_CYCLES_WIDTH;
|
|
|
|
|
2018-03-15 20:35:04 +07:00
|
|
|
return notes->have_cycles ? ANNOTATION__IPC_WIDTH + ANNOTATION__CYCLES_WIDTH : 0;
|
|
|
|
}
|
|
|
|
|
2018-03-15 22:41:39 +07:00
|
|
|
static inline int annotation__pcnt_width(struct annotation *notes)
|
|
|
|
{
|
|
|
|
return (notes->options->show_total_period ? 12 : 7) * notes->nr_events;
|
|
|
|
}
|
|
|
|
|
2018-03-16 20:39:24 +07:00
|
|
|
static inline bool annotation_line__filter(struct annotation_line *al, struct annotation *notes)
|
|
|
|
{
|
|
|
|
return notes->options->hide_src_code && al->offset == -1;
|
|
|
|
}
|
2018-03-16 01:59:01 +07:00
|
|
|
|
|
|
|
void annotation__set_offsets(struct annotation *notes, s64 size);
|
2018-03-15 21:46:23 +07:00
|
|
|
void annotation__compute_ipc(struct annotation *notes, size_t size);
|
2018-03-16 01:31:56 +07:00
|
|
|
void annotation__mark_jump_targets(struct annotation *notes, struct symbol *sym);
|
2018-03-16 02:19:59 +07:00
|
|
|
void annotation__update_column_widths(struct annotation *notes);
|
2018-03-16 02:26:29 +07:00
|
|
|
void annotation__init_column_widths(struct annotation *notes, struct symbol *sym);
|
2018-03-15 21:46:23 +07:00
|
|
|
|
2018-05-25 02:28:29 +07:00
|
|
|
static inline struct sym_hist *annotated_source__histogram(struct annotated_source *src, int idx)
|
|
|
|
{
|
|
|
|
return ((void *)src->histograms) + (src->sizeof_sym_hist * idx);
|
|
|
|
}
|
|
|
|
|
2011-02-04 22:43:24 +07:00
|
|
|
static inline struct sym_hist *annotation__histogram(struct annotation *notes, int idx)
|
|
|
|
{
|
2018-05-25 02:28:29 +07:00
|
|
|
return annotated_source__histogram(notes->src, idx);
|
2011-02-04 22:43:24 +07:00
|
|
|
}
|
|
|
|
|
2011-02-04 18:45:46 +07:00
|
|
|
static inline struct annotation *symbol__annotation(struct symbol *sym)
|
|
|
|
{
|
2015-01-14 18:18:05 +07:00
|
|
|
return (void *)sym - symbol_conf.priv_size;
|
2011-02-04 18:45:46 +07:00
|
|
|
}
|
|
|
|
|
2017-07-21 02:28:53 +07:00
|
|
|
int addr_map_symbol__inc_samples(struct addr_map_symbol *ams, struct perf_sample *sample,
|
2018-05-24 22:05:39 +07:00
|
|
|
struct perf_evsel *evsel);
|
2013-12-19 02:48:29 +07:00
|
|
|
|
2015-07-18 22:24:48 +07:00
|
|
|
int addr_map_symbol__account_cycles(struct addr_map_symbol *ams,
|
|
|
|
struct addr_map_symbol *start,
|
|
|
|
unsigned cycles);
|
|
|
|
|
2017-07-21 02:28:53 +07:00
|
|
|
int hist_entry__inc_addr_samples(struct hist_entry *he, struct perf_sample *sample,
|
2018-05-24 22:05:39 +07:00
|
|
|
struct perf_evsel *evsel, u64 addr);
|
2013-12-19 03:10:15 +07:00
|
|
|
|
2018-05-25 03:33:18 +07:00
|
|
|
struct annotated_source *symbol__hists(struct symbol *sym, int nr_hists);
|
2011-02-06 23:54:44 +07:00
|
|
|
void symbol__annotate_zero_histograms(struct symbol *sym);
|
2011-02-04 18:45:46 +07:00
|
|
|
|
2017-10-11 22:01:28 +07:00
|
|
|
int symbol__annotate(struct symbol *sym, struct map *map,
|
2017-10-11 22:01:33 +07:00
|
|
|
struct perf_evsel *evsel, size_t privsize,
|
2018-05-28 21:27:40 +07:00
|
|
|
struct annotation_options *options,
|
2017-12-11 22:46:11 +07:00
|
|
|
struct arch **parch);
|
2018-03-16 02:54:11 +07:00
|
|
|
int symbol__annotate2(struct symbol *sym, struct map *map,
|
|
|
|
struct perf_evsel *evsel,
|
|
|
|
struct annotation_options *options,
|
|
|
|
struct arch **parch);
|
2013-12-19 03:10:15 +07:00
|
|
|
|
2016-07-30 02:27:18 +07:00
|
|
|
enum symbol_disassemble_errno {
|
|
|
|
SYMBOL_ANNOTATE_ERRNO__SUCCESS = 0,
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Choose an arbitrary negative big number not to clash with standard
|
|
|
|
* errno since SUS requires the errno has distinct positive values.
|
|
|
|
* See 'Issue 6' in the link below.
|
|
|
|
*
|
|
|
|
* http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html
|
|
|
|
*/
|
|
|
|
__SYMBOL_ANNOTATE_ERRNO__START = -10000,
|
|
|
|
|
|
|
|
SYMBOL_ANNOTATE_ERRNO__NO_VMLINUX = __SYMBOL_ANNOTATE_ERRNO__START,
|
|
|
|
|
|
|
|
__SYMBOL_ANNOTATE_ERRNO__END,
|
|
|
|
};
|
|
|
|
|
|
|
|
int symbol__strerror_disassemble(struct symbol *sym, struct map *map,
|
|
|
|
int errnum, char *buf, size_t buflen);
|
|
|
|
|
2013-03-05 12:53:21 +07:00
|
|
|
int symbol__annotate_printf(struct symbol *sym, struct map *map,
|
2018-05-26 03:28:37 +07:00
|
|
|
struct perf_evsel *evsel,
|
|
|
|
struct annotation_options *options);
|
2011-02-06 23:54:44 +07:00
|
|
|
void symbol__annotate_zero_histogram(struct symbol *sym, int evidx);
|
2011-02-08 22:27:39 +07:00
|
|
|
void symbol__annotate_decay_histogram(struct symbol *sym, int evidx);
|
2017-10-11 22:01:38 +07:00
|
|
|
void annotated_source__purge(struct annotated_source *as);
|
2011-02-04 18:45:46 +07:00
|
|
|
|
perf annotate browser: Add 'P' hotkey to dump annotation to file
Just like we have in the histograms browser used as the main screen for
'perf top --tui' and 'perf report --tui', to print the current
annotation to a file with a named composed by the symbol name and the
".annotation" suffix.
Here is one example of pressing 'A' on 'perf top' to live annotate a
kernel function and then press 'P' to dump that annotation, the
resulting file:
# cat _raw_spin_lock_irqsave.annotation
_raw_spin_lock_irqsave() /proc/kcore
Event: cycles:ppp
7.14 nop
21.43 push %rbx
7.14 pushfq
pop %rax
nop
mov %rax,%rbx
cli
nop
xor %eax,%eax
mov $0x1,%edx
64.29 lock cmpxchg %edx,(%rdi)
test %eax,%eax
↓ jne 2b
mov %rbx,%rax
pop %rbx
← retq
2b: mov %eax,%esi
→ callq queued_spin_lock_slowpath
mov %rbx,%rax
pop %rbx
← retq
#
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-zzmnrwugb5vtk7bvg0rbx150@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2018-03-17 02:57:47 +07:00
|
|
|
int map_symbol__annotation_dump(struct map_symbol *ms, struct perf_evsel *evsel);
|
|
|
|
|
2014-02-20 08:32:53 +07:00
|
|
|
bool ui__has_annotation(void);
|
|
|
|
|
2013-03-05 12:53:21 +07:00
|
|
|
int symbol__tty_annotate(struct symbol *sym, struct map *map,
|
2018-05-26 03:28:37 +07:00
|
|
|
struct perf_evsel *evsel, struct annotation_options *opts);
|
2011-02-04 18:45:46 +07:00
|
|
|
|
2018-03-16 09:44:34 +07:00
|
|
|
int symbol__tty_annotate2(struct symbol *sym, struct map *map,
|
2018-05-26 03:28:37 +07:00
|
|
|
struct perf_evsel *evsel, struct annotation_options *opts);
|
2018-03-16 09:44:34 +07:00
|
|
|
|
2013-09-30 17:07:11 +07:00
|
|
|
#ifdef HAVE_SLANG_SUPPORT
|
2013-03-05 12:53:21 +07:00
|
|
|
int symbol__tui_annotate(struct symbol *sym, struct map *map,
|
|
|
|
struct perf_evsel *evsel,
|
2018-05-28 23:54:59 +07:00
|
|
|
struct hist_browser_timer *hbt,
|
|
|
|
struct annotation_options *opts);
|
2012-09-28 16:32:02 +07:00
|
|
|
#else
|
2012-09-11 05:15:03 +07:00
|
|
|
static inline int symbol__tui_annotate(struct symbol *sym __maybe_unused,
|
2013-03-05 12:53:21 +07:00
|
|
|
struct map *map __maybe_unused,
|
|
|
|
struct perf_evsel *evsel __maybe_unused,
|
2018-05-28 23:54:59 +07:00
|
|
|
struct hist_browser_timer *hbt __maybe_unused,
|
|
|
|
struct annotation_options *opts __maybe_unused)
|
2011-02-04 18:45:46 +07:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-03-17 00:33:38 +07:00
|
|
|
void annotation_config__init(void);
|
|
|
|
|
2011-02-04 18:45:46 +07:00
|
|
|
#endif /* __PERF_ANNOTATE_H */
|