From patchwork Thu Jan 5 12:37:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: maddy X-Patchwork-Id: 711379 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tvS2N0Z6mz9sQw for ; Thu, 5 Jan 2017 23:40:28 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3tvS2M6sHDzDqht for ; Thu, 5 Jan 2017 23:40:27 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3tvRzh0QNVzDqQ0 for ; Thu, 5 Jan 2017 23:38:07 +1100 (AEDT) Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id v05CYJkU119017 for ; Thu, 5 Jan 2017 07:38:05 -0500 Received: from e23smtp04.au.ibm.com (e23smtp04.au.ibm.com [202.81.31.146]) by mx0a-001b2d01.pphosted.com with ESMTP id 27sjbyuyrp-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 05 Jan 2017 07:38:04 -0500 Received: from localhost by e23smtp04.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 5 Jan 2017 22:38:02 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp04.au.ibm.com (202.81.31.210) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 5 Jan 2017 22:38:01 +1000 Received: from d23relay06.au.ibm.com (d23relay06.au.ibm.com [9.185.63.219]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id A971C2BB0055 for ; Thu, 5 Jan 2017 23:38:00 +1100 (EST) Received: from d23av06.au.ibm.com (d23av06.au.ibm.com [9.190.235.151]) by d23relay06.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v05Cc17U55574688 for ; Thu, 5 Jan 2017 23:38:01 +1100 Received: from d23av06.au.ibm.com (localhost [127.0.0.1]) by d23av06.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v05Cc04M016714 for ; Thu, 5 Jan 2017 23:38:00 +1100 Received: from SrihariSrinidhi.in.ibm.com (sriharisrinidhi.in.ibm.com [9.121.0.140]) by d23av06.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v05CbtNq016460; Thu, 5 Jan 2017 23:37:58 +1100 From: Madhavan Srinivasan To: mpe@ellerman.id.au Subject: [PATCH v2 2/2] powerpc/perf: support new BHRB filtering modes Date: Thu, 5 Jan 2017 18:07:53 +0530 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1483619873-13899-1-git-send-email-maddy@linux.vnet.ibm.com> References: <1483619873-13899-1-git-send-email-maddy@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17010512-0012-0000-0000-000002007FC2 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17010512-0013-0000-0000-000006C251C9 Message-Id: <1483619873-13899-2-git-send-email-maddy@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-01-05_08:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1701050199 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Madhavan Srinivasan , linuxppc-dev@lists.ozlabs.org, khandual@linux.vnet.ibm.com Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 --- 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;