Commit 411ee135 authored by Namhyung Kim's avatar Namhyung Kim

perf hist: Add symbol_conf.skip_empty

Add the skip_empty flag to symbol_conf and set the value from the report
command to preserve the existing behavior.  This makes the code simpler
and will be needed other code which is hard to add a new argument.
Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240607202918.2357459-4-namhyung@kernel.org
parent 8f6071a3
...@@ -571,8 +571,8 @@ static int __cmd_annotate(struct perf_annotate *ann) ...@@ -571,8 +571,8 @@ static int __cmd_annotate(struct perf_annotate *ann)
goto out; goto out;
if (dump_trace) { if (dump_trace) {
perf_session__fprintf_nr_events(session, stdout, false); perf_session__fprintf_nr_events(session, stdout);
evlist__fprintf_nr_events(session->evlist, stdout, false); evlist__fprintf_nr_events(session->evlist, stdout);
goto out; goto out;
} }
......
...@@ -810,8 +810,8 @@ static int stats_print(struct report *rep) ...@@ -810,8 +810,8 @@ static int stats_print(struct report *rep)
{ {
struct perf_session *session = rep->session; struct perf_session *session = rep->session;
perf_session__fprintf_nr_events(session, stdout, rep->skip_empty); perf_session__fprintf_nr_events(session, stdout);
evlist__fprintf_nr_events(session->evlist, stdout, rep->skip_empty); evlist__fprintf_nr_events(session->evlist, stdout);
return 0; return 0;
} }
...@@ -1089,10 +1089,8 @@ static int __cmd_report(struct report *rep) ...@@ -1089,10 +1089,8 @@ static int __cmd_report(struct report *rep)
perf_session__fprintf_dsos(session, stdout); perf_session__fprintf_dsos(session, stdout);
if (dump_trace) { if (dump_trace) {
perf_session__fprintf_nr_events(session, stdout, perf_session__fprintf_nr_events(session, stdout);
rep->skip_empty); evlist__fprintf_nr_events(session->evlist, stdout);
evlist__fprintf_nr_events(session->evlist, stdout,
rep->skip_empty);
return 0; return 0;
} }
} }
...@@ -1562,6 +1560,8 @@ int cmd_report(int argc, const char **argv) ...@@ -1562,6 +1560,8 @@ int cmd_report(int argc, const char **argv)
data.path = input_name; data.path = input_name;
data.force = symbol_conf.force; data.force = symbol_conf.force;
symbol_conf.skip_empty = report.skip_empty;
repeat: repeat:
session = perf_session__new(&data, &report.tool); session = perf_session__new(&data, &report.tool);
if (IS_ERR(session)) { if (IS_ERR(session)) {
......
...@@ -897,8 +897,7 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows, ...@@ -897,8 +897,7 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
return ret; return ret;
} }
size_t events_stats__fprintf(struct events_stats *stats, FILE *fp, size_t events_stats__fprintf(struct events_stats *stats, FILE *fp)
bool skip_empty)
{ {
int i; int i;
size_t ret = 0; size_t ret = 0;
...@@ -910,7 +909,7 @@ size_t events_stats__fprintf(struct events_stats *stats, FILE *fp, ...@@ -910,7 +909,7 @@ size_t events_stats__fprintf(struct events_stats *stats, FILE *fp,
name = perf_event__name(i); name = perf_event__name(i);
if (!strcmp(name, "UNKNOWN")) if (!strcmp(name, "UNKNOWN"))
continue; continue;
if (skip_empty && !stats->nr_events[i]) if (symbol_conf.skip_empty && !stats->nr_events[i])
continue; continue;
if (i && total) { if (i && total) {
......
...@@ -52,7 +52,6 @@ struct hists_stats { ...@@ -52,7 +52,6 @@ struct hists_stats {
void events_stats__inc(struct events_stats *stats, u32 type); void events_stats__inc(struct events_stats *stats, u32 type);
size_t events_stats__fprintf(struct events_stats *stats, FILE *fp, size_t events_stats__fprintf(struct events_stats *stats, FILE *fp);
bool skip_empty);
#endif /* __PERF_EVENTS_STATS_ */ #endif /* __PERF_EVENTS_STATS_ */
...@@ -2706,8 +2706,7 @@ void hist__account_cycles(struct branch_stack *bs, struct addr_location *al, ...@@ -2706,8 +2706,7 @@ void hist__account_cycles(struct branch_stack *bs, struct addr_location *al,
} }
} }
size_t evlist__fprintf_nr_events(struct evlist *evlist, FILE *fp, size_t evlist__fprintf_nr_events(struct evlist *evlist, FILE *fp)
bool skip_empty)
{ {
struct evsel *pos; struct evsel *pos;
size_t ret = 0; size_t ret = 0;
...@@ -2715,7 +2714,8 @@ size_t evlist__fprintf_nr_events(struct evlist *evlist, FILE *fp, ...@@ -2715,7 +2714,8 @@ size_t evlist__fprintf_nr_events(struct evlist *evlist, FILE *fp,
evlist__for_each_entry(evlist, pos) { evlist__for_each_entry(evlist, pos) {
struct hists *hists = evsel__hists(pos); struct hists *hists = evsel__hists(pos);
if (skip_empty && !hists->stats.nr_samples && !hists->stats.nr_lost_samples) if (symbol_conf.skip_empty && !hists->stats.nr_samples &&
!hists->stats.nr_lost_samples)
continue; continue;
ret += fprintf(fp, "%s stats:\n", evsel__name(pos)); ret += fprintf(fp, "%s stats:\n", evsel__name(pos));
......
...@@ -375,8 +375,7 @@ void hists__inc_nr_lost_samples(struct hists *hists, u32 lost); ...@@ -375,8 +375,7 @@ void hists__inc_nr_lost_samples(struct hists *hists, u32 lost);
size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows, size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
int max_cols, float min_pcnt, FILE *fp, int max_cols, float min_pcnt, FILE *fp,
bool ignore_callchains); bool ignore_callchains);
size_t evlist__fprintf_nr_events(struct evlist *evlist, FILE *fp, size_t evlist__fprintf_nr_events(struct evlist *evlist, FILE *fp);
bool skip_empty);
void hists__filter_by_dso(struct hists *hists); void hists__filter_by_dso(struct hists *hists);
void hists__filter_by_thread(struct hists *hists); void hists__filter_by_thread(struct hists *hists);
......
...@@ -2696,8 +2696,7 @@ size_t perf_session__fprintf_dsos_buildid(struct perf_session *session, FILE *fp ...@@ -2696,8 +2696,7 @@ size_t perf_session__fprintf_dsos_buildid(struct perf_session *session, FILE *fp
return machines__fprintf_dsos_buildid(&session->machines, fp, skip, parm); return machines__fprintf_dsos_buildid(&session->machines, fp, skip, parm);
} }
size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp, size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp)
bool skip_empty)
{ {
size_t ret; size_t ret;
const char *msg = ""; const char *msg = "";
...@@ -2707,7 +2706,7 @@ size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp, ...@@ -2707,7 +2706,7 @@ size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp,
ret = fprintf(fp, "\nAggregated stats:%s\n", msg); ret = fprintf(fp, "\nAggregated stats:%s\n", msg);
ret += events_stats__fprintf(&session->evlist->stats, fp, skip_empty); ret += events_stats__fprintf(&session->evlist->stats, fp);
return ret; return ret;
} }
......
...@@ -130,8 +130,7 @@ size_t perf_session__fprintf_dsos(struct perf_session *session, FILE *fp); ...@@ -130,8 +130,7 @@ size_t perf_session__fprintf_dsos(struct perf_session *session, FILE *fp);
size_t perf_session__fprintf_dsos_buildid(struct perf_session *session, FILE *fp, size_t perf_session__fprintf_dsos_buildid(struct perf_session *session, FILE *fp,
bool (fn)(struct dso *dso, int parm), int parm); bool (fn)(struct dso *dso, int parm), int parm);
size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp, size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp);
bool skip_empty);
void perf_session__dump_kmaps(struct perf_session *session); void perf_session__dump_kmaps(struct perf_session *session);
......
...@@ -46,7 +46,8 @@ struct symbol_conf { ...@@ -46,7 +46,8 @@ struct symbol_conf {
lazy_load_kernel_maps, lazy_load_kernel_maps,
keep_exited_threads, keep_exited_threads,
annotate_data_member, annotate_data_member,
annotate_data_sample; annotate_data_sample,
skip_empty;
const char *vmlinux_name, const char *vmlinux_name,
*kallsyms_name, *kallsyms_name,
*source_prefix, *source_prefix,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment