aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-report.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/builtin-report.c')
-rw-r--r--tools/perf/builtin-report.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index fe66895111b1..86981bd08f65 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -46,9 +46,12 @@ static int full_paths;
46static unsigned long page_size; 46static unsigned long page_size;
47static unsigned long mmap_window = 32; 47static unsigned long mmap_window = 32;
48 48
49static char *parent_pattern = "^sys_|^do_page_fault"; 49static char default_parent_pattern[] = "^sys_|^do_page_fault";
50static char *parent_pattern = default_parent_pattern;
50static regex_t parent_regex; 51static regex_t parent_regex;
51 52
53static int exclude_other = 1;
54
52struct ip_event { 55struct ip_event {
53 struct perf_event_header header; 56 struct perf_event_header header;
54 __u64 ip; 57 __u64 ip;
@@ -742,6 +745,9 @@ hist_entry__fprintf(FILE *fp, struct hist_entry *self, __u64 total_samples)
742 struct sort_entry *se; 745 struct sort_entry *se;
743 size_t ret; 746 size_t ret;
744 747
748 if (exclude_other && !self->parent)
749 return 0;
750
745 if (total_samples) { 751 if (total_samples) {
746 double percent = self->count * 100.0 / total_samples; 752 double percent = self->count * 100.0 / total_samples;
747 char *color = PERF_COLOR_NORMAL; 753 char *color = PERF_COLOR_NORMAL;
@@ -764,6 +770,9 @@ hist_entry__fprintf(FILE *fp, struct hist_entry *self, __u64 total_samples)
764 ret = fprintf(fp, "%12Ld ", self->count); 770 ret = fprintf(fp, "%12Ld ", self->count);
765 771
766 list_for_each_entry(se, &hist_entry__sort_list, list) { 772 list_for_each_entry(se, &hist_entry__sort_list, list) {
773 if (exclude_other && (se == &sort_parent))
774 continue;
775
767 fprintf(fp, " "); 776 fprintf(fp, " ");
768 ret += se->print(fp, self); 777 ret += se->print(fp, self);
769 } 778 }
@@ -855,6 +864,7 @@ hist_entry__add(struct thread *thread, struct map *map, struct dso *dso,
855 .ip = ip, 864 .ip = ip,
856 .level = level, 865 .level = level,
857 .count = count, 866 .count = count,
867 .parent = NULL,
858 }; 868 };
859 int cmp; 869 int cmp;
860 870
@@ -1029,14 +1039,20 @@ static size_t output__fprintf(FILE *fp, __u64 total_samples)
1029 fprintf(fp, "#\n"); 1039 fprintf(fp, "#\n");
1030 1040
1031 fprintf(fp, "# Overhead"); 1041 fprintf(fp, "# Overhead");
1032 list_for_each_entry(se, &hist_entry__sort_list, list) 1042 list_for_each_entry(se, &hist_entry__sort_list, list) {
1043 if (exclude_other && (se == &sort_parent))
1044 continue;
1033 fprintf(fp, " %s", se->header); 1045 fprintf(fp, " %s", se->header);
1046 }
1034 fprintf(fp, "\n"); 1047 fprintf(fp, "\n");
1035 1048
1036 fprintf(fp, "# ........"); 1049 fprintf(fp, "# ........");
1037 list_for_each_entry(se, &hist_entry__sort_list, list) { 1050 list_for_each_entry(se, &hist_entry__sort_list, list) {
1038 int i; 1051 int i;
1039 1052
1053 if (exclude_other && (se == &sort_parent))
1054 continue;
1055
1040 fprintf(fp, " "); 1056 fprintf(fp, " ");
1041 for (i = 0; i < strlen(se->header); i++) 1057 for (i = 0; i < strlen(se->header); i++)
1042 fprintf(fp, "."); 1058 fprintf(fp, ".");
@@ -1050,7 +1066,8 @@ static size_t output__fprintf(FILE *fp, __u64 total_samples)
1050 ret += hist_entry__fprintf(fp, pos, total_samples); 1066 ret += hist_entry__fprintf(fp, pos, total_samples);
1051 } 1067 }
1052 1068
1053 if (!strcmp(sort_order, default_sort_order)) { 1069 if (sort_order == default_sort_order &&
1070 parent_pattern == default_parent_pattern) {
1054 fprintf(fp, "#\n"); 1071 fprintf(fp, "#\n");
1055 fprintf(fp, "# (For more details, try: perf report --sort comm,dso,symbol)\n"); 1072 fprintf(fp, "# (For more details, try: perf report --sort comm,dso,symbol)\n");
1056 fprintf(fp, "#\n"); 1073 fprintf(fp, "#\n");
@@ -1508,6 +1525,8 @@ static const struct option options[] = {
1508 "Don't shorten the pathnames taking into account the cwd"), 1525 "Don't shorten the pathnames taking into account the cwd"),
1509 OPT_STRING('p', "parent", &parent_pattern, "regex", 1526 OPT_STRING('p', "parent", &parent_pattern, "regex",
1510 "regex filter to identify parent, see: '--sort parent'"), 1527 "regex filter to identify parent, see: '--sort parent'"),
1528 OPT_BOOLEAN('x', "exclude-other", &exclude_other,
1529 "Only display entries with parent-match"),
1511 OPT_END() 1530 OPT_END()
1512}; 1531};
1513 1532
@@ -1536,6 +1555,11 @@ int cmd_report(int argc, const char **argv, const char *prefix)
1536 1555
1537 setup_sorting(); 1556 setup_sorting();
1538 1557
1558 if (parent_pattern != default_parent_pattern)
1559 sort_dimension__add("parent");
1560 else
1561 exclude_other = 0;
1562
1539 /* 1563 /*
1540 * Any (unrecognized) arguments left? 1564 * Any (unrecognized) arguments left?
1541 */ 1565 */