[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAPhsuW5xqgG=6VVGaaStHYRNAO=rB=mL7YALWN89r8Wf+0M5sA@mail.gmail.com>
Date: Fri, 13 Jan 2023 14:57:17 -0800
From: Song Liu <song@...nel.org>
To: Namhyung Kim <namhyung@...nel.org>
Cc: Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Jiri Olsa <jolsa@...nel.org>,
LKML <linux-kernel@...r.kernel.org>, linux-s390@...r.kernel.org,
x86@...nel.org, bpf@...r.kernel.org
Subject: Re: [PATCH 3/8] perf/core: Add perf_sample_save_raw_data() helper
On Fri, Jan 13, 2023 at 1:56 PM Namhyung Kim <namhyung@...nel.org> wrote:
>
> Hi Song,
>
> On Fri, Jan 13, 2023 at 1:01 PM Song Liu <song@...nel.org> wrote:
> >
> > On Thu, Jan 12, 2023 at 1:40 PM Namhyung Kim <namhyung@...nel.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@...r.kernel.org
> > > Cc: x86@...nel.org
> > > Cc: bpf@...r.kernel.org
> > > Suggested-by: Peter Zijlstra <peterz@...radead.org>
> > > Signed-off-by: Namhyung Kim <namhyung@...nel.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.
Got it. Thanks for the explanation.
Song
Powered by blists - more mailing lists