Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cee75ac7 authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo
Browse files

perf hist: Clarify events_stats fields usage



The events_stats.total field is too generic, rename it to .total_period,
and also add a comment explaining that it is the sum of all the .period
fields in samples, that is needed because we use auto-freq to avoid
sampling artifacts.

Ditto for events_stats.lost, that is the sum of all lost_event.lost
fields, i.e. the number of events the kernel dropped.

Looking at the users, builtin-sched.c can make use of these fields and
stop doing it again.

Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <new-submission>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent c8446b9b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ static int diff__process_sample_event(event_t *event, struct perf_session *sessi
		return -1;
	}

	session->hists.stats.total += data.period;
	session->hists.stats.total_period += data.period;
	return 0;
}

+4 −4
Original line number Diff line number Diff line
@@ -138,14 +138,14 @@ static int add_event_total(struct perf_session *session,
	if (!hists)
		return -ENOMEM;

	hists->stats.total += data->period;
	hists->stats.total_period += data->period;
	/*
	 * FIXME: add_event_total should be moved from here to
	 * perf_session__process_event so that the proper hist is passed to
	 * the event_op methods.
	 */
	hists__inc_nr_events(hists, PERF_RECORD_SAMPLE);
	session->hists.stats.total += data->period;
	session->hists.stats.total_period += data->period;
	return 0;
}

@@ -322,10 +322,10 @@ static int __cmd_report(void)
			if (rb_first(&session->hists.entries) ==
			    rb_last(&session->hists.entries))
				fprintf(stdout, "# Samples: %Ld\n#\n",
					hists->stats.total);
					hists->stats.total_period);
			else
				fprintf(stdout, "# Samples: %Ld %s\n#\n",
					hists->stats.total,
					hists->stats.total_period,
					__event_name(hists->type, hists->config));

			hists__fprintf(hists, NULL, false, stdout);
+6 −11
Original line number Diff line number Diff line
@@ -1641,19 +1641,10 @@ static int process_sample_event(event_t *event, struct perf_session *session)
	return 0;
}

static int process_lost_event(event_t *event __used,
			      struct perf_session *session __used)
{
	nr_lost_chunks++;
	nr_lost_events += event->lost.lost;

	return 0;
}

static struct perf_event_ops event_ops = {
	.sample			= process_sample_event,
	.comm			= event__process_comm,
	.lost			= process_lost_event,
	.lost			= event__process_lost,
	.ordered_samples	= true,
};

@@ -1664,8 +1655,12 @@ static int read_events(void)
	if (session == NULL)
		return -ENOMEM;

	if (perf_session__has_traces(session, "record -R"))
	if (perf_session__has_traces(session, "record -R")) {
		err = perf_session__process_events(session, &event_ops);
		nr_events      = session->hists.stats.nr_events[0];
		nr_lost_events = session->hists.stats.total_lost;
		nr_lost_chunks = session->hists.stats.nr_events[PERF_RECORD_LOST];
	}

	perf_session__delete(session);
	return err;
+1 −1
Original line number Diff line number Diff line
@@ -109,7 +109,7 @@ static int process_sample_event(event_t *event, struct perf_session *session)
					     data.time, thread->comm);
	}

	session->hists.stats.total += data.period;
	session->hists.stats.total_period += data.period;
	return 0;
}

+1 −1
Original line number Diff line number Diff line
@@ -385,7 +385,7 @@ int event__process_comm(event_t *self, struct perf_session *session)
int event__process_lost(event_t *self, struct perf_session *session)
{
	dump_printf(": id:%Ld: lost:%Ld\n", self->lost.id, self->lost.lost);
	session->hists.stats.lost += self->lost.lost;
	session->hists.stats.total_lost += self->lost.lost;
	return 0;
}

Loading