All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <olsajiri@gmail.com>
To: Namhyung Kim <namhyung@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>,
	LKML <linux-kernel@vger.kernel.org>, Song Liu <song@kernel.org>,
	bpf@vger.kernel.org
Subject: Re: [PATCHSET 0/8] perf/core: Prepare sample data for BPF
Date: Fri, 13 Jan 2023 14:25:55 +0100	[thread overview]
Message-ID: <Y8Fb45iZ5yp3TUDD@krava> (raw)
In-Reply-To: <20230112214015.1014857-1-namhyung@kernel.org>

On Thu, Jan 12, 2023 at 01:40:07PM -0800, Namhyung Kim wrote:
> Hello,
> 
> The perf_prepare_sample() is to fill the perf sample data and update the
> header info before sending it to the ring buffer.  But we want to use it
> for BPF overflow handler so that it can access the sample data to filter
> relevant ones.
> 
> Changes in v2)
>  * the layout change is merged
>  * reduce branches using __cond_set  (PeterZ)
>  * add helpers to set dynamic sample data  (PeterZ)
>  * introduce perf_prepare_header()  (PeterZ)
>  * call perf_prepare_sample() before bpf_overflow_handler unconditionally
> 
> This means the perf_prepare_handler() can be called more than once.  To
> avoid duplicate work, use the data->sample_flags and save the data size.
> 
> I also added a few of helpers to set those information accordingly.
> But it looks some fields like REGS_USER, STACK_USER and AUX are saved in
> the perf_prepare_sample() so I didn't add the helpers for them.
> 
> After than we can just check the filtered_sample_type flags begin zero
> to determine if it has more work.  In that case, it needs to update the
> data->type since it's possible to miss when PMU driver sets all required
> sample flags before calling perf_prepare_sample().
> 
> The code is also available at 'perf/prepare-sample-v2' branch in
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git
> 
> Thanks,
> Namhyung
> 
> 
> Cc: Song Liu <song@kernel.org>
> Cc: bpf@vger.kernel.org
> 
> 
> Namhyung Kim (8):
>   perf/core: Save the dynamic parts of sample data size
>   perf/core: Add perf_sample_save_callchain() helper
>   perf/core: Add perf_sample_save_raw_data() helper
>   perf/core: Add perf_sample_save_brstack() helper
>   perf/core: Set data->sample_flags in perf_prepare_sample()
>   perf/core: Do not pass header for sample id init
>   perf/core: Introduce perf_prepare_header()
>   perf/core: Call perf_prepare_sample() before running BPF

lgtm, I ran the bpf selftests on top of that and it's ok

jirka

> 
>  arch/powerpc/perf/core-book3s.c    |   3 +-
>  arch/s390/kernel/perf_cpum_cf.c    |   4 +-
>  arch/s390/kernel/perf_cpum_sf.c    |   3 +-
>  arch/s390/kernel/perf_pai_crypto.c |   4 +-
>  arch/s390/kernel/perf_pai_ext.c    |   4 +-
>  arch/x86/events/amd/core.c         |   6 +-
>  arch/x86/events/amd/ibs.c          |   9 +-
>  arch/x86/events/intel/core.c       |   6 +-
>  arch/x86/events/intel/ds.c         |  24 ++--
>  include/linux/perf_event.h         | 133 +++++++++++++-----
>  kernel/events/core.c               | 207 ++++++++++++++++-------------
>  kernel/trace/bpf_trace.c           |   6 +-
>  12 files changed, 236 insertions(+), 173 deletions(-)
> 
> 
> base-commit: 9fcad995c6c52cc9791f7ee9f1386a5684055f9c
> -- 
> 2.39.0.314.g84b9a713c41-goog
> 

  parent reply	other threads:[~2023-01-13 13:33 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
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   ` 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 [this message]
2023-01-17  8:12   ` 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=Y8Fb45iZ5yp3TUDD@krava \
    --to=olsajiri@gmail.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=bpf@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=song@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.