All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Leo Yan <leo.yan@arm.com>, Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim	 <namhyung@kernel.org>, Jiri Olsa <jolsa@kernel.org>,
	Ian Rogers	 <irogers@google.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	KP Singh	 <kpsingh@kernel.org>,
	Matt Bobrowski <mattbobrowski@google.com>,
	Song Liu	 <song@kernel.org>, Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann	 <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Martin KaFai Lau	 <martin.lau@linux.dev>,
	Yonghong Song <yonghong.song@linux.dev>,
	John Fastabend	 <john.fastabend@gmail.com>,
	Stanislav Fomichev <sdf@fomichev.me>,
	Hao Luo	 <haoluo@google.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Masami Hiramatsu	 <mhiramat@kernel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	 James Clark <james.clark@linaro.org>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Mike Leach	 <mike.leach@linaro.org>
Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	 bpf@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH PATCH v2 v2 2/6] bpf: Add bpf_perf_event_aux_pause kfunc
Date: Mon, 21 Jul 2025 15:38:59 -0700	[thread overview]
Message-ID: <ac8266f19ecde10a49911192014dddf35b3b496d.camel@gmail.com> (raw)
In-Reply-To: <20250718-perf_aux_pause_resume_bpf_rebase-v2-2-992557b8fb16@arm.com>

On Fri, 2025-07-18 at 16:25 +0100, Leo Yan wrote:

[...]

> +__bpf_kfunc int bpf_perf_event_aux_pause(void *p__map, u64 flags, u32 pause)
> +{
> +	struct bpf_map *map = p__map;
> +	struct bpf_array *array = container_of(map, struct bpf_array, map);

Verifier makes sure that p__map is a not null pointer to an object of
type bpf_map, but it does not guarantee that the object is an instance
of bpf_array.
You need to check map->type, same way bpf_arena_alloc_pages() does.

> +	unsigned int cpu = smp_processor_id();
> +	u64 index = flags & BPF_F_INDEX_MASK;
> +	struct bpf_event_entry *ee;
> +	int ret = 0;
> +
> +	/* Disabling IRQ avoids race condition with perf event flows. */
> +	guard(irqsave)();
> +
> +	if (unlikely(flags & ~(BPF_F_INDEX_MASK))) {
> +		ret = -EINVAL;
> +		goto out;
> +	}
> +
> +	if (index == BPF_F_CURRENT_CPU)
> +		index = cpu;
> +
> +	if (unlikely(index >= array->map.max_entries)) {
> +		ret = -E2BIG;
> +		goto out;
> +	}
> +
> +	ee = READ_ONCE(array->ptrs[index]);
> +	if (!ee) {
> +		ret = -ENOENT;
> +		goto out;
> +	}
> +
> +	if (!has_aux(ee->event))
> +		ret = -EINVAL;
> +
> +	perf_event_aux_pause(ee->event, pause);
> +out:
> +	return ret;
> +}

[...]

  reply	other threads:[~2025-07-21 22:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-18 15:25 [PATCH v2 0/6] perf auxtrace: Support AUX pause and resume with BPF Leo Yan
2025-07-18 15:25 ` [PATCH PATCH v2 v2 1/6] perf/core: Make perf_event_aux_pause() as external function Leo Yan
2025-07-18 15:25 ` [PATCH PATCH v2 v2 2/6] bpf: Add bpf_perf_event_aux_pause kfunc Leo Yan
2025-07-21 22:38   ` Eduard Zingerman [this message]
2025-07-22  8:14     ` Leo Yan
2025-07-18 15:25 ` [PATCH PATCH v2 v2 3/6] perf: auxtrace: Control AUX pause and resume with BPF Leo Yan
2025-07-18 15:25 ` [PATCH PATCH v2 v2 4/6] perf: auxtrace: Add BPF userspace program for AUX pause and resume Leo Yan
2025-07-18 15:25 ` [PATCH PATCH v2 v2 5/6] perf record: Support AUX pause and resume with BPF Leo Yan
2025-07-18 15:25 ` [PATCH PATCH v2 v2 6/6] perf docs: Document " Leo Yan

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=ac8266f19ecde10a49911192014dddf35b3b496d.camel@gmail.com \
    --to=eddyz87@gmail.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=haoluo@google.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=leo.yan@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mattbobrowski@google.com \
    --cc=mhiramat@kernel.org \
    --cc=mike.leach@linaro.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=sdf@fomichev.me \
    --cc=song@kernel.org \
    --cc=suzuki.poulose@arm.com \
    --cc=yonghong.song@linux.dev \
    /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.