[patch 3/4] This patch introduces a new oprofile sample add function (oprofile_add_ext_hw_sample)

Previous thread: [patch 2/4] This patch enhances OProfile to support System zs hardware sampling feature by graalfs on Monday, December 20, 2010 - 6:05 am. (2 messages)

Next thread: [patch 1/4] This patch adds support for hardware based sampling on System z processors (models z10 and up) by graalfs on Monday, December 20, 2010 - 6:05 am. (2 messages)
From: graalfs
Date: Monday, December 20, 2010 - 6:05 am

From: graalfs@linux.vnet.ibm.com

This patch introduces a new oprofile sample add function (oprofile_add_ext_hw_sample)
that can also take task_struct as an argument, which is used by the hwsampler kernel module 
when copying hardware samples to OProfile buffers.

Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
Signed-off-by: Maran Pakkirisamy <maranp@linux.vnet.ibm.com>
Signed-off-by: Heinz Graalfs <graalfs@linux.vnet.ibm.com>
---
 drivers/oprofile/cpu_buffer.c |   26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

Index: linux-2.6/drivers/oprofile/cpu_buffer.c
===================================================================
--- linux-2.6.orig/drivers/oprofile/cpu_buffer.c
+++ linux-2.6/drivers/oprofile/cpu_buffer.c
@@ -22,6 +22,7 @@
 #include <linux/sched.h>
 #include <linux/oprofile.h>
 #include <linux/errno.h>
+#include <linux/module.h>
 
 #include "event_buffer.h"
 #include "cpu_buffer.h"
@@ -258,8 +259,10 @@ op_add_sample(struct oprofile_cpu_buffer
  */
 static int
 log_sample(struct oprofile_cpu_buffer *cpu_buf, unsigned long pc,
-	   unsigned long backtrace, int is_kernel, unsigned long event)
+	unsigned long backtrace, int is_kernel, unsigned long event,
+	struct task_struct *task)
 {
+	struct task_struct *tsk = task ? task : current;
 	cpu_buf->sample_received++;
 
 	if (pc == ESCAPE_CODE) {
@@ -267,7 +270,7 @@ log_sample(struct oprofile_cpu_buffer *c
 		return 0;
 	}
 
-	if (op_add_code(cpu_buf, backtrace, is_kernel, current))
+	if (op_add_code(cpu_buf, backtrace, is_kernel, tsk))
 		goto fail;
 
 	if (op_add_sample(cpu_buf, pc, event))
@@ -292,7 +295,8 @@ static inline void oprofile_end_trace(st
 
 static inline void
 __oprofile_add_ext_sample(unsigned long pc, struct pt_regs * const regs,
-			  unsigned long event, int is_kernel)
+			  unsigned long event, int is_kernel,
+			  struct task_struct *task)
 {
 	struct oprofile_cpu_buffer *cpu_buf = &__get_cpu_var(op_cpu_buffer);
 	unsigned long ...
From: Robert Richter
Date: Tuesday, January 4, 2011 - 8:34 am

Hmm, I am not convinced of this new interface between the hwsampler
module and oprofile. It is asymmetric and bloats the function's
parameters list. A first simplification would be to not implement
hwsampler as module and integrate this in oprofile. Then, we can look
for a better way to add samples to the oprofile buffer. What do you
think?

-Robert

-- 
Advanced Micro Devices, Inc.
Operating System Research Center

--

Previous thread: [patch 2/4] This patch enhances OProfile to support System zs hardware sampling feature by graalfs on Monday, December 20, 2010 - 6:05 am. (2 messages)

Next thread: [patch 1/4] This patch adds support for hardware based sampling on System z processors (models z10 and up) by graalfs on Monday, December 20, 2010 - 6:05 am. (2 messages)