builtin-record.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736
  1. /*
  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.
  7. */
  8. #include "builtin.h"
  9. #include "perf.h"
  10. #include "util/util.h"
  11. #include "util/parse-options.h"
  12. #include "util/parse-events.h"
  13. #include "util/string.h"
  14. #include "util/header.h"
  15. #include "util/event.h"
  16. #include "util/debug.h"
  17. #include "util/trace-event.h"
  18. #include <unistd.h>
  19. #include <sched.h>
  20. #define ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a)-1)
  21. #define __ALIGN_MASK(x, mask) (((x)+(mask))&~(mask))
  22. static int fd[MAX_NR_CPUS][MAX_COUNTERS];
  23. static long default_interval = 100000;
  24. static int nr_cpus = 0;
  25. static unsigned int page_size;
  26. static unsigned int mmap_pages = 128;
  27. static int freq = 0;
  28. static int output;
  29. static const char *output_name = "perf.data";
  30. static int group = 0;
  31. static unsigned int realtime_prio = 0;
  32. static int raw_samples = 0;
  33. static int system_wide = 0;
  34. static int profile_cpu = -1;
  35. static pid_t target_pid = -1;
  36. static int inherit = 1;
  37. static int force = 0;
  38. static int append_file = 0;
  39. static int call_graph = 0;
  40. static int inherit_stat = 0;
  41. static int no_samples = 0;
  42. static int sample_address = 0;
  43. static int multiplex = 0;
  44. static int multiplex_fd = -1;
  45. static long samples;
  46. static struct timeval last_read;
  47. static struct timeval this_read;
  48. static u64 bytes_written;
  49. static struct pollfd event_array[MAX_NR_CPUS * MAX_COUNTERS];
  50. static int nr_poll;
  51. static int nr_cpu;
  52. static int file_new = 1;
  53. struct perf_header *header;
  54. struct mmap_data {
  55. int counter;
  56. void *base;
  57. unsigned int mask;
  58. unsigned int prev;
  59. };
  60. static struct mmap_data mmap_array[MAX_NR_CPUS][MAX_COUNTERS];
  61. static unsigned long mmap_read_head(struct mmap_data *md)
  62. {
  63. struct perf_event_mmap_page *pc = md->base;
  64. long head;
  65. head = pc->data_head;
  66. rmb();
  67. return head;
  68. }
  69. static void mmap_write_tail(struct mmap_data *md, unsigned long tail)
  70. {
  71. struct perf_event_mmap_page *pc = md->base;
  72. /*
  73. * ensure all reads are done before we write the tail out.
  74. */
  75. /* mb(); */
  76. pc->data_tail = tail;
  77. }
  78. static void write_output(void *buf, size_t size)
  79. {
  80. while (size) {
  81. int ret = write(output, buf, size);
  82. if (ret < 0)
  83. die("failed to write");
  84. size -= ret;
  85. buf += ret;
  86. bytes_written += ret;
  87. }
  88. }
  89. static void mmap_read(struct mmap_data *md)
  90. {
  91. unsigned int head = mmap_read_head(md);
  92. unsigned int old = md->prev;
  93. unsigned char *data = md->base + page_size;
  94. unsigned long size;
  95. void *buf;
  96. int diff;
  97. gettimeofday(&this_read, NULL);
  98. /*
  99. * If we're further behind than half the buffer, there's a chance
  100. * the writer will bite our tail and mess up the samples under us.
  101. *
  102. * If we somehow ended up ahead of the head, we got messed up.
  103. *
  104. * In either case, truncate and restart at head.
  105. */
  106. diff = head - old;
  107. if (diff < 0) {
  108. struct timeval iv;
  109. unsigned long msecs;
  110. timersub(&this_read, &last_read, &iv);
  111. msecs = iv.tv_sec*1000 + iv.tv_usec/1000;
  112. fprintf(stderr, "WARNING: failed to keep up with mmap data."
  113. " Last read %lu msecs ago.\n", msecs);
  114. /*
  115. * head points to a known good entry, start there.
  116. */
  117. old = head;
  118. }
  119. last_read = this_read;
  120. if (old != head)
  121. samples++;
  122. size = head - old;
  123. if ((old & md->mask) + size != (head & md->mask)) {
  124. buf = &data[old & md->mask];
  125. size = md->mask + 1 - (old & md->mask);
  126. old += size;
  127. write_output(buf, size);
  128. }
  129. buf = &data[old & md->mask];
  130. size = head - old;
  131. old += size;
  132. write_output(buf, size);
  133. md->prev = old;
  134. mmap_write_tail(md, old);
  135. }
  136. static volatile int done = 0;
  137. static volatile int signr = -1;
  138. static void sig_handler(int sig)
  139. {
  140. done = 1;
  141. signr = sig;
  142. }
  143. static void sig_atexit(void)
  144. {
  145. if (signr == -1)
  146. return;
  147. signal(signr, SIG_DFL);
  148. kill(getpid(), signr);
  149. }
  150. static pid_t pid_synthesize_comm_event(pid_t pid, int full)
  151. {
  152. struct comm_event comm_ev;
  153. char filename[PATH_MAX];
  154. char bf[BUFSIZ];
  155. FILE *fp;
  156. size_t size = 0;
  157. DIR *tasks;
  158. struct dirent dirent, *next;
  159. pid_t tgid = 0;
  160. snprintf(filename, sizeof(filename), "/proc/%d/status", pid);
  161. fp = fopen(filename, "r");
  162. if (fp == NULL) {
  163. /*
  164. * We raced with a task exiting - just return:
  165. */
  166. if (verbose)
  167. fprintf(stderr, "couldn't open %s\n", filename);
  168. return 0;
  169. }
  170. memset(&comm_ev, 0, sizeof(comm_ev));
  171. while (!comm_ev.comm[0] || !comm_ev.pid) {
  172. if (fgets(bf, sizeof(bf), fp) == NULL)
  173. goto out_failure;
  174. if (memcmp(bf, "Name:", 5) == 0) {
  175. char *name = bf + 5;
  176. while (*name && isspace(*name))
  177. ++name;
  178. size = strlen(name) - 1;
  179. memcpy(comm_ev.comm, name, size++);
  180. } else if (memcmp(bf, "Tgid:", 5) == 0) {
  181. char *tgids = bf + 5;
  182. while (*tgids && isspace(*tgids))
  183. ++tgids;
  184. tgid = comm_ev.pid = atoi(tgids);
  185. }
  186. }
  187. comm_ev.header.type = PERF_RECORD_COMM;
  188. size = ALIGN(size, sizeof(u64));
  189. comm_ev.header.size = sizeof(comm_ev) - (sizeof(comm_ev.comm) - size);
  190. if (!full) {
  191. comm_ev.tid = pid;
  192. write_output(&comm_ev, comm_ev.header.size);
  193. goto out_fclose;
  194. }
  195. snprintf(filename, sizeof(filename), "/proc/%d/task", pid);
  196. tasks = opendir(filename);
  197. while (!readdir_r(tasks, &dirent, &next) && next) {
  198. char *end;
  199. pid = strtol(dirent.d_name, &end, 10);
  200. if (*end)
  201. continue;
  202. comm_ev.tid = pid;
  203. write_output(&comm_ev, comm_ev.header.size);
  204. }
  205. closedir(tasks);
  206. out_fclose:
  207. fclose(fp);
  208. return tgid;
  209. out_failure:
  210. fprintf(stderr, "couldn't get COMM and pgid, malformed %s\n",
  211. filename);
  212. exit(EXIT_FAILURE);
  213. }
  214. static void pid_synthesize_mmap_samples(pid_t pid, pid_t tgid)
  215. {
  216. char filename[PATH_MAX];
  217. FILE *fp;
  218. snprintf(filename, sizeof(filename), "/proc/%d/maps", pid);
  219. fp = fopen(filename, "r");
  220. if (fp == NULL) {
  221. /*
  222. * We raced with a task exiting - just return:
  223. */
  224. if (verbose)
  225. fprintf(stderr, "couldn't open %s\n", filename);
  226. return;
  227. }
  228. while (1) {
  229. char bf[BUFSIZ], *pbf = bf;
  230. struct mmap_event mmap_ev = {
  231. .header = { .type = PERF_RECORD_MMAP },
  232. };
  233. int n;
  234. size_t size;
  235. if (fgets(bf, sizeof(bf), fp) == NULL)
  236. break;
  237. /* 00400000-0040c000 r-xp 00000000 fd:01 41038 /bin/cat */
  238. n = hex2u64(pbf, &mmap_ev.start);
  239. if (n < 0)
  240. continue;
  241. pbf += n + 1;
  242. n = hex2u64(pbf, &mmap_ev.len);
  243. if (n < 0)
  244. continue;
  245. pbf += n + 3;
  246. if (*pbf == 'x') { /* vm_exec */
  247. char *execname = strchr(bf, '/');
  248. /* Catch VDSO */
  249. if (execname == NULL)
  250. execname = strstr(bf, "[vdso]");
  251. if (execname == NULL)
  252. continue;
  253. size = strlen(execname);
  254. execname[size - 1] = '\0'; /* Remove \n */
  255. memcpy(mmap_ev.filename, execname, size);
  256. size = ALIGN(size, sizeof(u64));
  257. mmap_ev.len -= mmap_ev.start;
  258. mmap_ev.header.size = (sizeof(mmap_ev) -
  259. (sizeof(mmap_ev.filename) - size));
  260. mmap_ev.pid = tgid;
  261. mmap_ev.tid = pid;
  262. write_output(&mmap_ev, mmap_ev.header.size);
  263. }
  264. }
  265. fclose(fp);
  266. }
  267. static void synthesize_all(void)
  268. {
  269. DIR *proc;
  270. struct dirent dirent, *next;
  271. proc = opendir("/proc");
  272. while (!readdir_r(proc, &dirent, &next) && next) {
  273. char *end;
  274. pid_t pid, tgid;
  275. pid = strtol(dirent.d_name, &end, 10);
  276. if (*end) /* only interested in proper numerical dirents */
  277. continue;
  278. tgid = pid_synthesize_comm_event(pid, 1);
  279. pid_synthesize_mmap_samples(pid, tgid);
  280. }
  281. closedir(proc);
  282. }
  283. static int group_fd;
  284. static struct perf_header_attr *get_header_attr(struct perf_event_attr *a, int nr)
  285. {
  286. struct perf_header_attr *h_attr;
  287. if (nr < header->attrs) {
  288. h_attr = header->attr[nr];
  289. } else {
  290. h_attr = perf_header_attr__new(a);
  291. perf_header__add_attr(header, h_attr);
  292. }
  293. return h_attr;
  294. }
  295. static void create_counter(int counter, int cpu, pid_t pid)
  296. {
  297. struct perf_event_attr *attr = attrs + counter;
  298. struct perf_header_attr *h_attr;
  299. int track = !counter; /* only the first counter needs these */
  300. struct {
  301. u64 count;
  302. u64 time_enabled;
  303. u64 time_running;
  304. u64 id;
  305. } read_data;
  306. attr->read_format = PERF_FORMAT_TOTAL_TIME_ENABLED |
  307. PERF_FORMAT_TOTAL_TIME_RUNNING |
  308. PERF_FORMAT_ID;
  309. attr->sample_type |= PERF_SAMPLE_IP | PERF_SAMPLE_TID;
  310. if (freq) {
  311. attr->sample_type |= PERF_SAMPLE_PERIOD;
  312. attr->freq = 1;
  313. attr->sample_freq = freq;
  314. }
  315. if (no_samples)
  316. attr->sample_freq = 0;
  317. if (inherit_stat)
  318. attr->inherit_stat = 1;
  319. if (sample_address)
  320. attr->sample_type |= PERF_SAMPLE_ADDR;
  321. if (call_graph)
  322. attr->sample_type |= PERF_SAMPLE_CALLCHAIN;
  323. if (raw_samples) {
  324. attr->sample_type |= PERF_SAMPLE_TIME;
  325. attr->sample_type |= PERF_SAMPLE_RAW;
  326. attr->sample_type |= PERF_SAMPLE_CPU;
  327. }
  328. attr->mmap = track;
  329. attr->comm = track;
  330. attr->inherit = (cpu < 0) && inherit;
  331. attr->disabled = 1;
  332. try_again:
  333. fd[nr_cpu][counter] = sys_perf_event_open(attr, pid, cpu, group_fd, 0);
  334. if (fd[nr_cpu][counter] < 0) {
  335. int err = errno;
  336. if (err == EPERM)
  337. die("Permission error - are you root?\n");
  338. else if (err == ENODEV && profile_cpu != -1)
  339. die("No such device - did you specify an out-of-range profile CPU?\n");
  340. /*
  341. * If it's cycles then fall back to hrtimer
  342. * based cpu-clock-tick sw counter, which
  343. * is always available even if no PMU support:
  344. */
  345. if (attr->type == PERF_TYPE_HARDWARE
  346. && attr->config == PERF_COUNT_HW_CPU_CYCLES) {
  347. if (verbose)
  348. warning(" ... trying to fall back to cpu-clock-ticks\n");
  349. attr->type = PERF_TYPE_SOFTWARE;
  350. attr->config = PERF_COUNT_SW_CPU_CLOCK;
  351. goto try_again;
  352. }
  353. printf("\n");
  354. error("perfcounter syscall returned with %d (%s)\n",
  355. fd[nr_cpu][counter], strerror(err));
  356. die("No CONFIG_PERF_EVENTS=y kernel support configured?\n");
  357. exit(-1);
  358. }
  359. h_attr = get_header_attr(attr, counter);
  360. if (!file_new) {
  361. if (memcmp(&h_attr->attr, attr, sizeof(*attr))) {
  362. fprintf(stderr, "incompatible append\n");
  363. exit(-1);
  364. }
  365. }
  366. if (read(fd[nr_cpu][counter], &read_data, sizeof(read_data)) == -1) {
  367. perror("Unable to read perf file descriptor\n");
  368. exit(-1);
  369. }
  370. perf_header_attr__add_id(h_attr, read_data.id);
  371. assert(fd[nr_cpu][counter] >= 0);
  372. fcntl(fd[nr_cpu][counter], F_SETFL, O_NONBLOCK);
  373. /*
  374. * First counter acts as the group leader:
  375. */
  376. if (group && group_fd == -1)
  377. group_fd = fd[nr_cpu][counter];
  378. if (multiplex && multiplex_fd == -1)
  379. multiplex_fd = fd[nr_cpu][counter];
  380. if (multiplex && fd[nr_cpu][counter] != multiplex_fd) {
  381. int ret;
  382. ret = ioctl(fd[nr_cpu][counter], PERF_EVENT_IOC_SET_OUTPUT, multiplex_fd);
  383. assert(ret != -1);
  384. } else {
  385. event_array[nr_poll].fd = fd[nr_cpu][counter];
  386. event_array[nr_poll].events = POLLIN;
  387. nr_poll++;
  388. mmap_array[nr_cpu][counter].counter = counter;
  389. mmap_array[nr_cpu][counter].prev = 0;
  390. mmap_array[nr_cpu][counter].mask = mmap_pages*page_size - 1;
  391. mmap_array[nr_cpu][counter].base = mmap(NULL, (mmap_pages+1)*page_size,
  392. PROT_READ|PROT_WRITE, MAP_SHARED, fd[nr_cpu][counter], 0);
  393. if (mmap_array[nr_cpu][counter].base == MAP_FAILED) {
  394. error("failed to mmap with %d (%s)\n", errno, strerror(errno));
  395. exit(-1);
  396. }
  397. }
  398. ioctl(fd[nr_cpu][counter], PERF_EVENT_IOC_ENABLE);
  399. }
  400. static void open_counters(int cpu, pid_t pid)
  401. {
  402. int counter;
  403. group_fd = -1;
  404. for (counter = 0; counter < nr_counters; counter++)
  405. create_counter(counter, cpu, pid);
  406. nr_cpu++;
  407. }
  408. static void atexit_header(void)
  409. {
  410. header->data_size += bytes_written;
  411. perf_header__write(header, output);
  412. }
  413. static int __cmd_record(int argc, const char **argv)
  414. {
  415. int i, counter;
  416. struct stat st;
  417. pid_t pid = 0;
  418. int flags;
  419. int ret;
  420. unsigned long waking = 0;
  421. page_size = sysconf(_SC_PAGE_SIZE);
  422. nr_cpus = sysconf(_SC_NPROCESSORS_ONLN);
  423. assert(nr_cpus <= MAX_NR_CPUS);
  424. assert(nr_cpus >= 0);
  425. atexit(sig_atexit);
  426. signal(SIGCHLD, sig_handler);
  427. signal(SIGINT, sig_handler);
  428. if (!stat(output_name, &st) && st.st_size) {
  429. if (!force && !append_file) {
  430. fprintf(stderr, "Error, output file %s exists, use -A to append or -f to overwrite.\n",
  431. output_name);
  432. exit(-1);
  433. }
  434. } else {
  435. append_file = 0;
  436. }
  437. flags = O_CREAT|O_RDWR;
  438. if (append_file)
  439. file_new = 0;
  440. else
  441. flags |= O_TRUNC;
  442. output = open(output_name, flags, S_IRUSR|S_IWUSR);
  443. if (output < 0) {
  444. perror("failed to create output file");
  445. exit(-1);
  446. }
  447. if (!file_new)
  448. header = perf_header__read(output);
  449. else
  450. header = perf_header__new();
  451. if (raw_samples) {
  452. read_tracing_data(attrs, nr_counters);
  453. } else {
  454. for (i = 0; i < nr_counters; i++) {
  455. if (attrs[i].sample_type & PERF_SAMPLE_RAW) {
  456. read_tracing_data(attrs, nr_counters);
  457. break;
  458. }
  459. }
  460. }
  461. atexit(atexit_header);
  462. if (!system_wide) {
  463. pid = target_pid;
  464. if (pid == -1)
  465. pid = getpid();
  466. open_counters(profile_cpu, pid);
  467. } else {
  468. if (profile_cpu != -1) {
  469. open_counters(profile_cpu, target_pid);
  470. } else {
  471. for (i = 0; i < nr_cpus; i++)
  472. open_counters(i, target_pid);
  473. }
  474. }
  475. if (file_new)
  476. perf_header__write(header, output);
  477. if (!system_wide) {
  478. pid_t tgid = pid_synthesize_comm_event(pid, 0);
  479. pid_synthesize_mmap_samples(pid, tgid);
  480. } else
  481. synthesize_all();
  482. if (target_pid == -1 && argc) {
  483. pid = fork();
  484. if (pid < 0)
  485. perror("failed to fork");
  486. if (!pid) {
  487. if (execvp(argv[0], (char **)argv)) {
  488. perror(argv[0]);
  489. exit(-1);
  490. }
  491. }
  492. }
  493. if (realtime_prio) {
  494. struct sched_param param;
  495. param.sched_priority = realtime_prio;
  496. if (sched_setscheduler(0, SCHED_FIFO, &param)) {
  497. printf("Could not set realtime priority.\n");
  498. exit(-1);
  499. }
  500. }
  501. for (;;) {
  502. int hits = samples;
  503. for (i = 0; i < nr_cpu; i++) {
  504. for (counter = 0; counter < nr_counters; counter++) {
  505. if (mmap_array[i][counter].base)
  506. mmap_read(&mmap_array[i][counter]);
  507. }
  508. }
  509. if (hits == samples) {
  510. if (done)
  511. break;
  512. ret = poll(event_array, nr_poll, -1);
  513. waking++;
  514. }
  515. if (done) {
  516. for (i = 0; i < nr_cpu; i++) {
  517. for (counter = 0; counter < nr_counters; counter++)
  518. ioctl(fd[i][counter], PERF_EVENT_IOC_DISABLE);
  519. }
  520. }
  521. }
  522. fprintf(stderr, "[ perf record: Woken up %ld times to write data ]\n", waking);
  523. /*
  524. * Approximate RIP event size: 24 bytes.
  525. */
  526. fprintf(stderr,
  527. "[ perf record: Captured and wrote %.3f MB %s (~%lld samples) ]\n",
  528. (double)bytes_written / 1024.0 / 1024.0,
  529. output_name,
  530. bytes_written / 24);
  531. return 0;
  532. }
  533. static const char * const record_usage[] = {
  534. "perf record [<options>] [<command>]",
  535. "perf record [<options>] -- <command> [<options>]",
  536. NULL
  537. };
  538. static const struct option options[] = {
  539. OPT_CALLBACK('e', "event", NULL, "event",
  540. "event selector. use 'perf list' to list available events",
  541. parse_events),
  542. OPT_INTEGER('p', "pid", &target_pid,
  543. "record events on existing pid"),
  544. OPT_INTEGER('r', "realtime", &realtime_prio,
  545. "collect data with this RT SCHED_FIFO priority"),
  546. OPT_BOOLEAN('R', "raw-samples", &raw_samples,
  547. "collect raw sample records from all opened counters"),
  548. OPT_BOOLEAN('a', "all-cpus", &system_wide,
  549. "system-wide collection from all CPUs"),
  550. OPT_BOOLEAN('A', "append", &append_file,
  551. "append to the output file to do incremental profiling"),
  552. OPT_INTEGER('C', "profile_cpu", &profile_cpu,
  553. "CPU to profile on"),
  554. OPT_BOOLEAN('f', "force", &force,
  555. "overwrite existing data file"),
  556. OPT_LONG('c', "count", &default_interval,
  557. "event period to sample"),
  558. OPT_STRING('o', "output", &output_name, "file",
  559. "output file name"),
  560. OPT_BOOLEAN('i', "inherit", &inherit,
  561. "child tasks inherit counters"),
  562. OPT_INTEGER('F', "freq", &freq,
  563. "profile at this frequency"),
  564. OPT_INTEGER('m', "mmap-pages", &mmap_pages,
  565. "number of mmap data pages"),
  566. OPT_BOOLEAN('g', "call-graph", &call_graph,
  567. "do call-graph (stack chain/backtrace) recording"),
  568. OPT_BOOLEAN('v', "verbose", &verbose,
  569. "be more verbose (show counter open errors, etc)"),
  570. OPT_BOOLEAN('s', "stat", &inherit_stat,
  571. "per thread counts"),
  572. OPT_BOOLEAN('d', "data", &sample_address,
  573. "Sample addresses"),
  574. OPT_BOOLEAN('n', "no-samples", &no_samples,
  575. "don't sample"),
  576. OPT_BOOLEAN('M', "multiplex", &multiplex,
  577. "multiplex counter output in a single channel"),
  578. OPT_END()
  579. };
  580. int cmd_record(int argc, const char **argv, const char *prefix __used)
  581. {
  582. int counter;
  583. argc = parse_options(argc, argv, options, record_usage,
  584. PARSE_OPT_STOP_AT_NON_OPTION);
  585. if (!argc && target_pid == -1 && !system_wide)
  586. usage_with_options(record_usage, options);
  587. if (!nr_counters) {
  588. nr_counters = 1;
  589. attrs[0].type = PERF_TYPE_HARDWARE;
  590. attrs[0].config = PERF_COUNT_HW_CPU_CYCLES;
  591. }
  592. for (counter = 0; counter < nr_counters; counter++) {
  593. if (attrs[counter].sample_period)
  594. continue;
  595. attrs[counter].sample_period = default_interval;
  596. }
  597. return __cmd_record(argc, argv);
  598. }