linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
To: mpe@ellerman.id.au
Cc: linuxppc-dev@lists.ozlabs.org, khandual@linux.vnet.ibm.com,
	Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
Subject: [PATCH v2 2/2] powerpc/perf: support new BHRB filtering modes
Date: Thu,  5 Jan 2017 18:07:53 +0530	[thread overview]
Message-ID: <1483619873-13899-2-git-send-email-maddy@linux.vnet.ibm.com> (raw)
In-Reply-To: <1483619873-13899-1-git-send-email-maddy@linux.vnet.ibm.com>

Add support for new BHRB filtering modes in power9.
Filtering modes restrict the type of branch
instructions that can enter into the BHRB.

The filtering criteria are defined using the following
terminology, Call, Return, Jump, Conditional Branch,
Unconditional Branch, Indirect Branch and Direct Branch.

PowerISA v3.0 defines 5 new BHRB filtering bits
in MMCRA[27:31] for the software to prevent various
combinations of each of the above types of Branch
instructions from being entered into the BHRB.

Patch updates the branch types based on "Progrmming Note"
information from PowerISA v3.0 "BHRB Filtering" section.

Signed-off-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
---
Changelog v1:
1) Added mode comments in code
2) Updates to commit message

 arch/powerpc/perf/power9-pmu.c | 53 +++++++++++++++++++++++++++++++++++++-----
 1 file changed, 47 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/perf/power9-pmu.c b/arch/powerpc/perf/power9-pmu.c
index 56ad09801fff..0d232916cab2 100644
--- a/arch/powerpc/perf/power9-pmu.c
+++ b/arch/powerpc/perf/power9-pmu.c
@@ -103,6 +103,31 @@ enum {
 #define POWER9_MMCRA_IFM2		0x0000000080000000UL
 #define POWER9_MMCRA_IFM3		0x00000000C0000000UL
 
+/*
+ * BHRB Filtering mode FJ -- Filter Jump Instructions
+ */
+#define POWER9_MMCRA_FJ			0x0000000100000000UL
+
+/*
+ * BHRB Filtering mode FR -- Filter Return Instructions
+ */
+#define POWER9_MMCRA_FR			0x0000000200000000UL
+
+/*
+ * BHRB Filtering mode FC -- Filter Call Instructions
+ */
+#define POWER9_MMCRA_FC			0x0000000400000000UL
+
+/*
+ * BHRB Filtering mode FU -- Filter Unconditional Branch Instructions
+ */
+#define POWER9_MMCRA_FU			0x0000000800000000UL
+
+/*
+ * BHRB Filtering mode FD -- Filter Direct Branch Instructions
+ */
+#define POWER9_MMCRA_FD			0x0000001000000000UL
+
 /* PowerISA v2.07 format attribute structure*/
 extern struct attribute_group isa207_pmu_format_group;
 
@@ -240,14 +265,30 @@ static u64 power9_bhrb_filter_map(u64 branch_sample_type)
 		return pmu_bhrb_filter;
 
 	/* Invalid branch filter options - HW does not support */
-	if (branch_sample_type & PERF_SAMPLE_BRANCH_ANY_RETURN)
-		return -1;
+	if (branch_sample_type & PERF_SAMPLE_BRANCH_ANY_RETURN) {
+		pmu_bhrb_filter = POWER9_MMCRA_FC | POWER9_MMCRA_FJ;
+		return pmu_bhrb_filter;
+	}
 
-	if (branch_sample_type & PERF_SAMPLE_BRANCH_IND_CALL)
-		return -1;
+	if (branch_sample_type & PERF_SAMPLE_BRANCH_IND_CALL) {
+		pmu_bhrb_filter = POWER9_MMCRA_FD | POWER9_MMCRA_FR | POWER9_MMCRA_FJ;
+		return pmu_bhrb_filter;
+	}
 
-	if (branch_sample_type & PERF_SAMPLE_BRANCH_CALL)
-		return -1;
+	if (branch_sample_type & PERF_SAMPLE_BRANCH_COND) {
+		pmu_bhrb_filter = POWER9_MMCRA_FU;
+		return pmu_bhrb_filter;
+	}
+
+	if (branch_sample_type & PERF_SAMPLE_BRANCH_IND_JUMP) {
+		pmu_bhrb_filter = POWER9_MMCRA_FD | POWER9_MMCRA_FC | POWER9_MMCRA_FR;
+		return pmu_bhrb_filter;
+	}
+
+	if (branch_sample_type & PERF_SAMPLE_BRANCH_CALL) {
+		pmu_bhrb_filter = POWER9_MMCRA_FC;
+		return pmu_bhrb_filter;
+	}
 
 	if (branch_sample_type & PERF_SAMPLE_BRANCH_ANY_CALL) {
 		pmu_bhrb_filter |= POWER9_MMCRA_IFM1;
-- 
2.7.4

      reply	other threads:[~2017-01-05 12:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-05 12:37 [PATCH v2 1/2] powerpc/perf: Factor out bhrb functions Madhavan Srinivasan
2017-01-05 12:37 ` Madhavan Srinivasan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1483619873-13899-2-git-send-email-maddy@linux.vnet.ibm.com \
    --to=maddy@linux.vnet.ibm.com \
    --cc=khandual@linux.vnet.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).