History

Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip

* 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: perf tools: Add group event scheduling option to perf record/stat MAINTAINERS: Fix list of perf events source files perf tools: Fix build against newer glibc perf tools: Fix error handling of unknown events perf evlist: Fix missing event name init for default event perf list: Fix exit value

Linus Torvalds committed 15 years ago

Commit 8f6544e2 parents 4762e25 fe4c51b6 files · +26 −8Browse files

Unified · Split

6 files
  1. MAINTAINERS +1 −1
  2. tools/perf/builtin-record.c +3 −1
  3. tools/perf/builtin-stat.c +5 −2
  4. tools/perf/util/evlist.c +10 −1
  5. tools/perf/util/include/linux/compiler.h +2 −0
  6. tools/perf/util/parse-events.c +5 −3
MAINTAINERS+1−1
@@ -4971,7 +4971,7 @@ M: Paul Mackerras <paulus@samba.org> · 4970 unmodified lines
49714971 M: Ingo Molnar <mingo@elte.hu>
49724972 M: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
49734973 S: Supported
4974−F: kernel/perf_event*.c
4974+F: kernel/events/*
49754975 F: include/linux/perf_event.h
49764976 F: arch/*/kernel/perf_event*.c
49774977 F: arch/*/kernel/*/perf_event*.c
tools/perf/builtin-record.c+3−1
@@ -45,7 +45,7 @@ static int freq = 1000; · 44 unmodified lines
4545 static int output;
4646 static int pipe_output = 0;
4747 static const char *output_name = NULL;
48−static int group = 0;
48+static bool group = false;
4949 static int realtime_prio = 0;
5050 static bool nodelay = false;
5151 static bool raw_samples = false;
@@ -753,6 +753,8 @@ const struct option record_options[] = { · 701 unmodified lines
753753 "child tasks do not inherit counters"),
754754 OPT_UINTEGER('F', "freq", &user_freq, "profile at this frequency"),
755755 OPT_UINTEGER('m', "mmap-pages", &mmap_pages, "number of mmap data pages"),
756+ OPT_BOOLEAN(0, "group", &group,
757+ "put the counters into a counter group"),
756758 OPT_BOOLEAN('g', "call-graph", &call_graph,
757759 "do call-graph (stack chain/backtrace) recording"),
758760 OPT_INCR('v', "verbose", &verbose,
tools/perf/builtin-stat.c+5−2
@@ -193,6 +193,7 @@ static int big_num_opt = -1; · 192 unmodified lines
193193 static const char *cpu_list;
194194 static const char *csv_sep = NULL;
195195 static bool csv_output = false;
196+static bool group = false;
196197
197198 static volatile int done = 0;
198199
@@ -280,14 +281,14 @@ static int create_perf_stat_counter(struct perf_evsel *evsel) · 81 unmodified lines
280281 attr->inherit = !no_inherit;
281282
282283 if (system_wide)
283− return perf_evsel__open_per_cpu(evsel, evsel_list->cpus, false);
284+ return perf_evsel__open_per_cpu(evsel, evsel_list->cpus, group);
284285
285286 if (target_pid == -1 && target_tid == -1) {
286287 attr->disabled = 1;
287288 attr->enable_on_exec = 1;
288289 }
289290
290− return perf_evsel__open_per_thread(evsel, evsel_list->threads, false);
291+ return perf_evsel__open_per_thread(evsel, evsel_list->threads, group);
291292 }
292293
293294 /*
@@ -1043,6 +1044,8 @@ static const struct option options[] = { · 749 unmodified lines
10431044 "stat events on existing thread id"),
10441045 OPT_BOOLEAN('a', "all-cpus", &system_wide,
10451046 "system-wide collection from all CPUs"),
1047+ OPT_BOOLEAN('g', "group", &group,
1048+ "put the counters into a counter group"),
10461049 OPT_BOOLEAN('c', "scale", &scale,
10471050 "scale/normalize counters"),
10481051 OPT_INCR('v', "verbose", &verbose,
tools/perf/util/evlist.c+10−1
@@ -85,10 +85,19 @@ int perf_evlist__add_default(struct perf_evlist *evlist) · 84 unmodified lines
8585 struct perf_evsel *evsel = perf_evsel__new(&attr, 0);
8686
8787 if (evsel == NULL)
88− return -ENOMEM;
88+ goto error;
89+
90+ /* use strdup() because free(evsel) assumes name is allocated */
91+ evsel->name = strdup("cycles");
92+ if (!evsel->name)
93+ goto error_free;
8994
9095 perf_evlist__add(evlist, evsel);
9196 return 0;
97+error_free:
98+ perf_evsel__delete(evsel);
99+error:
100+ return -ENOMEM;
92101 }
93102
94103 void perf_evlist__disable(struct perf_evlist *evlist)
tools/perf/util/include/linux/compiler.h+2−0
@@ -5,7 +5,9 @@ · 4 unmodified lines
55 #define __always_inline inline
66 #endif
77 #define __user
8+#ifndef __attribute_const__
89 #define __attribute_const__
10+#endif
911
1012 #define __used __attribute__((__unused__))
1113
tools/perf/util/parse-events.c+5−3
@@ -697,7 +697,11 @@ parse_raw_event(const char **strp, struct perf_event_attr *attr) · 696 unmodified lines
697697 return EVT_FAILED;
698698 n = hex2u64(str + 1, &config);
699699 if (n > 0) {
700− *strp = str + n + 1;
700+ const char *end = str + n + 1;
701+ if (*end != '\0' && *end != ',' && *end != ':')
702+ return EVT_FAILED;
703+
704+ *strp = end;
701705 attr->type = PERF_TYPE_RAW;
702706 attr->config = config;
703707 return EVT_HANDLED;
@@ -1097,6 +1101,4 @@ void print_events(const char *event_glob) · 393 unmodified lines
10971101 printf("\n");
10981102
10991103 print_tracepoint_events(NULL, NULL);
1100−
1101− exit(129);
11021104 }