netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexei Starovoitov <ast@plumgrid.com>
To: Kaixu Xia <xiakaixu@huawei.com>,
	davem@davemloft.net, acme@kernel.org, mingo@redhat.com,
	a.p.zijlstra@chello.nl, masami.hiramatsu.pt@hitachi.com,
	jolsa@kernel.org, daniel@iogearbox.net
Cc: wangnan0@huawei.com, linux-kernel@vger.kernel.org,
	pi3orama@163.com, hekuang@huawei.com, netdev@vger.kernel.org
Subject: Re: [PATCH V3 2/2] bpf: control all the perf events stored in PERF_EVENT_ARRAY maps
Date: Fri, 16 Oct 2015 15:12:20 -0700	[thread overview]
Message-ID: <56217644.2060707@plumgrid.com> (raw)
In-Reply-To: <1444981333-70429-3-git-send-email-xiakaixu@huawei.com>

On 10/16/15 12:42 AM, Kaixu Xia wrote:
> This patch implements the function that controlling all the perf
> events stored in PERF_EVENT_ARRAY maps by setting the parameter
> 'index' to maps max_entries.
>
> Signed-off-by: Kaixu Xia <xiakaixu@huawei.com>
> ---
>   kernel/trace/bpf_trace.c | 20 ++++++++++++++++++--
>   1 file changed, 18 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
> index 3175600..4b385863 100644
> --- a/kernel/trace/bpf_trace.c
> +++ b/kernel/trace/bpf_trace.c
> @@ -229,13 +229,30 @@ static u64 bpf_perf_event_dump_control(u64 r1, u64 index, u64 flag, u64 r4, u64
>   	struct bpf_map *map = (struct bpf_map *) (unsigned long) r1;
>   	struct bpf_array *array = container_of(map, struct bpf_array, map);
>   	struct perf_event *event;
> +	int i;
>
> -	if (unlikely(index >= array->map.max_entries))
> +	if (unlikely(index > array->map.max_entries))
>   		return -E2BIG;
>
>   	if (flag & BIT_FLAG_CHECK)
>   		return -EINVAL;
>
> +	if (index == array->map.max_entries) {

I don't like in-band signaling like this, since it's easy to make
mistake on the bpf program side.
Please use 2nd bit of 'flags' for that instead.
Also squash this patch into 1st.

      reply	other threads:[~2015-10-16 22:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-16  7:42 [PATCH V3 0/2] bpf: control events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling Kaixu Xia
2015-10-16  7:42 ` [PATCH V3 1/2] bpf: control the trace data output on current cpu " Kaixu Xia
2015-10-16 22:06   ` Alexei Starovoitov
2015-10-19  2:48     ` xiakaixu
2015-10-19  4:03     ` xiakaixu
2015-10-16  7:42 ` [PATCH V3 2/2] bpf: control all the perf events stored in PERF_EVENT_ARRAY maps Kaixu Xia
2015-10-16 22:12   ` Alexei Starovoitov [this message]

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=56217644.2060707@plumgrid.com \
    --to=ast@plumgrid.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=hekuang@huawei.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mingo@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pi3orama@163.com \
    --cc=wangnan0@huawei.com \
    --cc=xiakaixu@huawei.com \
    /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).