public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/10] oprofile and ftrace: some trivial patches
@ 2008-12-11 15:04 Robert Richter
  2008-12-11 15:04 ` [PATCH 01/10] oprofile: comment cleanup Robert Richter
                   ` (9 more replies)
  0 siblings, 10 replies; 13+ messages in thread
From: Robert Richter @ 2008-12-11 15:04 UTC (permalink / raw)
  To: oprofile-list; +Cc: LKML

The following patch set contains some cleanups, code reworks and fixes
for oprofile. Additional there are 2 trivial patches for ftrace
too. This patch set is in preparation of a follow on patch set that
ports to the new ring buffer.

Patches are also here:

git://git.kernel.org/pub/scm/linux/kernel/git/rric/oprofile.git next

-Robert




^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 01/10] oprofile: comment cleanup
  2008-12-11 15:04 [PATCH 0/10] oprofile and ftrace: some trivial patches Robert Richter
@ 2008-12-11 15:04 ` Robert Richter
  2008-12-11 15:04 ` [PATCH 02/10] oprofile: update comment for oprofile_add_sample() Robert Richter
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Robert Richter @ 2008-12-11 15:04 UTC (permalink / raw)
  To: oprofile-list; +Cc: LKML, Robert Richter

This fixes the coding style of some comments.

Signed-off-by: Robert Richter <robert.richter@amd.com>
---
 arch/x86/oprofile/op_model_amd.c |   31 ++++++++++++++++---------------
 drivers/oprofile/cpu_buffer.c    |   25 ++++++++++++++++---------
 2 files changed, 32 insertions(+), 24 deletions(-)

diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
index 5095137..fb67e19 100644
--- a/arch/x86/oprofile/op_model_amd.c
+++ b/arch/x86/oprofile/op_model_amd.c
@@ -65,8 +65,10 @@ static unsigned long reset_value[NUM_COUNTERS];
 #define IBS_FETCH_BEGIN 3
 #define IBS_OP_BEGIN    4
 
-/* The function interface needs to be fixed, something like add
-   data. Should then be added to linux/oprofile.h. */
+/*
+ * The function interface needs to be fixed, something like add
+ * data. Should then be added to linux/oprofile.h.
+ */
 extern void
 oprofile_add_ibs_sample(struct pt_regs *const regs,
 			unsigned int *const ibs_sample, int ibs_code);
