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 06/13] powerpc/perf: Add support for perf_arch_regs in powerpc
Date: Mon, 29 Aug 2016 02:30:51 +0530	[thread overview]
Message-ID: <1472418058-28659-7-git-send-email-maddy@linux.vnet.ibm.com> (raw)
In-Reply-To: <1472418058-28659-1-git-send-email-maddy@linux.vnet.ibm.com>

Patch defines struct perf_arch_regs{} for powerpc and
update the per-cpu perf pmu structure to include
perf_arch_regs bits. perf_arch_reg_value(), perf_get_arch_reg()
and perf_get_arch_regs_mask() are implemented to return
proper values for powerpc. Finally adds code to call the
processor specific function to update the arch_regs register
values.

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>
---
 arch/powerpc/include/asm/perf_event_server.h | 11 ++++++++
 arch/powerpc/perf/core-book3s.c              | 38 ++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+)

diff --git a/arch/powerpc/include/asm/perf_event_server.h b/arch/powerpc/include/asm/perf_event_server.h
index e157489ee7a1..65699fefb5a8 100644
--- a/arch/powerpc/include/asm/perf_event_server.h
+++ b/arch/powerpc/include/asm/perf_event_server.h
@@ -12,6 +12,7 @@
 #include <linux/types.h>
 #include <asm/hw_irq.h>
 #include <linux/device.h>
+#include <uapi/asm/perf_regs.h>
 #include <uapi/asm/perf_event.h>
 
 /* Update perf_event_print_debug() if this changes */
@@ -21,6 +22,12 @@
 
 struct perf_event;
 
+struct perf_arch_regs {
+	unsigned long regs[PERF_ARCH_REG_POWERPC_MAX];
+};
+
+#define perf_arch_regs perf_arch_regs
+
 /*
  * This struct provides the constants and functions needed to
  * describe the PMU on a particular POWER-family CPU.
@@ -52,6 +59,10 @@ struct power_pmu {
 
 	/* BHRB entries in the PMU */
 	int		bhrb_nr;
+
+	/* perf_arch_regs bits */
+	u64		ar_mask;
+	void		(*get_arch_regs)(struct perf_arch_regs *regs);
 };
 
 /*
diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
index 4ed377f0f7b2..6acf086f31b3 100644
--- a/arch/powerpc/perf/core-book3s.c
+++ b/arch/powerpc/perf/core-book3s.c
@@ -57,6 +57,9 @@ struct cpu_hw_events {
 	void				*bhrb_context;
 	struct	perf_branch_stack	bhrb_stack;
 	struct	perf_branch_entry	bhrb_entries[BHRB_MAX_ENTRIES];
+
+	/* perf_arch_regs bits */
+	struct perf_arch_regs		ar_regs;
 };
 
 static DEFINE_PER_CPU(struct cpu_hw_events, cpu_hw_events);
@@ -1928,6 +1931,33 @@ ssize_t power_events_sysfs_show(struct device *dev,
 	return sprintf(page, "event=0x%02llx\n", pmu_attr->id);
 }
 
+u64 perf_get_arch_regs_mask(void)
+{
+	return ppmu->ar_mask;
+}
+
+struct perf_arch_regs *perf_get_arch_reg()
+{
+	struct cpu_hw_events *cpuhw;
+
+	cpuhw = this_cpu_ptr(&cpu_hw_events);
+	if (!ppmu->ar_mask)
+		return NULL;
+
+	return &cpuhw->ar_regs;
+}
+
+u64 perf_arch_reg_value(struct perf_arch_regs *regs, int idx)
+{
+	struct cpu_hw_events *cpuhw;
+
+	cpuhw = this_cpu_ptr(&cpu_hw_events);
+	if (WARN_ON_ONCE(idx >= PERF_ARCH_REG_POWERPC_MAX))
+		return 0;
+
+	return cpuhw->ar_regs.regs[idx];
+}
+
 static struct pmu power_pmu = {
 	.pmu_enable	= power_pmu_enable,
 	.pmu_disable	= power_pmu_disable,
@@ -2009,6 +2039,14 @@ 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);
+
+			if (ppmu->get_arch_regs)
+				ppmu->get_arch_regs(&cpuhw->ar_regs);
+		}
+
 		if (perf_event_overflow(event, &data, regs))
 			power_pmu_stop(event, 0);
 	}
-- 
2.7.4

  parent reply	other threads:[~2016-08-28 21:02 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 ` [PATCH 01/13] perf/core: Add perf_arch_regs and mask to perf_regs structure Madhavan Srinivasan
2016-08-28 21:22   ` 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 ` Madhavan Srinivasan [this message]
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-7-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).