From patchwork Wed Nov 4 20:46:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Madhavan Srinivasan X-Patchwork-Id: 7553261 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 362399F327 for ; Wed, 4 Nov 2015 20:49:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 19F5A20642 for ; Wed, 4 Nov 2015 20:49:02 +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 F34E020640 for ; Wed, 4 Nov 2015 20:49:00 +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 1Zu4xZ-00076e-RS; Wed, 04 Nov 2015 20:47:09 +0000 Received: from e28smtp01.in.ibm.com ([122.248.162.1]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zu4xN-00072F-2a for linux-arm-kernel@lists.infradead.org; Wed, 04 Nov 2015 20:46:58 +0000 Received: from /spool/local by e28smtp01.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 5 Nov 2015 02:16:37 +0530 Received: from d28dlp01.in.ibm.com (9.184.220.126) by e28smtp01.in.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 5 Nov 2015 02:16:35 +0530 X-Helo: d28dlp01.in.ibm.com X-MailFrom: maddy@linux.vnet.ibm.com X-RcptTo: linux-arm-kernel@lists.infradead.org Received: from d28relay04.in.ibm.com (d28relay04.in.ibm.com [9.184.220.61]) by d28dlp01.in.ibm.com (Postfix) with ESMTP id 27494E005C for ; Thu, 5 Nov 2015 02:16:52 +0530 (IST) Received: from d28av03.in.ibm.com (d28av03.in.ibm.com [9.184.220.65]) by d28relay04.in.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id tA4KkZ9I4718876 for ; Thu, 5 Nov 2015 02:16:35 +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 tA4KkWUH027845 for ; Thu, 5 Nov 2015 02:16:34 +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 tA4KkL11027305; Thu, 5 Nov 2015 02:16:29 +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 1/3] perf/core: extend perf_regs to include arch specific regs Date: Thu, 5 Nov 2015 02:16:16 +0530 Message-Id: <1446669978-6366-2-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-4790-0000-0000-00000B5DC388 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151104_124657_613245_495DAF55 X-CRM114-Status: GOOD ( 17.28 ) 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 , Russell King , Stephane Eranian , Peter Zijlstra , Catalin Marinas , Will Deacon , Arnaldo Carvalho de Melo , Michael Ellerman , Jiri Olsa , Benjamin Herrenschmidt , 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 As a foundation patch, new structure called arch_misc_regs added to perf_regs. And perf_reg_value() is modified to expect perf_regs instead of pt_regs. This way, perf_reg_value() can decide on the struct to pick based on the register idx. Signed-off-by: Madhavan Srinivasan Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Jiri Olsa Cc: Arnaldo Carvalho de Melo Cc: Stephane Eranian Cc: Russell King Cc: Catalin Marinas Cc: Will Deacon Cc: Benjamin Herrenschmidt Cc: Michael Ellerman Cc: Sukadev Bhattiprolu --- Will really appreciate comments and feedback for the patch arch/arm/include/asm/ptrace.h | 2 ++ arch/arm/kernel/perf_regs.c | 4 +++- arch/arm64/include/asm/ptrace.h | 2 ++ arch/arm64/kernel/perf_regs.c | 4 +++- arch/powerpc/include/uapi/asm/ptrace.h | 2 ++ arch/powerpc/perf/perf_regs.c | 4 +++- arch/x86/include/asm/ptrace.h | 2 ++ arch/x86/kernel/perf_regs.c | 4 +++- include/linux/perf_regs.h | 5 +++-- kernel/events/core.c | 6 +++--- 10 files changed, 26 insertions(+), 9 deletions(-) diff --git a/arch/arm/include/asm/ptrace.h b/arch/arm/include/asm/ptrace.h index 51622ba7c4a6..26cd8dbf1f02 100644 --- a/arch/arm/include/asm/ptrace.h +++ b/arch/arm/include/asm/ptrace.h @@ -17,6 +17,8 @@ struct pt_regs { unsigned long uregs[18]; }; +struct arch_misc_regs {}; + #define user_mode(regs) \ (((regs)->ARM_cpsr & 0xf) == 0) diff --git a/arch/arm/kernel/perf_regs.c b/arch/arm/kernel/perf_regs.c index 592dda3f21ff..18999abbadbe 100644 --- a/arch/arm/kernel/perf_regs.c +++ b/arch/arm/kernel/perf_regs.c @@ -6,8 +6,10 @@ #include #include -u64 perf_reg_value(struct pt_regs *regs, int idx) +u64 perf_reg_value(struct perf_regs *p_regs, int idx) { + struct pt_regs *regs = p_regs->regs; + if (WARN_ON_ONCE((u32)idx >= PERF_REG_ARM_MAX)) return 0; diff --git a/arch/arm64/include/asm/ptrace.h b/arch/arm64/include/asm/ptrace.h index 536274ed292e..9a33ab69f19f 100644 --- a/arch/arm64/include/asm/ptrace.h +++ b/arch/arm64/include/asm/ptrace.h @@ -118,6 +118,8 @@ struct pt_regs { u64 syscallno; }; +struct arch_misc_regs {}; + #define arch_has_single_step() (1) #ifdef CONFIG_COMPAT diff --git a/arch/arm64/kernel/perf_regs.c b/arch/arm64/kernel/perf_regs.c index 3f62b35fb6f1..8ee80d7c8604 100644 --- a/arch/arm64/kernel/perf_regs.c +++ b/arch/arm64/kernel/perf_regs.c @@ -7,8 +7,10 @@ #include #include -u64 perf_reg_value(struct pt_regs *regs, int idx) +u64 perf_reg_value(struct perf_regs *p_regs, int idx) { + struct pt_regs *regs = p_regs->regs; + if (WARN_ON_ONCE((u32)idx >= PERF_REG_ARM64_MAX)) return 0; diff --git a/arch/powerpc/include/uapi/asm/ptrace.h b/arch/powerpc/include/uapi/asm/ptrace.h index 8036b385417d..0025651ab8bc 100644 --- a/arch/powerpc/include/uapi/asm/ptrace.h +++ b/arch/powerpc/include/uapi/asm/ptrace.h @@ -51,6 +51,8 @@ struct pt_regs { unsigned long result; /* Result of a system call */ }; +struct arch_misc_regs {}; + #endif /* __ASSEMBLY__ */ diff --git a/arch/powerpc/perf/perf_regs.c b/arch/powerpc/perf/perf_regs.c index 0520492d4078..f7995b46078a 100644 --- a/arch/powerpc/perf/perf_regs.c +++ b/arch/powerpc/perf/perf_regs.c @@ -61,8 +61,10 @@ static unsigned int pt_regs_offset[PERF_REG_POWERPC_MAX] = { PT_REGS_OFFSET(PERF_REG_POWERPC_DSISR, dsisr), }; -u64 perf_reg_value(struct pt_regs *regs, int idx) +u64 perf_reg_value(struct perf_regs *p_regs, int idx) { + struct pt_regs *regs = p_regs->regs; + if (WARN_ON_ONCE(idx >= PERF_REG_POWERPC_MAX)) return 0; return regs_get_register(regs, pt_regs_offset[idx]); diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h index 6271281f947d..410a2eb885c1 100644 --- a/arch/x86/include/asm/ptrace.h +++ b/arch/x86/include/asm/ptrace.h @@ -67,6 +67,8 @@ struct pt_regs { #endif /* !__i386__ */ +struct arch_misc_regs {}; + #ifdef CONFIG_PARAVIRT #include #endif diff --git a/arch/x86/kernel/perf_regs.c b/arch/x86/kernel/perf_regs.c index da8cb987b973..c6e41f7f648b 100644 --- a/arch/x86/kernel/perf_regs.c +++ b/arch/x86/kernel/perf_regs.c @@ -55,8 +55,10 @@ static unsigned int pt_regs_offset[PERF_REG_X86_MAX] = { #endif }; -u64 perf_reg_value(struct pt_regs *regs, int idx) +u64 perf_reg_value(struct perf_regs *p_regs, int idx) { + struct pt_regs *regs = p_regs->regs; + if (WARN_ON_ONCE(idx >= ARRAY_SIZE(pt_regs_offset))) return 0; diff --git a/include/linux/perf_regs.h b/include/linux/perf_regs.h index a5f98d53d732..7727a30e7d84 100644 --- a/include/linux/perf_regs.h +++ b/include/linux/perf_regs.h @@ -4,18 +4,19 @@ struct perf_regs { __u64 abi; struct pt_regs *regs; + struct arch_misc_regs *arch_regs; }; #ifdef CONFIG_HAVE_PERF_REGS #include -u64 perf_reg_value(struct pt_regs *regs, int idx); +u64 perf_reg_value(struct perf_regs *p_regs, int idx); int perf_reg_validate(u64 mask); u64 perf_reg_abi(struct task_struct *task); void perf_get_regs_user(struct perf_regs *regs_user, struct pt_regs *regs, struct pt_regs *regs_user_copy); #else -static inline u64 perf_reg_value(struct pt_regs *regs, int idx) +static inline u64 perf_reg_value(struct perf_regs *p_regs, int idx) { return 0; } diff --git a/kernel/events/core.c b/kernel/events/core.c index b11756f9b6dc..c04bdad3d365 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -4934,7 +4934,7 @@ EXPORT_SYMBOL_GPL(perf_unregister_guest_info_callbacks); static void perf_output_sample_regs(struct perf_output_handle *handle, - struct pt_regs *regs, u64 mask) + struct perf_regs *regs, u64 mask) { int bit; @@ -5331,7 +5331,7 @@ void perf_output_sample(struct perf_output_handle *handle, if (abi) { u64 mask = event->attr.sample_regs_user; perf_output_sample_regs(handle, - data->regs_user.regs, + &data->regs_user, mask); } } @@ -5363,7 +5363,7 @@ void perf_output_sample(struct perf_output_handle *handle, u64 mask = event->attr.sample_regs_intr; perf_output_sample_regs(handle, - data->regs_intr.regs, + &data->regs_intr, mask); } }