Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 297188
b: refs/heads/master
c: 1ce447b
h: refs/heads/master
v: v3
  • Loading branch information
Benjamin Herrenschmidt committed Mar 28, 2012
1 parent 42af26e commit 611ecb5
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: cb52d8970eee65bf2c47d9a91bd4f58b17f595f4
refs/heads/master: 1ce447b90f3e71c81ae59e0062bc305ef267668b
2 changes: 2 additions & 0 deletions trunk/arch/powerpc/include/asm/perf_event_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ struct power_pmu {
*/
#define PPMU_LIMITED_PMC5_6 1 /* PMC5/6 have limited function */
#define PPMU_ALT_SIPR 2 /* uses alternate posn for SIPR/HV */
#define PPMU_NO_SIPR 4 /* no SIPR/HV in MMCRA at all */
#define PPMU_NO_CONT_SAMPLING 8 /* no continuous sampling */

/*
* Values for flags to get_alternatives()
Expand Down
46 changes: 41 additions & 5 deletions trunk/arch/powerpc/perf/core-book3s.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,45 @@ static inline void perf_get_data_addr(struct pt_regs *regs, u64 *addrp)
*addrp = mfspr(SPRN_SDAR);
}

static inline u32 perf_flags_from_msr(struct pt_regs *regs)
{
if (regs->msr & MSR_PR)
return PERF_RECORD_MISC_USER;
if ((regs->msr & MSR_HV) && freeze_events_kernel != MMCR0_FCHV)
return PERF_RECORD_MISC_HYPERVISOR;
return PERF_RECORD_MISC_KERNEL;
}

static inline u32 perf_get_misc_flags(struct pt_regs *regs)
{
unsigned long mmcra = regs->dsisr;
unsigned long sihv = MMCRA_SIHV;
unsigned long sipr = MMCRA_SIPR;

/* Not a PMU interrupt: Make up flags from regs->msr */
if (TRAP(regs) != 0xf00)
return 0; /* not a PMU interrupt */
return perf_flags_from_msr(regs);

/*
* If we don't support continuous sampling and this
* is not a marked event, same deal
*/
if ((ppmu->flags & PPMU_NO_CONT_SAMPLING) &&
!(mmcra & MMCRA_SAMPLE_ENABLE))
return perf_flags_from_msr(regs);

/*
* 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 (siar >= PAGE_OFFSET)
return PERF_RECORD_MISC_KERNEL;
return PERF_RECORD_MISC_USER;
}

if (ppmu->flags & PPMU_ALT_SIPR) {
sihv = POWER6_MMCRA_SIHV;
Expand Down Expand Up @@ -1299,13 +1330,18 @@ unsigned long perf_misc_flags(struct pt_regs *regs)
*/
unsigned long perf_instruction_pointer(struct pt_regs *regs)
{
unsigned long ip;
unsigned long mmcra = regs->dsisr;

/* Not a PMU interrupt */
if (TRAP(regs) != 0xf00)
return regs->nip; /* not a PMU interrupt */
return regs->nip;

/* Processor doesn't support sampling non marked events */
if ((ppmu->flags & PPMU_NO_CONT_SAMPLING) &&
!(mmcra & MMCRA_SAMPLE_ENABLE))
return regs->nip;

ip = mfspr(SPRN_SIAR) + perf_ip_adjust(regs);
return ip;
return mfspr(SPRN_SIAR) + perf_ip_adjust(regs);
}

static bool pmc_overflow(unsigned long val)
Expand Down
1 change: 1 addition & 0 deletions trunk/arch/powerpc/perf/power4-pmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ static struct power_pmu power4_pmu = {
.n_generic = ARRAY_SIZE(p4_generic_events),
.generic_events = p4_generic_events,
.cache_events = &power4_cache_events,
.flags = PPMU_NO_SIPR | PPMU_NO_CONT_SAMPLING,
};

static int __init init_power4_pmu(void)
Expand Down
1 change: 1 addition & 0 deletions trunk/arch/powerpc/perf/ppc970-pmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ static struct power_pmu ppc970_pmu = {
.n_generic = ARRAY_SIZE(ppc970_generic_events),
.generic_events = ppc970_generic_events,
.cache_events = &ppc970_cache_events,
.flags = PPMU_NO_SIPR | PPMU_NO_CONT_SAMPLING,
};

static int __init init_ppc970_pmu(void)
Expand Down

0 comments on commit 611ecb5

Please sign in to comment.