All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Yan, Zheng" <zheng.z.yan@intel.com>
To: linux-kernel@vger.kernel.org
Cc: a.p.zijlstra@chello.nl, mingo@kernel.org, acme@infradead.org,
	eranian@google.com, andi@firstfloor.org, "Yan,
	Zheng" <zheng.z.yan@intel.com>
Subject: [PATCH V4 11/16] perf, core: Pass perf_sample_data to perf_callchain()
Date: Mon, 30 Jun 2014 16:50:48 +0800	[thread overview]
Message-ID: <1404118253-19532-12-git-send-email-zheng.z.yan@intel.com> (raw)
In-Reply-To: <1404118253-19532-1-git-send-email-zheng.z.yan@intel.com>

Haswell has a new feature that utilizes the existing Last Branch Record
facility to record call chains. When the feature is enabled, function
call will be collected as normal, but as return instructions are executed
the last captured branch record is popped from the on-chip LBR registers.
The LBR call stack facility can help perf to get call chains of progam
without frame pointer.

This patch modifies various architectures' perf_callchain() to accept
perf sample data. Later patch will add code that use the sample data to
get call chains.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
---
 arch/arm/kernel/perf_event.c     | 4 ++--
 arch/powerpc/perf/callchain.c    | 4 ++--
 arch/sparc/kernel/perf_event.c   | 4 ++--
 arch/x86/kernel/cpu/perf_event.c | 4 ++--
 include/linux/perf_event.h       | 3 ++-
 kernel/events/callchain.c        | 8 +++++---
 kernel/events/core.c             | 2 +-
 kernel/events/internal.h         | 3 ++-
 8 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/arch/arm/kernel/perf_event.c b/arch/arm/kernel/perf_event.c
index 4238bcb..4bc9148 100644
--- a/arch/arm/kernel/perf_event.c
+++ b/arch/arm/kernel/perf_event.c
@@ -579,8 +579,8 @@ user_backtrace(struct frame_tail __user *tail,
 	return buftail.fp - 1;
 }
 
-void
-perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
+void perf_callchain_user(struct perf_callchain_entry *entry,
+			 struct pt_regs *regs, struct perf_sample_data *data)
 {
 	struct frame_tail __user *tail;
 
diff --git a/arch/powerpc/perf/callchain.c b/arch/powerpc/perf/callchain.c
index 74d1e78..b379ebc 100644
--- a/arch/powerpc/perf/callchain.c
+++ b/arch/powerpc/perf/callchain.c
@@ -482,8 +482,8 @@ static void perf_callchain_user_32(struct perf_callchain_entry *entry,
 	}
 }
 
-void
-perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
+void perf_callchain_user(struct perf_callchain_entry *entry,
+			 struct pt_regs *regs, struct perf_sample_data *data)
 {
 	if (current_is_64bit())
 		perf_callchain_user_64(entry, regs);
diff --git a/arch/sparc/kernel/perf_event.c b/arch/sparc/kernel/perf_event.c
index 8efd337..85c190e 100644
--- a/arch/sparc/kernel/perf_event.c
+++ b/arch/sparc/kernel/perf_event.c
@@ -1788,8 +1788,8 @@ static void perf_callchain_user_32(struct perf_callchain_entry *entry,
 	} while (entry->nr < PERF_MAX_STACK_DEPTH);
 }
 
-void
-perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
+void perf_callchain_user(struct perf_callchain_entry *entry,
+			 struct pt_regs *regs, struct perf_sample_data *data)
 {
 	perf_callchain_store(entry, regs->tpc);
 
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 2008c2a..3ed9c6a 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -2043,8 +2043,8 @@ perf_callchain_user32(struct pt_regs *regs, struct perf_callchain_entry *entry)
 }
 #endif
 
-void
-perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
+void perf_callchain_user(struct perf_callchain_entry *entry,
+			 struct pt_regs *regs, struct perf_sample_data *data)
 {
 	struct stack_frame frame;
 	const void __user *fp;
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 2bf2cb2a..cc0b86e 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -720,7 +720,8 @@ extern void perf_event_fork(struct task_struct *tsk);
 /* Callchains */
 DECLARE_PER_CPU(struct perf_callchain_entry, perf_callchain_entry);
 
-extern void perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs);
+extern void perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs,
+				struct perf_sample_data *data);
 extern void perf_callchain_kernel(struct perf_callchain_entry *entry, struct pt_regs *regs);
 
 static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64 ip)
diff --git a/kernel/events/callchain.c b/kernel/events/callchain.c
index 97b67df..19d497c 100644
--- a/kernel/events/callchain.c
+++ b/kernel/events/callchain.c
@@ -30,7 +30,8 @@ __weak void perf_callchain_kernel(struct perf_callchain_entry *entry,
 }
 
 __weak void perf_callchain_user(struct perf_callchain_entry *entry,
-				struct pt_regs *regs)
+				struct pt_regs *regs,
+				struct perf_sample_data *data)
 {
 }
 
@@ -157,7 +158,8 @@ put_callchain_entry(int rctx)
 }
 
 struct perf_callchain_entry *
