Skip to content

Commit d24e3c9

Browse files
olsajiriacmel
authored andcommitted
perf top: Save and display the lost count stats
Add a 'lost count' to 'perf top' headers: # perf top --stdio PerfTop: 3850 irqs/sec kernel:49.0% exact: 100.0% lost: 0/0 [4000Hz cycles:ppp], (all, 8 CPUs) # perf top Samples: 0 of event 'cycles:ppp', 4000 Hz, Event count (approx.): 0 lost: 0/0 The format is: <current period lost>/<total lost> Signed-off-by: Jiri Olsa <[email protected]> Acked-by: David S. Miller <[email protected]> Acked-by: Namhyung Kim <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: https://lkml.kernel.org/n/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent a4a6668 commit d24e3c9

File tree

4 files changed

+35
-4
lines changed

4 files changed

+35
-4
lines changed

tools/perf/builtin-top.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,29 @@ static void perf_event__process_sample(struct perf_tool *tool,
800800
addr_location__put(&al);
801801
}
802802

803+
static void
804+
perf_top__process_lost(struct perf_top *top, union perf_event *event,
805+
struct perf_evsel *evsel)
806+
{
807+
struct hists *hists = evsel__hists(evsel);
808+
809+
top->lost += event->lost.lost;
810+
top->lost_total += event->lost.lost;
811+
hists->stats.total_lost += event->lost.lost;
812+
}
813+
814+
static void
815+
perf_top__process_lost_samples(struct perf_top *top,
816+
union perf_event *event,
817+
struct perf_evsel *evsel)
818+
{
819+
struct hists *hists = evsel__hists(evsel);
820+
821+
top->lost += event->lost_samples.lost;
822+
top->lost_total += event->lost_samples.lost;
823+
hists->stats.total_lost_samples += event->lost_samples.lost;
824+
}
825+
803826
static void perf_top__mmap_read_idx(struct perf_top *top, int idx)
804827
{
805828
struct record_opts *opts = &top->record_opts;
@@ -865,6 +888,10 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx)
865888
if (event->header.type == PERF_RECORD_SAMPLE) {
866889
perf_event__process_sample(&top->tool, event, evsel,
867890
&sample, machine);
891+
} else if (event->header.type == PERF_RECORD_LOST) {
892+
perf_top__process_lost(top, event, evsel);
893+
} else if (event->header.type == PERF_RECORD_LOST_SAMPLES) {
894+
perf_top__process_lost_samples(top, event, evsel);
868895
} else if (event->header.type < PERF_RECORD_MAX) {
869896
hists__inc_nr_events(evsel__hists(evsel), event->header.type);
870897
machine__process_event(machine, event, &sample);

tools/perf/ui/browsers/hists.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2219,6 +2219,10 @@ static int hists_browser__scnprintf_title(struct hist_browser *browser, char *bf
22192219
if (!is_report_browser(hbt)) {
22202220
struct perf_top *top = hbt->arg;
22212221

2222+
printed += scnprintf(bf + printed, size - printed,
2223+
" lost: %" PRIu64 "/%" PRIu64,
2224+
top->lost, top->lost_total);
2225+
22222226
if (top->zero)
22232227
printed += scnprintf(bf + printed, size - printed, " [z]");
22242228
}

tools/perf/util/top.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ size_t perf_top__header_snprintf(struct perf_top *top, char *bf, size_t size)
4646
samples_per_sec;
4747
ret = SNPRINTF(bf, size,
4848
" PerfTop:%8.0f irqs/sec kernel:%4.1f%%"
49-
" exact: %4.1f%% [", samples_per_sec,
50-
ksamples_percent, esamples_percent);
49+
" exact: %4.1f%% lost: %" PRIu64 "/%" PRIu64 " [", samples_per_sec,
50+
ksamples_percent, esamples_percent, top->lost, top->lost_total);
5151
} else {
5252
float us_samples_per_sec = top->us_samples / top->delay_secs;
5353
float guest_kernel_samples_per_sec = top->guest_kernel_samples / top->delay_secs;
@@ -113,5 +113,5 @@ void perf_top__reset_sample_counters(struct perf_top *top)
113113
{
114114
top->samples = top->us_samples = top->kernel_samples =
115115
top->exact_samples = top->guest_kernel_samples =
116-
top->guest_us_samples = 0;
116+
top->guest_us_samples = top->lost = 0;
117117
}

tools/perf/util/top.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct perf_top {
2222
* Symbols will be added here in perf_event__process_sample and will
2323
* get out after decayed.
2424
*/
25-
u64 samples;
25+
u64 samples, lost, lost_total;
2626
u64 kernel_samples, us_samples;
2727
u64 exact_samples;
2828
u64 guest_us_samples, guest_kernel_samples;

0 commit comments

Comments
 (0)