lkml.org 
[lkml]   [2023]   [Jan]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 3/8] perf/core: Add perf_sample_save_raw_data() helper
Hi Song,

On Fri, Jan 13, 2023 at 1:01 PM Song Liu <song@kernel.org> wrote:
>
> On Thu, Jan 12, 2023 at 1:40 PM Namhyung Kim <namhyung@kernel.org> wrote:
> >
> > When it saves the raw_data to the perf sample data, it needs to update
> > the sample flags and the dynamic size. To make sure this, add the
> > perf_sample_save_raw_data() helper and convert all call sites.
> >
> > Cc: linux-s390@vger.kernel.org
> > Cc: x86@kernel.org
> > Cc: bpf@vger.kernel.org
> > Suggested-by: Peter Zijlstra <peterz@infradead.org>
> > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> > ---

[SNIP]
> > diff --git a/kernel/events/core.c b/kernel/events/core.c
> > index 0fba98b9cd65..133894ae5e30 100644
> > --- a/kernel/events/core.c
> > +++ b/kernel/events/core.c
> > @@ -7588,30 +7588,10 @@ void perf_prepare_sample(struct perf_event_header *header,
> > if (filtered_sample_type & PERF_SAMPLE_CALLCHAIN)
> > perf_sample_save_callchain(data, event, regs);
> >
> > - if (sample_type & PERF_SAMPLE_RAW) {
> > - struct perf_raw_record *raw = data->raw;
> > - int size;
> > -
> > - if (raw && (data->sample_flags & PERF_SAMPLE_RAW)) {
> > - struct perf_raw_frag *frag = &raw->frag;
> > - u32 sum = 0;
> > -
> > - do {
> > - sum += frag->size;
> > - if (perf_raw_frag_last(frag))
> > - break;
> > - frag = frag->next;
> > - } while (1);
> > -
> > - size = round_up(sum + sizeof(u32), sizeof(u64));
> > - raw->size = size - sizeof(u32);
> > - frag->pad = raw->size - sum;
> > - } else {
> > - size = sizeof(u64);
> > - data->raw = NULL;
> > - }
> > -
> > - data->dyn_size += size;
> > + if (filtered_sample_type & PERF_SAMPLE_RAW) {
> > + data->raw = NULL;
> > + data->dyn_size += sizeof(u64);
> > + data->sample_flags |= PERF_SAMPLE_RAW;
> > }
>
> I don't quite follow this change, and the commit log doesn't seem
> to cover this part.

It's for when the user requested RAW but no actual data.
It assumes PMU drivers call perf_sample_save_raw_data()
before perf_prepare_sample() if there's RAW data.
So we can only handle the 'else' part in the original code.

Thanks,
Namhyung

\
 
 \ /
  Last update: 2023-03-26 23:41    [W:0.055 / U:0.236 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site