-perf_callchain(struct perf_event *event, struct pt_regs *regs)
+perf_callchain(struct perf_event *event, struct pt_regs *regs,
+	       struct perf_sample_data *data)
 {
 	int rctx;
 	struct perf_callchain_entry *entry;
@@ -198,7 +200,7 @@ perf_callchain(struct perf_event *event, struct pt_regs *regs)
 				goto exit_put;
 
 			perf_callchain_store(entry, PERF_CONTEXT_USER);
-			perf_callchain_user(entry, regs);
+			perf_callchain_user(entry, regs, data);
 		}
 	}
 
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 73a6e77..d684269 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -4738,7 +4738,7 @@ void perf_prepare_sample(struct perf_event_header *header,
 	if (sample_type & PERF_SAMPLE_CALLCHAIN) {
 		int size = 1;
 
-		data->callchain = perf_callchain(event, regs);
+		data->callchain = perf_callchain(event, regs, data);
 
 		if (data->callchain)
 			size += data->callchain->nr;
diff --git a/kernel/events/internal.h b/kernel/events/internal.h
index 569b2187..cd18b64 100644
--- a/kernel/events/internal.h
+++ b/kernel/events/internal.h
@@ -147,7 +147,8 @@ DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
 
 /* Callchain handling */
 extern struct perf_callchain_entry *
-perf_callchain(struct perf_event *event, struct pt_regs *regs);
+perf_callchain(struct perf_event *event, struct pt_regs *regs,
+	       struct perf_sample_data *data);
 extern int get_callchain_buffers(void);
 extern void put_callchain_buffers(void);
 
-- 
1.9.0


  parent reply	other threads:[~2014-06-30  8:52 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-30  8:50 [PATCH V4 00/16] perf, x86: Haswell LBR call stack support Yan, Zheng
2014-06-30  8:50 ` [PATCH V4 01/16] perf, x86: Reduce lbr_sel_map size Yan, Zheng
2014-06-30  8:50 ` [PATCH V4 02/16] perf, core: introduce pmu context switch callback Yan, Zheng
2014-07-02  8:48   ` Peter Zijlstra
2014-07-02 10:12   ` Peter Zijlstra
2014-07-03  5:47     ` Yan, Zheng
2014-06-30  8:50 ` [PATCH V4 03/16] perf, x86: use context switch callback to flush LBR stack Yan, Zheng
2014-07-02  9:06   ` Peter Zijlstra
2014-07-03  5:44     ` Yan, Zheng
2014-06-30  8:50 ` [PATCH V4 04/16] perf, x86: Basic Haswell LBR call stack support Yan, Zheng
2014-07-02 10:14   ` Peter Zijlstra
2014-06-30  8:50 ` [PATCH V4 05/16] perf, core: pmu specific data for perf task context Yan, Zheng
2014-07-02 10:18   ` Peter Zijlstra
2014-06-30  8:50 ` [PATCH V4 06/16] perf, core: always switch pmu specific data during context switch Yan, Zheng
2014-07-02 10:19   ` Peter Zijlstra
2014-06-30  8:50 ` [PATCH V4 07/16] perf, x86: track number of events that use LBR callstack Yan, Zheng
2014-07-02 10:21   ` Peter Zijlstra
2014-07-03  5:59     ` Yan, Zheng
2014-07-02 10:25   ` Peter Zijlstra
2014-06-30  8:50 ` [PATCH V4 08/16] perf, x86: allocate space for storing LBR stack Yan, Zheng
2014-06-30  8:50 ` [PATCH V4 09/16] perf, x86: Save/resotre LBR stack during context switch Yan, Zheng
2014-07-02 10:49   ` Peter Zijlstra
2014-06-30  8:50 ` [PATCH V4 10/16] perf, core: simplify need branch stack check Yan, Zheng
2014-07-02 10:57   ` Peter Zijlstra
2014-07-02 11:08     ` Stephane Eranian
2014-07-02 12:27       ` Peter Zijlstra
2014-07-02 13:00         ` Stephane Eranian
2014-07-02 13:28           ` Peter Zijlstra
2014-06-30  8:50 ` Yan, Zheng [this message]
2014-06-30  8:50 ` [PATCH V4 12/16] perf, x86: use LBR call stack to get user callchain Yan, Zheng
2014-06-30  8:50 ` [PATCH V4 13/16] perf, x86: re-organize code that implicitly enables LBR/PEBS Yan, Zheng
2014-06-30  8:50 ` [PATCH V4 14/16] perf, x86: enable LBR callstack when recording callchain Yan, Zheng
2014-06-30 14:45   ` Andi Kleen
2014-06-30  8:50 ` [PATCH V4 15/16] perf, x86: disable FREEZE_LBRS_ON_PMI when LBR operates in callstack mode Yan, Zheng
2014-07-02 11:13   ` Peter Zijlstra
2014-06-30  8:50 ` [PATCH V4 16/16] perf, x86: Discard zero length call entries in LBR call stack Yan, Zheng
  -- strict thread matches above, loose matches on Subject: below --
2014-03-17  5:57 [PATCH v4 00/16] perf, x86: Haswell LBR call stack support Yan, Zheng
2014-03-17  5:57 ` [PATCH v4 11/16] perf, core: Pass perf_sample_data to perf_callchain() Yan, Zheng

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=1404118253-19532-12-git-send-email-zheng.z.yan@intel.com \
    --to=zheng.z.yan@intel.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@infradead.org \
    --cc=andi@firstfloor.org \
    --cc=eranian@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.