@@ -106,7 +108,7 @@ struct ibs_op_sample {
 
 /*
  * unitialize the APIC for the IBS interrupts if needed on AMD Family10h+
-*/
+ */
 static void clear_ibs_nmi(void);
 
 static int ibs_allowed;	/* AMD Family10h and later */
@@ -223,7 +225,7 @@ op_amd_handle_ibs(struct pt_regs * const regs,
 						(unsigned int *)&ibs_fetch,
 						IBS_FETCH_BEGIN);
 
-			/*reenable the IRQ */
+			/* reenable the IRQ */
 			rdmsr(MSR_AMD64_IBSFETCHCTL, low, high);
 			high &= ~IBS_FETCH_HIGH_VALID_BIT;
 			high |= IBS_FETCH_HIGH_ENABLE;
@@ -331,8 +333,10 @@ static void op_amd_stop(struct op_msrs const * const msrs)
 	unsigned int low, high;
 	int i;
 
-	/* Subtle: stop on all counters to avoid race with
-	 * setting our pm callback */
+	/*
+	 * Subtle: stop on all counters to avoid race with setting our
+	 * pm callback
+	 */
 	for (i = 0 ; i < NUM_COUNTERS ; ++i) {
 		if (!reset_value[i])
 			continue;
@@ -343,13 +347,15 @@ static void op_amd_stop(struct op_msrs const * const msrs)
 
 #ifdef CONFIG_OPROFILE_IBS
 	if (ibs_allowed && ibs_config.fetch_enabled) {
-		low = 0;		/* clear max count and enable */
+		/* clear max count and enable */
+		low = 0;
 		high = 0;
 		wrmsr(MSR_AMD64_IBSFETCHCTL, low, high);
 	}
 
 	if (ibs_allowed && ibs_config.op_enabled) {
-		low = 0;		/* clear max count and enable */
+		/* clear max count and enable */
+		low = 0;
 		high = 0;
 		wrmsr(MSR_AMD64_IBSOPCTL, low, high);
 	}
@@ -443,10 +449,7 @@ static int pfm_amd64_setup_eilvt(void)
 	return 0;
 }
 
-/*
- * initialize the APIC for the IBS interrupts
- * if available (AMD Family10h rev B0 and later)
- */
+/* initialize the APIC for the IBS interrupts if available */
 static void setup_ibs(void)
 {
 	ibs_allowed = boot_cpu_has(X86_FEATURE_IBS);
@@ -463,9 +466,7 @@ static void setup_ibs(void)
 }
 
 
-/*
- * unitialize the APIC for the IBS interrupts if needed on AMD Family10h
- * rev B0 and later */
+/* uninitialize the APIC for the IBS interrupts if needed */
 static void clear_ibs_nmi(void)
 {
 	if (ibs_allowed)
diff --git a/drivers/oprofile/cpu_buffer.c b/drivers/oprofile/cpu_buffer.c
index 01d38e7..3958107 100644
--- a/drivers/oprofile/cpu_buffer.c
+++ b/drivers/oprofile/cpu_buffer.c
@@ -127,9 +127,10 @@ void end_cpu_work(void)
 /* Resets the cpu buffer to a sane state. */
 void cpu_buffer_reset(struct oprofile_cpu_buffer *cpu_buf)
 {
-	/* reset these to invalid values; the next sample
-	 * collected will populate the buffer with proper
-	 * values to initialize the buffer
+	/*
+	 * reset these to invalid values; the next sample collected
+	 * will populate the buffer with proper values to initialize
+	 * the buffer
 	 */
 	cpu_buf->last_is_kernel = -1;
 	cpu_buf->last_task = NULL;
@@ -151,8 +152,10 @@ static void increment_head(struct oprofile_cpu_buffer *b)
 {
 	unsigned long new_head = b->head_pos + 1;
 
-	/* Ensure anything written to the slot before we
-	 * increment is visible */
+	/*
+	 * Ensure anything written to the slot before we increment is
+	 * visible
+	 */
 	wmb();
 
 	if (new_head < b->buffer_size)
@@ -253,8 +256,10 @@ void oprofile_add_ext_sample(unsigned long pc, struct pt_regs * const regs,
 	if (!oprofile_begin_trace(cpu_buf))
 		return;
 
-	/* if log_sample() fail we can't backtrace since we lost the source
-	 * of this event */
+	/*
+	 * if log_sample() fail we can't backtrace since we lost the
+	 * source of this event
+	 */
 	if (log_sample(cpu_buf, pc, is_kernel, event))
 		oprofile_ops.backtrace(regs, backtrace_depth);
 	oprofile_end_trace(cpu_buf);
@@ -338,8 +343,10 @@ void oprofile_add_trace(unsigned long pc)
 		return;
 	}
 
-	/* broken frame can give an eip with the same value as an escape code,
-	 * abort the trace if we get it */
+	/*
+	 * broken frame can give an eip with the same value as an
+	 * escape code, abort the trace if we get it
+	 */
 	if (pc == ESCAPE_CODE) {
 		cpu_buf->tracing = 0;
 		cpu_buf->backtrace_aborted++;
-- 
1.6.0.1



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 02/10] oprofile: update comment for oprofile_add_sample()
  2008-12-11 15:04 [PATCH 0/10] oprofile and ftrace: some trivial patches Robert Richter
  2008-12-11 15:04 ` [PATCH 01/10] oprofile: comment cleanup Robert Richter
@ 2008-12-11 15:04 ` Robert Richter
  2008-12-11 15:04 ` [PATCH 03/10] oprofile: whitspace changes only Robert Richter
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Robert Richter @ 2008-12-11 15:04 UTC (permalink / raw)
  To: oprofile-list; +Cc: LKML, Robert Richter

The cpu argument is no longer part of the parameter list.

Signed-off-by: Robert Richter <robert.richter@amd.com>
---
 include/linux/oprofile.h |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
index 5231861..1ce9fe5 100644
--- a/include/linux/oprofile.h
+++ b/include/linux/oprofile.h
@@ -86,8 +86,7 @@ int oprofile_arch_init(struct oprofile_operations * ops);
 void oprofile_arch_exit(void);
 
 /**
- * Add a sample. This may be called from any context. Pass
- * smp_processor_id() as cpu.
+ * Add a sample. This may be called from any context.
  */
 void oprofile_add_sample(struct pt_regs * const regs, unsigned long event);
 
-- 
1.6.0.1



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 03/10] oprofile: whitspace changes only
  2008-12-11 15:04 [PATCH 0/10] oprofile and ftrace: some trivial patches Robert Richter
  2008-12-11 15:04 ` [PATCH 01/10] oprofile: comment cleanup Robert Richter
  2008-12-11 15:04 ` [PATCH 02/10] oprofile: update comment for oprofile_add_sample() Robert Richter
@ 2008-12-11 15:04 ` Robert Richter
  2008-12-11 15:04 ` [PATCH 04/10] oprofile: fix typo Robert Richter
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Robert Richter @ 2008-12-11 15:04 UTC (permalink / raw)
  To: oprofile-list; +Cc: LKML, Robert Richter

Signed-off-by: Robert Richter <robert.richter@amd.com>
---
 arch/x86/oprofile/op_model_amd.c |    4 ++--
 drivers/oprofile/cpu_buffer.c    |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
index fb67e19..f71bd21 100644
--- a/arch/x86/oprofile/op_model_amd.c
+++ b/arch/x86/oprofile/op_model_amd.c
@@ -70,8 +70,8 @@ static unsigned long reset_value[NUM_COUNTERS];
  * data. Should then be added to linux/oprofile.h.
  */
 extern void
-oprofile_add_ibs_sample(struct pt_regs *const regs,
-			unsigned int *const ibs_sample, int ibs_code);
+oprofile_add_ibs_sample(struct pt_regs * const regs,
+			unsigned int * const ibs_sample, int ibs_code);
 
 struct ibs_fetch_sample {
 	/* MSRC001_1031 IBS Fetch Linear Address Register */
diff --git a/drivers/oprofile/cpu_buffer.c b/drivers/oprofile/cpu_buffer.c
index 3958107..2c4d541 100644
--- a/drivers/oprofile/cpu_buffer.c
+++ b/drivers/oprofile/cpu_buffer.c
@@ -277,8 +277,8 @@ void oprofile_add_sample(struct pt_regs * const regs, unsigned long event)
 
 #define MAX_IBS_SAMPLE_SIZE 14
 
-void oprofile_add_ibs_sample(struct pt_regs *const regs,
-			     unsigned int *const ibs_sample, int ibs_code)
+void oprofile_add_ibs_sample(struct pt_regs * const regs,
+			     unsigned int * const ibs_sample, int ibs_code)
 {
 	int is_kernel = !user_mode(regs);
 	struct oprofile_cpu_buffer *cpu_buf = &__get_cpu_var(cpu_buffer);
-- 
1.6.0.1



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 04/10] oprofile: fix typo
  2008-12-11 15:04 [PATCH 0/10] oprofile and ftrace: some trivial patches Robert Richter
                   ` (2 preceding siblings ...)
  2008-12-11 15:04 ` [PATCH 03/10] oprofile: whitspace changes only Robert Richter
@ 2008-12-11 15:04 ` Robert Richter
  2008-12-11 15:04 ` [PATCH 05/10] x86/oprofile: reordering IBS code in op_model_amd.c Robert Richter
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Robert Richter @ 2008-12-11 15:04 UTC (permalink / raw)
  To: oprofile-list; +Cc: LKML, Robert Richter

Signed-off-by: Robert Richter <robert.richter@amd.com>
---
 drivers/oprofile/buffer_sync.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
index b55cd23..774b081 100644
--- a/drivers/oprofile/buffer_sync.c
+++ b/drivers/oprofile/buffer_sync.c
@@ -272,7 +272,7 @@ static void increment_tail(struct oprofile_cpu_buffer *b)
 {
 	unsigned long new_tail = b->tail_pos + 1;
 
-	rmb();	/* be sure fifo pointers are synchromized */
+	rmb();	/* be sure fifo pointers are synchronized */
 
 	if (new_tail < b->buffer_size)
 		b->tail_pos = new_tail;
-- 
1.6.0.1



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 05/10] x86/oprofile: reordering IBS code in op_model_amd.c
  2008-12-11 15:04 [PATCH 0/10] oprofile and ftrace: some trivial patches Robert Richter
                   ` (3 preceding siblings ...)
  2008-12-11 15:04 ` [PATCH 04/10] oprofile: fix typo Robert Richter
@ 2008-12-11 15:04 ` Robert Richter
  2008-12-11 15:04 ` [PATCH 06/10] x86/oprofile: cleanup IBS init/exit functions " Robert Richter
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Robert Richter @ 2008-12-11 15:04 UTC (permalink / raw)
  To: oprofile-list; +Cc: LKML, Robert Richter

This is part of the cpu buffer rework.

Signed-off-by: Robert Richter <robert.richter@amd.com>
---
 arch/x86/oprofile/op_model_amd.c |   26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
index f71bd21..8ff657b 100644
--- a/arch/x86/oprofile/op_model_amd.c
+++ b/arch/x86/oprofile/op_model_amd.c
@@ -376,18 +376,7 @@ static void op_amd_shutdown(struct op_msrs const * const msrs)
 	}
 }
 
-#ifndef CONFIG_OPROFILE_IBS
-
-/* no IBS support */
-
-static int op_amd_init(struct oprofile_operations *ops)
-{
-	return 0;
-}
-
-static void op_amd_exit(void) {}
-
-#else
+#ifdef CONFIG_OPROFILE_IBS
 
 static u8 ibs_eilvt_off;
 
@@ -531,7 +520,18 @@ static void op_amd_exit(void)
 	clear_ibs_nmi();
 }
 
-#endif
+#else
+
+/* no IBS support */
+
+static int op_amd_init(struct oprofile_operations *ops)
+{
+	return 0;
+}
+
+static void op_amd_exit(void) {}
+
+#endif /* CONFIG_OPROFILE_IBS */
 
 struct op_x86_model_spec const op_amd_spec = {
 	.init			= op_amd_init,
-- 
1.6.0.1



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 06/10] x86/oprofile: cleanup IBS init/exit functions in op_model_amd.c
  2008-12-11 15:04 [PATCH 0/10] oprofile and ftrace: some trivial patches Robert Richter
                   ` (4 preceding siblings ...)
  2008-12-11 15:04 ` [PATCH 05/10] x86/oprofile: reordering IBS code in op_model_amd.c Robert Richter
@ 2008-12-11 15:04 ` Robert Richter
  2008-12-11 15:04 ` [PATCH 07/10] oprofile: implement switch/case in buffer_sync.c Robert Richter
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Robert Richter @ 2008-12-11 15:04 UTC (permalink / raw)
  To: oprofile-list; +Cc: LKML, Robert Richter

Implementation of pairwise init/exit funcions for IBS and IBS NMI
setup. There are also some function renames and the removal of forward
function declarations.

Signed-off-by: Robert Richter <robert.richter@amd.com>
---
 arch/x86/oprofile/op_model_amd.c |   32 +++++++++++++++++---------------
 1 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
index 8ff657b..98658f2 100644
--- a/arch/x86/oprofile/op_model_amd.c
+++ b/arch/x86/oprofile/op_model_amd.c
@@ -106,11 +106,6 @@ struct ibs_op_sample {
 	unsigned int ibs_dc_phys_high;
 };
 
-/*
- * unitialize the APIC for the IBS interrupts if needed on AMD Family10h+
- */
-static void clear_ibs_nmi(void);
-
 static int ibs_allowed;	/* AMD Family10h and later */
 
 struct op_ibs_config {
@@ -390,7 +385,7 @@ static inline void apic_clear_ibs_nmi_per_cpu(void *arg)
 	setup_APIC_eilvt_ibs(0, APIC_EILVT_MSG_FIX, 1);
 }
 
-static int pfm_amd64_setup_eilvt(void)
+static int init_ibs_nmi(void)
 {
 #define IBSCTL_LVTOFFSETVAL		(1 << 8)
 #define IBSCTL				0x1cc
@@ -438,15 +433,22 @@ static int pfm_amd64_setup_eilvt(void)
 	return 0;
 }
 
+/* uninitialize the APIC for the IBS interrupts if needed */
+static void clear_ibs_nmi(void)
+{
+	if (ibs_allowed)
+		on_each_cpu(apic_clear_ibs_nmi_per_cpu, NULL, 1);
+}
+
 /* initialize the APIC for the IBS interrupts if available */
-static void setup_ibs(void)
+static void ibs_init(void)
 {
 	ibs_allowed = boot_cpu_has(X86_FEATURE_IBS);
 
 	if (!ibs_allowed)
 		return;
 
-	if (pfm_amd64_setup_eilvt()) {
+	if (init_ibs_nmi()) {
 		ibs_allowed = 0;
 		return;
 	}
@@ -454,12 +456,12 @@ static void setup_ibs(void)
 	printk(KERN_INFO "oprofile: AMD IBS detected\n");
 }
 
-
-/* uninitialize the APIC for the IBS interrupts if needed */
-static void clear_ibs_nmi(void)
+static void ibs_exit(void)
 {
-	if (ibs_allowed)
-		on_each_cpu(apic_clear_ibs_nmi_per_cpu, NULL, 1);
+	if (!ibs_allowed)
+		return;
+
+	clear_ibs_nmi();
 }
 
 static int (*create_arch_files)(struct super_block *sb, struct dentry *root);
@@ -509,7 +511,7 @@ static int setup_ibs_files(struct super_block *sb, struct dentry *root)
 
 static int op_amd_init(struct oprofile_operations *ops)
 {
-	setup_ibs();
+	ibs_init();
 	create_arch_files = ops->create_files;
 	ops->create_files = setup_ibs_files;
 	return 0;
@@ -517,7 +519,7 @@ static int op_amd_init(struct oprofile_operations *ops)
 
 static void op_amd_exit(void)
 {
-	clear_ibs_nmi();
+	ibs_exit();
 }
 
 #else
-- 
1.6.0.1



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 07/10] oprofile: implement switch/case in buffer_sync.c
  2008-12-11 15:04 [PATCH 0/10] oprofile and ftrace: some trivial patches Robert Richter
                   ` (5 preceding siblings ...)
  2008-12-11 15:04 ` [PATCH 06/10] x86/oprofile: cleanup IBS init/exit functions " Robert Richter
@ 2008-12-11 15:04 ` Robert Richter
  2008-12-11 15:04 ` [PATCH 08/10] oprofile: set values to default when creating oprofilefs Robert Richter
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Robert Richter @ 2008-12-11 15:04 UTC (permalink / raw)
  To: oprofile-list; +Cc: LKML, Robert Richter

Signed-off-by: Robert Richter <robert.richter@amd.com>
---
 drivers/oprofile/buffer_sync.c |   22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
index 774b081..7d61ae8 100644
--- a/drivers/oprofile/buffer_sync.c
+++ b/drivers/oprofile/buffer_sync.c
@@ -561,6 +561,7 @@ void sync_buffer(int cpu)
 {
 	struct oprofile_cpu_buffer *cpu_buf = &per_cpu(cpu_buffer, cpu);
 	struct mm_struct *mm = NULL;
+	struct mm_struct *oldmm;
 	struct task_struct *new;
 	unsigned long cookie = 0;
 	int in_kernel = 1;
@@ -586,34 +587,39 @@ void sync_buffer(int cpu)
 		struct op_sample *s = &cpu_buf->buffer[cpu_buf->tail_pos];
 
 		if (is_code(s->eip)) {
-			if (s->event <= CPU_IS_KERNEL) {
+			switch (s->event) {
+			case 0:
+			case CPU_IS_KERNEL:
 				/* kernel/userspace switch */
 				in_kernel = s->event;
 				if (state == sb_buffer_start)
 					state = sb_sample_start;
 				add_kernel_ctx_switch(s->event);
-			} else if (s->event == CPU_TRACE_BEGIN) {
+				break;
+			case CPU_TRACE_BEGIN:
 				state = sb_bt_start;
 				add_trace_begin();
+				break;
 #ifdef CONFIG_OPROFILE_IBS
-			} else if (s->event == IBS_FETCH_BEGIN) {
+			case IBS_FETCH_BEGIN:
 				state = sb_bt_start;
 				add_ibs_begin(cpu_buf, IBS_FETCH_CODE, mm);
-			} else if (s->event == IBS_OP_BEGIN) {
+				break;
+			case IBS_OP_BEGIN:
 				state = sb_bt_start;
 				add_ibs_begin(cpu_buf, IBS_OP_CODE, mm);
+				break;
 #endif
-			} else {
-				struct mm_struct *oldmm = mm;
-
+			default:
 				/* userspace context switch */
+				oldmm = mm;
 				new = (struct task_struct *)s->event;
-
 				release_mm(oldmm);
 				mm = take_tasks_mm(new);
 				if (mm != oldmm)
 					cookie = get_exec_dcookie(mm);
 				add_user_ctx_switch(new, cookie);
+				break;
 			}
 		} else if (state >= sb_bt_start &&
 			   !add_sample(mm, s, in_kernel)) {
-- 
1.6.0.1



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 08/10] oprofile: set values to default when creating oprofilefs
  2008-12-11 15:04 [PATCH 0/10] oprofile and ftrace: some trivial patches Robert Richter
                   ` (6 preceding siblings ...)
  2008-12-11 15:04 ` [PATCH 07/10] oprofile: implement switch/case in buffer_sync.c Robert Richter
@ 2008-12-11 15:04 ` Robert Richter
  2008-12-16  9:32   ` Andrew Morton
  2008-12-11 15:04 ` [PATCH 09/10] ring_buffer: update description for ring_buffer_alloc() Robert Richter
  2008-12-11 15:04 ` [PATCH 10/10] ftrace: remove unused function arg in trace_iterator_increment() Robert Richter
  9 siblings, 1 reply; 13+ messages in thread
From: Robert Richter @ 2008-12-11 15:04 UTC (permalink / raw)
  To: oprofile-list; +Cc: LKML, Robert Richter

This patch restores default values for:

/dev/oprofile/cpu_buffer_size
/dev/oprofile/buffer_watershed
/dev/oprofile/buffer_size

when creating the oprofilefs:

 # opcontrol --deinit
 # opcontrol --init
 # cat /dev/oprofile/cpu_buffer_size
 8192
 # echo 5123 > /dev/oprofile/cpu_buffer_size
 # cat /dev/oprofile/cpu_buffer_size
 5123
 # opcontrol --deinit
 # opcontrol --init
 # cat /dev/oprofile/cpu_buffer_size
 8192
 # opcontrol --deinit

This sets the values in a defined state. Before, there was no way to
restore the defaults without rebooting the system or reloading the
module.

Signed-off-by: Robert Richter <robert.richter@amd.com>
---
 drivers/oprofile/oprofile_files.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
index cc106d5..d820199 100644
--- a/drivers/oprofile/oprofile_files.c
+++ b/drivers/oprofile/oprofile_files.c
@@ -14,9 +14,13 @@
 #include "oprofile_stats.h"
 #include "oprof.h"
 
-unsigned long fs_buffer_size = 131072;
-unsigned long fs_cpu_buffer_size = 8192;
-unsigned long fs_buffer_watershed = 32768; /* FIXME: tune */
+#define FS_BUFFER_SIZE_DEFAULT		131072
+#define FS_CPU_BUFFER_SIZE_DEFAULT	8192
+#define FS_BUFFER_WATERSHED_DEFAULT	32768	/* FIXME: tune */
+
+unsigned long fs_buffer_size;
+unsigned long fs_cpu_buffer_size;
+unsigned long fs_buffer_watershed;
 
 static ssize_t depth_read(struct file *file, char __user *buf, size_t count, loff_t *offset)
 {
@@ -120,6 +124,11 @@ static const struct file_operations dump_fops = {
 
 void oprofile_create_files(struct super_block *sb, struct dentry *root)
 {
+	/* reinitialize default values */
+	fs_buffer_size =	FS_BUFFER_SIZE_DEFAULT;
+	fs_cpu_buffer_size =	FS_CPU_BUFFER_SIZE_DEFAULT;
+	fs_buffer_watershed =	FS_BUFFER_WATERSHED_DEFAULT;
+
 	oprofilefs_create_file(sb, root, "enable", &enable_fops);
 	oprofilefs_create_file_perm(sb, root, "dump", &dump_fops, 0666);
 	oprofilefs_create_file(sb, root, "buffer", &event_buffer_fops);
-- 
1.6.0.1



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 09/10] ring_buffer: update description for ring_buffer_alloc()
  2008-12-11 15:04 [PATCH 0/10] oprofile and ftrace: some trivial patches Robert Richter
                   ` (7 preceding siblings ...)
  2008-12-11 15:04 ` [PATCH 08/10] oprofile: set values to default when creating oprofilefs Robert Richter
@ 2008-12-11 15:04 ` Robert Richter
  2008-12-11 15:04 ` [PATCH 10/10] ftrace: remove unused function arg in trace_iterator_increment() Robert Richter
  9 siblings, 0 replies; 13+ messages in thread
From: Robert Richter @ 2008-12-11 15:04 UTC (permalink / raw)
  To: oprofile-list; +Cc: LKML, Robert Richter, Steven Rostedt

Trivial patch.

Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Robert Richter <robert.richter@amd.com>
---
 kernel/trace/ring_buffer.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 668bbb5..c8996d2 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -381,7 +381,7 @@ extern int ring_buffer_page_too_big(void);
 
 /**
  * ring_buffer_alloc - allocate a new ring_buffer
- * @size: the size in bytes that is needed.
+ * @size: the size in bytes per cpu that is needed.
  * @flags: attributes to set for the ring buffer.
  *
  * Currently the only flag that is available is the RB_FL_OVERWRITE
-- 
1.6.0.1



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 10/10] ftrace: remove unused function arg in trace_iterator_increment()
  2008-12-11 15:04 [PATCH 0/10] oprofile and ftrace: some trivial patches Robert Richter
                   ` (8 preceding siblings ...)
  2008-12-11 15:04 ` [PATCH 09/10] ring_buffer: update description for ring_buffer_alloc() Robert Richter
@ 2008-12-11 15:04 ` Robert Richter
  9 siblings, 0 replies; 13+ messages in thread
From: Robert Richter @ 2008-12-11 15:04 UTC (permalink / raw)
  To: oprofile-list; +Cc: LKML, Robert Richter, Steven Rostedt

This removes the unused cpu function parameter.

Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Robert Richter <robert.richter@amd.com>
---
 kernel/trace/trace.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index d86e325..a96b335 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -914,7 +914,7 @@ enum trace_file_type {
 	TRACE_FILE_LAT_FMT	= 1,
 };
 
-static void trace_iterator_increment(struct trace_iterator *iter, int cpu)
+static void trace_iterator_increment(struct trace_iterator *iter)
 {
 	/* Don't allow ftrace to trace into the ring buffers */
 	ftrace_disable_cpu();
@@ -993,7 +993,7 @@ static void *find_next_entry_inc(struct trace_iterator *iter)
 	iter->ent = __find_next_entry(iter, &iter->cpu, &iter->ts);
 
 	if (iter->ent)
-		trace_iterator_increment(iter, iter->cpu);
+		trace_iterator_increment(iter);
 
 	return iter->ent ? iter : NULL;
 }
-- 
1.6.0.1



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 08/10] oprofile: set values to default when creating oprofilefs
  2008-12-11 15:04 ` [PATCH 08/10] oprofile: set values to default when creating oprofilefs Robert Richter
@ 2008-12-16  9:32   ` Andrew Morton
  2008-12-16 11:56     ` Robert Richter
  0 siblings, 1 reply; 13+ messages in thread
From: Andrew Morton @ 2008-12-16  9:32 UTC (permalink / raw)
  To: Robert Richter; +Cc: oprofile-list, LKML

On Thu, 11 Dec 2008 16:04:44 +0100 Robert Richter <robert.richter@amd.com> wrote:

> This patch restores default values for:
> 
> /dev/oprofile/cpu_buffer_size
> /dev/oprofile/buffer_watershed
> /dev/oprofile/buffer_size
> 
> when creating the oprofilefs:
> 
>  # opcontrol --deinit
>  # opcontrol --init
>  # cat /dev/oprofile/cpu_buffer_size
>  8192
>  # echo 5123 > /dev/oprofile/cpu_buffer_size
>  # cat /dev/oprofile/cpu_buffer_size
>  5123
>  # opcontrol --deinit
>  # opcontrol --init
>  # cat /dev/oprofile/cpu_buffer_size
>  8192
>  # opcontrol --deinit
> 
> This sets the values in a defined state. Before, there was no way to
> restore the defaults without rebooting the system or reloading the
> module.
> 
> Signed-off-by: Robert Richter <robert.richter@amd.com>
> ---
>  drivers/oprofile/oprofile_files.c |   15 ++++++++++++---
>  1 files changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
> index cc106d5..d820199 100644
> --- a/drivers/oprofile/oprofile_files.c
> +++ b/drivers/oprofile/oprofile_files.c
> @@ -14,9 +14,13 @@
>  #include "oprofile_stats.h"
>  #include "oprof.h"
>  
> -unsigned long fs_buffer_size = 131072;
> -unsigned long fs_cpu_buffer_size = 8192;
> -unsigned long fs_buffer_watershed = 32768; /* FIXME: tune */
> +#define FS_BUFFER_SIZE_DEFAULT		131072
> +#define FS_CPU_BUFFER_SIZE_DEFAULT	8192
> +#define FS_BUFFER_WATERSHED_DEFAULT	32768	/* FIXME: tune */
> +
> +unsigned long fs_buffer_size;
> +unsigned long fs_cpu_buffer_size;
> +unsigned long fs_buffer_watershed;

These were poorly chosen kernel-wide identifiers.

>  static ssize_t depth_read(struct file *file, char __user *buf, size_t count, loff_t *offset)
>  {
> @@ -120,6 +124,11 @@ static const struct file_operations dump_fops = {
>  
>  void oprofile_create_files(struct super_block *sb, struct dentry *root)
>  {
> +	/* reinitialize default values */
> +	fs_buffer_size =	FS_BUFFER_SIZE_DEFAULT;
> +	fs_cpu_buffer_size =	FS_CPU_BUFFER_SIZE_DEFAULT;
> +	fs_buffer_watershed =	FS_BUFFER_WATERSHED_DEFAULT;
> +
>  	oprofilefs_create_file(sb, root, "enable", &enable_fops);
>  	oprofilefs_create_file_perm(sb, root, "dump", &dump_fops, 0666);
>  	oprofilefs_create_file(sb, root, "buffer", &event_buffer_fops);

afacit oprofile_create_files() only gets run when the module is loaded,
so this patch is a no-op?



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 08/10] oprofile: set values to default when creating oprofilefs
  2008-12-16  9:32   ` Andrew Morton
@ 2008-12-16 11:56     ` Robert Richter
  0 siblings, 0 replies; 13+ messages in thread
From: Robert Richter @ 2008-12-16 11:56 UTC (permalink / raw)
  To: Andrew Morton; +Cc: oprofile-list, LKML

On 16.12.08 01:32:25, Andrew Morton wrote:
> > +unsigned long fs_buffer_size;
> > +unsigned long fs_cpu_buffer_size;
> > +unsigned long fs_buffer_watershed;
> 
> These were poorly chosen kernel-wide identifiers.

Right, didn't notice that. Will change this.

> >  static ssize_t depth_read(struct file *file, char __user *buf, size_t count, loff_t *offset)
> >  {
> > @@ -120,6 +124,11 @@ static const struct file_operations dump_fops = {
> >  
> >  void oprofile_create_files(struct super_block *sb, struct dentry *root)
> >  {
> > +	/* reinitialize default values */
> > +	fs_buffer_size =	FS_BUFFER_SIZE_DEFAULT;
> > +	fs_cpu_buffer_size =	FS_CPU_BUFFER_SIZE_DEFAULT;
> > +	fs_buffer_watershed =	FS_BUFFER_WATERSHED_DEFAULT;
> > +
> >  	oprofilefs_create_file(sb, root, "enable", &enable_fops);
> >  	oprofilefs_create_file_perm(sb, root, "dump", &dump_fops, 0666);
> >  	oprofilefs_create_file(sb, root, "buffer", &event_buffer_fops);
> 
> afacit oprofile_create_files() only gets run when the module is loaded,
> so this patch is a no-op?

This code runs when oprofilefs is mounted. This happens typically in
an opcontrol --init/--deinit sequence. Before, the previous values
would have been used after mounting again. Now, default values are
restored.

-Robert

-- 
Advanced Micro Devices, Inc.
Operating System Research Center
email: robert.richter@amd.com


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2008-12-16 11:57 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-11 15:04 [PATCH 0/10] oprofile and ftrace: some trivial patches Robert Richter
2008-12-11 15:04 ` [PATCH 01/10] oprofile: comment cleanup Robert Richter
2008-12-11 15:04 ` [PATCH 02/10] oprofile: update comment for oprofile_add_sample() Robert Richter
2008-12-11 15:04 ` [PATCH 03/10] oprofile: whitspace changes only Robert Richter
2008-12-11 15:04 ` [PATCH 04/10] oprofile: fix typo Robert Richter
2008-12-11 15:04 ` [PATCH 05/10] x86/oprofile: reordering IBS code in op_model_amd.c Robert Richter
2008-12-11 15:04 ` [PATCH 06/10] x86/oprofile: cleanup IBS init/exit functions " Robert Richter
2008-12-11 15:04 ` [PATCH 07/10] oprofile: implement switch/case in buffer_sync.c Robert Richter
2008-12-11 15:04 ` [PATCH 08/10] oprofile: set values to default when creating oprofilefs Robert Richter
2008-12-16  9:32   ` Andrew Morton
2008-12-16 11:56     ` Robert Richter
2008-12-11 15:04 ` [PATCH 09/10] ring_buffer: update description for ring_buffer_alloc() Robert Richter
2008-12-11 15:04 ` [PATCH 10/10] ftrace: remove unused function arg in trace_iterator_increment() Robert Richter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox