linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
To: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org
Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Jiri Olsa <jolsa@kernel.org>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Stephane Eranian <eranian@gmail.com>,
	Russell King <linux@arm.linux.org.uk>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will.deacon@arm.com>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Subject: [PATCH 01/13] perf/core: Add perf_arch_regs and mask to perf_regs structure
Date: Mon, 29 Aug 2016 02:30:46 +0530	[thread overview]
Message-ID: <1472418058-28659-2-git-send-email-maddy@linux.vnet.ibm.com> (raw)
In-Reply-To: <1472418058-28659-1-git-send-email-maddy@linux.vnet.ibm.com>

It's a perennial request from hardware folks to be able to
see the raw values of the pmu registers. Partly it's so that
they can verify perf is doing what they want, and some
of it is that they're interested in some of the more obscure
info that isn't plumbed out through other perf interfaces.

Over the years internally have used various hack to get
the requested data out but this is an attempt to use a
somewhat standard mechanism (using PERF_SAMPLE_REGS_INTR).

This would also be helpful for those of us working on the perf
hardware backends, to be able to verify that we're programming
things correctly, without resorting to debug printks etc.

Mechanism proposed:

1)perf_regs structure is extended with a perf_arch_regs structure
which each arch/ can populate with their specific platform
registers to sample on each perf interrupt and an arch_regs_mask
variable, which is for perf tool to know about the perf_arch_regs
that are supported.

2)perf/core func perf_sample_regs_intr() extended to update
the perf_arch_regs structure and the perf_arch_reg_mask. Set of new
support functions added perf_get_arch_regs_mask() and
perf_get_arch_reg() to aid the updates from arch/ side.

3) perf/core funcs perf_prepare_sample() and perf_output_sample()
are extended to support the update for the perf_arch_regs_mask and
perf_arch_regs in the sample

4)perf/core func perf_output_sample_regs() extended to dump
the arch_regs to the output sample.

5)Finally, perf tool side is updated a) to include a new element
"arch_regs_mask" in the "struct regs_dump", b) event sample funcs
to updated to include "arch_regs_mask" and c) print functions
are updated.

This foundation patch just extends the perf_regs structure, defines
support function and subsequent patches completes the implimentation
for powerpc arch.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Stephane Eranian <eranian@gmail.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
---
 include/linux/perf_regs.h | 26 ++++++++++++++++++++++++++
 kernel/events/core.c      | 16 ++++++++++++++++
 2 files changed, 42 insertions(+)

diff --git a/include/linux/perf_regs.h b/include/linux/perf_regs.h
index a5f98d53d732..bd19b15703e2 100644
--- a/include/linux/perf_regs.h
+++ b/include/linux/perf_regs.h
@@ -4,8 +4,14 @@
 struct perf_regs {
 	__u64		abi;
 	struct pt_regs	*regs;
+	struct perf_arch_regs	*arch_regs;
+	u64		arch_regs_mask;
 };
 
+#ifndef perf_arch_regs
+struct perf_arch_regs { };
+#endif
+
 #ifdef CONFIG_HAVE_PERF_REGS
 #include <asm/perf_regs.h>
 u64 perf_reg_value(struct pt_regs *regs, int idx);
@@ -14,6 +20,11 @@ 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);
+
+u64 perf_get_arch_regs_mask(void);
+struct perf_arch_regs *perf_get_arch_reg(void);
+u64 perf_arch_reg_value(struct perf_arch_regs *regs, int idx);
+
 #else
 static inline u64 perf_reg_value(struct pt_regs *regs, int idx)
 {
@@ -37,5 +48,20 @@ static inline void perf_get_regs_user(struct perf_regs *regs_user,
 	regs_user->regs = task_pt_regs(current);
 	regs_user->abi = perf_reg_abi(current);
 }
+
+u64 perf_get_arch_regs_mask(void)
+{
+	return 0;
+}
+
+struct perf_arch_regs *perf_get_arch_reg(void)
+{
+	return 0;
+}
+
+u64 perf_arch_reg_value(struct perf_arch_regs *regs, int idx)
+{
+	return 0;
+}
 #endif /* CONFIG_HAVE_PERF_REGS */
 #endif /* _LINUX_PERF_REGS_H */
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 3f07e6cfc1b6..2f6e6a16b117 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -5353,6 +5353,22 @@ int perf_unregister_guest_info_callbacks(struct perf_guest_info_callbacks *cbs)
 }
 EXPORT_SYMBOL_GPL(perf_unregister_guest_info_callbacks);
 
