<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 06-May-2020, at 9:56 AM, Madhavan Srinivasan <<a href="mailto:maddy@linux.ibm.com" class="">maddy@linux.ibm.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">On 4/29/20 11:34 AM, Anju T Sudhakar wrote:</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">The capability flag PERF_PMU_CAP_EXTENDED_REGS, is used to indicate the<br class="">PMU which support extended registers. The generic code define the mask<br class="">of extended registers as 0 for non supported architectures.<br class=""><br class="">Add support for extended registers in POWER9 architecture. For POWER9,<br class="">the extended registers are mmcr0, mmc1 and mmcr2.<br class=""><br class="">REG_RESERVED mask is redefined to accommodate the extended registers.<br class=""><br class="">With patch:<br class="">----------------<br class=""><br class=""># perf record -I?<br class="">available registers: r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14<br class="">r15 r16 r17 r18 r19 r20 r21 r22 r23 r24 r25 r26 r27 r28 r29 r30 r31 nip<br class="">msr orig_r3 ctr link xer ccr softe trap dar dsisr sier mmcra mmcr0<br class="">mmcr1 mmcr2<br class=""></blockquote><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""></div></blockquote><br class=""><blockquote type="cite" class=""><div class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Would prefer to have some flexibility in deciding what to expose</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">in as extended regs. Meaning say if we want to add extended regs</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">in power8 and if we dont want to show for ex say mmcr2 (just for example).</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""></div></blockquote><div><br class=""></div><div>One way to approach this is to have the "extended mask" exposed in </div><div>sysfs: "/sys/bus/event_source/devices/cpu/caps/ext_regs_mask" by the platform pmu</div><div>driver. This way the perf tool side can look at this and platform driver will also have control </div><div>on what to expose as part of the extended regs.</div><div><br class=""></div><div>perf tools side uses extended mask to display the platform supported register names (with -I? option)</div><div>to the user and also send this mask to the kernel to capture the extended registers in each sample. </div><div>Hence we need to expose the appropriated mask to the perf tool side.</div><div><br class=""></div><div>Thanks</div><div>Athira</div><div><br class=""></div><blockquote type="cite" class=""><div class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Maddy</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br class=""># perf record -I ls<br class=""># perf script -D<br class=""><br class="">PERF_RECORD_SAMPLE(IP, 0x1): 9019/9019: 0 period: 1 addr: 0<br class="">... intr regs: mask 0xffffffffffff ABI 64-bit<br class="">.... r0 0xc00000000011b12c<br class="">.... r1 0xc000003f9a98b930<br class="">.... r2 0xc000000001a32100<br class="">.... r3 0xc000003f8fe9a800<br class="">.... r4 0xc000003fd1810000<br class="">.... r5 0x3e32557150<br class="">.... r6 0xc000003f9a98b908<br class="">.... r7 0xffffffc1cdae06ac<br class="">.... r8 0x818<br class="">[.....]<br class="">.... r31 0xc000003ffd047230<br class="">.... nip 0xc00000000011b2c0<br class="">.... msr 0x9000000000009033<br class="">.... orig_r3 0xc00000000011b21c<br class="">.... ctr 0xc000000000119380<br class="">.... link 0xc00000000011b12c<br class="">.... xer 0x0<br class="">.... ccr 0x28002222<br class="">.... softe 0x1<br class="">.... trap 0xf00<br class="">.... dar 0x0<br class="">.... dsisr 0x80000000000<br class="">.... sier 0x0<br class="">.... mmcra 0x80000000000<br class="">.... mmcr0 0x82008090<br class="">.... mmcr1 0x1e000000<br class="">.... mmcr2 0x0<br class=""> ... thread: perf:9019<br class=""><br class="">Signed-off-by: Anju T Sudhakar <<a href="mailto:anju@linux.vnet.ibm.com" class="">anju@linux.vnet.ibm.com</a>><br class="">---<br class=""> arch/powerpc/include/asm/perf_event_server.h | 5 +++<br class=""> arch/powerpc/include/uapi/asm/perf_regs.h | 13 +++++++-<br class=""> arch/powerpc/perf/core-book3s.c | 1 +<br class=""> arch/powerpc/perf/perf_regs.c | 29 ++++++++++++++--<br class=""> arch/powerpc/perf/power9-pmu.c | 1 +<br class=""> .../arch/powerpc/include/uapi/asm/perf_regs.h | 13 +++++++-<br class=""> tools/perf/arch/powerpc/include/perf_regs.h | 6 +++-<br class=""> tools/perf/arch/powerpc/util/perf_regs.c | 33 +++++++++++++++++++<br class=""> 8 files changed, 95 insertions(+), 6 deletions(-)<br class=""><br class="">diff --git a/arch/powerpc/include/asm/perf_event_server.h b/arch/powerpc/include/asm/perf_event_server.h<br class="">index 3e9703f44c7c..1d15953bd99e 100644<br class="">--- a/arch/powerpc/include/asm/perf_event_server.h<br class="">+++ b/arch/powerpc/include/asm/perf_event_server.h<br class="">@@ -55,6 +55,11 @@ struct power_pmu {<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>int<span class="Apple-converted-space"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>*blacklist_ev;<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>/* BHRB entries in the PMU */<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>int<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>bhrb_nr;<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>/*<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-converted-space"> </span>* set this flag with `PERF_PMU_CAP_EXTENDED_REGS` if<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-converted-space"> </span>* the pmu supports extended perf regs capability<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-converted-space"> </span>*/<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>int<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>capabilities;<br class=""> };<br class=""><br class=""> /*<br class="">diff --git a/arch/powerpc/include/uapi/asm/perf_regs.h b/arch/powerpc/include/uapi/asm/perf_regs.h<br class="">index f599064dd8dc..604b831378fe 100644<br class="">--- a/arch/powerpc/include/uapi/asm/perf_regs.h<br class="">+++ b/arch/powerpc/include/uapi/asm/perf_regs.h<br class="">@@ -48,6 +48,17 @@ enum perf_event_powerpc_regs {<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>PERF_REG_POWERPC_DSISR,<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>PERF_REG_POWERPC_SIER,<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>PERF_REG_POWERPC_MMCRA,<br class="">-<span class="Apple-tab-span" style="white-space: pre;"> </span>PERF_REG_POWERPC_MAX,<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>/* Extended registers */<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>PERF_REG_POWERPC_MMCR0,<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>PERF_REG_POWERPC_MMCR1,<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>PERF_REG_POWERPC_MMCR2,<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>PERF_REG_EXTENDED_MAX,<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>/* Max regs without the extended regs */<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>PERF_REG_POWERPC_MAX = PERF_REG_POWERPC_MMCRA + 1,<br class=""> };<br class="">+<br class="">+#define PERF_REG_PMU_MASK<span class="Apple-tab-span" style="white-space: pre;"> </span>((1ULL << PERF_REG_POWERPC_MAX) - 1)<br class="">+#define PERF_REG_EXTENDED_MASK (((1ULL << (PERF_REG_EXTENDED_MAX))<span class="Apple-tab-span" style="white-space: pre;"> </span>\<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>- 1) - PERF_REG_PMU_MASK)<br class="">+<br class=""> #endif /* _UAPI_ASM_POWERPC_PERF_REGS_H */<br class="">diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c<br class="">index 3dcfecf858f3..f56b77800a7b 100644<br class="">--- a/arch/powerpc/perf/core-book3s.c<br class="">+++ b/arch/powerpc/perf/core-book3s.c<br class="">@@ -2276,6 +2276,7 @@ int register_power_pmu(struct power_pmu *pmu)<br class=""><br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>power_pmu.attr_groups = ppmu->attr_groups;<br class=""><br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>power_pmu.capabilities |= (ppmu->capabilities & PERF_PMU_CAP_EXTENDED_REGS);<br class=""> #ifdef MSR_HV<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>/*<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-converted-space"> </span>* Use FCHV to ignore kernel events if MSR.HV is set.<br class="">diff --git a/arch/powerpc/perf/perf_regs.c b/arch/powerpc/perf/perf_regs.c<br class="">index a213a0aa5d25..57aa02568caf 100644<br class="">--- a/arch/powerpc/perf/perf_regs.c<br class="">+++ b/arch/powerpc/perf/perf_regs.c<br class="">@@ -15,7 +15,8 @@<br class=""><br class=""> #define PT_REGS_OFFSET(id, r) [id] = offsetof(struct pt_regs, r)<br class=""><br class="">-#define REG_RESERVED (~((1ULL << PERF_REG_POWERPC_MAX) - 1))<br class="">+#define REG_RESERVED (~(PERF_REG_EXTENDED_MASK) &<span class="Apple-tab-span" style="white-space: pre;"> </span>\<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>(~((1ULL << PERF_REG_POWERPC_MAX) - 1)))<br class=""><br class=""> static unsigned int pt_regs_offset[PERF_REG_POWERPC_MAX] = {<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>PT_REGS_OFFSET(PERF_REG_POWERPC_R0, gpr[0]),<br class="">@@ -69,10 +70,22 @@ static unsigned int pt_regs_offset[PERF_REG_POWERPC_MAX] = {<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>PT_REGS_OFFSET(PERF_REG_POWERPC_MMCRA, dsisr),<br class=""> };<br class=""><br class="">+/* Function to return the extended register values */<br class="">+static u64 get_ext_regs_value(int idx)<br class="">+{<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>switch (idx) {<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>case PERF_REG_POWERPC_MMCR0:<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-converted-space"> </span> return mfspr(SPRN_MMCR0);<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>case PERF_REG_POWERPC_MMCR1:<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-converted-space"> </span> return mfspr(SPRN_MMCR1);<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>case PERF_REG_POWERPC_MMCR2:<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-converted-space"> </span> return mfspr(SPRN_MMCR2);<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>default: return 0;<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br class="">+}<br class="">+<br class=""> u64 perf_reg_value(struct pt_regs *regs, int idx)<br class=""> {<br class="">-<span class="Apple-tab-span" style="white-space: pre;"> </span>if (WARN_ON_ONCE(idx >= PERF_REG_POWERPC_MAX))<br class="">-<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>return 0;<br class=""><br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>if (idx == PERF_REG_POWERPC_SIER &&<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-converted-space"> </span> (IS_ENABLED(CONFIG_FSL_EMB_PERF_EVENT) ||<br class="">@@ -85,6 +98,16 @@ u64 perf_reg_value(struct pt_regs *regs, int idx)<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-converted-space"> </span> IS_ENABLED(CONFIG_PPC32)))<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>return 0;<br class=""><br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>if (idx >= PERF_REG_POWERPC_MAX && idx < PERF_REG_EXTENDED_MAX)<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>return get_ext_regs_value(idx);<br class="">+<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>/*<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-converted-space"> </span>* If the idx is referring to value beyond the<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-converted-space"> </span>* supported registers, return 0 with a warning<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-converted-space"> </span>*/<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>if (WARN_ON_ONCE(idx >= PERF_REG_EXTENDED_MAX))<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>return 0;<br class="">+<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>return regs_get_register(regs, pt_regs_offset[idx]);<br class=""> }<br class=""><br class="">diff --git a/arch/powerpc/perf/power9-pmu.c b/arch/powerpc/perf/power9-pmu.c<br class="">index 08c3ef796198..c37193b3e73f 100644<br class="">--- a/arch/powerpc/perf/power9-pmu.c<br class="">+++ b/arch/powerpc/perf/power9-pmu.c<br class="">@@ -434,6 +434,7 @@ static struct power_pmu power9_pmu = {<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>.cache_events<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>= &power9_cache_events,<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>.attr_groups<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>= power9_pmu_attr_groups,<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>.bhrb_nr<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>= 32,<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>.capabilities<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>= PERF_PMU_CAP_EXTENDED_REGS,<br class=""> };<br class=""><br class=""> int init_power9_pmu(void)<br class="">diff --git a/tools/arch/powerpc/include/uapi/asm/perf_regs.h b/tools/arch/powerpc/include/uapi/asm/perf_regs.h<br class="">index f599064dd8dc..d66953294c73 100644<br class="">--- a/tools/arch/powerpc/include/uapi/asm/perf_regs.h<br class="">+++ b/tools/arch/powerpc/include/uapi/asm/perf_regs.h<br class="">@@ -48,6 +48,17 @@ enum perf_event_powerpc_regs {<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>PERF_REG_POWERPC_DSISR,<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>PERF_REG_POWERPC_SIER,<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>PERF_REG_POWERPC_MMCRA,<br class="">-<span class="Apple-tab-span" style="white-space: pre;"> </span>PERF_REG_POWERPC_MAX,<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>/* Extended arch registers */<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>PERF_REG_POWERPC_MMCR0,<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>PERF_REG_POWERPC_MMCR1,<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>PERF_REG_POWERPC_MMCR2,<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>PERF_REG_EXTENDED_MAX,<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>/* Max regs without extended arch regs */<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>PERF_REG_POWERPC_MAX = PERF_REG_POWERPC_MMCRA + 1,<br class="">+<br class=""> };<br class="">+#define PERF_REG_PMU_MASK<span class="Apple-tab-span" style="white-space: pre;"> </span>((1ULL << PERF_REG_POWERPC_MAX) - 1)<br class="">+#define PERF_REG_EXTENDED_MASK (((1ULL << (PERF_REG_EXTENDED_MAX))\<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>- 1) - PERF_REG_PMU_MASK)<br class="">+<br class=""> #endif /* _UAPI_ASM_POWERPC_PERF_REGS_H */<br class="">diff --git a/tools/perf/arch/powerpc/include/perf_regs.h b/tools/perf/arch/powerpc/include/perf_regs.h<br class="">index e18a3556f5e3..f7bbdb816f88 100644<br class="">--- a/tools/perf/arch/powerpc/include/perf_regs.h<br class="">+++ b/tools/perf/arch/powerpc/include/perf_regs.h<br class="">@@ -64,7 +64,11 @@ static const char *reg_names[] = {<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>[PERF_REG_POWERPC_DAR] = "dar",<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>[PERF_REG_POWERPC_DSISR] = "dsisr",<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>[PERF_REG_POWERPC_SIER] = "sier",<br class="">-<span class="Apple-tab-span" style="white-space: pre;"> </span>[PERF_REG_POWERPC_MMCRA] = "mmcra"<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>[PERF_REG_POWERPC_MMCRA] = "mmcra",<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>[PERF_REG_POWERPC_MMCR0] = "mmcr0",<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>[PERF_REG_POWERPC_MMCR1] = "mmcr1",<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>[PERF_REG_POWERPC_MMCR2] = "mmcr2",<br class="">+<br class=""> };<br class=""><br class=""> static inline const char *perf_reg_name(int id)<br class="">diff --git a/tools/perf/arch/powerpc/util/perf_regs.c b/tools/perf/arch/powerpc/util/perf_regs.c<br class="">index 0a5242900248..37b150f9d1a1 100644<br class="">--- a/tools/perf/arch/powerpc/util/perf_regs.c<br class="">+++ b/tools/perf/arch/powerpc/util/perf_regs.c<br class="">@@ -6,6 +6,8 @@<br class=""><br class=""> #include "../../../util/perf_regs.h"<br class=""> #include "../../../util/debug.h"<br class="">+#include "../../../util/event.h"<br class="">+#include "../../../perf-sys.h"<br class=""><br class=""> #include <linux/kernel.h><br class=""><br class="">@@ -55,6 +57,9 @@ const struct sample_reg sample_reg_masks[] = {<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>SMPL_REG(dsisr, PERF_REG_POWERPC_DSISR),<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>SMPL_REG(sier, PERF_REG_POWERPC_SIER),<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>SMPL_REG(mmcra, PERF_REG_POWERPC_MMCRA),<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>SMPL_REG(mmcr0, PERF_REG_POWERPC_MMCR0),<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>SMPL_REG(mmcr1, PERF_REG_POWERPC_MMCR1),<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>SMPL_REG(mmcr2, PERF_REG_POWERPC_MMCR2),<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>SMPL_REG_END<br class=""> };<br class=""><br class="">@@ -163,3 +168,31 @@ int arch_sdt_arg_parse_op(char *old_op, char **new_op)<br class=""><br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>return SDT_ARG_VALID;<br class=""> }<br class="">+<br class="">+uint64_t arch__intr_reg_mask(void)<br class="">+{<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>struct perf_event_attr attr = {<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>.type = PERF_TYPE_HARDWARE,<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>.config = PERF_COUNT_HW_CPU_CYCLES,<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>.sample_type = PERF_SAMPLE_REGS_INTR,<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>.sample_regs_intr = PERF_REG_EXTENDED_MASK,<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>.precise_ip = 1,<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>.disabled = 1,<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>.exclude_kernel = 1,<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>};<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>int fd;<br class="">+<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>attr.sample_period = 1;<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>event_attr_init(&attr);<br class="">+<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>/*<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-converted-space"> </span>* check if the pmu supports perf extended regs, before<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-converted-space"> </span>* returning the register mask to sample.<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-converted-space"> </span>*/<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>fd = sys_perf_event_open(&attr, 0, -1, -1, 0);<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>if (fd != -1) {<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>close(fd);<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>return (PERF_REG_EXTENDED_MASK | PERF_REGS_MASK);<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>return PERF_REGS_MASK;<br class="">+}</blockquote></div></blockquote></div><br class=""></body></html>