linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf,perf]] bpf,perf: return EOPNOTSUPP for attaching bpf handler on PERF_COUNT_SW_DUMMY
@ 2020-11-14 13:51 Florian Lehner
  2020-11-14 16:07 ` Alexei Starovoitov
  0 siblings, 1 reply; 3+ messages in thread
From: Florian Lehner @ 2020-11-14 13:51 UTC (permalink / raw)
  To: bpf
  Cc: netdev, linux-kernel, ast, daniel, andrii, john.fastabend,
	peterz, mingo, acme, Florian Lehner

At the moment it is not possible to attach a bpf handler to a perf event
of type PERF_TYPE_SOFTWARE with a configuration of PERF_COUNT_SW_DUMMY.

Signed-off-by: Florian Lehner <dev@der-flo.net>
---
 kernel/events/core.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index da467e1dd49a..4e8846b7ceda 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -9668,6 +9668,10 @@ static int perf_event_set_bpf_handler(struct perf_event *event, u32 prog_fd)
 	if (event->prog)
 		return -EEXIST;
 
+	if (event->attr.type == PERF_TYPE_SOFTWARE &&
+	    event->attr.config == PERF_COUNT_SW_DUMMY)
+		return -EOPNOTSUPP;
+
 	prog = bpf_prog_get_type(prog_fd, BPF_PROG_TYPE_PERF_EVENT);
 	if (IS_ERR(prog))
 		return PTR_ERR(prog);
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH bpf,perf]] bpf,perf: return EOPNOTSUPP for attaching bpf handler on PERF_COUNT_SW_DUMMY
  2020-11-14 13:51 [PATCH bpf,perf]] bpf,perf: return EOPNOTSUPP for attaching bpf handler on PERF_COUNT_SW_DUMMY Florian Lehner
@ 2020-11-14 16:07 ` Alexei Starovoitov
  2020-11-14 18:49   ` Florian Lehner
  0 siblings, 1 reply; 3+ messages in thread
From: Alexei Starovoitov @ 2020-11-14 16:07 UTC (permalink / raw)
  To: Florian Lehner
  Cc: bpf, Network Development, LKML, Alexei Starovoitov,
	Daniel Borkmann, Andrii Nakryiko, John Fastabend, Peter Zijlstra,
	Ingo Molnar, Arnaldo Carvalho de Melo

On Sat, Nov 14, 2020 at 5:53 AM Florian Lehner <dev@der-flo.net> wrote:
>
> At the moment it is not possible to attach a bpf handler to a perf event
> of type PERF_TYPE_SOFTWARE with a configuration of PERF_COUNT_SW_DUMMY.

It is possible or it is not possible?

Such "commit log as an abstract statement" patches are a mystery to a reader.
Please explain what problem you're trying to solve and how it's being addressed.

> Signed-off-by: Florian Lehner <dev@der-flo.net>
> ---
>  kernel/events/core.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index da467e1dd49a..4e8846b7ceda 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -9668,6 +9668,10 @@ static int perf_event_set_bpf_handler(struct perf_event *event, u32 prog_fd)
>         if (event->prog)
>                 return -EEXIST;
>
> +       if (event->attr.type == PERF_TYPE_SOFTWARE &&
> +           event->attr.config == PERF_COUNT_SW_DUMMY)
> +               return -EOPNOTSUPP;

Is it a fix or a feature?
If it is a fix please add 'Fixes:' tag.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH bpf,perf]] bpf,perf: return EOPNOTSUPP for attaching bpf handler on PERF_COUNT_SW_DUMMY
  2020-11-14 16:07 ` Alexei Starovoitov
@ 2020-11-14 18:49   ` Florian Lehner
  0 siblings, 0 replies; 3+ messages in thread
From: Florian Lehner @ 2020-11-14 18:49 UTC (permalink / raw)
  To: Alexei Starovoitov
  Cc: acme, andrii, ast, bpf, daniel, john.fastabend, linux-kernel,
	mingo, netdev, peterz

On Sat, Nov 14, 2020 at 08:07:29AM -0800, Alexei Starovoitov wrote:
> On Sat, Nov 14, 2020 at 5:53 AM Florian Lehner <dev@der-flo.net> wrote:
> >
> > At the moment it is not possible to attach a bpf handler to a perf event
> > of type PERF_TYPE_SOFTWARE with a configuration of PERF_COUNT_SW_DUMMY.
> 
> It is possible or it is not possible?
> 
> Such "commit log as an abstract statement" patches are a mystery to a reader.
> Please explain what problem you're trying to solve and how it's being addressed.

Perf events of type software/dummy are just placeholder events and don't
require a counting event. So attaching the bpf handler to the
overflow_handler of this event does not trigger the execution of the bpf
handler.
So the idea of this fix was to indicate to the user that attaching a bpf
handler to such a perf event is not (yet) supported.

> > Signed-off-by: Florian Lehner <dev@der-flo.net>
> > ---
> >  kernel/events/core.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/kernel/events/core.c b/kernel/events/core.c
> > index da467e1dd49a..4e8846b7ceda 100644
> > --- a/kernel/events/core.c
> > +++ b/kernel/events/core.c
> > @@ -9668,6 +9668,10 @@ static int perf_event_set_bpf_handler(struct perf_event *event, u32 prog_fd)
> >         if (event->prog)
> >                 return -EEXIST;
> >
> > +       if (event->attr.type == PERF_TYPE_SOFTWARE &&
> > +           event->attr.config == PERF_COUNT_SW_DUMMY)
> > +               return -EOPNOTSUPP;
> 
> Is it a fix or a feature?
> If it is a fix please add 'Fixes:' tag.

I was not sure how to address it and so I have chosen PATCH. As bpf
handlers are still not executed on such events, I also would not call it
a feature.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-11-14 18:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-14 13:51 [PATCH bpf,perf]] bpf,perf: return EOPNOTSUPP for attaching bpf handler on PERF_COUNT_SW_DUMMY Florian Lehner
2020-11-14 16:07 ` Alexei Starovoitov
2020-11-14 18:49   ` Florian Lehner

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).