perf tools: Add a per tracepoint counter attribute to get raw sample

Add a new flag field while opening a tracepoint perf counter:

-e tracepoint_subsystem:tracepoint_name:flags

This is intended to be generic although for now it only supports the
r[e[c[o[r[d]]]]] flag:

./perf record -e workqueue:workqueue_insertion:record
./perf record -e workqueue:workqueue_insertion:r

will have the same effect: enabling the raw samples record for
the given tracepoint counter.

In the future, we may want to support further flags, separated
by commas.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
LKML-Reference: <1250152039-7284-1-git-send-email-fweisbec@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

authored by Frederic Weisbecker and committed by Ingo Molnar 3a9f131f 28402971

+11 -1
+1 -1
tools/perf/builtin-record.c
··· 398 398 PERF_FORMAT_TOTAL_TIME_RUNNING | 399 399 PERF_FORMAT_ID; 400 400 401 - attr->sample_type = PERF_SAMPLE_IP | PERF_SAMPLE_TID; 401 + attr->sample_type |= PERF_SAMPLE_IP | PERF_SAMPLE_TID; 402 402 403 403 if (freq) { 404 404 attr->sample_type |= PERF_SAMPLE_PERIOD;
+10
tools/perf/util/parse-events.c
··· 379 379 struct perf_counter_attr *attr) 380 380 { 381 381 const char *evt_name; 382 + char *flags; 382 383 char sys_name[MAX_EVENT_LENGTH]; 383 384 char id_buf[4]; 384 385 int fd; ··· 401 400 strncpy(sys_name, *strp, sys_length); 402 401 sys_name[sys_length] = '\0'; 403 402 evt_name = evt_name + 1; 403 + 404 + flags = strchr(evt_name, ':'); 405 + if (flags) { 406 + *flags = '\0'; 407 + flags++; 408 + if (!strncmp(flags, "record", strlen(flags))) 409 + attr->sample_type |= PERF_SAMPLE_RAW; 410 + } 411 + 404 412 evt_length = strlen(evt_name); 405 413 if (evt_length >= MAX_EVENT_LENGTH) 406 414 return 0;