Skip to content

Commit 8ad24cd

Browse files
Dapeng Mivijay-suman
authored andcommitted
perf/x86/intel: Allow to update user space GPRs from PEBS records
commit 71dcc11c2cd9e434c34a63154ecadca21c135ddd upstream. Currently when a user samples user space GPRs (--user-regs option) with PEBS, the user space GPRs actually always come from software PMI instead of from PEBS hardware. This leads to the sampled GPRs to possibly be inaccurate for single PEBS record case because of the skid between counter overflow and GPRs sampling on PMI. For the large PEBS case, it is even worse. If user sets the exclude_kernel attribute, large PEBS would be used to sample user space GPRs, but since PEBS GPRs group is not really enabled, it leads to all samples in the large PEBS record to share the same piece of user space GPRs, like this reproducer shows: $ perf record -e branches:pu --user-regs=ip,ax -c 100000 ./foo $ perf report -D | grep "AX" .... AX 0x000000003a0d4ead .... AX 0x000000003a0d4ead .... AX 0x000000003a0d4ead .... AX 0x000000003a0d4ead .... AX 0x000000003a0d4ead .... AX 0x000000003a0d4ead .... AX 0x000000003a0d4ead .... AX 0x000000003a0d4ead .... AX 0x000000003a0d4ead .... AX 0x000000003a0d4ead .... AX 0x000000003a0d4ead So enable GPRs group for user space GPRs sampling and prioritize reading GPRs from PEBS. If the PEBS sampled GPRs is not user space GPRs (single PEBS record case), perf_sample_regs_user() modifies them to user space GPRs. [ mingo: Clarified the changelog. ] Fixes: c22497f ("perf/x86/intel: Support adaptive PEBS v4") Signed-off-by: Dapeng Mi <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]> (cherry picked from commit b55b385b3938c28185e4ce9eae81fd6e25655057) Signed-off-by: Vijayendra Suman <[email protected]>
1 parent 156eeef commit 8ad24cd

File tree

1 file changed

+5
-3
lines changed
  • arch/x86/events/intel

1 file changed

+5
-3
lines changed

arch/x86/events/intel/ds.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,8 +1195,10 @@ static u64 pebs_update_adaptive_cfg(struct perf_event *event)
11951195
* + precise_ip < 2 for the non event IP
11961196
* + For RTM TSX weight we need GPRs for the abort code.
11971197
*/
1198-
gprs = (sample_type & PERF_SAMPLE_REGS_INTR) &&
1199-
(attr->sample_regs_intr & PEBS_GP_REGS);
1198+
gprs = ((sample_type & PERF_SAMPLE_REGS_INTR) &&
1199+
(attr->sample_regs_intr & PEBS_GP_REGS)) ||
1200+
((sample_type & PERF_SAMPLE_REGS_USER) &&
1201+
(attr->sample_regs_user & PEBS_GP_REGS));
12001202

12011203
tsx_weight = (sample_type & PERF_SAMPLE_WEIGHT_TYPE) &&
12021204
((attr->config & INTEL_ARCH_EVENT_MASK) ==
@@ -1797,7 +1799,7 @@ static void setup_pebs_adaptive_sample_data(struct perf_event *event,
17971799
regs->flags &= ~PERF_EFLAGS_EXACT;
17981800
}
17991801

1800-
if (sample_type & PERF_SAMPLE_REGS_INTR)
1802+
if (sample_type & (PERF_SAMPLE_REGS_INTR | PERF_SAMPLE_REGS_USER))
18011803
adaptive_pebs_save_regs(regs, gprs);
18021804
}
18031805

0 commit comments

Comments
 (0)