Re: [PATCH V8 7/8] perf, x86: introduce PERF_RECORD_LOST_SAMPLES

From: Arnaldo Carvalho de Melo
Date: Thu May 07 2015 - 16:01:33 EST


Em Thu, May 07, 2015 at 07:37:50PM +0200, Peter Zijlstra escreveu:
> On Thu, May 07, 2015 at 01:22:23PM -0300, Arnaldo Carvalho de Melo wrote:
> > Em Thu, May 07, 2015 at 04:39:39PM +0200, Peter Zijlstra escreveu:
> > > On Thu, May 07, 2015 at 11:15:20AM -0300, Arnaldo Carvalho de Melo wrote:
> > > > Em Thu, May 07, 2015 at 01:54:46PM +0200, Peter Zijlstra escreveu:
> > > > > On Thu, May 07, 2015 at 01:35:24PM +0200, Peter Zijlstra wrote:
> > > > > >
> > > > > > - dropped the @id field from the record, it is already included in the
> > > > > > @sample_id values.
> > > > >
> > > > > Hmm, this would force people to use sample_id; which in general is a
> > > > > good idea, but should we really force that on people?
> > > >
> > > > Well, if there are more than one sample, we need it, right? If there is
> > > > just one, we don't need it, what is different? Am I needing (even more)
> > > > coffee?
> > > >
> > > > /me goes read some code...
> > >
> > > So the question was, do we do:
> > >
> > > /*
> > > * struct {
> > > * struct perf_event_header header;
> > > * u64 id;
> > > * u64 lost;
> > > * struct sample_id sample_id;
> > > * };
> > > */
> > > PERF_RECORD_LOST_SAMPLES
> > >
> > > And have the id thing twice if attr.sample_id && PERF_SAMPLE_ID, but
> > > allow decoding if !attr.sample_id.
> > >
> > > Or force attr.sample_id && PERF_SAMPLE_ID if there's multiple events and
> > > do away with the extra id field, like:
> > >
> > > /*
> > > * struct {
> > > * struct perf_event_header header;
> > > * u64 lost;
> > > * struct sample_id sample_id;
> > > * };
> > > */
> > > PERF_RECORD_LOST_SAMPLES
> > >
> > > Should we force the use of sample_id on people?
> >
> > If we have more than one event we _need_ PERF_SAMPLE_ID, to
> > disambiguate, if we don't, then the lost events are just for that one,
> > no?

> Sure, PERF_SAMPLE_ID is required, but attr::sample_id_all is not is it?
>
> We can largely get by without using sample_id_all, as we did for a
> while.

> That said; sample_id_all has been around for more than 4 years and its
> recommended for use; but should we mandate it?

Got it now, to have PERF_SAMPLE_ID(ENTIFIER) in records !=
PERF_RECORD_SAMPLE when multiplexing more than one event on a ring
buffer, one would have to set attr.sample_id_all.

So, if we have just one event, we don't need sample_id_all (but we will
end up using it to have PERF_SAMPLE_TIME, to order metadata events
accross CPUs), we also don't need PERF_SAMPLE_ID, and we don't need to
have the u64 id in the PERF_RECORD_LOST_SAMPLE, no?

- Arnaldo


Below is some rambling, thinking out loud, ignore it if you want.

The attr::sample_id_all thing was more to be able to have
PERF_SAMPLE_TIME, and with that be able to order metadata events
together with PERF_SAMPLE_TIME, where we can ask for PERF_SAMPLE_TIME.

PERF_SAMPLE_ID(ENTIFIER) is about mapping back a PERF_RECORD_SAMPLE to
an event, with this it would also be used to figure out what event is
getting samples LOST, so I think the same semantic applies, i.e. if we
mux more than one event in a ring buffer, then PERF_RECORD_SAMPLE _and_
PERF_RECORD_LOST_SAMPLES should use the same mechanism _when we need to
disambiguate_, right?

I.e. those 8 bytes would only be required when we have more than one
event.

What downsides would we have if we used attr.sample_id_all +
PERF_SAMPLE_ID(ENTIFIER) to figure out what event the
PERF_RECORD_LOST_SAMPLES refers to?

Looking at
__perf_event__output_id_sample(kernel)/perf_evsel__parse_id_sample(tools)
we only insert/parse:

if (type & PERF_SAMPLE_IDENTIFIER) {
if (type & PERF_SAMPLE_CPU) {
if (type & PERF_SAMPLE_STREAM_ID) {
if (type & PERF_SAMPLE_ID) {
if (type & PERF_SAMPLE_TIME) {
if (type & PERF_SAMPLE_TID) {

- Arnaldo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/