1 #include <linux/compiler.h>
2 #include <linux/kernel.h>
3 #include <linux/stringify.h>
8 #include <subcmd/parse-options.h>
9 #include "mem-events.h"
19 struct perf_hpp_list list
;
20 struct c2c_stats stats
;
23 struct c2c_hist_entry
{
24 struct c2c_hists
*hists
;
25 struct c2c_stats stats
;
26 unsigned long *cpuset
;
27 struct c2c_stats
*node_stats
;
30 * because of its callchain dynamic entry
36 struct perf_tool tool
;
37 struct c2c_hists hists
;
39 unsigned long **nodes
;
46 static struct perf_c2c c2c
;
48 static void *c2c_he_zalloc(size_t size
)
50 struct c2c_hist_entry
*c2c_he
;
52 c2c_he
= zalloc(size
+ sizeof(*c2c_he
));
56 c2c_he
->cpuset
= bitmap_alloc(c2c
.cpus_cnt
);
60 c2c_he
->node_stats
= zalloc(c2c
.nodes_cnt
* sizeof(*c2c_he
->node_stats
));
61 if (!c2c_he
->node_stats
)
67 static void c2c_he_free(void *he
)
69 struct c2c_hist_entry
*c2c_he
;
71 c2c_he
= container_of(he
, struct c2c_hist_entry
, he
);
73 hists__delete_entries(&c2c_he
->hists
->hists
);
78 free(c2c_he
->node_stats
);
82 static struct hist_entry_ops c2c_entry_ops
= {
87 static int c2c_hists__init(struct c2c_hists
*hists
,
90 static struct c2c_hists
*
91 he__get_c2c_hists(struct hist_entry
*he
,
94 struct c2c_hist_entry
*c2c_he
;
95 struct c2c_hists
*hists
;
98 c2c_he
= container_of(he
, struct c2c_hist_entry
, he
);
100 return c2c_he
->hists
;
102 hists
= c2c_he
->hists
= zalloc(sizeof(*hists
));
106 ret
= c2c_hists__init(hists
, sort
);
115 static void c2c_he__set_cpu(struct c2c_hist_entry
*c2c_he
,
116 struct perf_sample
*sample
)
118 if (WARN_ONCE(sample
->cpu
== (unsigned int) -1,
119 "WARNING: no sample cpu value"))
122 set_bit(sample
->cpu
, c2c_he
->cpuset
);
125 static int process_sample_event(struct perf_tool
*tool __maybe_unused
,
126 union perf_event
*event
,
127 struct perf_sample
*sample
,
128 struct perf_evsel
*evsel __maybe_unused
,
129 struct machine
*machine
)
131 struct c2c_hists
*c2c_hists
= &c2c
.hists
;
132 struct c2c_hist_entry
*c2c_he
;
133 struct c2c_stats stats
= { .nr_entries
= 0, };
134 struct hist_entry
*he
;
135 struct addr_location al
;
136 struct mem_info
*mi
, *mi_dup
;
139 if (machine__resolve(machine
, &al
, sample
) < 0) {
140 pr_debug("problem processing %d event, skipping it.\n",
145 mi
= sample__resolve_mem(sample
, &al
);
149 mi_dup
= memdup(mi
, sizeof(*mi
));
153 c2c_decode_stats(&stats
, mi
);
155 he
= hists__add_entry_ops(&c2c_hists
->hists
, &c2c_entry_ops
,
161 c2c_he
= container_of(he
, struct c2c_hist_entry
, he
);
162 c2c_add_stats(&c2c_he
->stats
, &stats
);
163 c2c_add_stats(&c2c_hists
->stats
, &stats
);
165 c2c_he__set_cpu(c2c_he
, sample
);
167 hists__inc_nr_samples(&c2c_hists
->hists
, he
->filtered
);
168 ret
= hist_entry__append_callchain(he
, sample
);
172 * There's already been warning about missing
173 * sample's cpu value. Let's account all to
174 * node 0 in this case, without any further
177 * Doing node stats only for single callchain data.
179 int cpu
= sample
->cpu
== (unsigned int) -1 ? 0 : sample
->cpu
;
180 int node
= c2c
.cpu2node
[cpu
];
184 mi_dup
= memdup(mi
, sizeof(*mi
));
188 c2c_hists
= he__get_c2c_hists(he
, "offset");
192 he
= hists__add_entry_ops(&c2c_hists
->hists
, &c2c_entry_ops
,
198 c2c_he
= container_of(he
, struct c2c_hist_entry
, he
);
199 c2c_add_stats(&c2c_he
->stats
, &stats
);
200 c2c_add_stats(&c2c_hists
->stats
, &stats
);
201 c2c_add_stats(&c2c_he
->node_stats
[node
], &stats
);
203 c2c_he__set_cpu(c2c_he
, sample
);
205 hists__inc_nr_samples(&c2c_hists
->hists
, he
->filtered
);
206 ret
= hist_entry__append_callchain(he
, sample
);
210 addr_location__put(&al
);
221 static struct perf_c2c c2c
= {
223 .sample
= process_sample_event
,
224 .mmap
= perf_event__process_mmap
,
225 .mmap2
= perf_event__process_mmap2
,
226 .comm
= perf_event__process_comm
,
227 .exit
= perf_event__process_exit
,
228 .fork
= perf_event__process_fork
,
229 .lost
= perf_event__process_lost
,
230 .ordered_events
= true,
231 .ordering_requires_timestamps
= true,
235 static const char * const c2c_usage
[] = {
236 "perf c2c {record|report}",
240 static const char * const __usage_report
[] = {
245 static const char * const *report_c2c_usage
= __usage_report
;
247 #define C2C_HEADER_MAX 2
253 } line
[C2C_HEADER_MAX
];
256 struct c2c_dimension
{
257 struct c2c_header header
;
260 struct sort_entry
*se
;
262 int64_t (*cmp
)(struct perf_hpp_fmt
*fmt
,
263 struct hist_entry
*, struct hist_entry
*);
264 int (*entry
)(struct perf_hpp_fmt
*fmt
, struct perf_hpp
*hpp
,
265 struct hist_entry
*he
);
266 int (*color
)(struct perf_hpp_fmt
*fmt
, struct perf_hpp
*hpp
,
267 struct hist_entry
*he
);
271 struct perf_hpp_fmt fmt
;
272 struct c2c_dimension
*dim
;
275 static int c2c_width(struct perf_hpp_fmt
*fmt
,
276 struct perf_hpp
*hpp __maybe_unused
,
277 struct hists
*hists __maybe_unused
)
279 struct c2c_fmt
*c2c_fmt
;
280 struct c2c_dimension
*dim
;
282 c2c_fmt
= container_of(fmt
, struct c2c_fmt
, fmt
);
285 return dim
->se
? hists__col_len(hists
, dim
->se
->se_width_idx
) :
289 static int c2c_header(struct perf_hpp_fmt
*fmt
, struct perf_hpp
*hpp
,
290 struct hists
*hists
, int line
, int *span
)
292 struct perf_hpp_list
*hpp_list
= hists
->hpp_list
;
293 struct c2c_fmt
*c2c_fmt
;
294 struct c2c_dimension
*dim
;
295 const char *text
= NULL
;
296 int width
= c2c_width(fmt
, hpp
, hists
);
298 c2c_fmt
= container_of(fmt
, struct c2c_fmt
, fmt
);
302 text
= dim
->header
.line
[line
].text
;
303 /* Use the last line from sort_entry if not defined. */
304 if (!text
&& (line
== hpp_list
->nr_header_lines
- 1))
305 text
= dim
->se
->se_header
;
307 text
= dim
->header
.line
[line
].text
;
313 *span
= dim
->header
.line
[line
].span
;
320 return scnprintf(hpp
->buf
, hpp
->size
, "%*s", width
, text
);
323 #define HEX_STR(__s, __v) \
325 scnprintf(__s, sizeof(__s), "0x%" PRIx64, __v); \
330 dcacheline_cmp(struct perf_hpp_fmt
*fmt __maybe_unused
,
331 struct hist_entry
*left
, struct hist_entry
*right
)
333 return sort__dcacheline_cmp(left
, right
);
336 static int dcacheline_entry(struct perf_hpp_fmt
*fmt
, struct perf_hpp
*hpp
,
337 struct hist_entry
*he
)
340 int width
= c2c_width(fmt
, hpp
, he
->hists
);
344 addr
= cl_address(he
->mem_info
->daddr
.addr
);
346 return scnprintf(hpp
->buf
, hpp
->size
, "%*s", width
, HEX_STR(buf
, addr
));
349 static int offset_entry(struct perf_hpp_fmt
*fmt
, struct perf_hpp
*hpp
,
350 struct hist_entry
*he
)
353 int width
= c2c_width(fmt
, hpp
, he
->hists
);
357 addr
= cl_offset(he
->mem_info
->daddr
.al_addr
);
359 return scnprintf(hpp
->buf
, hpp
->size
, "%*s", width
, HEX_STR(buf
, addr
));
363 offset_cmp(struct perf_hpp_fmt
*fmt __maybe_unused
,
364 struct hist_entry
*left
, struct hist_entry
*right
)
366 uint64_t l
= 0, r
= 0;
369 l
= cl_offset(left
->mem_info
->daddr
.addr
);
371 r
= cl_offset(right
->mem_info
->daddr
.addr
);
373 return (int64_t)(r
- l
);
377 iaddr_entry(struct perf_hpp_fmt
*fmt
, struct perf_hpp
*hpp
,
378 struct hist_entry
*he
)
381 int width
= c2c_width(fmt
, hpp
, he
->hists
);
385 addr
= he
->mem_info
->iaddr
.addr
;
387 return scnprintf(hpp
->buf
, hpp
->size
, "%*s", width
, HEX_STR(buf
, addr
));
391 iaddr_cmp(struct perf_hpp_fmt
*fmt __maybe_unused
,
392 struct hist_entry
*left
, struct hist_entry
*right
)
394 return sort__iaddr_cmp(left
, right
);
398 tot_hitm_entry(struct perf_hpp_fmt
*fmt
, struct perf_hpp
*hpp
,
399 struct hist_entry
*he
)
401 struct c2c_hist_entry
*c2c_he
;
402 int width
= c2c_width(fmt
, hpp
, he
->hists
);
403 unsigned int tot_hitm
;
405 c2c_he
= container_of(he
, struct c2c_hist_entry
, he
);
406 tot_hitm
= c2c_he
->stats
.lcl_hitm
+ c2c_he
->stats
.rmt_hitm
;
408 return scnprintf(hpp
->buf
, hpp
->size
, "%*u", width
, tot_hitm
);
412 tot_hitm_cmp(struct perf_hpp_fmt
*fmt __maybe_unused
,
413 struct hist_entry
*left
, struct hist_entry
*right
)
415 struct c2c_hist_entry
*c2c_left
;
416 struct c2c_hist_entry
*c2c_right
;
417 unsigned int tot_hitm_left
;
418 unsigned int tot_hitm_right
;
420 c2c_left
= container_of(left
, struct c2c_hist_entry
, he
);
421 c2c_right
= container_of(right
, struct c2c_hist_entry
, he
);
423 tot_hitm_left
= c2c_left
->stats
.lcl_hitm
+ c2c_left
->stats
.rmt_hitm
;
424 tot_hitm_right
= c2c_right
->stats
.lcl_hitm
+ c2c_right
->stats
.rmt_hitm
;
426 return tot_hitm_left
- tot_hitm_right
;
429 #define STAT_FN_ENTRY(__f) \
431 __f ## _entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, \
432 struct hist_entry *he) \
434 struct c2c_hist_entry *c2c_he; \
435 int width = c2c_width(fmt, hpp, he->hists); \
437 c2c_he = container_of(he, struct c2c_hist_entry, he); \
438 return scnprintf(hpp->buf, hpp->size, "%*u", width, \
439 c2c_he->stats.__f); \
442 #define STAT_FN_CMP(__f) \
444 __f ## _cmp(struct perf_hpp_fmt *fmt __maybe_unused, \
445 struct hist_entry *left, struct hist_entry *right) \
447 struct c2c_hist_entry *c2c_left, *c2c_right; \
449 c2c_left = container_of(left, struct c2c_hist_entry, he); \
450 c2c_right = container_of(right, struct c2c_hist_entry, he); \
451 return c2c_left->stats.__f - c2c_right->stats.__f; \
454 #define STAT_FN(__f) \
469 static uint64_t llc_miss(struct c2c_stats
*stats
)
473 llcmiss
= stats
->lcl_dram
+
482 ld_llcmiss_entry(struct perf_hpp_fmt
*fmt
, struct perf_hpp
*hpp
,
483 struct hist_entry
*he
)
485 struct c2c_hist_entry
*c2c_he
;
486 int width
= c2c_width(fmt
, hpp
, he
->hists
);
488 c2c_he
= container_of(he
, struct c2c_hist_entry
, he
);
490 return scnprintf(hpp
->buf
, hpp
->size
, "%*lu", width
,
491 llc_miss(&c2c_he
->stats
));
495 ld_llcmiss_cmp(struct perf_hpp_fmt
*fmt __maybe_unused
,
496 struct hist_entry
*left
, struct hist_entry
*right
)
498 struct c2c_hist_entry
*c2c_left
;
499 struct c2c_hist_entry
*c2c_right
;
501 c2c_left
= container_of(left
, struct c2c_hist_entry
, he
);
502 c2c_right
= container_of(right
, struct c2c_hist_entry
, he
);
504 return llc_miss(&c2c_left
->stats
) - llc_miss(&c2c_right
->stats
);
507 static uint64_t total_records(struct c2c_stats
*stats
)
509 uint64_t lclmiss
, ldcnt
, total
;
511 lclmiss
= stats
->lcl_dram
+
531 tot_recs_entry(struct perf_hpp_fmt
*fmt
, struct perf_hpp
*hpp
,
532 struct hist_entry
*he
)
534 struct c2c_hist_entry
*c2c_he
;
535 int width
= c2c_width(fmt
, hpp
, he
->hists
);
538 c2c_he
= container_of(he
, struct c2c_hist_entry
, he
);
539 tot_recs
= total_records(&c2c_he
->stats
);
541 return scnprintf(hpp
->buf
, hpp
->size
, "%*" PRIu64
, width
, tot_recs
);
545 tot_recs_cmp(struct perf_hpp_fmt
*fmt __maybe_unused
,
546 struct hist_entry
*left
, struct hist_entry
*right
)
548 struct c2c_hist_entry
*c2c_left
;
549 struct c2c_hist_entry
*c2c_right
;
550 uint64_t tot_recs_left
;
551 uint64_t tot_recs_right
;
553 c2c_left
= container_of(left
, struct c2c_hist_entry
, he
);
554 c2c_right
= container_of(right
, struct c2c_hist_entry
, he
);
556 tot_recs_left
= total_records(&c2c_left
->stats
);
557 tot_recs_right
= total_records(&c2c_right
->stats
);
559 return tot_recs_left
- tot_recs_right
;
562 static uint64_t total_loads(struct c2c_stats
*stats
)
564 uint64_t lclmiss
, ldcnt
;
566 lclmiss
= stats
->lcl_dram
+
582 tot_loads_entry(struct perf_hpp_fmt
*fmt
, struct perf_hpp
*hpp
,
583 struct hist_entry
*he
)
585 struct c2c_hist_entry
*c2c_he
;
586 int width
= c2c_width(fmt
, hpp
, he
->hists
);
589 c2c_he
= container_of(he
, struct c2c_hist_entry
, he
);
590 tot_recs
= total_loads(&c2c_he
->stats
);
592 return scnprintf(hpp
->buf
, hpp
->size
, "%*" PRIu64
, width
, tot_recs
);
596 tot_loads_cmp(struct perf_hpp_fmt
*fmt __maybe_unused
,
597 struct hist_entry
*left
, struct hist_entry
*right
)
599 struct c2c_hist_entry
*c2c_left
;
600 struct c2c_hist_entry
*c2c_right
;
601 uint64_t tot_recs_left
;
602 uint64_t tot_recs_right
;
604 c2c_left
= container_of(left
, struct c2c_hist_entry
, he
);
605 c2c_right
= container_of(right
, struct c2c_hist_entry
, he
);
607 tot_recs_left
= total_loads(&c2c_left
->stats
);
608 tot_recs_right
= total_loads(&c2c_right
->stats
);
610 return tot_recs_left
- tot_recs_right
;
613 typedef double (get_percent_cb
)(struct c2c_hist_entry
*);
616 percent_color(struct perf_hpp_fmt
*fmt
, struct perf_hpp
*hpp
,
617 struct hist_entry
*he
, get_percent_cb get_percent
)
619 struct c2c_hist_entry
*c2c_he
;
620 int width
= c2c_width(fmt
, hpp
, he
->hists
);
623 c2c_he
= container_of(he
, struct c2c_hist_entry
, he
);
624 per
= get_percent(c2c_he
);
626 return hpp_color_scnprintf(hpp
, "%*.2f%%", width
- 1, per
);
629 static double percent_hitm(struct c2c_hist_entry
*c2c_he
)
631 struct c2c_hists
*hists
;
632 struct c2c_stats
*stats
;
633 struct c2c_stats
*total
;
637 hists
= container_of(c2c_he
->he
.hists
, struct c2c_hists
, hists
);
638 stats
= &c2c_he
->stats
;
639 total
= &hists
->stats
;
641 st
= stats
->rmt_hitm
;
642 tot
= total
->rmt_hitm
;
644 p
= tot
? (double) st
/ tot
: 0;
649 #define PERC_STR(__s, __v) \
651 scnprintf(__s, sizeof(__s), "%.2F%%", __v); \
656 percent_hitm_entry(struct perf_hpp_fmt
*fmt
, struct perf_hpp
*hpp
,
657 struct hist_entry
*he
)
659 struct c2c_hist_entry
*c2c_he
;
660 int width
= c2c_width(fmt
, hpp
, he
->hists
);
664 c2c_he
= container_of(he
, struct c2c_hist_entry
, he
);
665 per
= percent_hitm(c2c_he
);
666 return scnprintf(hpp
->buf
, hpp
->size
, "%*s", width
, PERC_STR(buf
, per
));
670 percent_hitm_color(struct perf_hpp_fmt
*fmt
, struct perf_hpp
*hpp
,
671 struct hist_entry
*he
)
673 return percent_color(fmt
, hpp
, he
, percent_hitm
);
677 percent_hitm_cmp(struct perf_hpp_fmt
*fmt __maybe_unused
,
678 struct hist_entry
*left
, struct hist_entry
*right
)
680 struct c2c_hist_entry
*c2c_left
;
681 struct c2c_hist_entry
*c2c_right
;
685 c2c_left
= container_of(left
, struct c2c_hist_entry
, he
);
686 c2c_right
= container_of(right
, struct c2c_hist_entry
, he
);
688 per_left
= percent_hitm(c2c_left
);
689 per_right
= percent_hitm(c2c_right
);
691 return per_left
- per_right
;
694 static struct c2c_stats
*he_stats(struct hist_entry
*he
)
696 struct c2c_hist_entry
*c2c_he
;
698 c2c_he
= container_of(he
, struct c2c_hist_entry
, he
);
699 return &c2c_he
->stats
;
702 static struct c2c_stats
*total_stats(struct hist_entry
*he
)
704 struct c2c_hists
*hists
;
706 hists
= container_of(he
->hists
, struct c2c_hists
, hists
);
707 return &hists
->stats
;
710 static double percent(int st
, int tot
)
712 return tot
? 100. * (double) st
/ (double) tot
: 0;
715 #define PERCENT(__h, __f) percent(he_stats(__h)->__f, total_stats(__h)->__f)
717 #define PERCENT_FN(__f) \
718 static double percent_ ## __f(struct c2c_hist_entry *c2c_he) \
720 struct c2c_hists *hists; \
722 hists = container_of(c2c_he->he.hists, struct c2c_hists, hists); \
723 return percent(c2c_he->stats.__f, hists->stats.__f); \
729 PERCENT_FN(st_l1miss
)
732 percent_rmt_hitm_entry(struct perf_hpp_fmt
*fmt
, struct perf_hpp
*hpp
,
733 struct hist_entry
*he
)
735 int width
= c2c_width(fmt
, hpp
, he
->hists
);
736 double per
= PERCENT(he
, rmt_hitm
);
739 return scnprintf(hpp
->buf
, hpp
->size
, "%*s", width
, PERC_STR(buf
, per
));
743 percent_rmt_hitm_color(struct perf_hpp_fmt
*fmt
, struct perf_hpp
*hpp
,
744 struct hist_entry
*he
)
746 return percent_color(fmt
, hpp
, he
, percent_rmt_hitm
);
750 percent_rmt_hitm_cmp(struct perf_hpp_fmt
*fmt __maybe_unused
,
751 struct hist_entry
*left
, struct hist_entry
*right
)
756 per_left
= PERCENT(left
, lcl_hitm
);
757 per_right
= PERCENT(right
, lcl_hitm
);
759 return per_left
- per_right
;
763 percent_lcl_hitm_entry(struct perf_hpp_fmt
*fmt
, struct perf_hpp
*hpp
,
764 struct hist_entry
*he
)
766 int width
= c2c_width(fmt
, hpp
, he
->hists
);
767 double per
= PERCENT(he
, lcl_hitm
);
770 return scnprintf(hpp
->buf
, hpp
->size
, "%*s", width
, PERC_STR(buf
, per
));
774 percent_lcl_hitm_color(struct perf_hpp_fmt
*fmt
, struct perf_hpp
*hpp
,
775 struct hist_entry
*he
)
777 return percent_color(fmt
, hpp
, he
, percent_lcl_hitm
);
781 percent_lcl_hitm_cmp(struct perf_hpp_fmt
*fmt __maybe_unused
,
782 struct hist_entry
*left
, struct hist_entry
*right
)
787 per_left
= PERCENT(left
, lcl_hitm
);
788 per_right
= PERCENT(right
, lcl_hitm
);
790 return per_left
- per_right
;
794 percent_stores_l1hit_entry(struct perf_hpp_fmt
*fmt
, struct perf_hpp
*hpp
,
795 struct hist_entry
*he
)
797 int width
= c2c_width(fmt
, hpp
, he
->hists
);
798 double per
= PERCENT(he
, st_l1hit
);
801 return scnprintf(hpp
->buf
, hpp
->size
, "%*s", width
, PERC_STR(buf
, per
));
805 percent_stores_l1hit_color(struct perf_hpp_fmt
*fmt
, struct perf_hpp
*hpp
,
806 struct hist_entry
*he
)
808 return percent_color(fmt
, hpp
, he
, percent_st_l1hit
);
812 percent_stores_l1hit_cmp(struct perf_hpp_fmt
*fmt __maybe_unused
,
813 struct hist_entry
*left
, struct hist_entry
*right
)
818 per_left
= PERCENT(left
, st_l1hit
);
819 per_right
= PERCENT(right
, st_l1hit
);
821 return per_left
- per_right
;
825 percent_stores_l1miss_entry(struct perf_hpp_fmt
*fmt
, struct perf_hpp
*hpp
,
826 struct hist_entry
*he
)
828 int width
= c2c_width(fmt
, hpp
, he
->hists
);
829 double per
= PERCENT(he
, st_l1miss
);
832 return scnprintf(hpp
->buf
, hpp
->size
, "%*s", width
, PERC_STR(buf
, per
));
836 percent_stores_l1miss_color(struct perf_hpp_fmt
*fmt
, struct perf_hpp
*hpp
,
837 struct hist_entry
*he
)
839 return percent_color(fmt
, hpp
, he
, percent_st_l1miss
);
843 percent_stores_l1miss_cmp(struct perf_hpp_fmt
*fmt __maybe_unused
,
844 struct hist_entry
*left
, struct hist_entry
*right
)
849 per_left
= PERCENT(left
, st_l1miss
);
850 per_right
= PERCENT(right
, st_l1miss
);
852 return per_left
- per_right
;
859 pid_entry(struct perf_hpp_fmt
*fmt
, struct perf_hpp
*hpp
,
860 struct hist_entry
*he
)
862 int width
= c2c_width(fmt
, hpp
, he
->hists
);
864 return scnprintf(hpp
->buf
, hpp
->size
, "%*d", width
, he
->thread
->pid_
);
868 pid_cmp(struct perf_hpp_fmt
*fmt __maybe_unused
,
869 struct hist_entry
*left
, struct hist_entry
*right
)
871 return left
->thread
->pid_
- right
->thread
->pid_
;
875 empty_cmp(struct perf_hpp_fmt
*fmt __maybe_unused
,
876 struct hist_entry
*left __maybe_unused
,
877 struct hist_entry
*right __maybe_unused
)
883 node_entry(struct perf_hpp_fmt
*fmt __maybe_unused
, struct perf_hpp
*hpp
,
884 struct hist_entry
*he
)
886 struct c2c_hist_entry
*c2c_he
;
891 c2c_he
= container_of(he
, struct c2c_hist_entry
, he
);
893 for (node
= 0; node
< c2c
.nodes_cnt
; node
++) {
894 DECLARE_BITMAP(set
, c2c
.cpus_cnt
);
896 bitmap_zero(set
, c2c
.cpus_cnt
);
897 bitmap_and(set
, c2c_he
->cpuset
, c2c
.nodes
[node
], c2c
.cpus_cnt
);
899 if (!bitmap_weight(set
, c2c
.cpus_cnt
)) {
900 if (c2c
.node_info
== 1) {
901 ret
= scnprintf(hpp
->buf
, hpp
->size
, "%21s", " ");
902 advance_hpp(hpp
, ret
);
908 ret
= scnprintf(hpp
->buf
, hpp
->size
, " ");
909 advance_hpp(hpp
, ret
);
912 switch (c2c
.node_info
) {
914 ret
= scnprintf(hpp
->buf
, hpp
->size
, "%2d", node
);
915 advance_hpp(hpp
, ret
);
919 int num
= bitmap_weight(c2c_he
->cpuset
, c2c
.cpus_cnt
);
920 struct c2c_stats
*stats
= &c2c_he
->node_stats
[node
];
922 ret
= scnprintf(hpp
->buf
, hpp
->size
, "%2d{%2d ", node
, num
);
923 advance_hpp(hpp
, ret
);
926 if (c2c_he
->stats
.rmt_hitm
> 0) {
927 ret
= scnprintf(hpp
->buf
, hpp
->size
, "%5.1f%% ",
928 percent(stats
->rmt_hitm
, c2c_he
->stats
.rmt_hitm
));
930 ret
= scnprintf(hpp
->buf
, hpp
->size
, "%6s ", "n/a");
933 advance_hpp(hpp
, ret
);
935 if (c2c_he
->stats
.store
> 0) {
936 ret
= scnprintf(hpp
->buf
, hpp
->size
, "%5.1f%%}",
937 percent(stats
->store
, c2c_he
->stats
.store
));
939 ret
= scnprintf(hpp
->buf
, hpp
->size
, "%6s}", "n/a");
942 advance_hpp(hpp
, ret
);
946 ret
= scnprintf(hpp
->buf
, hpp
->size
, "%2d{", node
);
947 advance_hpp(hpp
, ret
);
949 ret
= bitmap_scnprintf(set
, c2c
.cpus_cnt
, hpp
->buf
, hpp
->size
);
950 advance_hpp(hpp
, ret
);
952 ret
= scnprintf(hpp
->buf
, hpp
->size
, "}");
953 advance_hpp(hpp
, ret
);
965 #define HEADER_LOW(__h) \
972 #define HEADER_BOTH(__h0, __h1) \
982 #define HEADER_SPAN(__h0, __h1, __s) \
993 #define HEADER_SPAN_LOW(__h) \
1000 static struct c2c_dimension dim_dcacheline
= {
1001 .header
= HEADER_LOW("Cacheline"),
1002 .name
= "dcacheline",
1003 .cmp
= dcacheline_cmp
,
1004 .entry
= dcacheline_entry
,
1008 static struct c2c_dimension dim_offset
= {
1009 .header
= HEADER_BOTH("Data address", "Offset"),
1012 .entry
= offset_entry
,
1016 static struct c2c_dimension dim_iaddr
= {
1017 .header
= HEADER_LOW("Code address"),
1020 .entry
= iaddr_entry
,
1024 static struct c2c_dimension dim_tot_hitm
= {
1025 .header
= HEADER_SPAN("----- LLC Load Hitm -----", "Total", 2),
1027 .cmp
= tot_hitm_cmp
,
1028 .entry
= tot_hitm_entry
,
1032 static struct c2c_dimension dim_lcl_hitm
= {
1033 .header
= HEADER_SPAN_LOW("Lcl"),
1035 .cmp
= lcl_hitm_cmp
,
1036 .entry
= lcl_hitm_entry
,
1040 static struct c2c_dimension dim_rmt_hitm
= {
1041 .header
= HEADER_SPAN_LOW("Rmt"),
1043 .cmp
= rmt_hitm_cmp
,
1044 .entry
= rmt_hitm_entry
,
1048 static struct c2c_dimension dim_cl_rmt_hitm
= {
1049 .header
= HEADER_SPAN("----- HITM -----", "Rmt", 1),
1050 .name
= "cl_rmt_hitm",
1051 .cmp
= rmt_hitm_cmp
,
1052 .entry
= rmt_hitm_entry
,
1056 static struct c2c_dimension dim_cl_lcl_hitm
= {
1057 .header
= HEADER_SPAN_LOW("Lcl"),
1058 .name
= "cl_lcl_hitm",
1059 .cmp
= lcl_hitm_cmp
,
1060 .entry
= lcl_hitm_entry
,
1064 static struct c2c_dimension dim_stores
= {
1065 .header
= HEADER_SPAN("---- Store Reference ----", "Total", 2),
1068 .entry
= store_entry
,
1072 static struct c2c_dimension dim_stores_l1hit
= {
1073 .header
= HEADER_SPAN_LOW("L1Hit"),
1074 .name
= "stores_l1hit",
1075 .cmp
= st_l1hit_cmp
,
1076 .entry
= st_l1hit_entry
,
1080 static struct c2c_dimension dim_stores_l1miss
= {
1081 .header
= HEADER_SPAN_LOW("L1Miss"),
1082 .name
= "stores_l1miss",
1083 .cmp
= st_l1miss_cmp
,
1084 .entry
= st_l1miss_entry
,
1088 static struct c2c_dimension dim_cl_stores_l1hit
= {
1089 .header
= HEADER_SPAN("-- Store Refs --", "L1 Hit", 1),
1090 .name
= "cl_stores_l1hit",
1091 .cmp
= st_l1hit_cmp
,
1092 .entry
= st_l1hit_entry
,
1096 static struct c2c_dimension dim_cl_stores_l1miss
= {
1097 .header
= HEADER_SPAN_LOW("L1 Miss"),
1098 .name
= "cl_stores_l1miss",
1099 .cmp
= st_l1miss_cmp
,
1100 .entry
= st_l1miss_entry
,
1104 static struct c2c_dimension dim_ld_fbhit
= {
1105 .header
= HEADER_SPAN("----- Core Load Hit -----", "FB", 2),
1107 .cmp
= ld_fbhit_cmp
,
1108 .entry
= ld_fbhit_entry
,
1112 static struct c2c_dimension dim_ld_l1hit
= {
1113 .header
= HEADER_SPAN_LOW("L1"),
1115 .cmp
= ld_l1hit_cmp
,
1116 .entry
= ld_l1hit_entry
,
1120 static struct c2c_dimension dim_ld_l2hit
= {
1121 .header
= HEADER_SPAN_LOW("L2"),
1123 .cmp
= ld_l2hit_cmp
,
1124 .entry
= ld_l2hit_entry
,
1128 static struct c2c_dimension dim_ld_llchit
= {
1129 .header
= HEADER_SPAN("-- LLC Load Hit --", "Llc", 1),
1130 .name
= "ld_lclhit",
1131 .cmp
= ld_llchit_cmp
,
1132 .entry
= ld_llchit_entry
,
1136 static struct c2c_dimension dim_ld_rmthit
= {
1137 .header
= HEADER_SPAN_LOW("Rmt"),
1138 .name
= "ld_rmthit",
1140 .entry
= rmt_hit_entry
,
1144 static struct c2c_dimension dim_ld_llcmiss
= {
1145 .header
= HEADER_BOTH("LLC", "Ld Miss"),
1146 .name
= "ld_llcmiss",
1147 .cmp
= ld_llcmiss_cmp
,
1148 .entry
= ld_llcmiss_entry
,
1152 static struct c2c_dimension dim_tot_recs
= {
1153 .header
= HEADER_BOTH("Total", "records"),
1155 .cmp
= tot_recs_cmp
,
1156 .entry
= tot_recs_entry
,
1160 static struct c2c_dimension dim_tot_loads
= {
1161 .header
= HEADER_BOTH("Total", "Loads"),
1162 .name
= "tot_loads",
1163 .cmp
= tot_loads_cmp
,
1164 .entry
= tot_loads_entry
,
1168 static struct c2c_dimension dim_percent_hitm
= {
1169 .header
= HEADER_LOW("%hitm"),
1170 .name
= "percent_hitm",
1171 .cmp
= percent_hitm_cmp
,
1172 .entry
= percent_hitm_entry
,
1173 .color
= percent_hitm_color
,
1177 static struct c2c_dimension dim_percent_rmt_hitm
= {
1178 .header
= HEADER_SPAN("----- HITM -----", "Rmt", 1),
1179 .name
= "percent_rmt_hitm",
1180 .cmp
= percent_rmt_hitm_cmp
,
1181 .entry
= percent_rmt_hitm_entry
,
1182 .color
= percent_rmt_hitm_color
,
1186 static struct c2c_dimension dim_percent_lcl_hitm
= {
1187 .header
= HEADER_SPAN_LOW("Lcl"),
1188 .name
= "percent_lcl_hitm",
1189 .cmp
= percent_lcl_hitm_cmp
,
1190 .entry
= percent_lcl_hitm_entry
,
1191 .color
= percent_lcl_hitm_color
,
1195 static struct c2c_dimension dim_percent_stores_l1hit
= {
1196 .header
= HEADER_SPAN("-- Store Refs --", "L1 Hit", 1),
1197 .name
= "percent_stores_l1hit",
1198 .cmp
= percent_stores_l1hit_cmp
,
1199 .entry
= percent_stores_l1hit_entry
,
1200 .color
= percent_stores_l1hit_color
,
1204 static struct c2c_dimension dim_percent_stores_l1miss
= {
1205 .header
= HEADER_SPAN_LOW("L1 Miss"),
1206 .name
= "percent_stores_l1miss",
1207 .cmp
= percent_stores_l1miss_cmp
,
1208 .entry
= percent_stores_l1miss_entry
,
1209 .color
= percent_stores_l1miss_color
,
1213 static struct c2c_dimension dim_dram_lcl
= {
1214 .header
= HEADER_SPAN("--- Load Dram ----", "Lcl", 1),
1216 .cmp
= lcl_dram_cmp
,
1217 .entry
= lcl_dram_entry
,
1221 static struct c2c_dimension dim_dram_rmt
= {
1222 .header
= HEADER_SPAN_LOW("Rmt"),
1224 .cmp
= rmt_dram_cmp
,
1225 .entry
= rmt_dram_entry
,
1229 static struct c2c_dimension dim_pid
= {
1230 .header
= HEADER_LOW("Pid"),
1237 static struct c2c_dimension dim_tid
= {
1238 .header
= HEADER_LOW("Tid"),
1243 static struct c2c_dimension dim_symbol
= {
1248 static struct c2c_dimension dim_dso
= {
1249 .header
= HEADER_BOTH("Shared", "Object"),
1254 static struct c2c_header header_node
[3] = {
1256 HEADER_LOW("Node{cpus %hitms %stores}"),
1257 HEADER_LOW("Node{cpu list}"),
1260 static struct c2c_dimension dim_node
= {
1263 .entry
= node_entry
,
1267 static struct c2c_dimension
*dimensions
[] = {
1279 &dim_cl_stores_l1hit
,
1280 &dim_cl_stores_l1miss
,
1290 &dim_percent_rmt_hitm
,
1291 &dim_percent_lcl_hitm
,
1292 &dim_percent_stores_l1hit
,
1293 &dim_percent_stores_l1miss
,
1304 static void fmt_free(struct perf_hpp_fmt
*fmt
)
1306 struct c2c_fmt
*c2c_fmt
;
1308 c2c_fmt
= container_of(fmt
, struct c2c_fmt
, fmt
);
1312 static bool fmt_equal(struct perf_hpp_fmt
*a
, struct perf_hpp_fmt
*b
)
1314 struct c2c_fmt
*c2c_a
= container_of(a
, struct c2c_fmt
, fmt
);
1315 struct c2c_fmt
*c2c_b
= container_of(b
, struct c2c_fmt
, fmt
);
1317 return c2c_a
->dim
== c2c_b
->dim
;
1320 static struct c2c_dimension
*get_dimension(const char *name
)
1324 for (i
= 0; dimensions
[i
]; i
++) {
1325 struct c2c_dimension
*dim
= dimensions
[i
];
1327 if (!strcmp(dim
->name
, name
))
1334 static int c2c_se_entry(struct perf_hpp_fmt
*fmt
, struct perf_hpp
*hpp
,
1335 struct hist_entry
*he
)
1337 struct c2c_fmt
*c2c_fmt
= container_of(fmt
, struct c2c_fmt
, fmt
);
1338 struct c2c_dimension
*dim
= c2c_fmt
->dim
;
1339 size_t len
= fmt
->user_len
;
1342 len
= hists__col_len(he
->hists
, dim
->se
->se_width_idx
);
1344 return dim
->se
->se_snprintf(he
, hpp
->buf
, hpp
->size
, len
);
1347 static int64_t c2c_se_cmp(struct perf_hpp_fmt
*fmt
,
1348 struct hist_entry
*a
, struct hist_entry
*b
)
1350 struct c2c_fmt
*c2c_fmt
= container_of(fmt
, struct c2c_fmt
, fmt
);
1351 struct c2c_dimension
*dim
= c2c_fmt
->dim
;
1353 return dim
->se
->se_cmp(a
, b
);
1356 static int64_t c2c_se_collapse(struct perf_hpp_fmt
*fmt
,
1357 struct hist_entry
*a
, struct hist_entry
*b
)
1359 struct c2c_fmt
*c2c_fmt
= container_of(fmt
, struct c2c_fmt
, fmt
);
1360 struct c2c_dimension
*dim
= c2c_fmt
->dim
;
1361 int64_t (*collapse_fn
)(struct hist_entry
*, struct hist_entry
*);
1363 collapse_fn
= dim
->se
->se_collapse
?: dim
->se
->se_cmp
;
1364 return collapse_fn(a
, b
);
1367 static struct c2c_fmt
*get_format(const char *name
)
1369 struct c2c_dimension
*dim
= get_dimension(name
);
1370 struct c2c_fmt
*c2c_fmt
;
1371 struct perf_hpp_fmt
*fmt
;
1376 c2c_fmt
= zalloc(sizeof(*c2c_fmt
));
1382 fmt
= &c2c_fmt
->fmt
;
1383 INIT_LIST_HEAD(&fmt
->list
);
1384 INIT_LIST_HEAD(&fmt
->sort_list
);
1386 fmt
->cmp
= dim
->se
? c2c_se_cmp
: dim
->cmp
;
1387 fmt
->sort
= dim
->se
? c2c_se_cmp
: dim
->cmp
;
1388 fmt
->color
= dim
->se
? NULL
: dim
->color
;
1389 fmt
->entry
= dim
->se
? c2c_se_entry
: dim
->entry
;
1390 fmt
->header
= c2c_header
;
1391 fmt
->width
= c2c_width
;
1392 fmt
->collapse
= dim
->se
? c2c_se_collapse
: dim
->cmp
;
1393 fmt
->equal
= fmt_equal
;
1394 fmt
->free
= fmt_free
;
1399 static int c2c_hists__init_output(struct perf_hpp_list
*hpp_list
, char *name
)
1401 struct c2c_fmt
*c2c_fmt
= get_format(name
);
1405 return output_field_add(hpp_list
, name
);
1408 perf_hpp_list__column_register(hpp_list
, &c2c_fmt
->fmt
);
1412 static int c2c_hists__init_sort(struct perf_hpp_list
*hpp_list
, char *name
)
1414 struct c2c_fmt
*c2c_fmt
= get_format(name
);
1415 struct c2c_dimension
*dim
;
1419 return sort_dimension__add(hpp_list
, name
, NULL
, 0);
1423 if (dim
== &dim_dso
)
1426 perf_hpp_list__register_sort_field(hpp_list
, &c2c_fmt
->fmt
);
1430 #define PARSE_LIST(_list, _fn) \
1438 for (tok = strtok_r((char *)_list, ", ", &tmp); \
1439 tok; tok = strtok_r(NULL, ", ", &tmp)) { \
1440 ret = _fn(hpp_list, tok); \
1441 if (ret == -EINVAL) { \
1442 error("Invalid --fields key: `%s'", tok); \
1444 } else if (ret == -ESRCH) { \
1445 error("Unknown --fields key: `%s'", tok); \
1451 static int hpp_list__parse(struct perf_hpp_list
*hpp_list
,
1452 const char *output_
,
1455 char *output
= output_
? strdup(output_
) : NULL
;
1456 char *sort
= sort_
? strdup(sort_
) : NULL
;
1459 PARSE_LIST(output
, c2c_hists__init_output
);
1460 PARSE_LIST(sort
, c2c_hists__init_sort
);
1462 /* copy sort keys to output fields */
1463 perf_hpp__setup_output_field(hpp_list
);
1466 * We dont need other sorting keys other than those
1467 * we already specified. It also really slows down
1468 * the processing a lot with big number of output
1469 * fields, so switching this off for c2c.
1473 /* and then copy output fields to sort keys */
1474 perf_hpp__append_sort_keys(&hists
->list
);
1482 static int c2c_hists__init(struct c2c_hists
*hists
,
1485 __hists__init(&hists
->hists
, &hists
->list
);
1488 * Initialize only with sort fields, we need to resort
1489 * later anyway, and that's where we add output fields
1492 perf_hpp_list__init(&hists
->list
);
1494 return hpp_list__parse(&hists
->list
, NULL
, sort
);
1498 static int c2c_hists__reinit(struct c2c_hists
*c2c_hists
,
1502 perf_hpp__reset_output_field(&c2c_hists
->list
);
1503 return hpp_list__parse(&c2c_hists
->list
, output
, sort
);
1506 static int filter_cb(struct hist_entry
*he __maybe_unused
)
1511 static int resort_cl_cb(struct hist_entry
*he
)
1513 struct c2c_hist_entry
*c2c_he
;
1514 struct c2c_hists
*c2c_hists
;
1516 c2c_he
= container_of(he
, struct c2c_hist_entry
, he
);
1517 c2c_hists
= c2c_he
->hists
;
1520 hists__collapse_resort(&c2c_hists
->hists
, NULL
);
1521 hists__output_resort_cb(&c2c_hists
->hists
, NULL
, filter_cb
);
1527 static void setup_nodes_header(void)
1529 dim_node
.header
= header_node
[c2c
.node_info
];
1532 static int setup_nodes(struct perf_session
*session
)
1534 struct numa_node
*n
;
1535 unsigned long **nodes
;
1539 if (c2c
.node_info
> 2)
1542 c2c
.nodes_cnt
= session
->header
.env
.nr_numa_nodes
;
1543 c2c
.cpus_cnt
= session
->header
.env
.nr_cpus_online
;
1545 n
= session
->header
.env
.numa_nodes
;
1549 nodes
= zalloc(sizeof(unsigned long *) * c2c
.nodes_cnt
);
1555 cpu2node
= zalloc(sizeof(int) * c2c
.cpus_cnt
);
1559 for (cpu
= 0; cpu
< c2c
.cpus_cnt
; cpu
++)
1562 c2c
.cpu2node
= cpu2node
;
1564 for (node
= 0; node
< c2c
.nodes_cnt
; node
++) {
1565 struct cpu_map
*map
= n
[node
].map
;
1568 set
= bitmap_alloc(c2c
.cpus_cnt
);
1572 for (cpu
= 0; cpu
< map
->nr
; cpu
++) {
1573 set_bit(map
->map
[cpu
], set
);
1575 if (WARN_ONCE(cpu2node
[map
->map
[cpu
]] != -1, "node/cpu topology bug"))
1578 cpu2node
[map
->map
[cpu
]] = node
;
1584 setup_nodes_header();
1589 static int perf_c2c__report(int argc
, const char **argv
)
1591 struct perf_session
*session
;
1592 struct ui_progress prog
;
1593 struct perf_data_file file
= {
1594 .mode
= PERF_DATA_MODE_READ
,
1596 const struct option c2c_options
[] = {
1597 OPT_STRING('k', "vmlinux", &symbol_conf
.vmlinux_name
,
1598 "file", "vmlinux pathname"),
1599 OPT_INCR('v', "verbose", &verbose
,
1600 "be more verbose (show counter open errors, etc)"),
1601 OPT_STRING('i', "input", &input_name
, "file",
1602 "the input file to process"),
1603 OPT_INCR('N', "node-info", &c2c
.node_info
,
1604 "show extra node info in report (repeat for more info)"),
1609 argc
= parse_options(argc
, argv
, c2c_options
, report_c2c_usage
,
1610 PARSE_OPT_STOP_AT_NON_OPTION
);
1612 usage_with_options(report_c2c_usage
, c2c_options
);
1614 if (!input_name
|| !strlen(input_name
))
1615 input_name
= "perf.data";
1617 file
.path
= input_name
;
1619 err
= c2c_hists__init(&c2c
.hists
, "dcacheline");
1621 pr_debug("Failed to initialize hists\n");
1625 session
= perf_session__new(&file
, 0, &c2c
.tool
);
1626 if (session
== NULL
) {
1627 pr_debug("No memory for session\n");
1630 err
= setup_nodes(session
);
1632 pr_err("Failed setup nodes\n");
1636 if (symbol__init(&session
->header
.env
) < 0)
1639 /* No pipe support at the moment. */
1640 if (perf_data_file__is_pipe(session
->file
)) {
1641 pr_debug("No pipe support at the moment.\n");
1645 err
= perf_session__process_events(session
);
1647 pr_err("failed to process sample\n");
1651 ui_progress__init(&prog
, c2c
.hists
.hists
.nr_entries
, "Sorting...");
1653 hists__collapse_resort(&c2c
.hists
.hists
, NULL
);
1654 hists__output_resort_cb(&c2c
.hists
.hists
, &prog
, resort_cl_cb
);
1656 ui_progress__finish();
1659 perf_session__delete(session
);
1664 static int parse_record_events(const struct option
*opt __maybe_unused
,
1665 const char *str
, int unset __maybe_unused
)
1667 bool *event_set
= (bool *) opt
->value
;
1670 return perf_mem_events__parse(str
);
1674 static const char * const __usage_record
[] = {
1675 "perf c2c record [<options>] [<command>]",
1676 "perf c2c record [<options>] -- <command> [<options>]",
1680 static const char * const *record_mem_usage
= __usage_record
;
1682 static int perf_c2c__record(int argc
, const char **argv
)
1684 int rec_argc
, i
= 0, j
;
1685 const char **rec_argv
;
1687 bool all_user
= false, all_kernel
= false;
1688 bool event_set
= false;
1689 struct option options
[] = {
1690 OPT_CALLBACK('e', "event", &event_set
, "event",
1691 "event selector. Use 'perf mem record -e list' to list available events",
1692 parse_record_events
),
1693 OPT_INCR('v', "verbose", &verbose
,
1694 "be more verbose (show counter open errors, etc)"),
1695 OPT_BOOLEAN('u', "all-user", &all_user
, "collect only user level data"),
1696 OPT_BOOLEAN('k', "all-kernel", &all_kernel
, "collect only kernel level data"),
1697 OPT_UINTEGER('l', "ldlat", &perf_mem_events__loads_ldlat
, "setup mem-loads latency"),
1701 if (perf_mem_events__init()) {
1702 pr_err("failed: memory events not supported\n");
1706 argc
= parse_options(argc
, argv
, options
, record_mem_usage
,
1707 PARSE_OPT_KEEP_UNKNOWN
);
1709 rec_argc
= argc
+ 10; /* max number of arguments */
1710 rec_argv
= calloc(rec_argc
+ 1, sizeof(char *));
1714 rec_argv
[i
++] = "record";
1717 perf_mem_events
[PERF_MEM_EVENTS__LOAD
].record
= true;
1718 perf_mem_events
[PERF_MEM_EVENTS__STORE
].record
= true;
1721 if (perf_mem_events
[PERF_MEM_EVENTS__LOAD
].record
)
1722 rec_argv
[i
++] = "-W";
1724 rec_argv
[i
++] = "-d";
1725 rec_argv
[i
++] = "--sample-cpu";
1727 for (j
= 0; j
< PERF_MEM_EVENTS__MAX
; j
++) {
1728 if (!perf_mem_events
[j
].record
)
1731 if (!perf_mem_events
[j
].supported
) {
1732 pr_err("failed: event '%s' not supported\n",
1733 perf_mem_events
[j
].name
);
1737 rec_argv
[i
++] = "-e";
1738 rec_argv
[i
++] = perf_mem_events__name(j
);
1742 rec_argv
[i
++] = "--all-user";
1745 rec_argv
[i
++] = "--all-kernel";
1747 for (j
= 0; j
< argc
; j
++, i
++)
1748 rec_argv
[i
] = argv
[j
];
1751 pr_debug("calling: ");
1755 while (rec_argv
[j
]) {
1756 pr_debug("%s ", rec_argv
[j
]);
1762 ret
= cmd_record(i
, rec_argv
, NULL
);
1767 int cmd_c2c(int argc
, const char **argv
, const char *prefix __maybe_unused
)
1769 const struct option c2c_options
[] = {
1770 OPT_INCR('v', "verbose", &verbose
, "be more verbose"),
1774 argc
= parse_options(argc
, argv
, c2c_options
, c2c_usage
,
1775 PARSE_OPT_STOP_AT_NON_OPTION
);
1778 usage_with_options(c2c_usage
, c2c_options
);
1780 if (!strncmp(argv
[0], "rec", 3)) {
1781 return perf_c2c__record(argc
, argv
);
1782 } else if (!strncmp(argv
[0], "rep", 3)) {
1783 return perf_c2c__report(argc
, argv
);
1785 usage_with_options(c2c_usage
, c2c_options
);