Commit a3397d69 authored by Namhyung Kim's avatar Namhyung Kim

perf annotate-data: Parse 'lock' prefix from llvm-objdump

For the performance reason, I prefer llvm-objdump over GNU's.  But I
found that llvm-objdump puts x86 lock prefix in a separate line like
below.

  ffffffff81000695: f0                    lock
  ffffffff81000696: ff 83 54 0b 00 00     incl    2900(%rbx)

This should be parsed properly, but I just changed to find the insn
with next offset for now.

This improves the statistics as it can process more instructions.

  Annotate data type stats:
  total 294, ok 144 (49.0%), bad 150 (51.0%)
  -----------------------------------------------------------
          30 : no_sym
          35 : no_mem_ops
          71 : no_var
           6 : no_typeinfo
           8 : bad_offset
Reviewed-by: default avatarIan Rogers <irogers@google.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Link: https://lore.kernel.org/r/20240117062657.985479-2-namhyung@kernel.orgSigned-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
parent 8462247f
...@@ -3660,9 +3660,18 @@ static struct disasm_line *find_disasm_line(struct symbol *sym, u64 ip) ...@@ -3660,9 +3660,18 @@ static struct disasm_line *find_disasm_line(struct symbol *sym, u64 ip)
notes = symbol__annotation(sym); notes = symbol__annotation(sym);
list_for_each_entry(dl, &notes->src->source, al.node) { list_for_each_entry(dl, &notes->src->source, al.node) {
if (sym->start + dl->al.offset == ip) if (sym->start + dl->al.offset == ip) {
/*
* llvm-objdump places "lock" in a separate line and
* in that case, we want to get the next line.
*/
if (!strcmp(dl->ins.name, "lock") && *dl->ops.raw == '\0') {
ip++;
continue;
}
return dl; return dl;
} }
}
return NULL; return NULL;
} }
...@@ -3758,6 +3767,9 @@ struct annotated_data_type *hist_entry__get_data_type(struct hist_entry *he) ...@@ -3758,6 +3767,9 @@ struct annotated_data_type *hist_entry__get_data_type(struct hist_entry *he)
if (!op_loc->mem_ref) if (!op_loc->mem_ref)
continue; continue;
/* Recalculate IP since it can be changed due to LOCK prefix */
ip = ms->sym->start + dl->al.offset;
mem_type = find_data_type(ms, ip, op_loc->reg, op_loc->offset); mem_type = find_data_type(ms, ip, op_loc->reg, op_loc->offset);
if (mem_type) if (mem_type)
istat->good++; istat->good++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment