diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-03-23 09:12:33 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-03-23 15:46:16 -0400 |
commit | 2eff061162819e00ec6379874ceb47caef17bcba (patch) | |
tree | 426ed44394a1a74c1e7be3a9b905afd3e46678e9 /tools/perf | |
parent | 83428f2fad48e16fddff0cb445cb4fedf5afe4ab (diff) |
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>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/ui/browsers/annotate.c | 2 | ||||
-rw-r--r-- | tools/perf/util/annotate.c | 9 | ||||
-rw-r--r-- | tools/perf/util/annotate.h | 14 |
3 files changed, 16 insertions, 9 deletions
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index 3834b264ba41..d77896a99570 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c | |||
@@ -155,7 +155,7 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser) | |||
155 | if (strstr(sym->name, "@plt")) | 155 | if (strstr(sym->name, "@plt")) |
156 | return; | 156 | return; |
157 | 157 | ||
158 | if (!disasm_line__is_valid_jump(cursor, sym)) | 158 | if (!disasm_line__is_valid_local_jump(cursor, sym)) |
159 | return; | 159 | return; |
160 | 160 | ||
161 | /* | 161 | /* |
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index c299881c640a..9524f322f597 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c | |||
@@ -1409,7 +1409,7 @@ static int symbol__parse_objdump_line(struct symbol *sym, FILE *file, | |||
1409 | if (dl == NULL) | 1409 | if (dl == NULL) |
1410 | return -1; | 1410 | return -1; |
1411 | 1411 | ||
1412 | if (!disasm_line__has_offset(dl)) { | 1412 | if (!disasm_line__has_local_offset(dl)) { |
1413 | dl->ops.target.offset = dl->ops.target.addr - | 1413 | dl->ops.target.offset = dl->ops.target.addr - |
1414 | map__rip_2objdump(map, sym->start); | 1414 | map__rip_2objdump(map, sym->start); |
1415 | dl->ops.target.offset_avail = true; | 1415 | dl->ops.target.offset_avail = true; |
@@ -2176,11 +2176,10 @@ size_t disasm__fprintf(struct list_head *head, FILE *fp) | |||
2176 | return printed; | 2176 | return printed; |
2177 | } | 2177 | } |
2178 | 2178 | ||
2179 | 2179 | bool disasm_line__is_valid_local_jump(struct disasm_line *dl, struct symbol *sym) | |
2180 | bool disasm_line__is_valid_jump(struct disasm_line *dl, struct symbol *sym) | ||
2181 | { | 2180 | { |
2182 | if (!dl || !dl->ins.ops || !ins__is_jump(&dl->ins) || | 2181 | if (!dl || !dl->ins.ops || !ins__is_jump(&dl->ins) || |
2183 | !disasm_line__has_offset(dl) || dl->ops.target.offset < 0 || | 2182 | !disasm_line__has_local_offset(dl) || dl->ops.target.offset < 0 || |
2184 | dl->ops.target.offset >= (s64)symbol__size(sym)) | 2183 | dl->ops.target.offset >= (s64)symbol__size(sym)) |
2185 | return false; | 2184 | return false; |
2186 | 2185 | ||
@@ -2201,7 +2200,7 @@ void annotation__mark_jump_targets(struct annotation *notes, struct symbol *sym) | |||
2201 | 2200 | ||
2202 | dl = disasm_line(al); | 2201 | dl = disasm_line(al); |
2203 | 2202 | ||
2204 | if (!disasm_line__is_valid_jump(dl, sym)) | 2203 | if (!disasm_line__is_valid_local_jump(dl, sym)) |
2205 | continue; | 2204 | continue; |
2206 | 2205 | ||
2207 | al = notes->offsets[dl->ops.target.offset]; | 2206 | al = notes->offsets[dl->ops.target.offset]; |
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index ad8baafaf9f9..ff7e3df31efa 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h | |||
@@ -117,12 +117,20 @@ static inline struct disasm_line *disasm_line(struct annotation_line *al) | |||
117 | return al ? container_of(al, struct disasm_line, al) : NULL; | 117 | return al ? container_of(al, struct disasm_line, al) : NULL; |
118 | } | 118 | } |
119 | 119 | ||
120 | static inline bool disasm_line__has_offset(const struct disasm_line *dl) | 120 | /* |
121 | * Is this offset in the same function as the line it is used? | ||
122 | * asm functions jump to other functions, for instance. | ||
123 | */ | ||
124 | static inline bool disasm_line__has_local_offset(const struct disasm_line *dl) | ||
121 | { | 125 | { |
122 | return dl->ops.target.offset_avail; | 126 | return dl->ops.target.offset_avail && !dl->ops.target.outside; |
123 | } | 127 | } |
124 | 128 | ||
125 | bool disasm_line__is_valid_jump(struct disasm_line *dl, struct symbol *sym); | 129 | /* |
130 | * Can we draw an arrow from the jump to its target, for instance? I.e. | ||
131 | * is the jump and its target in the same function? | ||
132 | */ | ||
133 | bool disasm_line__is_valid_local_jump(struct disasm_line *dl, struct symbol *sym); | ||
126 | 134 | ||
127 | void disasm_line__free(struct disasm_line *dl); | 135 | void disasm_line__free(struct disasm_line *dl); |
128 | struct annotation_line * | 136 | struct annotation_line * |