From: Robert Richter <robert.richter@amd.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: LKML <linux-kernel@vger.kernel.org>,
oprofile-list <oprofile-list@lists.sourceforge.net>,
Robert Richter <robert.richter@amd.com>
Subject: [PATCH 9/9] oprofile: make new cpu buffer functions part of the api
Date: Wed, 7 Jan 2009 23:45:25 +0100 [thread overview]
Message-ID: <1231368325-19246-10-git-send-email-robert.richter@amd.com> (raw)
In-Reply-To: <1231368325-19246-1-git-send-email-robert.richter@amd.com>
This patch creates the new functions
oprofile_write_reserve()
oprofile_add_data()
oprofile_write_commit()
and makes them part of the oprofile api.
Signed-off-by: Robert Richter <robert.richter@amd.com>
---
arch/x86/oprofile/op_model_amd.c | 57 ++++++++++++++++----------------------
drivers/oprofile/cpu_buffer.c | 17 +++++++++--
drivers/oprofile/cpu_buffer.h | 8 +----
include/linux/oprofile.h | 18 ++++++++++++
4 files changed, 57 insertions(+), 43 deletions(-)
diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
index cf310ae..8fdf06e 100644
--- a/arch/x86/oprofile/op_model_amd.c
+++ b/arch/x86/oprofile/op_model_amd.c
@@ -22,7 +22,6 @@
#include "op_x86_model.h"
#include "op_counter.h"
-#include "../../../drivers/oprofile/cpu_buffer.h"
#define NUM_COUNTERS 4
#define NUM_CONTROLS 4
@@ -61,14 +60,6 @@ static unsigned long reset_value[NUM_COUNTERS];
#define IBS_OP_LOW_VALID_BIT (1ULL<<18) /* bit 18 */
#define IBS_OP_LOW_ENABLE (1ULL<<17) /* bit 17 */
-/*
- * The function interface needs to be fixed, something like add
- * data. Should then be added to linux/oprofile.h.
- */
-extern
-void oprofile_add_data(struct op_entry *entry, struct pt_regs * const regs,
- unsigned long pc, int code, int size);
-
#define IBS_FETCH_SIZE 6
#define IBS_OP_SIZE 12
@@ -174,16 +165,16 @@ op_amd_handle_ibs(struct pt_regs * const regs,
rdmsr(MSR_AMD64_IBSFETCHCTL, low, high);
if (high & IBS_FETCH_HIGH_VALID_BIT) {
rdmsrl(MSR_AMD64_IBSFETCHLINAD, msr);
- oprofile_add_data(&entry, regs, msr, IBS_FETCH_CODE,
- IBS_FETCH_SIZE);
- op_cpu_buffer_add_data(&entry, (u32)msr);
- op_cpu_buffer_add_data(&entry, (u32)(msr >> 32));
- op_cpu_buffer_add_data(&entry, low);
- op_cpu_buffer_add_data(&entry, high);
+ oprofile_write_reserve(&entry, regs, msr,
+ IBS_FETCH_CODE, IBS_FETCH_SIZE);
+ oprofile_add_data(&entry, (u32)msr);
+ oprofile_add_data(&entry, (u32)(msr >> 32));
+ oprofile_add_data(&entry, low);
+ oprofile_add_data(&entry, high);
rdmsrl(MSR_AMD64_IBSFETCHPHYSAD, msr);
- op_cpu_buffer_add_data(&entry, (u32)msr);
- op_cpu_buffer_add_data(&entry, (u32)(msr >> 32));
- op_cpu_buffer_write_commit(&entry);
+ oprofile_add_data(&entry, (u32)msr);
+ oprofile_add_data(&entry, (u32)(msr >> 32));
+ oprofile_write_commit(&entry);
/* reenable the IRQ */
high &= ~IBS_FETCH_HIGH_VALID_BIT;
@@ -197,26 +188,26 @@ op_amd_handle_ibs(struct pt_regs * const regs,
rdmsr(MSR_AMD64_IBSOPCTL, low, high);
if (low & IBS_OP_LOW_VALID_BIT) {
rdmsrl(MSR_AMD64_IBSOPRIP, msr);
- oprofile_add_data(&entry, regs, msr, IBS_OP_CODE,
- IBS_OP_SIZE);
- op_cpu_buffer_add_data(&entry, (u32)msr);
- op_cpu_buffer_add_data(&entry, (u32)(msr >> 32));
+ oprofile_write_reserve(&entry, regs, msr,
+ IBS_OP_CODE, IBS_OP_SIZE);
+ oprofile_add_data(&entry, (u32)msr);
+ oprofile_add_data(&entry, (u32)(msr >> 32));
rdmsrl(MSR_AMD64_IBSOPDATA, msr);
- op_cpu_buffer_add_data(&entry, (u32)msr);
- op_cpu_buffer_add_data(&entry, (u32)(msr >> 32));
+ oprofile_add_data(&entry, (u32)msr);
+ oprofile_add_data(&entry, (u32)(msr >> 32));
rdmsrl(MSR_AMD64_IBSOPDATA2, msr);
- op_cpu_buffer_add_data(&entry, (u32)msr);
- op_cpu_buffer_add_data(&entry, (u32)(msr >> 32));
+ oprofile_add_data(&entry, (u32)msr);
+ oprofile_add_data(&entry, (u32)(msr >> 32));
rdmsrl(MSR_AMD64_IBSOPDATA3, msr);
- op_cpu_buffer_add_data(&entry, (u32)msr);
- op_cpu_buffer_add_data(&entry, (u32)(msr >> 32));
+ oprofile_add_data(&entry, (u32)msr);
+ oprofile_add_data(&entry, (u32)(msr >> 32));
rdmsrl(MSR_AMD64_IBSDCLINAD, msr);
- op_cpu_buffer_add_data(&entry, (u32)msr);
- op_cpu_buffer_add_data(&entry, (u32)(msr >> 32));
+ oprofile_add_data(&entry, (u32)msr);
+ oprofile_add_data(&entry, (u32)(msr >> 32));
rdmsrl(MSR_AMD64_IBSDCPHYSAD, msr);
- op_cpu_buffer_add_data(&entry, (u32)msr);
- op_cpu_buffer_add_data(&entry, (u32)(msr >> 32));
- op_cpu_buffer_write_commit(&entry);
+ oprofile_add_data(&entry, (u32)msr);
+ oprofile_add_data(&entry, (u32)(msr >> 32));
+ oprofile_write_commit(&entry);
/* reenable the IRQ */
high = 0;
diff --git a/drivers/oprofile/cpu_buffer.c b/drivers/oprofile/cpu_buffer.c
index b846af6..2e03b6d 100644
--- a/drivers/oprofile/cpu_buffer.c
+++ b/drivers/oprofile/cpu_buffer.c
@@ -364,10 +364,11 @@ void oprofile_add_sample(struct pt_regs * const regs, unsigned long event)
/*
* Add samples with data to the ring buffer.
*
- * Use op_cpu_buffer_add_data(&entry, val) to add data and
- * op_cpu_buffer_write_commit(&entry) to commit the sample.
+ * Use oprofile_add_data(&entry, val) to add data and
+ * oprofile_write_commit(&entry) to commit the sample.
*/
-void oprofile_add_data(struct op_entry *entry, struct pt_regs * const regs,
+void
+oprofile_write_reserve(struct op_entry *entry, struct pt_regs * const regs,
unsigned long pc, int code, int size)
{
struct op_sample *sample;
@@ -395,6 +396,16 @@ fail:
cpu_buf->sample_lost_overflow++;
}
+int oprofile_add_data(struct op_entry *entry, unsigned long val)
+{
+ return op_cpu_buffer_add_data(entry, val);
+}
+
+int oprofile_write_commit(struct op_entry *entry)
+{
+ return op_cpu_buffer_write_commit(entry);
+}
+
void oprofile_add_pc(unsigned long pc, int is_kernel, unsigned long event)
{
struct oprofile_cpu_buffer *cpu_buf = &__get_cpu_var(cpu_buffer);
diff --git a/drivers/oprofile/cpu_buffer.h b/drivers/oprofile/cpu_buffer.h
index 525cc4d..63f81c4 100644
--- a/drivers/oprofile/cpu_buffer.h
+++ b/drivers/oprofile/cpu_buffer.h
@@ -35,13 +35,7 @@ struct op_sample {
unsigned long data[0];
};
-struct op_entry {
- struct ring_buffer_event *event;
- struct op_sample *sample;
- unsigned long irq_flags;
- unsigned long size;
- unsigned long *data;
-};
+struct op_entry;
struct oprofile_cpu_buffer {
unsigned long buffer_size;
diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
index 1ce9fe5..1d9518b 100644
--- a/include/linux/oprofile.h
+++ b/include/linux/oprofile.h
@@ -164,4 +164,22 @@ void oprofile_put_buff(unsigned long *buf, unsigned int start,
unsigned long oprofile_get_cpu_buffer_size(void);
void oprofile_cpu_buffer_inc_smpl_lost(void);
+/* cpu buffer functions */
+
+struct op_sample;
+
+struct op_entry {
+ struct ring_buffer_event *event;
+ struct op_sample *sample;
+ unsigned long irq_flags;
+ unsigned long size;
+ unsigned long *data;
+};
+
+void oprofile_write_reserve(struct op_entry *entry,
+ struct pt_regs * const regs,
+ unsigned long pc, int code, int size);
+int oprofile_add_data(struct op_entry *entry, unsigned long val);
+int oprofile_write_commit(struct op_entry *entry);
+
#endif /* OPROFILE_H */
--
1.6.0.1
next prev parent reply other threads:[~2009-01-07 23:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-07 22:45 [PATCH 0/9] oprofile: implement support of samples with variable data size Robert Richter
2009-01-07 22:45 ` [PATCH 1/9] oprofile: add op_cpu_buffer_write_reserve() Robert Richter
2009-01-07 22:45 ` [PATCH 2/9] oprofile: modify op_cpu_buffer_read_entry() Robert Richter
2009-01-07 22:45 ` [PATCH 3/9] oprofile: rework implementation of cpu buffer events Robert Richter
2009-01-07 22:45 ` [PATCH 4/9] oprofile: add op_cpu_buffer_add_data() Robert Richter
2009-01-07 22:45 ` [PATCH 5/9] oprofile: add op_cpu_buffer_get_data() Robert Richter
2009-01-07 22:45 ` [PATCH 6/9] oprofile: use new data sample format for ibs Robert Richter
2009-01-07 22:45 ` [PATCH 7/9] ring_buffer: fix ring_buffer_event_length() Robert Richter
2009-01-07 22:45 ` [PATCH 8/9] oprofile: remove #ifdef CONFIG_OPROFILE_IBS in non-ibs code Robert Richter
2009-01-07 22:45 ` Robert Richter [this message]
2009-01-14 21:53 ` [PATCH 0/9] oprofile: implement support of samples with variable data size Maynard Johnson
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=1231368325-19246-10-git-send-email-robert.richter@amd.com \
--to=robert.richter@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=oprofile-list@lists.sourceforge.net \
/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
Powered by JetHome