From patchwork Wed Nov 4 20:46:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Madhavan Srinivasan X-Patchwork-Id: 7553281 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 111B9BEEA4 for ; Wed, 4 Nov 2015 20:49:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 366FE2064B for ; Wed, 4 Nov 2015 20:49:16 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2C1C720649 for ; Wed, 4 Nov 2015 20:49:15 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zu4xy-0007Fc-A6; Wed, 04 Nov 2015 20:47:34 +0000 Received: from e28smtp07.in.ibm.com ([122.248.162.7]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zu4xb-00073G-JB for linux-arm-kernel@lists.infradead.org; Wed, 04 Nov 2015 20:47:14 +0000 Received: from /spool/local by e28smtp07.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 5 Nov 2015 02:16:48 +0530 Received: from d28dlp02.in.ibm.com (9.184.220.127) by e28smtp07.in.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 5 Nov 2015 02:16:46 +0530 X-Helo: d28dlp02.in.ibm.com X-MailFrom: maddy@linux.vnet.ibm.com X-RcptTo: linux-arm-kernel@lists.infradead.org Received: from d28relay01.in.ibm.com (d28relay01.in.ibm.com [9.184.220.58]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id 129A2394005A for ; Thu, 5 Nov 2015 02:16:45 +0530 (IST) Received: from d28av03.in.ibm.com (d28av03.in.ibm.com [9.184.220.65]) by d28relay01.in.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id tA4KkiWC066022 for ; Thu, 5 Nov 2015 02:16:44 +0530 Received: from d28av03.in.ibm.com (localhost [127.0.0.1]) by d28av03.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id tA4KkhOS028436 for ; Thu, 5 Nov 2015 02:16:44 +0530 Received: from SrihariMadhavan.ibm.com ([9.80.69.130]) by d28av03.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id tA4KkL13027305; Thu, 5 Nov 2015 02:16:39 +0530 From: Madhavan Srinivasan To: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org Subject: [RFC PATCH 3/3]perf/powerpc: Functions to update arch_misc_regs Date: Thu, 5 Nov 2015 02:16:18 +0530 Message-Id: <1446669978-6366-4-git-send-email-maddy@linux.vnet.ibm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1446669978-6366-1-git-send-email-maddy@linux.vnet.ibm.com> References: <1446669978-6366-1-git-send-email-maddy@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15110420-0025-0000-0000-000007E61543 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151104_124712_365684_7E5C6EF7 X-CRM114-Status: GOOD ( 14.74 ) X-Spam-Score: -4.2 (----) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Madhavan Srinivasan , Stephane Eranian , Peter Zijlstra , Benjamin Herrenschmidt , Arnaldo Carvalho de Melo , Jiri Olsa , Michael Ellerman , Thomas Gleixner , Sukadev Bhattiprolu , Ingo Molnar MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Patch adds function to update the arch_misc_reg struct and an arch specific perf_sample_regs_intr() to hook up arch_misc_regs to perf_regs pointer. Also makes perf_sample_regs_intr() in kernel/event/core.c as __weak__ function to make arch specific implementation to replace. Signed-off-by: Madhavan Srinivasan Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Stephane Eranian Cc: Benjamin Herrenschmidt Cc: Michael Ellerman Cc: Sukadev Bhattiprolu --- Would really appreciate comments and feedback for the patch arch/powerpc/perf/core-book3s.c | 29 +++++++++++++++++++++++++++++ kernel/events/core.c | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) -- 1.9.1 diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c index b0382f3f1095..508c181c163f 100644 --- a/arch/powerpc/perf/core-book3s.c +++ b/arch/powerpc/perf/core-book3s.c @@ -57,6 +57,7 @@ struct cpu_hw_events { void *bhrb_context; struct perf_branch_stack bhrb_stack; struct perf_branch_entry bhrb_entries[BHRB_MAX_ENTRIES]; + struct arch_misc_regs arch_regs; }; static DEFINE_PER_CPU(struct cpu_hw_events, cpu_hw_events); @@ -1904,6 +1905,28 @@ ssize_t power_events_sysfs_show(struct device *dev, return sprintf(page, "event=0x%02llx\n", pmu_attr->id); } +void perf_sample_regs_intr(struct perf_regs *regs_intr, struct pt_regs *regs) +{ + struct cpu_hw_events *cpuhw; + cpuhw = this_cpu_ptr(&cpu_hw_events); + + regs_intr->regs = regs; + regs_intr->arch_regs = &cpuhw->arch_regs; + regs_intr->abi = perf_reg_abi(current); +} + +static void power_arch_misc_regs(struct arch_misc_regs *regs) +{ + regs->pmc1 = mfspr(SPRN_PMC1); + regs->pmc2 = mfspr(SPRN_PMC2); + regs->pmc3 = mfspr(SPRN_PMC3); + regs->pmc4 = mfspr(SPRN_PMC4); + regs->pmc5 = mfspr(SPRN_PMC5); + regs->pmc6 = mfspr(SPRN_PMC6); + regs->mmcr0 = mfspr(SPRN_MMCR0); + regs->mmcr1 = mfspr(SPRN_MMCR1); +} + static struct pmu power_pmu = { .pmu_enable = power_pmu_enable, .pmu_disable = power_pmu_disable, @@ -1985,6 +2008,12 @@ static void record_and_restart(struct perf_event *event, unsigned long val, data.br_stack = &cpuhw->bhrb_stack; } + if (event->attr.sample_type & PERF_SAMPLE_REGS_INTR) { + struct cpu_hw_events *cpuhw; + cpuhw = this_cpu_ptr(&cpu_hw_events); + power_arch_misc_regs(&cpuhw->arch_regs); + } + if (perf_event_overflow(event, &data, regs)) power_pmu_stop(event, 0); } diff --git a/kernel/events/core.c b/kernel/events/core.c index c04bdad3d365..9567be72da5a 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -4962,7 +4962,7 @@ static void perf_sample_regs_user(struct perf_regs *regs_user, } } -static void perf_sample_regs_intr(struct perf_regs *regs_intr, +void __attribute__((weak)) perf_sample_regs_intr(struct perf_regs *regs_intr, struct pt_regs *regs) { regs_intr->regs = regs;