1 // SPDX-License-Identifier: GPL-2.0
3 * This is rewrite of original c2c tool introduced in here:
4 * http://lwn.net/Articles/588866/
6 * The original tool was changed to fit in current perf state.
9 * Don Zickus <dzickus@redhat.com>
10 * Dick Fowles <fowles@inreach.com>
11 * Joe Mario <jmario@redhat.com>
15 #include <linux/compiler.h>
16 #include <linux/kernel.h>
17 #include <linux/stringify.h>
19 #include <sys/param.h>
23 #include <subcmd/parse-options.h>
24 #include "mem-events.h"
35 #include "ui/browsers/hists.h"
41 struct perf_hpp_list list;
42 struct c2c_stats stats;
45 struct compute_stats {
46 struct stats lcl_hitm;
47 struct stats rmt_hitm;
51 struct c2c_hist_entry {
52 struct c2c_hists *hists;
53 struct c2c_stats stats;
54 unsigned long *cpuset;
55 struct c2c_stats *node_stats;
56 unsigned int cacheline_idx;
58 struct compute_stats cstats;
62 * because of its callchain dynamic entry
67 static char const *coalesce_default = "pid,iaddr";
70 struct perf_tool tool;
71 struct c2c_hists hists;
73 unsigned long **nodes;
85 /* HITM shared clines stats */
86 struct c2c_stats hitm_stats;
104 static const char *display_str[DISPLAY_MAX] = {
105 [DISPLAY_LCL] = "Local",
106 [DISPLAY_RMT] = "Remote",
107 [DISPLAY_TOT] = "Total",
110 static const struct option c2c_options[] = {
111 OPT_INCR('v', "verbose", &verbose, "be more verbose (show counter open errors, etc)"),
115 static struct perf_c2c c2c;
117 static void *c2c_he_zalloc(size_t size)
119 struct c2c_hist_entry *c2c_he;
121 c2c_he = zalloc(size + sizeof(*c2c_he));
125 c2c_he->cpuset = bitmap_alloc(c2c.cpus_cnt);
129 c2c_he->node_stats = zalloc(c2c.nodes_cnt * sizeof(*c2c_he->node_stats));
130 if (!c2c_he->node_stats)
133 init_stats(&c2c_he->cstats.lcl_hitm);
134 init_stats(&c2c_he->cstats.rmt_hitm);
135 init_stats(&c2c_he->cstats.load);
140 static void c2c_he_free(void *he)
142 struct c2c_hist_entry *c2c_he;
144 c2c_he = container_of(he, struct c2c_hist_entry, he);
146 hists__delete_entries(&c2c_he->hists->hists);
150 free(c2c_he->cpuset);
151 free(c2c_he->node_stats);
155 static struct hist_entry_ops c2c_entry_ops = {
156 .new = c2c_he_zalloc,
160 static int c2c_hists__init(struct c2c_hists *hists,
162 int nr_header_lines);
164 static struct c2c_hists*
165 he__get_c2c_hists(struct hist_entry *he,
169 struct c2c_hist_entry *c2c_he;
170 struct c2c_hists *hists;
173 c2c_he = container_of(he, struct c2c_hist_entry, he);
175 return c2c_he->hists;
177 hists = c2c_he->hists = zalloc(sizeof(*hists));
181 ret = c2c_hists__init(hists, sort, nr_header_lines);
190 static void c2c_he__set_cpu(struct c2c_hist_entry *c2c_he,
191 struct perf_sample *sample)
193 if (WARN_ONCE(sample->cpu == (unsigned int) -1,
194 "WARNING: no sample cpu value"))
197 set_bit(sample->cpu, c2c_he->cpuset);
200 static void compute_stats(struct c2c_hist_entry *c2c_he,
201 struct c2c_stats *stats,
204 struct compute_stats *cstats = &c2c_he->cstats;
207 update_stats(&cstats->rmt_hitm, weight);
208 else if (stats->lcl_hitm)
209 update_stats(&cstats->lcl_hitm, weight);
210 else if (stats->load)
211 update_stats(&cstats->load, weight);
214 static int process_sample_event(struct perf_tool *tool __maybe_unused,
215 union perf_event *event,
216 struct perf_sample *sample,
217 struct perf_evsel *evsel,
218 struct machine *machine)
220 struct c2c_hists *c2c_hists = &c2c.hists;
221 struct c2c_hist_entry *c2c_he;
222 struct c2c_stats stats = { .nr_entries = 0, };
223 struct hist_entry *he;
224 struct addr_location al;
225 struct mem_info *mi, *mi_dup;
228 if (machine__resolve(machine, &al, sample) < 0) {
229 pr_debug("problem processing %d event, skipping it.\n",
234 ret = sample__resolve_callchain(sample, &callchain_cursor, NULL,
235 evsel, &al, sysctl_perf_event_max_stack);
239 mi = sample__resolve_mem(sample, &al);
243 mi_dup = memdup(mi, sizeof(*mi));
247 c2c_decode_stats(&stats, mi);
249 he = hists__add_entry_ops(&c2c_hists->hists, &c2c_entry_ops,
255 c2c_he = container_of(he, struct c2c_hist_entry, he);
256 c2c_add_stats(&c2c_he->stats, &stats);
257 c2c_add_stats(&c2c_hists->stats, &stats);
259 c2c_he__set_cpu(c2c_he, sample);
261 hists__inc_nr_samples(&c2c_hists->hists, he->filtered);
262 ret = hist_entry__append_callchain(he, sample);
266 * There's already been warning about missing
267 * sample's cpu value. Let's account all to
268 * node 0 in this case, without any further
271 * Doing node stats only for single callchain data.
273 int cpu = sample->cpu == (unsigned int) -1 ? 0 : sample->cpu;
274 int node = c2c.cpu2node[cpu];
278 mi_dup = memdup(mi, sizeof(*mi));
282 c2c_hists = he__get_c2c_hists(he, c2c.cl_sort, 2);
286 he = hists__add_entry_ops(&c2c_hists->hists, &c2c_entry_ops,
292 c2c_he = container_of(he, struct c2c_hist_entry, he);
293 c2c_add_stats(&c2c_he->stats, &stats);
294 c2c_add_stats(&c2c_hists->stats, &stats);
295 c2c_add_stats(&c2c_he->node_stats[node], &stats);
297 compute_stats(c2c_he, &stats, sample->weight);
299 c2c_he__set_cpu(c2c_he, sample);
301 hists__inc_nr_samples(&c2c_hists->hists, he->filtered);
302 ret = hist_entry__append_callchain(he, sample);
306 addr_location__put(&al);
317 static struct perf_c2c c2c = {
319 .sample = process_sample_event,
320 .mmap = perf_event__process_mmap,
321 .mmap2 = perf_event__process_mmap2,
322 .comm = perf_event__process_comm,
323 .exit = perf_event__process_exit,
324 .fork = perf_event__process_fork,
325 .lost = perf_event__process_lost,
326 .ordered_events = true,
327 .ordering_requires_timestamps = true,
331 static const char * const c2c_usage[] = {
332 "perf c2c {record|report}",
336 static const char * const __usage_report[] = {
341 static const char * const *report_c2c_usage = __usage_report;
343 #define C2C_HEADER_MAX 2
349 } line[C2C_HEADER_MAX];
352 struct c2c_dimension {
353 struct c2c_header header;
356 struct sort_entry *se;
358 int64_t (*cmp)(struct perf_hpp_fmt *fmt,
359 struct hist_entry *, struct hist_entry *);
360 int (*entry)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
361 struct hist_entry *he);
362 int (*color)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
363 struct hist_entry *he);
367 struct perf_hpp_fmt fmt;
368 struct c2c_dimension *dim;
371 #define SYMBOL_WIDTH 30
373 static struct c2c_dimension dim_symbol;
374 static struct c2c_dimension dim_srcline;
376 static int symbol_width(struct hists *hists, struct sort_entry *se)
378 int width = hists__col_len(hists, se->se_width_idx);
380 if (!c2c.symbol_full)
381 width = MIN(width, SYMBOL_WIDTH);
386 static int c2c_width(struct perf_hpp_fmt *fmt,
387 struct perf_hpp *hpp __maybe_unused,
390 struct c2c_fmt *c2c_fmt;
391 struct c2c_dimension *dim;
393 c2c_fmt = container_of(fmt, struct c2c_fmt, fmt);
396 if (dim == &dim_symbol || dim == &dim_srcline)
397 return symbol_width(hists, dim->se);
399 return dim->se ? hists__col_len(hists, dim->se->se_width_idx) :
403 static int c2c_header(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
404 struct hists *hists, int line, int *span)
406 struct perf_hpp_list *hpp_list = hists->hpp_list;
407 struct c2c_fmt *c2c_fmt;
408 struct c2c_dimension *dim;
409 const char *text = NULL;
410 int width = c2c_width(fmt, hpp, hists);
412 c2c_fmt = container_of(fmt, struct c2c_fmt, fmt);
416 text = dim->header.line[line].text;
417 /* Use the last line from sort_entry if not defined. */
418 if (!text && (line == hpp_list->nr_header_lines - 1))
419 text = dim->se->se_header;
421 text = dim->header.line[line].text;
427 *span = dim->header.line[line].span;
434 return scnprintf(hpp->buf, hpp->size, "%*s", width, text);
437 #define HEX_STR(__s, __v) \
439 scnprintf(__s, sizeof(__s), "0x%" PRIx64, __v); \
444 dcacheline_cmp(struct perf_hpp_fmt *fmt __maybe_unused,
445 struct hist_entry *left, struct hist_entry *right)
447 return sort__dcacheline_cmp(left, right);
450 static int dcacheline_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
451 struct hist_entry *he)
454 int width = c2c_width(fmt, hpp, he->hists);
458 addr = cl_address(he->mem_info->daddr.addr);
460 return scnprintf(hpp->buf, hpp->size, "%*s", width, HEX_STR(buf, addr));
463 static int offset_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
464 struct hist_entry *he)
467 int width = c2c_width(fmt, hpp, he->hists);
471 addr = cl_offset(he->mem_info->daddr.al_addr);
473 return scnprintf(hpp->buf, hpp->size, "%*s", width, HEX_STR(buf, addr));
477 offset_cmp(struct perf_hpp_fmt *fmt __maybe_unused,
478 struct hist_entry *left, struct hist_entry *right)
480 uint64_t l = 0, r = 0;
483 l = cl_offset(left->mem_info->daddr.addr);
485 r = cl_offset(right->mem_info->daddr.addr);
487 return (int64_t)(r - l);
491 iaddr_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
492 struct hist_entry *he)
495 int width = c2c_width(fmt, hpp, he->hists);
499 addr = he->mem_info->iaddr.addr;
501 return scnprintf(hpp->buf, hpp->size, "%*s", width, HEX_STR(buf, addr));
505 iaddr_cmp(struct perf_hpp_fmt *fmt __maybe_unused,
506 struct hist_entry *left, struct hist_entry *right)
508 return sort__iaddr_cmp(left, right);
512 tot_hitm_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
513 struct hist_entry *he)
515 struct c2c_hist_entry *c2c_he;
516 int width = c2c_width(fmt, hpp, he->hists);
517 unsigned int tot_hitm;
519 c2c_he = container_of(he, struct c2c_hist_entry, he);
520 tot_hitm = c2c_he->stats.lcl_hitm + c2c_he->stats.rmt_hitm;
522 return scnprintf(hpp->buf, hpp->size, "%*u", width, tot_hitm);
526 tot_hitm_cmp(struct perf_hpp_fmt *fmt __maybe_unused,
527 struct hist_entry *left, struct hist_entry *right)
529 struct c2c_hist_entry *c2c_left;
530 struct c2c_hist_entry *c2c_right;
531 uint64_t tot_hitm_left;
532 uint64_t tot_hitm_right;
534 c2c_left = container_of(left, struct c2c_hist_entry, he);
535 c2c_right = container_of(right, struct c2c_hist_entry, he);
537 tot_hitm_left = c2c_left->stats.lcl_hitm + c2c_left->stats.rmt_hitm;
538 tot_hitm_right = c2c_right->stats.lcl_hitm + c2c_right->stats.rmt_hitm;
540 return tot_hitm_left - tot_hitm_right;
543 #define STAT_FN_ENTRY(__f) \
545 __f ## _entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, \
546 struct hist_entry *he) \
548 struct c2c_hist_entry *c2c_he; \
549 int width = c2c_width(fmt, hpp, he->hists); \
551 c2c_he = container_of(he, struct c2c_hist_entry, he); \
552 return scnprintf(hpp->buf, hpp->size, "%*u", width, \
553 c2c_he->stats.__f); \
556 #define STAT_FN_CMP(__f) \
558 __f ## _cmp(struct perf_hpp_fmt *fmt __maybe_unused, \
559 struct hist_entry *left, struct hist_entry *right) \
561 struct c2c_hist_entry *c2c_left, *c2c_right; \
563 c2c_left = container_of(left, struct c2c_hist_entry, he); \
564 c2c_right = container_of(right, struct c2c_hist_entry, he); \
565 return (uint64_t) c2c_left->stats.__f - \
566 (uint64_t) c2c_right->stats.__f; \
569 #define STAT_FN(__f) \
584 static uint64_t llc_miss(struct c2c_stats *stats)
588 llcmiss = stats->lcl_dram +
597 ld_llcmiss_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
598 struct hist_entry *he)
600 struct c2c_hist_entry *c2c_he;
601 int width = c2c_width(fmt, hpp, he->hists);
603 c2c_he = container_of(he, struct c2c_hist_entry, he);
605 return scnprintf(hpp->buf, hpp->size, "%*lu", width,
606 llc_miss(&c2c_he->stats));
610 ld_llcmiss_cmp(struct perf_hpp_fmt *fmt __maybe_unused,
611 struct hist_entry *left, struct hist_entry *right)
613 struct c2c_hist_entry *c2c_left;
614 struct c2c_hist_entry *c2c_right;
616 c2c_left = container_of(left, struct c2c_hist_entry, he);
617 c2c_right = container_of(right, struct c2c_hist_entry, he);
619 return (uint64_t) llc_miss(&c2c_left->stats) -
620 (uint64_t) llc_miss(&c2c_right->stats);
623 static uint64_t total_records(struct c2c_stats *stats)
625 uint64_t lclmiss, ldcnt, total;
627 lclmiss = stats->lcl_dram +
647 tot_recs_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
648 struct hist_entry *he)
650 struct c2c_hist_entry *c2c_he;
651 int width = c2c_width(fmt, hpp, he->hists);
654 c2c_he = container_of(he, struct c2c_hist_entry, he);
655 tot_recs = total_records(&c2c_he->stats);
657 return scnprintf(hpp->buf, hpp->size, "%*" PRIu64, width, tot_recs);
661 tot_recs_cmp(struct perf_hpp_fmt *fmt __maybe_unused,
662 struct hist_entry *left, struct hist_entry *right)
664 struct c2c_hist_entry *c2c_left;
665 struct c2c_hist_entry *c2c_right;
666 uint64_t tot_recs_left;
667 uint64_t tot_recs_right;
669 c2c_left = container_of(left, struct c2c_hist_entry, he);
670 c2c_right = container_of(right, struct c2c_hist_entry, he);
672 tot_recs_left = total_records(&c2c_left->stats);
673 tot_recs_right = total_records(&c2c_right->stats);
675 return tot_recs_left - tot_recs_right;
678 static uint64_t total_loads(struct c2c_stats *stats)
680 uint64_t lclmiss, ldcnt;
682 lclmiss = stats->lcl_dram +
698 tot_loads_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
699 struct hist_entry *he)
701 struct c2c_hist_entry *c2c_he;
702 int width = c2c_width(fmt, hpp, he->hists);
705 c2c_he = container_of(he, struct c2c_hist_entry, he);
706 tot_recs = total_loads(&c2c_he->stats);
708 return scnprintf(hpp->buf, hpp->size, "%*" PRIu64, width, tot_recs);
712 tot_loads_cmp(struct perf_hpp_fmt *fmt __maybe_unused,
713 struct hist_entry *left, struct hist_entry *right)
715 struct c2c_hist_entry *c2c_left;
716 struct c2c_hist_entry *c2c_right;
717 uint64_t tot_recs_left;
718 uint64_t tot_recs_right;
720 c2c_left = container_of(left, struct c2c_hist_entry, he);
721 c2c_right = container_of(right, struct c2c_hist_entry, he);
723 tot_recs_left = total_loads(&c2c_left->stats);
724 tot_recs_right = total_loads(&c2c_right->stats);
726 return tot_recs_left - tot_recs_right;
729 typedef double (get_percent_cb)(struct c2c_hist_entry *);
732 percent_color(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
733 struct hist_entry *he, get_percent_cb get_percent)
735 struct c2c_hist_entry *c2c_he;
736 int width = c2c_width(fmt, hpp, he->hists);
739 c2c_he = container_of(he, struct c2c_hist_entry, he);
740 per = get_percent(c2c_he);
742 #ifdef HAVE_SLANG_SUPPORT
744 return __hpp__slsmg_color_printf(hpp, "%*.2f%%", width - 1, per);
746 return hpp_color_scnprintf(hpp, "%*.2f%%", width - 1, per);
749 static double percent_hitm(struct c2c_hist_entry *c2c_he)
751 struct c2c_hists *hists;
752 struct c2c_stats *stats;
753 struct c2c_stats *total;
757 hists = container_of(c2c_he->he.hists, struct c2c_hists, hists);
758 stats = &c2c_he->stats;
759 total = &hists->stats;
761 switch (c2c.display) {
763 st = stats->rmt_hitm;
764 tot = total->rmt_hitm;
767 st = stats->lcl_hitm;
768 tot = total->lcl_hitm;
771 st = stats->tot_hitm;
772 tot = total->tot_hitm;
777 p = tot ? (double) st / tot : 0;
782 #define PERC_STR(__s, __v) \
784 scnprintf(__s, sizeof(__s), "%.2F%%", __v); \
789 percent_hitm_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
790 struct hist_entry *he)
792 struct c2c_hist_entry *c2c_he;
793 int width = c2c_width(fmt, hpp, he->hists);
797 c2c_he = container_of(he, struct c2c_hist_entry, he);
798 per = percent_hitm(c2c_he);
799 return scnprintf(hpp->buf, hpp->size, "%*s", width, PERC_STR(buf, per));
803 percent_hitm_color(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
804 struct hist_entry *he)
806 return percent_color(fmt, hpp, he, percent_hitm);
810 percent_hitm_cmp(struct perf_hpp_fmt *fmt __maybe_unused,
811 struct hist_entry *left, struct hist_entry *right)
813 struct c2c_hist_entry *c2c_left;
814 struct c2c_hist_entry *c2c_right;
818 c2c_left = container_of(left, struct c2c_hist_entry, he);
819 c2c_right = container_of(right, struct c2c_hist_entry, he);
821 per_left = percent_hitm(c2c_left);
822 per_right = percent_hitm(c2c_right);
824 return per_left - per_right;
827 static struct c2c_stats *he_stats(struct hist_entry *he)
829 struct c2c_hist_entry *c2c_he;
831 c2c_he = container_of(he, struct c2c_hist_entry, he);
832 return &c2c_he->stats;
835 static struct c2c_stats *total_stats(struct hist_entry *he)
837 struct c2c_hists *hists;
839 hists = container_of(he->hists, struct c2c_hists, hists);
840 return &hists->stats;
843 static double percent(int st, int tot)
845 return tot ? 100. * (double) st / (double) tot : 0;
848 #define PERCENT(__h, __f) percent(he_stats(__h)->__f, total_stats(__h)->__f)
850 #define PERCENT_FN(__f) \
851 static double percent_ ## __f(struct c2c_hist_entry *c2c_he) \
853 struct c2c_hists *hists; \
855 hists = container_of(c2c_he->he.hists, struct c2c_hists, hists); \
856 return percent(c2c_he->stats.__f, hists->stats.__f); \
862 PERCENT_FN(st_l1miss)
865 percent_rmt_hitm_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
866 struct hist_entry *he)
868 int width = c2c_width(fmt, hpp, he->hists);
869 double per = PERCENT(he, rmt_hitm);
872 return scnprintf(hpp->buf, hpp->size, "%*s", width, PERC_STR(buf, per));
876 percent_rmt_hitm_color(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
877 struct hist_entry *he)
879 return percent_color(fmt, hpp, he, percent_rmt_hitm);
883 percent_rmt_hitm_cmp(struct perf_hpp_fmt *fmt __maybe_unused,
884 struct hist_entry *left, struct hist_entry *right)
889 per_left = PERCENT(left, rmt_hitm);
890 per_right = PERCENT(right, rmt_hitm);
892 return per_left - per_right;
896 percent_lcl_hitm_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
897 struct hist_entry *he)
899 int width = c2c_width(fmt, hpp, he->hists);
900 double per = PERCENT(he, lcl_hitm);
903 return scnprintf(hpp->buf, hpp->size, "%*s", width, PERC_STR(buf, per));
907 percent_lcl_hitm_color(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
908 struct hist_entry *he)
910 return percent_color(fmt, hpp, he, percent_lcl_hitm);
914 percent_lcl_hitm_cmp(struct perf_hpp_fmt *fmt __maybe_unused,
915 struct hist_entry *left, struct hist_entry *right)
920 per_left = PERCENT(left, lcl_hitm);
921 per_right = PERCENT(right, lcl_hitm);
923 return per_left - per_right;
927 percent_stores_l1hit_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
928 struct hist_entry *he)
930 int width = c2c_width(fmt, hpp, he->hists);
931 double per = PERCENT(he, st_l1hit);
934 return scnprintf(hpp->buf, hpp->size, "%*s", width, PERC_STR(buf, per));
938 percent_stores_l1hit_color(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
939 struct hist_entry *he)
941 return percent_color(fmt, hpp, he, percent_st_l1hit);
945 percent_stores_l1hit_cmp(struct perf_hpp_fmt *fmt __maybe_unused,
946 struct hist_entry *left, struct hist_entry *right)
951 per_left = PERCENT(left, st_l1hit);
952 per_right = PERCENT(right, st_l1hit);
954 return per_left - per_right;
958 percent_stores_l1miss_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
959 struct hist_entry *he)
961 int width = c2c_width(fmt, hpp, he->hists);
962 double per = PERCENT(he, st_l1miss);
965 return scnprintf(hpp->buf, hpp->size, "%*s", width, PERC_STR(buf, per));
969 percent_stores_l1miss_color(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
970 struct hist_entry *he)
972 return percent_color(fmt, hpp, he, percent_st_l1miss);
976 percent_stores_l1miss_cmp(struct perf_hpp_fmt *fmt __maybe_unused,
977 struct hist_entry *left, struct hist_entry *right)
982 per_left = PERCENT(left, st_l1miss);
983 per_right = PERCENT(right, st_l1miss);
985 return per_left - per_right;
992 pid_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
993 struct hist_entry *he)
995 int width = c2c_width(fmt, hpp, he->hists);
997 return scnprintf(hpp->buf, hpp->size, "%*d", width, he->thread->pid_);
1001 pid_cmp(struct perf_hpp_fmt *fmt __maybe_unused,
1002 struct hist_entry *left, struct hist_entry *right)
1004 return left->thread->pid_ - right->thread->pid_;
1008 empty_cmp(struct perf_hpp_fmt *fmt __maybe_unused,
1009 struct hist_entry *left __maybe_unused,
1010 struct hist_entry *right __maybe_unused)
1016 node_entry(struct perf_hpp_fmt *fmt __maybe_unused, struct perf_hpp *hpp,
1017 struct hist_entry *he)
1019 struct c2c_hist_entry *c2c_he;
1024 c2c_he = container_of(he, struct c2c_hist_entry, he);
1026 for (node = 0; node < c2c.nodes_cnt; node++) {
1027 DECLARE_BITMAP(set, c2c.cpus_cnt);
1029 bitmap_zero(set, c2c.cpus_cnt);
1030 bitmap_and(set, c2c_he->cpuset, c2c.nodes[node], c2c.cpus_cnt);
1032 if (!bitmap_weight(set, c2c.cpus_cnt)) {
1033 if (c2c.node_info == 1) {
1034 ret = scnprintf(hpp->buf, hpp->size, "%21s", " ");
1035 advance_hpp(hpp, ret);
1041 ret = scnprintf(hpp->buf, hpp->size, " ");
1042 advance_hpp(hpp, ret);
1045 switch (c2c.node_info) {
1047 ret = scnprintf(hpp->buf, hpp->size, "%2d", node);
1048 advance_hpp(hpp, ret);
1052 int num = bitmap_weight(c2c_he->cpuset, c2c.cpus_cnt);
1053 struct c2c_stats *stats = &c2c_he->node_stats[node];
1055 ret = scnprintf(hpp->buf, hpp->size, "%2d{%2d ", node, num);
1056 advance_hpp(hpp, ret);
1058 #define DISPLAY_HITM(__h) \
1059 if (c2c_he->stats.__h> 0) { \
1060 ret = scnprintf(hpp->buf, hpp->size, "%5.1f%% ", \
1061 percent(stats->__h, c2c_he->stats.__h));\
1063 ret = scnprintf(hpp->buf, hpp->size, "%6s ", "n/a"); \
1066 switch (c2c.display) {
1068 DISPLAY_HITM(rmt_hitm);
1071 DISPLAY_HITM(lcl_hitm);
1074 DISPLAY_HITM(tot_hitm);
1081 advance_hpp(hpp, ret);
1083 if (c2c_he->stats.store > 0) {
1084 ret = scnprintf(hpp->buf, hpp->size, "%5.1f%%}",
1085 percent(stats->store, c2c_he->stats.store));
1087 ret = scnprintf(hpp->buf, hpp->size, "%6s}", "n/a");
1090 advance_hpp(hpp, ret);
1094 ret = scnprintf(hpp->buf, hpp->size, "%2d{", node);
1095 advance_hpp(hpp, ret);
1097 ret = bitmap_scnprintf(set, c2c.cpus_cnt, hpp->buf, hpp->size);
1098 advance_hpp(hpp, ret);
1100 ret = scnprintf(hpp->buf, hpp->size, "}");
1101 advance_hpp(hpp, ret);
1114 mean_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
1115 struct hist_entry *he, double mean)
1117 int width = c2c_width(fmt, hpp, he->hists);
1120 scnprintf(buf, 10, "%6.0f", mean);
1121 return scnprintf(hpp->buf, hpp->size, "%*s", width, buf);
1124 #define MEAN_ENTRY(__func, __val) \
1126 __func(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, struct hist_entry *he) \
1128 struct c2c_hist_entry *c2c_he; \
1129 c2c_he = container_of(he, struct c2c_hist_entry, he); \
1130 return mean_entry(fmt, hpp, he, avg_stats(&c2c_he->cstats.__val)); \
1133 MEAN_ENTRY(mean_rmt_entry, rmt_hitm);
1134 MEAN_ENTRY(mean_lcl_entry, lcl_hitm);
1135 MEAN_ENTRY(mean_load_entry, load);
1138 cpucnt_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
1139 struct hist_entry *he)
1141 struct c2c_hist_entry *c2c_he;
1142 int width = c2c_width(fmt, hpp, he->hists);
1145 c2c_he = container_of(he, struct c2c_hist_entry, he);
1147 scnprintf(buf, 10, "%d", bitmap_weight(c2c_he->cpuset, c2c.cpus_cnt));
1148 return scnprintf(hpp->buf, hpp->size, "%*s", width, buf);
1152 cl_idx_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
1153 struct hist_entry *he)
1155 struct c2c_hist_entry *c2c_he;
1156 int width = c2c_width(fmt, hpp, he->hists);
1159 c2c_he = container_of(he, struct c2c_hist_entry, he);
1161 scnprintf(buf, 10, "%u", c2c_he->cacheline_idx);
1162 return scnprintf(hpp->buf, hpp->size, "%*s", width, buf);
1166 cl_idx_empty_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
1167 struct hist_entry *he)
1169 int width = c2c_width(fmt, hpp, he->hists);
1171 return scnprintf(hpp->buf, hpp->size, "%*s", width, "");
1174 #define HEADER_LOW(__h) \
1181 #define HEADER_BOTH(__h0, __h1) \
1191 #define HEADER_SPAN(__h0, __h1, __s) \
1202 #define HEADER_SPAN_LOW(__h) \
1209 static struct c2c_dimension dim_dcacheline = {
1210 .header = HEADER_LOW("Cacheline"),
1211 .name = "dcacheline",
1212 .cmp = dcacheline_cmp,
1213 .entry = dcacheline_entry,
1217 static struct c2c_header header_offset_tui = HEADER_LOW("Off");
1219 static struct c2c_dimension dim_offset = {
1220 .header = HEADER_BOTH("Data address", "Offset"),
1223 .entry = offset_entry,
1227 static struct c2c_dimension dim_iaddr = {
1228 .header = HEADER_LOW("Code address"),
1231 .entry = iaddr_entry,
1235 static struct c2c_dimension dim_tot_hitm = {
1236 .header = HEADER_SPAN("----- LLC Load Hitm -----", "Total", 2),
1238 .cmp = tot_hitm_cmp,
1239 .entry = tot_hitm_entry,
1243 static struct c2c_dimension dim_lcl_hitm = {
1244 .header = HEADER_SPAN_LOW("Lcl"),
1246 .cmp = lcl_hitm_cmp,
1247 .entry = lcl_hitm_entry,
1251 static struct c2c_dimension dim_rmt_hitm = {
1252 .header = HEADER_SPAN_LOW("Rmt"),
1254 .cmp = rmt_hitm_cmp,
1255 .entry = rmt_hitm_entry,
1259 static struct c2c_dimension dim_cl_rmt_hitm = {
1260 .header = HEADER_SPAN("----- HITM -----", "Rmt", 1),
1261 .name = "cl_rmt_hitm",
1262 .cmp = rmt_hitm_cmp,
1263 .entry = rmt_hitm_entry,
1267 static struct c2c_dimension dim_cl_lcl_hitm = {
1268 .header = HEADER_SPAN_LOW("Lcl"),
1269 .name = "cl_lcl_hitm",
1270 .cmp = lcl_hitm_cmp,
1271 .entry = lcl_hitm_entry,
1275 static struct c2c_dimension dim_stores = {
1276 .header = HEADER_SPAN("---- Store Reference ----", "Total", 2),
1279 .entry = store_entry,
1283 static struct c2c_dimension dim_stores_l1hit = {
1284 .header = HEADER_SPAN_LOW("L1Hit"),
1285 .name = "stores_l1hit",
1286 .cmp = st_l1hit_cmp,
1287 .entry = st_l1hit_entry,
1291 static struct c2c_dimension dim_stores_l1miss = {
1292 .header = HEADER_SPAN_LOW("L1Miss"),
1293 .name = "stores_l1miss",
1294 .cmp = st_l1miss_cmp,
1295 .entry = st_l1miss_entry,
1299 static struct c2c_dimension dim_cl_stores_l1hit = {
1300 .header = HEADER_SPAN("-- Store Refs --", "L1 Hit", 1),
1301 .name = "cl_stores_l1hit",
1302 .cmp = st_l1hit_cmp,
1303 .entry = st_l1hit_entry,
1307 static struct c2c_dimension dim_cl_stores_l1miss = {
1308 .header = HEADER_SPAN_LOW("L1 Miss"),
1309 .name = "cl_stores_l1miss",
1310 .cmp = st_l1miss_cmp,
1311 .entry = st_l1miss_entry,
1315 static struct c2c_dimension dim_ld_fbhit = {
1316 .header = HEADER_SPAN("----- Core Load Hit -----", "FB", 2),
1318 .cmp = ld_fbhit_cmp,
1319 .entry = ld_fbhit_entry,
1323 static struct c2c_dimension dim_ld_l1hit = {
1324 .header = HEADER_SPAN_LOW("L1"),
1326 .cmp = ld_l1hit_cmp,
1327 .entry = ld_l1hit_entry,
1331 static struct c2c_dimension dim_ld_l2hit = {
1332 .header = HEADER_SPAN_LOW("L2"),
1334 .cmp = ld_l2hit_cmp,
1335 .entry = ld_l2hit_entry,
1339 static struct c2c_dimension dim_ld_llchit = {
1340 .header = HEADER_SPAN("-- LLC Load Hit --", "Llc", 1),
1341 .name = "ld_lclhit",
1342 .cmp = ld_llchit_cmp,
1343 .entry = ld_llchit_entry,
1347 static struct c2c_dimension dim_ld_rmthit = {
1348 .header = HEADER_SPAN_LOW("Rmt"),
1349 .name = "ld_rmthit",
1351 .entry = rmt_hit_entry,
1355 static struct c2c_dimension dim_ld_llcmiss = {
1356 .header = HEADER_BOTH("LLC", "Ld Miss"),
1357 .name = "ld_llcmiss",
1358 .cmp = ld_llcmiss_cmp,
1359 .entry = ld_llcmiss_entry,
1363 static struct c2c_dimension dim_tot_recs = {
1364 .header = HEADER_BOTH("Total", "records"),
1366 .cmp = tot_recs_cmp,
1367 .entry = tot_recs_entry,
1371 static struct c2c_dimension dim_tot_loads = {
1372 .header = HEADER_BOTH("Total", "Loads"),
1373 .name = "tot_loads",
1374 .cmp = tot_loads_cmp,
1375 .entry = tot_loads_entry,
1379 static struct c2c_header percent_hitm_header[] = {
1380 [DISPLAY_LCL] = HEADER_BOTH("Lcl", "Hitm"),
1381 [DISPLAY_RMT] = HEADER_BOTH("Rmt", "Hitm"),
1382 [DISPLAY_TOT] = HEADER_BOTH("Tot", "Hitm"),
1385 static struct c2c_dimension dim_percent_hitm = {
1386 .name = "percent_hitm",
1387 .cmp = percent_hitm_cmp,
1388 .entry = percent_hitm_entry,
1389 .color = percent_hitm_color,
1393 static struct c2c_dimension dim_percent_rmt_hitm = {
1394 .header = HEADER_SPAN("----- HITM -----", "Rmt", 1),
1395 .name = "percent_rmt_hitm",
1396 .cmp = percent_rmt_hitm_cmp,
1397 .entry = percent_rmt_hitm_entry,
1398 .color = percent_rmt_hitm_color,
1402 static struct c2c_dimension dim_percent_lcl_hitm = {
1403 .header = HEADER_SPAN_LOW("Lcl"),
1404 .name = "percent_lcl_hitm",
1405 .cmp = percent_lcl_hitm_cmp,
1406 .entry = percent_lcl_hitm_entry,
1407 .color = percent_lcl_hitm_color,
1411 static struct c2c_dimension dim_percent_stores_l1hit = {
1412 .header = HEADER_SPAN("-- Store Refs --", "L1 Hit", 1),
1413 .name = "percent_stores_l1hit",
1414 .cmp = percent_stores_l1hit_cmp,
1415 .entry = percent_stores_l1hit_entry,
1416 .color = percent_stores_l1hit_color,
1420 static struct c2c_dimension dim_percent_stores_l1miss = {
1421 .header = HEADER_SPAN_LOW("L1 Miss"),
1422 .name = "percent_stores_l1miss",
1423 .cmp = percent_stores_l1miss_cmp,
1424 .entry = percent_stores_l1miss_entry,
1425 .color = percent_stores_l1miss_color,
1429 static struct c2c_dimension dim_dram_lcl = {
1430 .header = HEADER_SPAN("--- Load Dram ----", "Lcl", 1),
1432 .cmp = lcl_dram_cmp,
1433 .entry = lcl_dram_entry,
1437 static struct c2c_dimension dim_dram_rmt = {
1438 .header = HEADER_SPAN_LOW("Rmt"),
1440 .cmp = rmt_dram_cmp,
1441 .entry = rmt_dram_entry,
1445 static struct c2c_dimension dim_pid = {
1446 .header = HEADER_LOW("Pid"),
1453 static struct c2c_dimension dim_tid = {
1454 .header = HEADER_LOW("Tid"),
1459 static struct c2c_dimension dim_symbol = {
1464 static struct c2c_dimension dim_dso = {
1465 .header = HEADER_BOTH("Shared", "Object"),
1470 static struct c2c_header header_node[3] = {
1472 HEADER_LOW("Node{cpus %hitms %stores}"),
1473 HEADER_LOW("Node{cpu list}"),
1476 static struct c2c_dimension dim_node = {
1479 .entry = node_entry,
1483 static struct c2c_dimension dim_mean_rmt = {
1484 .header = HEADER_SPAN("---------- cycles ----------", "rmt hitm", 2),
1487 .entry = mean_rmt_entry,
1491 static struct c2c_dimension dim_mean_lcl = {
1492 .header = HEADER_SPAN_LOW("lcl hitm"),
1495 .entry = mean_lcl_entry,
1499 static struct c2c_dimension dim_mean_load = {
1500 .header = HEADER_SPAN_LOW("load"),
1501 .name = "mean_load",
1503 .entry = mean_load_entry,
1507 static struct c2c_dimension dim_cpucnt = {
1508 .header = HEADER_BOTH("cpu", "cnt"),
1511 .entry = cpucnt_entry,
1515 static struct c2c_dimension dim_srcline = {
1516 .name = "cl_srcline",
1517 .se = &sort_srcline,
1520 static struct c2c_dimension dim_dcacheline_idx = {
1521 .header = HEADER_LOW("Index"),
1524 .entry = cl_idx_entry,
1528 static struct c2c_dimension dim_dcacheline_num = {
1529 .header = HEADER_LOW("Num"),
1532 .entry = cl_idx_entry,
1536 static struct c2c_dimension dim_dcacheline_num_empty = {
1537 .header = HEADER_LOW("Num"),
1538 .name = "cl_num_empty",
1540 .entry = cl_idx_empty_entry,
1544 static struct c2c_dimension *dimensions[] = {
1556 &dim_cl_stores_l1hit,
1557 &dim_cl_stores_l1miss,
1567 &dim_percent_rmt_hitm,
1568 &dim_percent_lcl_hitm,
1569 &dim_percent_stores_l1hit,
1570 &dim_percent_stores_l1miss,
1583 &dim_dcacheline_idx,
1584 &dim_dcacheline_num,
1585 &dim_dcacheline_num_empty,
1589 static void fmt_free(struct perf_hpp_fmt *fmt)
1591 struct c2c_fmt *c2c_fmt;
1593 c2c_fmt = container_of(fmt, struct c2c_fmt, fmt);
1597 static bool fmt_equal(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b)
1599 struct c2c_fmt *c2c_a = container_of(a, struct c2c_fmt, fmt);
1600 struct c2c_fmt *c2c_b = container_of(b, struct c2c_fmt, fmt);
1602 return c2c_a->dim == c2c_b->dim;
1605 static struct c2c_dimension *get_dimension(const char *name)
1609 for (i = 0; dimensions[i]; i++) {
1610 struct c2c_dimension *dim = dimensions[i];
1612 if (!strcmp(dim->name, name))
1619 static int c2c_se_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
1620 struct hist_entry *he)
1622 struct c2c_fmt *c2c_fmt = container_of(fmt, struct c2c_fmt, fmt);
1623 struct c2c_dimension *dim = c2c_fmt->dim;
1624 size_t len = fmt->user_len;
1627 len = hists__col_len(he->hists, dim->se->se_width_idx);
1629 if (dim == &dim_symbol || dim == &dim_srcline)
1630 len = symbol_width(he->hists, dim->se);
1633 return dim->se->se_snprintf(he, hpp->buf, hpp->size, len);
1636 static int64_t c2c_se_cmp(struct perf_hpp_fmt *fmt,
1637 struct hist_entry *a, struct hist_entry *b)
1639 struct c2c_fmt *c2c_fmt = container_of(fmt, struct c2c_fmt, fmt);
1640 struct c2c_dimension *dim = c2c_fmt->dim;
1642 return dim->se->se_cmp(a, b);
1645 static int64_t c2c_se_collapse(struct perf_hpp_fmt *fmt,
1646 struct hist_entry *a, struct hist_entry *b)
1648 struct c2c_fmt *c2c_fmt = container_of(fmt, struct c2c_fmt, fmt);
1649 struct c2c_dimension *dim = c2c_fmt->dim;
1650 int64_t (*collapse_fn)(struct hist_entry *, struct hist_entry *);
1652 collapse_fn = dim->se->se_collapse ?: dim->se->se_cmp;
1653 return collapse_fn(a, b);
1656 static struct c2c_fmt *get_format(const char *name)
1658 struct c2c_dimension *dim = get_dimension(name);
1659 struct c2c_fmt *c2c_fmt;
1660 struct perf_hpp_fmt *fmt;
1665 c2c_fmt = zalloc(sizeof(*c2c_fmt));
1671 fmt = &c2c_fmt->fmt;
1672 INIT_LIST_HEAD(&fmt->list);
1673 INIT_LIST_HEAD(&fmt->sort_list);
1675 fmt->cmp = dim->se ? c2c_se_cmp : dim->cmp;
1676 fmt->sort = dim->se ? c2c_se_cmp : dim->cmp;
1677 fmt->color = dim->se ? NULL : dim->color;
1678 fmt->entry = dim->se ? c2c_se_entry : dim->entry;
1679 fmt->header = c2c_header;
1680 fmt->width = c2c_width;
1681 fmt->collapse = dim->se ? c2c_se_collapse : dim->cmp;
1682 fmt->equal = fmt_equal;
1683 fmt->free = fmt_free;
1688 static int c2c_hists__init_output(struct perf_hpp_list *hpp_list, char *name)
1690 struct c2c_fmt *c2c_fmt = get_format(name);
1694 return output_field_add(hpp_list, name);
1697 perf_hpp_list__column_register(hpp_list, &c2c_fmt->fmt);
1701 static int c2c_hists__init_sort(struct perf_hpp_list *hpp_list, char *name)
1703 struct c2c_fmt *c2c_fmt = get_format(name);
1704 struct c2c_dimension *dim;
1708 return sort_dimension__add(hpp_list, name, NULL, 0);
1712 if (dim == &dim_dso)
1715 perf_hpp_list__register_sort_field(hpp_list, &c2c_fmt->fmt);
1719 #define PARSE_LIST(_list, _fn) \
1727 for (tok = strtok_r((char *)_list, ", ", &tmp); \
1728 tok; tok = strtok_r(NULL, ", ", &tmp)) { \
1729 ret = _fn(hpp_list, tok); \
1730 if (ret == -EINVAL) { \
1731 pr_err("Invalid --fields key: `%s'", tok); \
1733 } else if (ret == -ESRCH) { \
1734 pr_err("Unknown --fields key: `%s'", tok); \
1740 static int hpp_list__parse(struct perf_hpp_list *hpp_list,
1741 const char *output_,
1744 char *output = output_ ? strdup(output_) : NULL;
1745 char *sort = sort_ ? strdup(sort_) : NULL;
1748 PARSE_LIST(output, c2c_hists__init_output);
1749 PARSE_LIST(sort, c2c_hists__init_sort);
1751 /* copy sort keys to output fields */
1752 perf_hpp__setup_output_field(hpp_list);
1755 * We dont need other sorting keys other than those
1756 * we already specified. It also really slows down
1757 * the processing a lot with big number of output
1758 * fields, so switching this off for c2c.
1762 /* and then copy output fields to sort keys */
1763 perf_hpp__append_sort_keys(&hists->list);
1771 static int c2c_hists__init(struct c2c_hists *hists,
1773 int nr_header_lines)
1775 __hists__init(&hists->hists, &hists->list);
1778 * Initialize only with sort fields, we need to resort
1779 * later anyway, and that's where we add output fields
1782 perf_hpp_list__init(&hists->list);
1784 /* Overload number of header lines.*/
1785 hists->list.nr_header_lines = nr_header_lines;
1787 return hpp_list__parse(&hists->list, NULL, sort);
1790 static int c2c_hists__reinit(struct c2c_hists *c2c_hists,
1794 perf_hpp__reset_output_field(&c2c_hists->list);
1795 return hpp_list__parse(&c2c_hists->list, output, sort);
1798 #define DISPLAY_LINE_LIMIT 0.0005
1800 static bool he__display(struct hist_entry *he, struct c2c_stats *stats)
1802 struct c2c_hist_entry *c2c_he;
1808 c2c_he = container_of(he, struct c2c_hist_entry, he);
1810 #define FILTER_HITM(__h) \
1812 ld_dist = ((double)c2c_he->stats.__h / stats->__h); \
1813 if (ld_dist < DISPLAY_LINE_LIMIT) \
1814 he->filtered = HIST_FILTER__C2C; \
1816 he->filtered = HIST_FILTER__C2C; \
1819 switch (c2c.display) {
1821 FILTER_HITM(lcl_hitm);
1824 FILTER_HITM(rmt_hitm);
1827 FILTER_HITM(tot_hitm);
1834 return he->filtered == 0;
1837 static inline int valid_hitm_or_store(struct hist_entry *he)
1839 struct c2c_hist_entry *c2c_he;
1842 c2c_he = container_of(he, struct c2c_hist_entry, he);
1843 has_hitm = c2c.display == DISPLAY_TOT ? c2c_he->stats.tot_hitm :
1844 c2c.display == DISPLAY_LCL ? c2c_he->stats.lcl_hitm :
1845 c2c_he->stats.rmt_hitm;
1846 return has_hitm || c2c_he->stats.store;
1849 static void calc_width(struct hist_entry *he)
1851 struct c2c_hists *c2c_hists;
1853 c2c_hists = container_of(he->hists, struct c2c_hists, hists);
1854 hists__calc_col_len(&c2c_hists->hists, he);
1857 static int filter_cb(struct hist_entry *he)
1859 if (c2c.show_src && !he->srcline)
1860 he->srcline = hist_entry__get_srcline(he);
1864 if (!valid_hitm_or_store(he))
1865 he->filtered = HIST_FILTER__C2C;
1870 static int resort_cl_cb(struct hist_entry *he)
1872 struct c2c_hist_entry *c2c_he;
1873 struct c2c_hists *c2c_hists;
1874 bool display = he__display(he, &c2c.hitm_stats);
1876 c2c_he = container_of(he, struct c2c_hist_entry, he);
1877 c2c_hists = c2c_he->hists;
1881 if (display && c2c_hists) {
1882 static unsigned int idx;
1884 c2c_he->cacheline_idx = idx++;
1886 c2c_hists__reinit(c2c_hists, c2c.cl_output, c2c.cl_resort);
1888 hists__collapse_resort(&c2c_hists->hists, NULL);
1889 hists__output_resort_cb(&c2c_hists->hists, NULL, filter_cb);
1895 static void setup_nodes_header(void)
1897 dim_node.header = header_node[c2c.node_info];
1900 static int setup_nodes(struct perf_session *session)
1902 struct numa_node *n;
1903 unsigned long **nodes;
1907 if (c2c.node_info > 2)
1910 c2c.nodes_cnt = session->header.env.nr_numa_nodes;
1911 c2c.cpus_cnt = session->header.env.nr_cpus_online;
1913 n = session->header.env.numa_nodes;
1917 nodes = zalloc(sizeof(unsigned long *) * c2c.nodes_cnt);
1923 cpu2node = zalloc(sizeof(int) * c2c.cpus_cnt);
1927 for (cpu = 0; cpu < c2c.cpus_cnt; cpu++)
1930 c2c.cpu2node = cpu2node;
1932 for (node = 0; node < c2c.nodes_cnt; node++) {
1933 struct cpu_map *map = n[node].map;
1936 set = bitmap_alloc(c2c.cpus_cnt);
1942 /* empty node, skip */
1943 if (cpu_map__empty(map))
1946 for (cpu = 0; cpu < map->nr; cpu++) {
1947 set_bit(map->map[cpu], set);
1949 if (WARN_ONCE(cpu2node[map->map[cpu]] != -1, "node/cpu topology bug"))
1952 cpu2node[map->map[cpu]] = node;
1956 setup_nodes_header();
1960 #define HAS_HITMS(__h) ((__h)->stats.lcl_hitm || (__h)->stats.rmt_hitm)
1962 static int resort_hitm_cb(struct hist_entry *he)
1964 struct c2c_hist_entry *c2c_he;
1965 c2c_he = container_of(he, struct c2c_hist_entry, he);
1967 if (HAS_HITMS(c2c_he)) {
1968 c2c.shared_clines++;
1969 c2c_add_stats(&c2c.hitm_stats, &c2c_he->stats);
1975 static int hists__iterate_cb(struct hists *hists, hists__resort_cb_t cb)
1977 struct rb_node *next = rb_first(&hists->entries);
1981 struct hist_entry *he;
1983 he = rb_entry(next, struct hist_entry, rb_node);
1987 next = rb_next(&he->rb_node);
1993 static void print_c2c__display_stats(FILE *out)
1996 struct c2c_stats *stats = &c2c.hists.stats;
1998 llc_misses = stats->lcl_dram +
2003 fprintf(out, "=================================================\n");
2004 fprintf(out, " Trace Event Information \n");
2005 fprintf(out, "=================================================\n");
2006 fprintf(out, " Total records : %10d\n", stats->nr_entries);
2007 fprintf(out, " Locked Load/Store Operations : %10d\n", stats->locks);
2008 fprintf(out, " Load Operations : %10d\n", stats->load);
2009 fprintf(out, " Loads - uncacheable : %10d\n", stats->ld_uncache);
2010 fprintf(out, " Loads - IO : %10d\n", stats->ld_io);
2011 fprintf(out, " Loads - Miss : %10d\n", stats->ld_miss);
2012 fprintf(out, " Loads - no mapping : %10d\n", stats->ld_noadrs);
2013 fprintf(out, " Load Fill Buffer Hit : %10d\n", stats->ld_fbhit);
2014 fprintf(out, " Load L1D hit : %10d\n", stats->ld_l1hit);
2015 fprintf(out, " Load L2D hit : %10d\n", stats->ld_l2hit);
2016 fprintf(out, " Load LLC hit : %10d\n", stats->ld_llchit + stats->lcl_hitm);
2017 fprintf(out, " Load Local HITM : %10d\n", stats->lcl_hitm);
2018 fprintf(out, " Load Remote HITM : %10d\n", stats->rmt_hitm);
2019 fprintf(out, " Load Remote HIT : %10d\n", stats->rmt_hit);
2020 fprintf(out, " Load Local DRAM : %10d\n", stats->lcl_dram);
2021 fprintf(out, " Load Remote DRAM : %10d\n", stats->rmt_dram);
2022 fprintf(out, " Load MESI State Exclusive : %10d\n", stats->ld_excl);
2023 fprintf(out, " Load MESI State Shared : %10d\n", stats->ld_shared);
2024 fprintf(out, " Load LLC Misses : %10d\n", llc_misses);
2025 fprintf(out, " LLC Misses to Local DRAM : %10.1f%%\n", ((double)stats->lcl_dram/(double)llc_misses) * 100.);
2026 fprintf(out, " LLC Misses to Remote DRAM : %10.1f%%\n", ((double)stats->rmt_dram/(double)llc_misses) * 100.);
2027 fprintf(out, " LLC Misses to Remote cache (HIT) : %10.1f%%\n", ((double)stats->rmt_hit /(double)llc_misses) * 100.);
2028 fprintf(out, " LLC Misses to Remote cache (HITM) : %10.1f%%\n", ((double)stats->rmt_hitm/(double)llc_misses) * 100.);
2029 fprintf(out, " Store Operations : %10d\n", stats->store);
2030 fprintf(out, " Store - uncacheable : %10d\n", stats->st_uncache);
2031 fprintf(out, " Store - no mapping : %10d\n", stats->st_noadrs);
2032 fprintf(out, " Store L1D Hit : %10d\n", stats->st_l1hit);
2033 fprintf(out, " Store L1D Miss : %10d\n", stats->st_l1miss);
2034 fprintf(out, " No Page Map Rejects : %10d\n", stats->nomap);
2035 fprintf(out, " Unable to parse data source : %10d\n", stats->noparse);
2038 static void print_shared_cacheline_info(FILE *out)
2040 struct c2c_stats *stats = &c2c.hitm_stats;
2041 int hitm_cnt = stats->lcl_hitm + stats->rmt_hitm;
2043 fprintf(out, "=================================================\n");
2044 fprintf(out, " Global Shared Cache Line Event Information \n");
2045 fprintf(out, "=================================================\n");
2046 fprintf(out, " Total Shared Cache Lines : %10d\n", c2c.shared_clines);
2047 fprintf(out, " Load HITs on shared lines : %10d\n", stats->load);
2048 fprintf(out, " Fill Buffer Hits on shared lines : %10d\n", stats->ld_fbhit);
2049 fprintf(out, " L1D hits on shared lines : %10d\n", stats->ld_l1hit);
2050 fprintf(out, " L2D hits on shared lines : %10d\n", stats->ld_l2hit);
2051 fprintf(out, " LLC hits on shared lines : %10d\n", stats->ld_llchit + stats->lcl_hitm);
2052 fprintf(out, " Locked Access on shared lines : %10d\n", stats->locks);
2053 fprintf(out, " Store HITs on shared lines : %10d\n", stats->store);
2054 fprintf(out, " Store L1D hits on shared lines : %10d\n", stats->st_l1hit);
2055 fprintf(out, " Total Merged records : %10d\n", hitm_cnt + stats->store);
2058 static void print_cacheline(struct c2c_hists *c2c_hists,
2059 struct hist_entry *he_cl,
2060 struct perf_hpp_list *hpp_list,
2064 struct perf_hpp hpp = {
2071 hists__fprintf_headers(&c2c_hists->hists, out);
2077 fprintf(out, " -------------------------------------------------------------\n");
2078 __hist_entry__snprintf(he_cl, &hpp, hpp_list);
2079 fprintf(out, "%s\n", bf);
2080 fprintf(out, " -------------------------------------------------------------\n");
2082 hists__fprintf(&c2c_hists->hists, false, 0, 0, 0, out, true);
2085 static void print_pareto(FILE *out)
2087 struct perf_hpp_list hpp_list;
2091 perf_hpp_list__init(&hpp_list);
2092 ret = hpp_list__parse(&hpp_list,
2101 if (WARN_ONCE(ret, "failed to setup sort entries\n"))
2104 nd = rb_first(&c2c.hists.hists.entries);
2106 for (; nd; nd = rb_next(nd)) {
2107 struct hist_entry *he = rb_entry(nd, struct hist_entry, rb_node);
2108 struct c2c_hist_entry *c2c_he;
2113 c2c_he = container_of(he, struct c2c_hist_entry, he);
2114 print_cacheline(c2c_he->hists, he, &hpp_list, out);
2118 static void print_c2c_info(FILE *out, struct perf_session *session)
2120 struct perf_evlist *evlist = session->evlist;
2121 struct perf_evsel *evsel;
2124 fprintf(out, "=================================================\n");
2125 fprintf(out, " c2c details \n");
2126 fprintf(out, "=================================================\n");
2128 evlist__for_each_entry(evlist, evsel) {
2129 fprintf(out, "%-36s: %s\n", first ? " Events" : "",
2130 perf_evsel__name(evsel));
2133 fprintf(out, " Cachelines sort on : %s HITMs\n",
2134 display_str[c2c.display]);
2135 fprintf(out, " Cacheline data grouping : %s\n", c2c.cl_sort);
2138 static void perf_c2c__hists_fprintf(FILE *out, struct perf_session *session)
2142 print_c2c__display_stats(out);
2144 print_shared_cacheline_info(out);
2146 print_c2c_info(out, session);
2152 fprintf(out, "=================================================\n");
2153 fprintf(out, " Shared Data Cache Line Table \n");
2154 fprintf(out, "=================================================\n");
2155 fprintf(out, "#\n");
2157 hists__fprintf(&c2c.hists.hists, true, 0, 0, 0, stdout, false);
2160 fprintf(out, "=================================================\n");
2161 fprintf(out, " Shared Cache Line Distribution Pareto \n");
2162 fprintf(out, "=================================================\n");
2163 fprintf(out, "#\n");
2168 #ifdef HAVE_SLANG_SUPPORT
2169 static void c2c_browser__update_nr_entries(struct hist_browser *hb)
2172 struct rb_node *nd = rb_first(&hb->hists->entries);
2175 struct hist_entry *he = rb_entry(nd, struct hist_entry, rb_node);
2183 hb->nr_non_filtered_entries = nr_entries;
2186 struct c2c_cacheline_browser {
2187 struct hist_browser hb;
2188 struct hist_entry *he;
2192 perf_c2c_cacheline_browser__title(struct hist_browser *browser,
2193 char *bf, size_t size)
2195 struct c2c_cacheline_browser *cl_browser;
2196 struct hist_entry *he;
2199 cl_browser = container_of(browser, struct c2c_cacheline_browser, hb);
2200 he = cl_browser->he;
2203 addr = cl_address(he->mem_info->daddr.addr);
2205 scnprintf(bf, size, "Cacheline 0x%lx", addr);
2209 static struct c2c_cacheline_browser*
2210 c2c_cacheline_browser__new(struct hists *hists, struct hist_entry *he)
2212 struct c2c_cacheline_browser *browser;
2214 browser = zalloc(sizeof(*browser));
2216 hist_browser__init(&browser->hb, hists);
2217 browser->hb.c2c_filter = true;
2218 browser->hb.title = perf_c2c_cacheline_browser__title;
2225 static int perf_c2c__browse_cacheline(struct hist_entry *he)
2227 struct c2c_hist_entry *c2c_he;
2228 struct c2c_hists *c2c_hists;
2229 struct c2c_cacheline_browser *cl_browser;
2230 struct hist_browser *browser;
2233 " ENTER Togle callchains (if present) \n"
2234 " n Togle Node details info \n"
2235 " s Togle full lenght of symbol and source line columns \n"
2236 " q Return back to cacheline list \n";
2241 /* Display compact version first. */
2242 c2c.symbol_full = false;
2244 c2c_he = container_of(he, struct c2c_hist_entry, he);
2245 c2c_hists = c2c_he->hists;
2247 cl_browser = c2c_cacheline_browser__new(&c2c_hists->hists, he);
2248 if (cl_browser == NULL)
2251 browser = &cl_browser->hb;
2253 /* reset abort key so that it can get Ctrl-C as a key */
2255 SLang_init_tty(0, 0, 0);
2257 c2c_browser__update_nr_entries(browser);
2260 key = hist_browser__run(browser, "? - help");
2264 c2c.symbol_full = !c2c.symbol_full;
2267 c2c.node_info = (c2c.node_info + 1) % 3;
2268 setup_nodes_header();
2273 ui_browser__help_window(&browser->b, help);
2285 static int perf_c2c_browser__title(struct hist_browser *browser,
2286 char *bf, size_t size)
2289 "Shared Data Cache Line Table "
2290 "(%lu entries, sorted on %s HITMs)",
2291 browser->nr_non_filtered_entries,
2292 display_str[c2c.display]);
2296 static struct hist_browser*
2297 perf_c2c_browser__new(struct hists *hists)
2299 struct hist_browser *browser = hist_browser__new(hists);
2302 browser->title = perf_c2c_browser__title;
2303 browser->c2c_filter = true;
2309 static int perf_c2c__hists_browse(struct hists *hists)
2311 struct hist_browser *browser;
2314 " d Display cacheline details \n"
2315 " ENTER Togle callchains (if present) \n"
2318 browser = perf_c2c_browser__new(hists);
2319 if (browser == NULL)
2322 /* reset abort key so that it can get Ctrl-C as a key */
2324 SLang_init_tty(0, 0, 0);
2326 c2c_browser__update_nr_entries(browser);
2329 key = hist_browser__run(browser, "? - help");
2335 perf_c2c__browse_cacheline(browser->he_selection);
2338 ui_browser__help_window(&browser->b, help);
2346 hist_browser__delete(browser);
2350 static void perf_c2c_display(struct perf_session *session)
2352 if (use_browser == 0)
2353 perf_c2c__hists_fprintf(stdout, session);
2355 perf_c2c__hists_browse(&c2c.hists.hists);
2358 static void perf_c2c_display(struct perf_session *session)
2361 perf_c2c__hists_fprintf(stdout, session);
2363 #endif /* HAVE_SLANG_SUPPORT */
2365 static void ui_quirks(void)
2367 if (!c2c.use_stdio) {
2368 dim_offset.width = 5;
2369 dim_offset.header = header_offset_tui;
2372 dim_percent_hitm.header = percent_hitm_header[c2c.display];
2375 #define CALLCHAIN_DEFAULT_OPT "graph,0.5,caller,function,percent"
2377 const char callchain_help[] = "Display call graph (stack chain/backtrace):\n\n"
2378 CALLCHAIN_REPORT_HELP
2379 "\n\t\t\t\tDefault: " CALLCHAIN_DEFAULT_OPT;
2382 parse_callchain_opt(const struct option *opt, const char *arg, int unset)
2384 struct callchain_param *callchain = opt->value;
2386 callchain->enabled = !unset;
2391 symbol_conf.use_callchain = false;
2392 callchain->mode = CHAIN_NONE;
2396 return parse_callchain_report_opt(arg);
2399 static int setup_callchain(struct perf_evlist *evlist)
2401 u64 sample_type = perf_evlist__combined_sample_type(evlist);
2402 enum perf_call_graph_mode mode = CALLCHAIN_NONE;
2404 if ((sample_type & PERF_SAMPLE_REGS_USER) &&
2405 (sample_type & PERF_SAMPLE_STACK_USER)) {
2406 mode = CALLCHAIN_DWARF;
2407 dwarf_callchain_users = true;
2408 } else if (sample_type & PERF_SAMPLE_BRANCH_STACK)
2409 mode = CALLCHAIN_LBR;
2410 else if (sample_type & PERF_SAMPLE_CALLCHAIN)
2411 mode = CALLCHAIN_FP;
2413 if (!callchain_param.enabled &&
2414 callchain_param.mode != CHAIN_NONE &&
2415 mode != CALLCHAIN_NONE) {
2416 symbol_conf.use_callchain = true;
2417 if (callchain_register_param(&callchain_param) < 0) {
2418 ui__error("Can't register callchain params.\n");
2423 callchain_param.record_mode = mode;
2424 callchain_param.min_percent = 0;
2428 static int setup_display(const char *str)
2430 const char *display = str ?: "tot";
2432 if (!strcmp(display, "tot"))
2433 c2c.display = DISPLAY_TOT;
2434 else if (!strcmp(display, "rmt"))
2435 c2c.display = DISPLAY_RMT;
2436 else if (!strcmp(display, "lcl"))
2437 c2c.display = DISPLAY_LCL;
2439 pr_err("failed: unknown display type: %s\n", str);
2446 #define for_each_token(__tok, __buf, __sep, __tmp) \
2447 for (__tok = strtok_r(__buf, __sep, &__tmp); __tok; \
2448 __tok = strtok_r(NULL, __sep, &__tmp))
2450 static int build_cl_output(char *cl_sort, bool no_source)
2452 char *tok, *tmp, *buf = strdup(cl_sort);
2453 bool add_pid = false;
2454 bool add_tid = false;
2455 bool add_iaddr = false;
2456 bool add_sym = false;
2457 bool add_dso = false;
2458 bool add_src = false;
2464 for_each_token(tok, buf, ",", tmp) {
2465 if (!strcmp(tok, "tid")) {
2467 } else if (!strcmp(tok, "pid")) {
2469 } else if (!strcmp(tok, "iaddr")) {
2473 add_src = no_source ? false : true;
2474 } else if (!strcmp(tok, "dso")) {
2476 } else if (strcmp(tok, "offset")) {
2477 pr_err("unrecognized sort token: %s\n", tok);
2483 if (asprintf(&c2c.cl_output,
2484 "%s%s%s%s%s%s%s%s%s%s",
2485 c2c.use_stdio ? "cl_num_empty," : "",
2488 "percent_stores_l1hit,"
2489 "percent_stores_l1miss,"
2491 add_pid ? "pid," : "",
2492 add_tid ? "tid," : "",
2493 add_iaddr ? "iaddr," : "",
2499 add_sym ? "symbol," : "",
2500 add_dso ? "dso," : "",
2501 add_src ? "cl_srcline," : "",
2507 c2c.show_src = add_src;
2513 static int setup_coalesce(const char *coalesce, bool no_source)
2515 const char *c = coalesce ?: coalesce_default;
2517 if (asprintf(&c2c.cl_sort, "offset,%s", c) < 0)
2520 if (build_cl_output(c2c.cl_sort, no_source))
2523 if (asprintf(&c2c.cl_resort, "offset,%s",
2524 c2c.display == DISPLAY_TOT ?
2526 c2c.display == DISPLAY_RMT ?
2527 "rmt_hitm,lcl_hitm" :
2528 "lcl_hitm,rmt_hitm") < 0)
2531 pr_debug("coalesce sort fields: %s\n", c2c.cl_sort);
2532 pr_debug("coalesce resort fields: %s\n", c2c.cl_resort);
2533 pr_debug("coalesce output fields: %s\n", c2c.cl_output);
2537 static int perf_c2c__report(int argc, const char **argv)
2539 struct perf_session *session;
2540 struct ui_progress prog;
2541 struct perf_data_file file = {
2542 .mode = PERF_DATA_MODE_READ,
2544 char callchain_default_opt[] = CALLCHAIN_DEFAULT_OPT;
2545 const char *display = NULL;
2546 const char *coalesce = NULL;
2547 bool no_source = false;
2548 const struct option options[] = {
2549 OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
2550 "file", "vmlinux pathname"),
2551 OPT_STRING('i', "input", &input_name, "file",
2552 "the input file to process"),
2553 OPT_INCR('N', "node-info", &c2c.node_info,
2554 "show extra node info in report (repeat for more info)"),
2555 OPT_BOOLEAN(0, "stdio", &c2c.use_stdio, "Use the stdio interface"),
2556 OPT_BOOLEAN(0, "stats", &c2c.stats_only,
2557 "Display only statistic tables (implies --stdio)"),
2558 OPT_BOOLEAN(0, "full-symbols", &c2c.symbol_full,
2559 "Display full length of symbols"),
2560 OPT_BOOLEAN(0, "no-source", &no_source,
2561 "Do not display Source Line column"),
2562 OPT_BOOLEAN(0, "show-all", &c2c.show_all,
2563 "Show all captured HITM lines."),
2564 OPT_CALLBACK_DEFAULT('g', "call-graph", &callchain_param,
2565 "print_type,threshold[,print_limit],order,sort_key[,branch],value",
2566 callchain_help, &parse_callchain_opt,
2567 callchain_default_opt),
2568 OPT_STRING('d', "display", &display, "Switch HITM output type", "lcl,rmt"),
2569 OPT_STRING('c', "coalesce", &coalesce, "coalesce fields",
2570 "coalesce fields: pid,tid,iaddr,dso"),
2571 OPT_BOOLEAN('f', "force", &symbol_conf.force, "don't complain, do it"),
2572 OPT_PARENT(c2c_options),
2577 argc = parse_options(argc, argv, options, report_c2c_usage,
2578 PARSE_OPT_STOP_AT_NON_OPTION);
2580 usage_with_options(report_c2c_usage, options);
2582 #ifndef HAVE_SLANG_SUPPORT
2583 c2c.use_stdio = true;
2587 c2c.use_stdio = true;
2589 if (!input_name || !strlen(input_name))
2590 input_name = "perf.data";
2592 file.path = input_name;
2593 file.force = symbol_conf.force;
2595 err = setup_display(display);
2599 err = setup_coalesce(coalesce, no_source);
2601 pr_debug("Failed to initialize hists\n");
2605 err = c2c_hists__init(&c2c.hists, "dcacheline", 2);
2607 pr_debug("Failed to initialize hists\n");
2611 session = perf_session__new(&file, 0, &c2c.tool);
2612 if (session == NULL) {
2613 pr_debug("No memory for session\n");
2617 err = setup_nodes(session);
2619 pr_err("Failed setup nodes\n");
2623 err = setup_callchain(session->evlist);
2627 if (symbol__init(&session->header.env) < 0)
2630 /* No pipe support at the moment. */
2631 if (perf_data_file__is_pipe(session->file)) {
2632 pr_debug("No pipe support at the moment.\n");
2641 setup_browser(false);
2643 err = perf_session__process_events(session);
2645 pr_err("failed to process sample\n");
2649 c2c_hists__reinit(&c2c.hists,
2654 "tot_hitm,lcl_hitm,rmt_hitm,"
2655 "stores,stores_l1hit,stores_l1miss,"
2656 "dram_lcl,dram_rmt,"
2659 "ld_fbhit,ld_l1hit,ld_l2hit,"
2660 "ld_lclhit,ld_rmthit",
2661 c2c.display == DISPLAY_TOT ? "tot_hitm" :
2662 c2c.display == DISPLAY_LCL ? "lcl_hitm" : "rmt_hitm"
2665 ui_progress__init(&prog, c2c.hists.hists.nr_entries, "Sorting...");
2667 hists__collapse_resort(&c2c.hists.hists, NULL);
2668 hists__output_resort_cb(&c2c.hists.hists, &prog, resort_hitm_cb);
2669 hists__iterate_cb(&c2c.hists.hists, resort_cl_cb);
2671 ui_progress__finish();
2675 perf_c2c_display(session);
2678 perf_session__delete(session);
2683 static int parse_record_events(const struct option *opt,
2684 const char *str, int unset __maybe_unused)
2686 bool *event_set = (bool *) opt->value;
2689 return perf_mem_events__parse(str);
2693 static const char * const __usage_record[] = {
2694 "perf c2c record [<options>] [<command>]",
2695 "perf c2c record [<options>] -- <command> [<options>]",
2699 static const char * const *record_mem_usage = __usage_record;
2701 static int perf_c2c__record(int argc, const char **argv)
2703 int rec_argc, i = 0, j;
2704 const char **rec_argv;
2706 bool all_user = false, all_kernel = false;
2707 bool event_set = false;
2708 struct option options[] = {
2709 OPT_CALLBACK('e', "event", &event_set, "event",
2710 "event selector. Use 'perf mem record -e list' to list available events",
2711 parse_record_events),
2712 OPT_BOOLEAN('u', "all-user", &all_user, "collect only user level data"),
2713 OPT_BOOLEAN('k', "all-kernel", &all_kernel, "collect only kernel level data"),
2714 OPT_UINTEGER('l', "ldlat", &perf_mem_events__loads_ldlat, "setup mem-loads latency"),
2715 OPT_PARENT(c2c_options),
2719 if (perf_mem_events__init()) {
2720 pr_err("failed: memory events not supported\n");
2724 argc = parse_options(argc, argv, options, record_mem_usage,
2725 PARSE_OPT_KEEP_UNKNOWN);
2727 rec_argc = argc + 10; /* max number of arguments */
2728 rec_argv = calloc(rec_argc + 1, sizeof(char *));
2732 rec_argv[i++] = "record";
2735 perf_mem_events[PERF_MEM_EVENTS__LOAD].record = true;
2736 perf_mem_events[PERF_MEM_EVENTS__STORE].record = true;
2739 if (perf_mem_events[PERF_MEM_EVENTS__LOAD].record)
2740 rec_argv[i++] = "-W";
2742 rec_argv[i++] = "-d";
2743 rec_argv[i++] = "--sample-cpu";
2745 for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) {
2746 if (!perf_mem_events[j].record)
2749 if (!perf_mem_events[j].supported) {
2750 pr_err("failed: event '%s' not supported\n",
2751 perf_mem_events[j].name);
2756 rec_argv[i++] = "-e";
2757 rec_argv[i++] = perf_mem_events__name(j);
2761 rec_argv[i++] = "--all-user";
2764 rec_argv[i++] = "--all-kernel";
2766 for (j = 0; j < argc; j++, i++)
2767 rec_argv[i] = argv[j];
2770 pr_debug("calling: ");
2774 while (rec_argv[j]) {
2775 pr_debug("%s ", rec_argv[j]);
2781 ret = cmd_record(i, rec_argv);
2786 int cmd_c2c(int argc, const char **argv)
2788 argc = parse_options(argc, argv, c2c_options, c2c_usage,
2789 PARSE_OPT_STOP_AT_NON_OPTION);
2792 usage_with_options(c2c_usage, c2c_options);
2794 if (!strncmp(argv[0], "rec", 3)) {
2795 return perf_c2c__record(argc, argv);
2796 } else if (!strncmp(argv[0], "rep", 3)) {
2797 return perf_c2c__report(argc, argv);
2799 usage_with_options(c2c_usage, c2c_options);