mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-30 22:03:17 +01:00
perf script: Show branch speculation info
Show the branch speculation info if provided by the branch recording hardware feature. This can be useful for optimizing code further. The speculation info is appended to the end of the list of fields so any existing tools that use "/" as a delimiter for access fields via an index remain unaffected. Also show "-" instead of "N/A" when speculation info is unavailable because "/" is used as the field separator. E.g. $ perf record -j any,u,save_type ./test_branch $ perf script --fields brstacksym Before: [...] check_match+0x60/strcmp+0x0/P/-/-/0/CALL do_lookup_x+0x3c5/check_match+0x0/P/-/-/0/CALL [...] After: [...] check_match+0x60/strcmp+0x0/P/-/-/0/CALL/NON_SPEC_CORRECT_PATH do_lookup_x+0x3c5/check_match+0x0/P/-/-/0/CALL/NON_SPEC_CORRECT_PATH [...] The bitfield swapping scheme used duing sample parsing has changed because of the addition of new branch flags, namely "spec", "new_type" and "priv". Earlier, these were all part of the "reserved" field but now, each of these fields get swapped separately. Change the expected flag values accordingly for the test to pass. E.g. $ perf test -v 27 Before: 27: Sample parsing : --- start --- test child forked, pid 61979 parsing failed for sample_type 0x800 test child finished with -1 ---- end ---- Sample parsing: FAILED! After: 27: Sample parsing : --- start --- test child forked, pid 63293 test child finished with 0 ---- end ---- Sample parsing: Ok Signed-off-by: Sandipan Das <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Ananth Narayan <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: James Clark <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kajol Jain <[email protected]> Cc: Madhavan Srinivasan <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Ravi Bangoria <[email protected]> Cc: Santosh Shukla <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Thomas Richter <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/56e272583552526e999ba0b536ac009ae3613966.1675333809.git.sandipan.das@amd.com Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
This commit is contained in:
1 parent
79b7ca7802
commit
6ade6c6460
5 files changed
+33
-6
No files matched your search
@@ -889,12 +889,13 @@ mispred_str(struct branch_entry *br)
|
||||
|
||||
static int print_bstack_flags(FILE *fp, struct branch_entry *br)
|
||||
{
|
||||
return fprintf(fp, "/%c/%c/%c/%d/%s ",
|
||||
return fprintf(fp, "/%c/%c/%c/%d/%s/%s ",
|
||||
mispred_str(br),
|
||||
br->flags.in_tx ? 'X' : '-',
|
||||
br->flags.abort ? 'A' : '-',
|
||||
br->flags.cycles,
|
||||
get_branch_type(br));
|
||||
get_branch_type(br),
|
||||
br->flags.spec ? branch_spec_desc(br->flags.spec) : "-");
|
||||
}
|
||||
|
||||
static int perf_sample__fprintf_brstack(struct perf_sample *sample,
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
* in branch_stack variable.
|
||||
*/
|
||||
#define BS_EXPECTED_BE 0xa000d00000000000
|
||||
#define BS_EXPECTED_LE 0xd5000000
|
||||
#define BS_EXPECTED_LE 0x1aa00000000
|
||||
#define FLAG(s) s->branch_stack->entries[i].flags
|
||||
|
||||
static bool samples_same(const struct perf_sample *s1,
|
||||
|
||||
@@ -212,3 +212,18 @@ int branch_type_str(struct branch_type_stat *st, char *bf, int size)
|
||||
|
||||
return printed;
|
||||
}
|
||||
|
||||
const char *branch_spec_desc(int spec)
|
||||
{
|
||||
const char *branch_spec_outcomes[PERF_BR_SPEC_MAX] = {
|
||||
"N/A",
|
||||
"SPEC_WRONG_PATH",
|
||||
"NON_SPEC_CORRECT_PATH",
|
||||
"SPEC_CORRECT_PATH",
|
||||
};
|
||||
|
||||
if (spec >= 0 && spec < PERF_BR_SPEC_MAX)
|
||||
return branch_spec_outcomes[spec];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -89,4 +89,6 @@ const char *get_branch_type(struct branch_entry *e);
|
||||
void branch_type_stat_display(FILE *fp, struct branch_type_stat *st);
|
||||
int branch_type_str(struct branch_type_stat *st, char *bf, int bfsize);
|
||||
|
||||
const char *branch_spec_desc(int spec);
|
||||
|
||||
#endif /* _PERF_BRANCH_H */
|
||||
+12
-3
@@ -2319,7 +2319,10 @@ u64 evsel__bitfield_swap_branch_flags(u64 value)
|
||||
* abort:1 //transaction abort
|
||||
* cycles:16 //cycle count to last branch
|
||||
* type:4 //branch type
|
||||
* reserved:40
|
||||
* spec:2 //branch speculation info
|
||||
* new_type:4 //additional branch type
|
||||
* priv:3 //privilege level
|
||||
* reserved:31
|
||||
* }
|
||||
* }
|
||||
*
|
||||
@@ -2335,7 +2338,10 @@ u64 evsel__bitfield_swap_branch_flags(u64 value)
|
||||
new_val |= bitfield_swap(value, 3, 1);
|
||||
new_val |= bitfield_swap(value, 4, 16);
|
||||
new_val |= bitfield_swap(value, 20, 4);
|
||||
new_val |= bitfield_swap(value, 24, 40);
|
||||
new_val |= bitfield_swap(value, 24, 2);
|
||||
new_val |= bitfield_swap(value, 26, 4);
|
||||
new_val |= bitfield_swap(value, 30, 3);
|
||||
new_val |= bitfield_swap(value, 33, 31);
|
||||
} else {
|
||||
new_val = bitfield_swap(value, 63, 1);
|
||||
new_val |= bitfield_swap(value, 62, 1);
|
||||
@@ -2343,7 +2349,10 @@ u64 evsel__bitfield_swap_branch_flags(u64 value)
|
||||
new_val |= bitfield_swap(value, 60, 1);
|
||||
new_val |= bitfield_swap(value, 44, 16);
|
||||
new_val |= bitfield_swap(value, 40, 4);
|
||||
new_val |= bitfield_swap(value, 0, 40);
|
||||
new_val |= bitfield_swap(value, 38, 2);
|
||||
new_val |= bitfield_swap(value, 34, 4);
|
||||
new_val |= bitfield_swap(value, 31, 3);
|
||||
new_val |= bitfield_swap(value, 0, 31);
|
||||
}
|
||||
|
||||
return new_val;
|
||||
|
||||
Reference in new issue
Block a user