Skip to content

Commit cf99ad1

Browse files
Andi Kleenacmel
authored andcommitted
perf record: Support weak groups
Implement a weak group fallback for 'perf record', similar to the existing 'perf stat' support. This allows to use groups that might be longer than the available counters without failing. Before: $ perf record -e '{cycles,cache-misses,cache-references,cpu_clk_unhalted.thread,cycles,cycles,cycles}' -a sleep 1 Error: The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (cycles). /bin/dmesg | grep -i perf may provide additional information. After: $ ./perf record -e '{cycles,cache-misses,cache-references,cpu_clk_unhalted.thread,cycles,cycles,cycles}:W' -a sleep 1 WARNING: No sample_id_all support, falling back to unordered processing [ perf record: Woken up 3 times to write data ] [ perf record: Captured and wrote 8.136 MB perf.data (134069 samples) ] Signed-off-by: Andi Kleen <ak@linux.intel.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Link: http://lkml.kernel.org/r/20181001195927.14211-2-andi@firstfloor.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent c3537fc commit cf99ad1

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

tools/perf/Documentation/perf-list.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ counted. The following modifiers exist:
5555
S - read sample value (PERF_SAMPLE_READ)
5656
D - pin the event to the PMU
5757
W - group is weak and will fallback to non-group if not schedulable,
58-
only supported in 'perf stat' for now.
5958

6059
The 'p' modifier can be used for specifying how precise the instruction
6160
address should be. The 'p' modifier can be specified multiple times:

tools/perf/builtin-record.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,12 @@ static int record__open(struct record *rec)
391391
ui__warning("%s\n", msg);
392392
goto try_again;
393393
}
394-
394+
if ((errno == EINVAL || errno == EBADF) &&
395+
pos->leader != pos &&
396+
pos->weak_group) {
397+
pos = perf_evlist__reset_weak_group(evlist, pos);
398+
goto try_again;
399+
}
395400
rc = -errno;
396401
perf_evsel__open_strerror(pos, &opts->target,
397402
errno, msg, sizeof(msg));

0 commit comments

Comments
 (0)