+u64 __attribute__((weak)) perf_get_arch_regs_mask()
+{
+	return 0;
+}
+
+struct perf_arch_regs *__attribute__((weak)) perf_get_arch_reg()
+{
+	return 0;
+}
+
+u64 __attribute__((weak)) perf_arch_reg_value(struct perf_arch_regs *regs,
+								int idx)
+{
+	return 0;
+}
+
 static void
 perf_output_sample_regs(struct perf_output_handle *handle,
 			struct pt_regs *regs, u64 mask)
-- 
2.7.4

  reply	other threads:[~2016-08-28 21:01 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-28 21:00 [PATCH 00/13] Add support for perf_arch_regs Madhavan Srinivasan
2016-08-28 21:00 ` Madhavan Srinivasan [this message]
2016-08-28 21:22   ` [PATCH 01/13] perf/core: Add perf_arch_regs and mask to perf_regs structure kbuild test robot
2016-08-28 23:41   ` kbuild test robot
2016-08-29  0:21   ` kbuild test robot
2016-09-01  7:26   ` Peter Zijlstra
2016-09-06  4:25     ` Madhavan Srinivasan
2016-09-06  9:10       ` Peter Zijlstra
2016-09-09  0:44         ` Madhavan Srinivasan
2016-08-28 21:00 ` [PATCH 02/13] perf/core: Extend perf_sample_regs_intr() to include perf_arch_regs update Madhavan Srinivasan
2016-08-28 21:00 ` [PATCH 03/13] perf/core: Update perf_*_sample() to include perf_arch_regs Madhavan Srinivasan
2016-08-28 21:00 ` [PATCH 04/13] perf/core: Extend perf_output_sample_regs() " Madhavan Srinivasan
2016-08-30 16:11   ` Nilay Vaish
2016-09-01  3:42     ` Madhavan Srinivasan
2016-08-28 21:00 ` [PATCH 05/13] powerpc/perf: Define enums for perf_arch_regs registers Madhavan Srinivasan
2016-08-28 21:00 ` [PATCH 06/13] powerpc/perf: Add support for perf_arch_regs in powerpc Madhavan Srinivasan
2016-08-28 21:00 ` [PATCH 07/13] powerpc/perf: Add support for perf_arch_regs for Power7 processor Madhavan Srinivasan
2016-08-28 21:00 ` [PATCH 08/13] powerpc/perf: Add support for perf_arch_regs for newer Power processor Madhavan Srinivasan
2016-08-28 21:00 ` [PATCH 09/13] powerpc/perf: Add support for perf_arch_regs for PPC970 processor Madhavan Srinivasan
2016-08-28 21:00 ` [PATCH 10/13] tool/perf: Add support for perf_arch_regs Madhavan Srinivasan
2016-08-28 21:00 ` [PATCH 11/13] tools/perf: Fix the mask in regs_dump__printf and print_sample_iregs Madhavan Srinivasan
2016-08-28 21:00 ` [PATCH 12/13] tool/perf: Add perf_arch_reg mask and arch_reg_names structure Madhavan Srinivasan
2016-08-28 21:00 ` [PATCH 13/13] powerpc/perf: Add support to dump only arch_regs Madhavan Srinivasan
2016-08-30 16:01 ` [PATCH 00/13] Add support for perf_arch_regs Nilay Vaish
2016-09-01  3:08   ` Madhavan Srinivasan

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=1472418058-28659-2-git-send-email-maddy@linux.vnet.ibm.com \
    --to=maddy@linux.vnet.ibm.com \
    --cc=acme@kernel.org \
    --cc=benh@kernel.crashing.org \
    --cc=catalin.marinas@arm.com \
    --cc=eranian@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mingo@kernel.org \
    --cc=mpe@ellerman.id.au \
    --cc=peterz@infradead.org \
    --cc=sukadev@linux.vnet.ibm.com \
    --cc=tglx@linutronix.de \
    --cc=will.deacon@arm.com \
    /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).