[RFC PATCH 6/6] perf: Humanize the number of contexts

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Frederic Weisbecker
Date: Monday, August 16, 2010 - 1:48 pm

Instead of hardcoding the number of contexts for the recursions
barriers, define a cpp constant to make the code more
self-explanatory.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Stephane Eranian <eranian@google.com>
---
 include/linux/perf_event.h |   14 ++++++++------
 kernel/perf_event.c        |    6 +++---
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index d7e8ea6..ae6fa60 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -808,6 +808,12 @@ struct perf_event_context {
 	struct rcu_head			rcu_head;
 };
 
+/*
+ * Number of contexts where an event can trigger:
+ * 	task, softirq, hardirq, nmi.
+ */
+#define PERF_NR_CONTEXTS	4
+
 /**
  * struct perf_event_cpu_context - per cpu event context structure
  */
@@ -821,12 +827,8 @@ struct perf_cpu_context {
 	struct mutex			hlist_mutex;
 	int				hlist_refcount;
 
-	/*
-	 * Recursion avoidance:
-	 *
-	 * task, softirq, irq, nmi context
-	 */
-	int				recursion[4];
+	/* Recursion avoidance in each contexts */
+	int				recursion[PERF_NR_CONTEXTS];
 };
 
 struct perf_output_handle {
diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 6ad61fb..e41e29b 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -1767,7 +1767,7 @@ static u64 perf_event_read(struct perf_event *event)
  * Callchain support
  */
 
-static DEFINE_PER_CPU(int, callchain_recursion[4]);
+static DEFINE_PER_CPU(int, callchain_recursion[PERF_NR_CONTEXTS]);
 static atomic_t nr_callchain_events;
 static DEFINE_MUTEX(callchain_mutex);
 static struct perf_callchain_entry **callchain_cpu_entries;
@@ -1812,8 +1812,8 @@ static int alloc_callchain_buffers(void)
 	callchain_cpu_entries = entries;
 
 	for_each_possible_cpu(cpu) {
-		entries[cpu] = kmalloc(sizeof(struct perf_callchain_entry) * 4,
-					GFP_KERNEL);
+		entries[cpu] = kmalloc(sizeof(struct perf_callchain_entry) *
+					PERF_NR_CONTEXTS, GFP_KERNEL);
 		if (!entries[cpu])
 			return -ENOMEM;
 	}
-- 
1.6.2.3

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[RFC PATCH 0/0 v3] callchain fixes and cleanups , Frederic Weisbecker, (Mon Aug 16, 1:48 pm)
[RFC PATCH 1/6] perf: Drop unappropriate tests on arch cal ..., Frederic Weisbecker, (Mon Aug 16, 1:48 pm)
[RFC PATCH 2/6] perf: Generalize callchain_store(), Frederic Weisbecker, (Mon Aug 16, 1:48 pm)
[RFC PATCH 3/6] perf: Generalize some arch callchain code, Frederic Weisbecker, (Mon Aug 16, 1:48 pm)
[RFC PATCH 4/6] perf: Factorize callchain context handling, Frederic Weisbecker, (Mon Aug 16, 1:48 pm)
[RFC PATCH 5/6] perf: Fix race in callchains, Frederic Weisbecker, (Mon Aug 16, 1:48 pm)
[RFC PATCH 6/6] perf: Humanize the number of contexts, Frederic Weisbecker, (Mon Aug 16, 1:48 pm)
[RFC PATCH 5/6 v4] perf: Fix race in callchains, Frederic Weisbecker, (Mon Aug 16, 6:34 pm)
Re: [RFC PATCH 2/6] perf: Generalize callchain_store(), Paul Mackerras, (Mon Aug 16, 9:37 pm)
Re: [RFC PATCH 5/6 v4] perf: Fix race in callchains, Paul Mackerras, (Mon Aug 16, 9:53 pm)
Re: [RFC PATCH 0/0 v3] callchain fixes and cleanups, Borislav Petkov, (Mon Aug 16, 9:58 pm)
Re: [RFC PATCH 0/0 v3] callchain fixes and cleanups, Will Deacon, (Tue Aug 17, 3:32 am)
Re: [RFC PATCH 5/6 v4] perf: Fix race in callchains, Frederic Weisbecker, (Tue Aug 17, 8:49 pm)
Re: [RFC PATCH 3/6] perf: Generalize some arch callchain code, Frederic Weisbecker, (Tue Aug 17, 8:51 pm)
Re: [RFC PATCH 0/0 v3] callchain fixes and cleanups, Frederic Weisbecker, (Tue Aug 17, 8:53 pm)
Re: [RFC PATCH 0/0 v3] callchain fixes and cleanups, Frederic Weisbecker, (Tue Aug 17, 8:55 pm)
Re: [RFC PATCH 0/0 v3] callchain fixes and cleanups, Will Deacon, (Wed Aug 18, 2:08 am)
Re: [RFC PATCH 0/0 v3] callchain fixes and cleanups, Ingo Molnar, (Wed Aug 18, 9:15 am)