From: Namhyung Kim <namhyung@kernel.org>
To: Song Liu <song@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Jiri Olsa <jolsa@kernel.org>, LKML <linux-kernel@vger.kernel.org>,
linux-s390@vger.kernel.org, x86@kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH 3/8] perf/core: Add perf_sample_save_raw_data() helper
Date: Fri, 13 Jan 2023 13:56:36 -0800 [thread overview]
Message-ID: <CAM9d7ciPAocvOvspzfrq2hym-u2+Fbg2A6WJhOQqxwG7CGiuJg@mail.gmail.com> (raw)
In-Reply-To: <CAPhsuW71GHAayZmGFfSrpCARiD3YEO1C8QBy1cc1ZEuSFJB=sA@mail.gmail.com>
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
next prev parent reply other threads:[~2023-01-13 21:56 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-12 21:40 [PATCHSET 0/8] perf/core: Prepare sample data for BPF Namhyung Kim
2023-01-12 21:40 ` [PATCH 1/8] perf/core: Save the dynamic parts of sample data size Namhyung Kim
2023-01-13 20:44 ` Song Liu
2023-01-12 21:40 ` [PATCH 2/8] perf/core: Add perf_sample_save_callchain() helper Namhyung Kim
2023-01-13 20:45 ` Song Liu
2023-01-12 21:40 ` [PATCH 3/8] perf/core: Add perf_sample_save_raw_data() helper Namhyung Kim
2023-01-13 11:19 ` Peter Zijlstra
2023-01-13 21:01 ` Song Liu
2023-01-13 21:56 ` Namhyung Kim [this message]
2023-01-13 22:57 ` Song Liu
2023-01-12 21:40 ` [PATCH 4/8] perf/core: Add perf_sample_save_brstack() helper Namhyung Kim
2023-01-12 21:40 ` [PATCH 5/8] perf/core: Set data->sample_flags in perf_prepare_sample() Namhyung Kim
2023-01-13 11:20 ` Peter Zijlstra
2023-01-13 19:31 ` Namhyung Kim
2023-01-12 21:40 ` [PATCH 6/8] perf/core: Do not pass header for sample id init Namhyung Kim
2023-01-13 21:07 ` Song Liu
2023-01-12 21:40 ` [PATCH 7/8] perf/core: Introduce perf_prepare_header() Namhyung Kim
2023-01-13 21:06 ` Song Liu
2023-01-12 21:40 ` [PATCH 8/8] perf/core: Call perf_prepare_sample() before running BPF Namhyung Kim
2023-01-13 21:06 ` Song Liu
2023-01-13 11:21 ` [PATCHSET 0/8] perf/core: Prepare sample data for BPF Peter Zijlstra
2023-01-13 13:25 ` Jiri Olsa
2023-01-17 8:12 ` Namhyung Kim
2023-01-18 6:05 [PATCHSET 0/8] perf/core: Prepare sample data for BPF (v3) Namhyung Kim
2023-01-18 6:05 ` [PATCH 3/8] perf/core: Add perf_sample_save_raw_data() helper Namhyung Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAM9d7ciPAocvOvspzfrq2hym-u2+Fbg2A6WJhOQqxwG7CGiuJg@mail.gmail.com \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=bpf@vger.kernel.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=song@kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).