Skip to content

Commit

Permalink
From patchwork series 407160
Browse files Browse the repository at this point in the history
  • Loading branch information
Fox Snowpatch committed May 17, 2024
1 parent 4727911 commit 576aef4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 27 deletions.
1 change: 1 addition & 0 deletions arch/powerpc/include/asm/perf_event_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ struct power_pmu {
#define PPMU_ARCH_31 0x00000200 /* Has MMCR3, SIER2 and SIER3 */
#define PPMU_P10_DD1 0x00000400 /* Is power10 DD1 processor version */
#define PPMU_HAS_ATTR_CONFIG1 0x00000800 /* Using config1 attribute */
#define PPMU_P10 0x00001000 /* For power10 pmu */

/*
* Values for flags to get_alternatives()
Expand Down
43 changes: 17 additions & 26 deletions arch/powerpc/perf/core-book3s.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,51 +266,42 @@ static inline u32 perf_flags_from_msr(struct pt_regs *regs)
static inline u32 perf_get_misc_flags(struct pt_regs *regs)
{
bool use_siar = regs_use_siar(regs);
unsigned long mmcra = regs->dsisr;
int marked = mmcra & MMCRA_SAMPLE_ENABLE;
unsigned long siar = mfspr(SPRN_SIAR);
unsigned long addr;

if (!use_siar)
return perf_flags_from_msr(regs);

/*
* Check the address in SIAR to identify the
* privilege levels since the SIER[MSR_HV, MSR_PR]
* bits are not set for marked events in power10
* DD1.
*/
if (marked && (ppmu->flags & PPMU_P10_DD1)) {
unsigned long siar = mfspr(SPRN_SIAR);
if (siar) {
if (is_kernel_addr(siar))
return PERF_RECORD_MISC_KERNEL;
return PERF_RECORD_MISC_USER;
} else {
if (is_kernel_addr(regs->nip))
return PERF_RECORD_MISC_KERNEL;
return PERF_RECORD_MISC_USER;
}
}

/*
* If we don't have flags in MMCRA, rather than using
* the MSR, we intuit the flags from the address in
* SIAR which should give slightly more reliable
* results
*/
if (ppmu->flags & PPMU_NO_SIPR) {
unsigned long siar = mfspr(SPRN_SIAR);
if (is_kernel_addr(siar))
return PERF_RECORD_MISC_KERNEL;
return PERF_RECORD_MISC_USER;
}

/* PR has priority over HV, so order below is important */
if (regs_sipr(regs))
return PERF_RECORD_MISC_USER;

if (regs_sihv(regs) && (freeze_events_kernel != MMCR0_FCHV))
if (regs_sipr(regs)) {
if (!(ppmu->flags & PPMU_P10))
return PERF_RECORD_MISC_USER;
} else if (regs_sihv(regs) && (freeze_events_kernel != MMCR0_FCHV))
return PERF_RECORD_MISC_HYPERVISOR;

/*
* Check the address in SIAR to identify the
* privilege levels since the SIER[MSR_HV, MSR_PR]
* bits are not set correctly in power10 sometimes
*/
if (ppmu->flags & PPMU_P10) {
addr = siar ? siar : regs->nip;
if (!is_kernel_addr(addr))
return PERF_RECORD_MISC_USER;
}

return PERF_RECORD_MISC_KERNEL;
}

Expand Down
3 changes: 2 additions & 1 deletion arch/powerpc/perf/power10-pmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,8 @@ static struct power_pmu power10_pmu = {
.get_mem_weight = isa207_get_mem_weight,
.disable_pmc = isa207_disable_pmc,
.flags = PPMU_HAS_SIER | PPMU_ARCH_207S |
PPMU_ARCH_31 | PPMU_HAS_ATTR_CONFIG1,
PPMU_ARCH_31 | PPMU_HAS_ATTR_CONFIG1 |
PPMU_P10,
.n_generic = ARRAY_SIZE(power10_generic_events),
.generic_events = power10_generic_events,
.cache_events = &power10_cache_events,
Expand Down

0 comments on commit 576aef4

Please sign in to comment.