Skip to contentSkip to conversation

perf sched: Determine the number of CPUs automatically

tip:perfcounters/core tip-bot for Ingo Molnar 1 participant 1 message Sep 17, 2009 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  40749d0ff49f99c3661b336fe5e5625207bd925a
Gitweb:     http://git.kernel.org/tip/40749d0ff49f99c3661b336fe5e5625207bd925a
Author:     Ingo Molnar <[email protected]>
AuthorDate: Thu, 17 Sep 2009 18:24:55 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 17 Sep 2009 22:09:19 +0200

perf sched: Determine the number of CPUs automatically

For 'perf sched map' output, determine max_cpu automatically, instead of the static default of 15.

[ v2: use sysconf() pointed out by Arjan van de Ven <[email protected]> ]

Cc: Peter Zijlstra <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
LKML-Reference: <new-submission>

---
 tools/perf/builtin-sched.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
tools/perf/builtin-sched.c +3 -1
index f67e351..9e04827 100644
@@ -1347,7 +1347,7 @@ process_sched_wakeup_event(struct raw_event_sample *raw,
  * Track the current task - that way we can know whether there's any
  * weird events, such as a task being switched away that is not current.
  */
-static int max_cpu = 15;
+static int max_cpu;
 
 static u32 curr_pid[MAX_CPUS] = { [0 ... MAX_CPUS-1] = -1 };
 
@@ -1818,6 +1818,8 @@ static struct trace_sched_handler map_ops  = {
 
 static void __cmd_map(void)
 {
+	max_cpu = sysconf(_SC_NPROCESSORS_CONF);
+
 	setup_pager();
 	read_events();
 	print_bad_events();