public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Alexei Starovoitov <ast@fb.com>
Cc: "David S . Miller" <davem@davemloft.net>,
	Brendan Gregg <bgregg@netflix.com>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Arnaldo Carvalho de Melo <acme@infradead.org>,
	Wang Nan <wangnan0@huawei.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-team@fb.com
Subject: Re: [PATCH v2 net-next 4/6] perf, bpf: add perf events core support for BPF_PROG_TYPE_PERF_EVENT programs
Date: Thu, 1 Sep 2016 10:12:51 +0200	[thread overview]
Message-ID: <20160901081251.GL10153@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <1472680243-1326608-5-git-send-email-ast@fb.com>

On Wed, Aug 31, 2016 at 02:50:41PM -0700, Alexei Starovoitov wrote:
> diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
> index 97bfe62f30d7..dcaaaf3ec8e6 100644
> --- a/include/linux/perf_event.h
> +++ b/include/linux/perf_event.h
> @@ -679,6 +679,8 @@ struct perf_event {
>  	u64				(*clock)(void);
>  	perf_overflow_handler_t		overflow_handler;
>  	void				*overflow_handler_context;

> +	perf_overflow_handler_t		orig_overflow_handler;
> +	struct bpf_prog			*prog;

Should we put that under CONFIG_BPF_SYSCALL too?

> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index 3cfabdf7b942..305433ab2447 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c

> @@ -7637,11 +7637,75 @@ static void perf_event_free_filter(struct perf_event *event)
>  	ftrace_profile_free_filter(event);
>  }
>  
> +static void bpf_overflow_handler(struct perf_event *event,
> +				 struct perf_sample_data *data,
> +				 struct pt_regs *regs)
> +{
> +	struct bpf_perf_event_data_kern ctx = {
> +		.data = data,
> +		.regs = regs,
> +	};
> +	int ret = 0;
> +
> +#ifdef CONFIG_BPF_SYSCALL
> +	preempt_disable();
> +	if (unlikely(__this_cpu_inc_return(bpf_prog_active) != 1))
> +		goto out;
> +	rcu_read_lock();
> +	ret = BPF_PROG_RUN(event->prog, (void *)&ctx);
> +	rcu_read_unlock();
> + out:

Please, no leading space before labels. Use something like:

[diff "default"]
        xfuncname = "^[[:alpha:]$_].*[^:]$"

In your .gitconfig if you want to keep diff output 'sane'.

> +	__this_cpu_dec(bpf_prog_active);
> +	preempt_enable();
> +#endif
> +	if (!ret)
> +		return;
> +
> +	event->orig_overflow_handler(event, data, regs);
> +}

Other than that, ACK.

  reply	other threads:[~2016-09-01  8:13 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-31 21:50 [PATCH v2 net-next 0/6] perf, bpf: add support for bpf in sw/hw perf_events Alexei Starovoitov
2016-08-31 21:50 ` [PATCH v2 net-next 1/6] bpf: support 8-byte metafield access Alexei Starovoitov
2016-08-31 21:50 ` [PATCH v2 net-next 2/6] bpf: introduce BPF_PROG_TYPE_PERF_EVENT program type Alexei Starovoitov
2016-09-01  7:44   ` Peter Zijlstra
2016-09-01  8:33     ` Daniel Borkmann
2016-08-31 21:50 ` [PATCH v2 net-next 3/6] bpf: perf_event progs should only use preallocated maps Alexei Starovoitov
2016-08-31 21:50 ` [PATCH v2 net-next 4/6] perf, bpf: add perf events core support for BPF_PROG_TYPE_PERF_EVENT programs Alexei Starovoitov
2016-09-01  8:12   ` Peter Zijlstra [this message]
2016-09-01 15:53     ` Alexei Starovoitov
2016-09-01 16:37       ` Peter Zijlstra
2016-08-31 21:50 ` [PATCH v2 net-next 5/6] samples/bpf: add perf_event+bpf example Alexei Starovoitov
2016-08-31 21:50 ` [PATCH v2 net-next 6/6] samples/bpf: add sampleip example Alexei Starovoitov
2016-09-01  0:18 ` [PATCH v2 net-next 0/6] perf, bpf: add support for bpf in sw/hw perf_events Brendan Gregg

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=20160901081251.GL10153@twins.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=acme@infradead.org \
    --cc=ast@fb.com \
    --cc=bgregg@netflix.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=wangnan0@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