perf session: Pass the perf_session to the event handling operations
[deliverable/linux.git] / tools / perf / builtin-record.c
CommitLineData
abaff32a 1/*
bf9e1876
IM
2 * builtin-record.c
3 *
4 * Builtin record command: Record the profile of a workload
5 * (or a CPU, or a PID) into the perf.data output file - for
6 * later analysis via perf report.
abaff32a 7 */
16f762a2 8#include "builtin.h"
bf9e1876
IM
9
10#include "perf.h"
11
6eda5838 12#include "util/util.h"
0e9b20b8 13#include "util/parse-options.h"
8ad8db37 14#include "util/parse-events.h"
a0055ae2 15#include "util/string.h"
6eda5838 16
7c6a1c65 17#include "util/header.h"
66e274f3 18#include "util/event.h"
8f28827a 19#include "util/debug.h"
94c744b6 20#include "util/session.h"
8d06367f 21#include "util/symbol.h"
7c6a1c65 22
97124d5e 23#include <unistd.h>
de9ac07b 24#include <sched.h>
de9ac07b 25
de9ac07b 26static int fd[MAX_NR_CPUS][MAX_COUNTERS];
a21ca2ca 27
7e4ff9e3 28static long default_interval = 0;
a21ca2ca 29
42e59d7d 30static int nr_cpus = 0;
de9ac07b 31static unsigned int page_size;
42e59d7d
IM
32static unsigned int mmap_pages = 128;
33static int freq = 1000;
de9ac07b 34static int output;
23ac9cbe 35static const char *output_name = "perf.data";
42e59d7d
IM
36static int group = 0;
37static unsigned int realtime_prio = 0;
38static int raw_samples = 0;
39static int system_wide = 0;
40static int profile_cpu = -1;
41static pid_t target_pid = -1;
42static pid_t child_pid = -1;
43static int inherit = 1;
44static int force = 0;
45static int append_file = 0;
46static int call_graph = 0;
47static int inherit_stat = 0;
48static int no_samples = 0;
49static int sample_address = 0;
50static int multiplex = 0;
51static int multiplex_fd = -1;
52
53static long samples = 0;
a21ca2ca
IM
54static struct timeval last_read;
55static struct timeval this_read;
56
42e59d7d 57static u64 bytes_written = 0;
a21ca2ca
IM
58
59static struct pollfd event_array[MAX_NR_CPUS * MAX_COUNTERS];
60
42e59d7d
IM
61static int nr_poll = 0;
62static int nr_cpu = 0;
a21ca2ca 63
42e59d7d 64static int file_new = 1;
7c6a1c65 65
94c744b6 66static struct perf_session *session;
f5970550 67
de9ac07b 68struct mmap_data {
a21ca2ca
IM
69 int counter;
70 void *base;
71 unsigned int mask;
72 unsigned int prev;
de9ac07b
PZ
73};
74
a21ca2ca
IM
75static struct mmap_data mmap_array[MAX_NR_CPUS][MAX_COUNTERS];
76
9d91a6f7 77static unsigned long mmap_read_head(struct mmap_data *md)
de9ac07b 78{
cdd6c482 79 struct perf_event_mmap_page *pc = md->base;
9d91a6f7 80 long head;
de9ac07b
PZ
81
82 head = pc->data_head;
83 rmb();
84
85 return head;
86}
87
9d91a6f7
PZ
88static void mmap_write_tail(struct mmap_data *md, unsigned long tail)
89{
cdd6c482 90 struct perf_event_mmap_page *pc = md->base;
9d91a6f7
PZ
91
92 /*
93 * ensure all reads are done before we write the tail out.
94 */
95 /* mb(); */
96 pc->data_tail = tail;
97}
98
f5970550
PZ
99static void write_output(void *buf, size_t size)
100{
101 while (size) {
102 int ret = write(output, buf, size);
103
104 if (ret < 0)
105 die("failed to write");
106
107 size -= ret;
108 buf += ret;
109
110 bytes_written += ret;
111 }
112}
113
8d06367f
ACM
114static void write_event(event_t *buf, size_t size)
115{
116 /*
117 * Add it to the list of DSOs, so that when we finish this
118 * record session we can pick the available build-ids.
119 */
120 if (buf->header.type == PERF_RECORD_MMAP)
121 dsos__findnew(buf->mmap.filename);
122
123 write_output(buf, size);
124}
125
d8f66248
ACM
126static int process_synthesized_event(event_t *event,
127 struct perf_session *self __used)
234fbbf5 128{
8d06367f 129 write_event(event, event->header.size);
234fbbf5
ACM
130 return 0;
131}
132
de9ac07b
PZ
133static void mmap_read(struct mmap_data *md)
134{
135 unsigned int head = mmap_read_head(md);
136 unsigned int old = md->prev;
137 unsigned char *data = md->base + page_size;
138 unsigned long size;
139 void *buf;
140 int diff;
141
142 gettimeofday(&this_read, NULL);
143
144 /*
145 * If we're further behind than half the buffer, there's a chance
2debbc83 146 * the writer will bite our tail and mess up the samples under us.
de9ac07b
PZ
147 *
148 * If we somehow ended up ahead of the head, we got messed up.
149 *
150 * In either case, truncate and restart at head.
151 */
152 diff = head - old;
9d91a6f7 153 if (diff < 0) {
de9ac07b
PZ
154 struct timeval iv;
155 unsigned long msecs;
156
157 timersub(&this_read, &last_read, &iv);
158 msecs = iv.tv_sec*1000 + iv.tv_usec/1000;
159
160 fprintf(stderr, "WARNING: failed to keep up with mmap data."
161 " Last read %lu msecs ago.\n", msecs);
162
163 /*
164 * head points to a known good entry, start there.
165 */
166 old = head;
167 }
168
169 last_read = this_read;
170
171 if (old != head)
2debbc83 172 samples++;
de9ac07b
PZ
173
174 size = head - old;
175
176 if ((old & md->mask) + size != (head & md->mask)) {
177 buf = &data[old & md->mask];
178 size = md->mask + 1 - (old & md->mask);
179 old += size;
021e9f47 180
8d06367f 181 write_event(buf, size);
de9ac07b
PZ
182 }
183
184 buf = &data[old & md->mask];
185 size = head - old;
186 old += size;
021e9f47 187
8d06367f 188 write_event(buf, size);
de9ac07b
PZ
189
190 md->prev = old;
9d91a6f7 191 mmap_write_tail(md, old);
de9ac07b
PZ
192}
193
194static volatile int done = 0;
f7b7c26e 195static volatile int signr = -1;
de9ac07b 196
16c8a109 197static void sig_handler(int sig)
de9ac07b 198{
16c8a109 199 done = 1;
f7b7c26e
PZ
200 signr = sig;
201}
202
203static void sig_atexit(void)
204{
933da83a
CW
205 if (child_pid != -1)
206 kill(child_pid, SIGTERM);
207
f7b7c26e
PZ
208 if (signr == -1)
209 return;
210
211 signal(signr, SIG_DFL);
212 kill(getpid(), signr);
de9ac07b
PZ
213}
214
f250c030
IM
215static int group_fd;
216
cdd6c482 217static struct perf_header_attr *get_header_attr(struct perf_event_attr *a, int nr)
7c6a1c65
PZ
218{
219 struct perf_header_attr *h_attr;
220
94c744b6
ACM
221 if (nr < session->header.attrs) {
222 h_attr = session->header.attr[nr];
7c6a1c65
PZ
223 } else {
224 h_attr = perf_header_attr__new(a);
dc79c0fc 225 if (h_attr != NULL)
94c744b6 226 if (perf_header__add_attr(&session->header, h_attr) < 0) {
11deb1f9
ACM
227 perf_header_attr__delete(h_attr);
228 h_attr = NULL;
229 }
7c6a1c65
PZ
230 }
231
232 return h_attr;
233}
234
f250c030 235static void create_counter(int counter, int cpu, pid_t pid)
de9ac07b 236{
c171b552 237 char *filter = filters[counter];
cdd6c482 238 struct perf_event_attr *attr = attrs + counter;
7c6a1c65
PZ
239 struct perf_header_attr *h_attr;
240 int track = !counter; /* only the first counter needs these */
c171b552 241 int ret;
7c6a1c65
PZ
242 struct {
243 u64 count;
244 u64 time_enabled;
245 u64 time_running;
246 u64 id;
247 } read_data;
248
249 attr->read_format = PERF_FORMAT_TOTAL_TIME_ENABLED |
250 PERF_FORMAT_TOTAL_TIME_RUNNING |
251 PERF_FORMAT_ID;
16c8a109 252
3a9f131f 253 attr->sample_type |= PERF_SAMPLE_IP | PERF_SAMPLE_TID;
3efa1cc9 254
1dba15e7 255 if (freq) {
ea1900e5 256 attr->sample_type |= PERF_SAMPLE_PERIOD;
a21ca2ca
IM
257 attr->freq = 1;
258 attr->sample_freq = freq;
1dba15e7 259 }
3efa1cc9 260
649c48a9
PZ
261 if (no_samples)
262 attr->sample_freq = 0;
263
264 if (inherit_stat)
265 attr->inherit_stat = 1;
266
4bba828d
AB
267 if (sample_address)
268 attr->sample_type |= PERF_SAMPLE_ADDR;
269
3efa1cc9
IM
270 if (call_graph)
271 attr->sample_type |= PERF_SAMPLE_CALLCHAIN;
272
cd6feeea 273 if (raw_samples) {
6ddf259d 274 attr->sample_type |= PERF_SAMPLE_TIME;
daac07b2 275 attr->sample_type |= PERF_SAMPLE_RAW;
cd6feeea
IM
276 attr->sample_type |= PERF_SAMPLE_CPU;
277 }
f413cdb8 278
a21ca2ca
IM
279 attr->mmap = track;
280 attr->comm = track;
281 attr->inherit = (cpu < 0) && inherit;
4502d77c 282 attr->disabled = 1;
16c8a109 283
3da297a6 284try_again:
cdd6c482 285 fd[nr_cpu][counter] = sys_perf_event_open(attr, pid, cpu, group_fd, 0);
16c8a109 286
f250c030
IM
287 if (fd[nr_cpu][counter] < 0) {
288 int err = errno;
16c8a109 289
c10edee2 290 if (err == EPERM || err == EACCES)
3da297a6 291 die("Permission error - are you root?\n");
0a5ac846
JA
292 else if (err == ENODEV && profile_cpu != -1)
293 die("No such device - did you specify an out-of-range profile CPU?\n");
3da297a6
IM
294
295 /*
296 * If it's cycles then fall back to hrtimer
297 * based cpu-clock-tick sw counter, which
298 * is always available even if no PMU support:
299 */
300 if (attr->type == PERF_TYPE_HARDWARE
f4dbfa8f 301 && attr->config == PERF_COUNT_HW_CPU_CYCLES) {
3da297a6
IM
302
303 if (verbose)
304 warning(" ... trying to fall back to cpu-clock-ticks\n");
305 attr->type = PERF_TYPE_SOFTWARE;
f4dbfa8f 306 attr->config = PERF_COUNT_SW_CPU_CLOCK;
3da297a6
IM
307 goto try_again;
308 }
30c806a0
IM
309 printf("\n");
310 error("perfcounter syscall returned with %d (%s)\n",
311 fd[nr_cpu][counter], strerror(err));
bfd45118
SK
312
313#if defined(__i386__) || defined(__x86_64__)
314 if (attr->type == PERF_TYPE_HARDWARE && err == EOPNOTSUPP)
315 die("No hardware sampling interrupt available. No APIC? If so then you can boot the kernel with the \"lapic\" boot parameter to force-enable it.\n");
316#endif
317
cdd6c482 318 die("No CONFIG_PERF_EVENTS=y kernel support configured?\n");
f250c030
IM
319 exit(-1);
320 }
3da297a6 321
7c6a1c65 322 h_attr = get_header_attr(attr, counter);
dc79c0fc
ACM
323 if (h_attr == NULL)
324 die("nomem\n");
7c6a1c65
PZ
325
326 if (!file_new) {
327 if (memcmp(&h_attr->attr, attr, sizeof(*attr))) {
328 fprintf(stderr, "incompatible append\n");
329 exit(-1);
330 }
331 }
332
3928ddbe
FW
333 if (read(fd[nr_cpu][counter], &read_data, sizeof(read_data)) == -1) {
334 perror("Unable to read perf file descriptor\n");
335 exit(-1);
336 }
7c6a1c65 337
58754121
ACM
338 if (perf_header_attr__add_id(h_attr, read_data.id) < 0) {
339 pr_warning("Not enough memory to add id\n");
340 exit(-1);
341 }
7c6a1c65 342
f250c030
IM
343 assert(fd[nr_cpu][counter] >= 0);
344 fcntl(fd[nr_cpu][counter], F_SETFL, O_NONBLOCK);
16c8a109 345
f250c030
IM
346 /*
347 * First counter acts as the group leader:
348 */
349 if (group && group_fd == -1)
350 group_fd = fd[nr_cpu][counter];
ea57c4f5
IM
351 if (multiplex && multiplex_fd == -1)
352 multiplex_fd = fd[nr_cpu][counter];
f250c030 353
ea57c4f5 354 if (multiplex && fd[nr_cpu][counter] != multiplex_fd) {
4502d77c 355
cdd6c482 356 ret = ioctl(fd[nr_cpu][counter], PERF_EVENT_IOC_SET_OUTPUT, multiplex_fd);
ea57c4f5
IM
357 assert(ret != -1);
358 } else {
359 event_array[nr_poll].fd = fd[nr_cpu][counter];
360 event_array[nr_poll].events = POLLIN;
361 nr_poll++;
362
363 mmap_array[nr_cpu][counter].counter = counter;
364 mmap_array[nr_cpu][counter].prev = 0;
365 mmap_array[nr_cpu][counter].mask = mmap_pages*page_size - 1;
366 mmap_array[nr_cpu][counter].base = mmap(NULL, (mmap_pages+1)*page_size,
367 PROT_READ|PROT_WRITE, MAP_SHARED, fd[nr_cpu][counter], 0);
368 if (mmap_array[nr_cpu][counter].base == MAP_FAILED) {
369 error("failed to mmap with %d (%s)\n", errno, strerror(errno));
370 exit(-1);
371 }
372 }
d1302522 373
c171b552
LZ
374 if (filter != NULL) {
375 ret = ioctl(fd[nr_cpu][counter],
376 PERF_EVENT_IOC_SET_FILTER, filter);
377 if (ret) {
378 error("failed to set filter with %d (%s)\n", errno,
379 strerror(errno));
380 exit(-1);
381 }
382 }
383
cdd6c482 384 ioctl(fd[nr_cpu][counter], PERF_EVENT_IOC_ENABLE);
f250c030 385}
f2521b6e 386
f250c030
IM
387static void open_counters(int cpu, pid_t pid)
388{
389 int counter;
16c8a109 390
f250c030
IM
391 group_fd = -1;
392 for (counter = 0; counter < nr_counters; counter++)
393 create_counter(counter, cpu, pid);
394
16c8a109
PZ
395 nr_cpu++;
396}
397
f5970550
PZ
398static void atexit_header(void)
399{
94c744b6 400 session->header.data_size += bytes_written;
f5970550 401
94c744b6 402 perf_header__write(&session->header, output, true);
f5970550
PZ
403}
404
0e9b20b8 405static int __cmd_record(int argc, const char **argv)
16c8a109
PZ
406{
407 int i, counter;
abaff32a 408 struct stat st;
7c6a1c65 409 pid_t pid = 0;
abaff32a 410 int flags;
4dc0a04b 411 int err;
8b412664 412 unsigned long waking = 0;
de9ac07b
PZ
413
414 page_size = sysconf(_SC_PAGE_SIZE);
de9ac07b
PZ
415 nr_cpus = sysconf(_SC_NPROCESSORS_ONLN);
416 assert(nr_cpus <= MAX_NR_CPUS);
417 assert(nr_cpus >= 0);
418
f5970550
PZ
419 atexit(sig_atexit);
420 signal(SIGCHLD, sig_handler);
421 signal(SIGINT, sig_handler);
422
266e0e21
PH
423 if (!stat(output_name, &st) && st.st_size) {
424 if (!force && !append_file) {
425 fprintf(stderr, "Error, output file %s exists, use -A to append or -f to overwrite.\n",
426 output_name);
427 exit(-1);
428 }
429 } else {
430 append_file = 0;
97124d5e
PZ
431 }
432
abaff32a
IM
433 flags = O_CREAT|O_RDWR;
434 if (append_file)
f5970550 435 file_new = 0;
abaff32a
IM
436 else
437 flags |= O_TRUNC;
438
439 output = open(output_name, flags, S_IRUSR|S_IWUSR);
de9ac07b
PZ
440 if (output < 0) {
441 perror("failed to create output file");
442 exit(-1);
443 }
444
94c744b6
ACM
445 session = perf_session__new(output_name, O_WRONLY, force);
446 if (session == NULL) {
a9a70bbc
ACM
447 pr_err("Not enough memory for reading perf file header\n");
448 return -1;
449 }
450
4dc0a04b 451 if (!file_new) {
94c744b6 452 err = perf_header__read(&session->header, output);
4dc0a04b
ACM
453 if (err < 0)
454 return err;
455 }
456
9df37ddd 457 if (raw_samples) {
94c744b6 458 perf_header__set_feat(&session->header, HEADER_TRACE_INFO);
9df37ddd
FW
459 } else {
460 for (i = 0; i < nr_counters; i++) {
461 if (attrs[i].sample_type & PERF_SAMPLE_RAW) {
94c744b6 462 perf_header__set_feat(&session->header, HEADER_TRACE_INFO);
9df37ddd
FW
463 break;
464 }
465 }
466 }
03456a15 467
f5970550
PZ
468 atexit(atexit_header);
469
1a853e36 470 if (!system_wide) {
7c6a1c65
PZ
471 pid = target_pid;
472 if (pid == -1)
473 pid = getpid();
474
0a5ac846
JA
475 open_counters(profile_cpu, pid);
476 } else {
477 if (profile_cpu != -1) {
478 open_counters(profile_cpu, target_pid);
479 } else {
480 for (i = 0; i < nr_cpus; i++)
481 open_counters(i, target_pid);
482 }
483 }
de9ac07b 484
d5eed904 485 if (file_new) {
94c744b6 486 err = perf_header__write(&session->header, output, false);
d5eed904
ACM
487 if (err < 0)
488 return err;
489 }
7c6a1c65 490
234fbbf5 491 if (!system_wide)
d8f66248
ACM
492 event__synthesize_thread(pid, process_synthesized_event,
493 session);
234fbbf5 494 else
d8f66248 495 event__synthesize_threads(process_synthesized_event, session);
7c6a1c65 496
ef65b2a0 497 if (target_pid == -1 && argc) {
1a853e36
ACM
498 pid = fork();
499 if (pid < 0)
de896721 500 die("failed to fork");
de9ac07b 501
1a853e36 502 if (!pid) {
0e9b20b8 503 if (execvp(argv[0], (char **)argv)) {
1a853e36
ACM
504 perror(argv[0]);
505 exit(-1);
506 }
de896721
FW
507 } else {
508 /*
509 * Wait a bit for the execv'ed child to appear
510 * and be updated in /proc
511 * FIXME: Do you know a less heuristical solution?
512 */
513 usleep(1000);
514 event__synthesize_thread(pid,
d8f66248
ACM
515 process_synthesized_event,
516 session);
de9ac07b 517 }
933da83a
CW
518
519 child_pid = pid;
de9ac07b
PZ
520 }
521
522 if (realtime_prio) {
523 struct sched_param param;
524
525 param.sched_priority = realtime_prio;
526 if (sched_setscheduler(0, SCHED_FIFO, &param)) {
6beba7ad 527 pr_err("Could not set realtime priority.\n");
de9ac07b
PZ
528 exit(-1);
529 }
530 }
531
649c48a9 532 for (;;) {
2debbc83 533 int hits = samples;
de9ac07b 534
16c8a109 535 for (i = 0; i < nr_cpu; i++) {
ea57c4f5
IM
536 for (counter = 0; counter < nr_counters; counter++) {
537 if (mmap_array[i][counter].base)
538 mmap_read(&mmap_array[i][counter]);
539 }
de9ac07b
PZ
540 }
541
649c48a9
PZ
542 if (hits == samples) {
543 if (done)
544 break;
4dc0a04b 545 err = poll(event_array, nr_poll, -1);
8b412664
PZ
546 waking++;
547 }
548
549 if (done) {
550 for (i = 0; i < nr_cpu; i++) {
551 for (counter = 0; counter < nr_counters; counter++)
cdd6c482 552 ioctl(fd[i][counter], PERF_EVENT_IOC_DISABLE);
8b412664 553 }
649c48a9 554 }
de9ac07b
PZ
555 }
556
8b412664
PZ
557 fprintf(stderr, "[ perf record: Woken up %ld times to write data ]\n", waking);
558
021e9f47
IM
559 /*
560 * Approximate RIP event size: 24 bytes.
561 */
562 fprintf(stderr,
2debbc83 563 "[ perf record: Captured and wrote %.3f MB %s (~%lld samples) ]\n",
021e9f47
IM
564 (double)bytes_written / 1024.0 / 1024.0,
565 output_name,
566 bytes_written / 24);
addc2785 567
de9ac07b
PZ
568 return 0;
569}
0e9b20b8 570
0e9b20b8 571static const char * const record_usage[] = {
9e096753
MG
572 "perf record [<options>] [<command>]",
573 "perf record [<options>] -- <command> [<options>]",
0e9b20b8
IM
574 NULL
575};
576
5242519b 577static const struct option options[] = {
0e9b20b8 578 OPT_CALLBACK('e', "event", NULL, "event",
86847b62
TG
579 "event selector. use 'perf list' to list available events",
580 parse_events),
c171b552
LZ
581 OPT_CALLBACK(0, "filter", NULL, "filter",
582 "event filter", parse_filter),
0e9b20b8
IM
583 OPT_INTEGER('p', "pid", &target_pid,
584 "record events on existing pid"),
585 OPT_INTEGER('r', "realtime", &realtime_prio,
586 "collect data with this RT SCHED_FIFO priority"),
daac07b2
FW
587 OPT_BOOLEAN('R', "raw-samples", &raw_samples,
588 "collect raw sample records from all opened counters"),
0e9b20b8
IM
589 OPT_BOOLEAN('a', "all-cpus", &system_wide,
590 "system-wide collection from all CPUs"),
abaff32a
IM
591 OPT_BOOLEAN('A', "append", &append_file,
592 "append to the output file to do incremental profiling"),
0a5ac846
JA
593 OPT_INTEGER('C', "profile_cpu", &profile_cpu,
594 "CPU to profile on"),
97124d5e
PZ
595 OPT_BOOLEAN('f', "force", &force,
596 "overwrite existing data file"),
e61078a0 597 OPT_LONG('c', "count", &default_interval,
abaff32a
IM
598 "event period to sample"),
599 OPT_STRING('o', "output", &output_name, "file",
600 "output file name"),
601 OPT_BOOLEAN('i', "inherit", &inherit,
602 "child tasks inherit counters"),
cf1f4574
IM
603 OPT_INTEGER('F', "freq", &freq,
604 "profile at this frequency"),
abaff32a
IM
605 OPT_INTEGER('m', "mmap-pages", &mmap_pages,
606 "number of mmap data pages"),
3efa1cc9
IM
607 OPT_BOOLEAN('g', "call-graph", &call_graph,
608 "do call-graph (stack chain/backtrace) recording"),
3da297a6
IM
609 OPT_BOOLEAN('v', "verbose", &verbose,
610 "be more verbose (show counter open errors, etc)"),
649c48a9
PZ
611 OPT_BOOLEAN('s', "stat", &inherit_stat,
612 "per thread counts"),
4bba828d
AB
613 OPT_BOOLEAN('d', "data", &sample_address,
614 "Sample addresses"),
649c48a9
PZ
615 OPT_BOOLEAN('n', "no-samples", &no_samples,
616 "don't sample"),
d1302522
FW
617 OPT_BOOLEAN('M', "multiplex", &multiplex,
618 "multiplex counter output in a single channel"),
0e9b20b8
IM
619 OPT_END()
620};
621
f37a291c 622int cmd_record(int argc, const char **argv, const char *prefix __used)
0e9b20b8
IM
623{
624 int counter;
625
8d06367f
ACM
626 symbol__init(0);
627
a0541234
AB
628 argc = parse_options(argc, argv, options, record_usage,
629 PARSE_OPT_STOP_AT_NON_OPTION);
ef65b2a0 630 if (!argc && target_pid == -1 && !system_wide)
0e9b20b8
IM
631 usage_with_options(record_usage, options);
632
bbd36e5e
PZ
633 if (!nr_counters) {
634 nr_counters = 1;
635 attrs[0].type = PERF_TYPE_HARDWARE;
636 attrs[0].config = PERF_COUNT_HW_CPU_CYCLES;
637 }
0e9b20b8 638
7e4ff9e3
MG
639 /*
640 * User specified count overrides default frequency.
641 */
642 if (default_interval)
643 freq = 0;
644 else if (freq) {
645 default_interval = freq;
646 } else {
647 fprintf(stderr, "frequency and count are zero, aborting\n");
648 exit(EXIT_FAILURE);
649 }
650
0e9b20b8 651 for (counter = 0; counter < nr_counters; counter++) {
a21ca2ca 652 if (attrs[counter].sample_period)
0e9b20b8
IM
653 continue;
654
a21ca2ca 655 attrs[counter].sample_period = default_interval;
0e9b20b8
IM
656 }
657
658 return __cmd_record(argc, argv);
659}
This page took 0.123599 seconds and 5 git commands to generate.