Re: [PATCH 1/2] perf: Use sample_flags for addr

From: Namhyung Kim
Date: Thu Sep 22 2022 - 12:32:37 EST


Hi Peter,

On Thu, Sep 22, 2022 at 7:48 AM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>
> On Wed, Sep 21, 2022 at 03:00:31PM -0700, Namhyung Kim wrote:
> > Use the new sample_flags to indicate whether the addr field is filled by
> > the PMU driver. As most PMU drivers pass 0, it can set the flag only if
> > it has a non-zero value. And use 0 in perf_sample_output() if it's not
> > filled already.
>
> So no objection to the general idea; just a question
>
> > diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
> > index 368bdc4f563f..f4a13579b0e8 100644
> > --- a/include/linux/perf_event.h
> > +++ b/include/linux/perf_event.h
> > @@ -1028,7 +1028,6 @@ struct perf_sample_data {
> > * minimize the cachelines touched.
> > */
> > u64 sample_flags;
> > - u64 addr;
> > struct perf_raw_record *raw;
> > u64 period;
> >
> > @@ -1040,6 +1039,7 @@ struct perf_sample_data {
> > union perf_sample_weight weight;
> > union perf_mem_data_src data_src;
> > u64 txn;
> > + u64 addr;
> >
> > u64 type;
> > u64 ip;
>
> Is there a reason you placed the variable where you did?

No I just followed the previous change.

>
> I'm thinking we should look at what perf-tool thinks is the common set
> of SAMPLE flags and make sure those fields are grouped in as little
> cachelines as possible.
>
> Things like @ip and @type, which are basically *always* set, should
> definitely be on top, no?

Yes, you're right. With this change we can move the optional fields
and group the common fields on top - like ip, period, pid and so on.

Will send a patch to do the move on top of this, ok?

Thanks,
Namhyung