Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf report: Add parallelism sort key

Show parallelism level in profiles if requested by user.

Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Andi Kleen <ak@linux.intel.com>
Link: https://lore.kernel.org/r/7f7bb87cbaa51bf1fb008a0d68b687423ce4bad4.1739437531.git.dvyukov@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Dmitry Vyukov and committed by
Namhyung Kim
7ae1972e f13bc61b

+53
+11
tools/perf/builtin-report.c
··· 1720 1720 symbol_conf.annotate_data_sample = true; 1721 1721 } 1722 1722 1723 + if (report.disable_order || !perf_session__has_switch_events(session)) { 1724 + if ((sort_order && strstr(sort_order, "parallelism")) || 1725 + (field_order && strstr(field_order, "parallelism"))) { 1726 + if (report.disable_order) 1727 + ui__error("Use of parallelism is incompatible with --disable-order.\n"); 1728 + else 1729 + ui__error("Use of parallelism requires --switch-events during record.\n"); 1730 + return -1; 1731 + } 1732 + } 1733 + 1723 1734 if (sort_order && strstr(sort_order, "ipc")) { 1724 1735 parse_options_usage(report_usage, options, "s", 1); 1725 1736 goto error;
+2
tools/perf/util/hist.c
··· 207 207 208 208 hists__new_col_len(hists, HISTC_CGROUP, 6); 209 209 hists__new_col_len(hists, HISTC_CGROUP_ID, 20); 210 + hists__new_col_len(hists, HISTC_PARALLELISM, 11); 210 211 hists__new_col_len(hists, HISTC_CPU, 3); 211 212 hists__new_col_len(hists, HISTC_SOCKET, 6); 212 213 hists__new_col_len(hists, HISTC_MEM_LOCKED, 6); ··· 742 741 .ip = al->addr, 743 742 .level = al->level, 744 743 .code_page_size = sample->code_page_size, 744 + .parallelism = al->parallelism, 745 745 .stat = { 746 746 .nr_events = 1, 747 747 .period = sample->period,
+3
tools/perf/util/hist.h
··· 42 42 HISTC_CGROUP_ID, 43 43 HISTC_CGROUP, 44 44 HISTC_PARENT, 45 + HISTC_PARALLELISM, 45 46 HISTC_CPU, 46 47 HISTC_SOCKET, 47 48 HISTC_SRCLINE, ··· 229 228 u64 transaction; 230 229 s32 socket; 231 230 s32 cpu; 231 + int parallelism; 232 232 u64 code_page_size; 233 233 u64 weight; 234 234 u64 ins_lat; ··· 582 580 bool perf_hpp__is_comm_entry(struct perf_hpp_fmt *fmt); 583 581 bool perf_hpp__is_dso_entry(struct perf_hpp_fmt *fmt); 584 582 bool perf_hpp__is_sym_entry(struct perf_hpp_fmt *fmt); 583 + bool perf_hpp__is_parallelism_entry(struct perf_hpp_fmt *fmt); 585 584 586 585 struct perf_hpp_fmt *perf_hpp_fmt__dup(struct perf_hpp_fmt *fmt); 587 586
+12
tools/perf/util/session.c
··· 2439 2439 return false; 2440 2440 } 2441 2441 2442 + bool perf_session__has_switch_events(struct perf_session *session) 2443 + { 2444 + struct evsel *evsel; 2445 + 2446 + evlist__for_each_entry(session->evlist, evsel) { 2447 + if (evsel->core.attr.context_switch) 2448 + return true; 2449 + } 2450 + 2451 + return false; 2452 + } 2453 + 2442 2454 int map__set_kallsyms_ref_reloc_sym(struct map *map, const char *symbol_name, u64 addr) 2443 2455 { 2444 2456 char *bracket;
+1
tools/perf/util/session.h
··· 141 141 struct symbol **parent); 142 142 143 143 bool perf_session__has_traces(struct perf_session *session, const char *msg); 144 + bool perf_session__has_switch_events(struct perf_session *session); 144 145 145 146 void perf_event__attr_swap(struct perf_event_attr *attr); 146 147
+23
tools/perf/util/sort.c
··· 892 892 .se_width_idx = HISTC_CPU, 893 893 }; 894 894 895 + /* --sort parallelism */ 896 + 897 + static int64_t 898 + sort__parallelism_cmp(struct hist_entry *left, struct hist_entry *right) 899 + { 900 + return right->parallelism - left->parallelism; 901 + } 902 + 903 + static int hist_entry__parallelism_snprintf(struct hist_entry *he, char *bf, 904 + size_t size, unsigned int width) 905 + { 906 + return repsep_snprintf(bf, size, "%*d", width, he->parallelism); 907 + } 908 + 909 + struct sort_entry sort_parallelism = { 910 + .se_header = "Parallelism", 911 + .se_cmp = sort__parallelism_cmp, 912 + .se_snprintf = hist_entry__parallelism_snprintf, 913 + .se_width_idx = HISTC_PARALLELISM, 914 + }; 915 + 895 916 /* --sort cgroup_id */ 896 917 897 918 static int64_t _sort__cgroup_dev_cmp(u64 left_dev, u64 right_dev) ··· 2555 2534 DIM(SORT_ANNOTATE_DATA_TYPE_OFFSET, "typeoff", sort_type_offset), 2556 2535 DIM(SORT_SYM_OFFSET, "symoff", sort_sym_offset), 2557 2536 DIM(SORT_ANNOTATE_DATA_TYPE_CACHELINE, "typecln", sort_type_cacheline), 2537 + DIM(SORT_PARALLELISM, "parallelism", sort_parallelism), 2558 2538 }; 2559 2539 2560 2540 #undef DIM ··· 2757 2735 MK_SORT_ENTRY_CHK(comm) 2758 2736 MK_SORT_ENTRY_CHK(dso) 2759 2737 MK_SORT_ENTRY_CHK(sym) 2738 + MK_SORT_ENTRY_CHK(parallelism) 2760 2739 2761 2740 2762 2741 static bool __sort__hpp_equal(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b)
+1
tools/perf/util/sort.h
··· 72 72 SORT_ANNOTATE_DATA_TYPE_OFFSET, 73 73 SORT_SYM_OFFSET, 74 74 SORT_ANNOTATE_DATA_TYPE_CACHELINE, 75 + SORT_PARALLELISM, 75 76 76 77 /* branch stack specific sort keys */ 77 78 __SORT_BRANCH_STACK,