From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Ingo Molnar <mingo@redhat.com>,
linux-kernel@vger.kernel.org, vince@deater.net,
eranian@google.com, Arnaldo Carvalho de Melo <acme@infradead.org>,
Jiri Olsa <jolsa@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Wang Nan <wangnan0@huawei.com>
Subject: Re: [PATCH v2] perf: Synchronously cleanup child events
Date: Tue, 26 Jan 2016 15:31:59 -0800 [thread overview]
Message-ID: <20160126233158.GA45142@ast-mbp.thefacebook.com> (raw)
In-Reply-To: <20160126172425.GJ6375@twins.programming.kicks-ass.net>
On Tue, Jan 26, 2016 at 06:24:25PM +0100, Peter Zijlstra wrote:
> On Tue, Jan 26, 2016 at 05:16:37PM +0100, Peter Zijlstra wrote:
> > > +struct file *perf_event_get(unsigned int fd)
> > > {
> > > + struct file *file;
> > >
> > > + file = fget_raw(fd);
> >
> > fget_raw() to guarantee the return value isn't NULL? afaict the O_PATH
> > stuff does not apply to perf events, so you'd put any fd for which the
> > distinction matters anyway.
yeah good catch. the following is needed:
file = fget_raw(fd);
+ if (!file)
+ return ERR_PTR(-EBADF);
> >
> > > + if (file->f_op != &perf_fops) {
> > > + fput(file);
> > > + return ERR_PTR(-EBADF);
> > > + }
> > >
> > > + return file;
> > > }
>
> It is not possible for one thread to concurrently call close() while
> this thread tries to fget() ? In which case, we must check the return
> value anyway?
the !file check is definitely needed, fd passed by the user can be bogus.
The caller of perf_event_get() checks for errors too.
This patch will conflict with kernel/bpf/arraymap.c and
kernel/trace/bpf_trace.c that are planned for net-next,
but the conflicts in kernel/events/core.c are probably harder
to resolve, so yes please take it into tip/perf.
I think your scm_right fixes depend on this patch and together
it's an important bug fix, so probably makes sense to send
them right now without waiting for the next merge window?
As soon as you get the whole thing into tip, I'll test it
to make sure bpf side is ok and I hope Wang will test it too.
I'm still a bit concerned about taking file reference for this,
since bpf prorgams that use perf_events won't be able to be
'detached'. Meaning there gotta be always a user space process
that will be holding perf_event FDs. On networking side we
don't have this limitation. Like we can attach bpf to TC,
iproute2 will exit and reattach some time later. So it
kinda sux, but sounds like you want to get rid of
perf_event->refcnt completely, so I don't see any other way.
We can fix it later if it really becomes an issue.
next prev parent reply other threads:[~2016-01-26 23:32 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-15 11:22 [PATCH] perf: Cleanup user's child events Alexander Shishkin
2016-01-15 12:54 ` Peter Zijlstra
2016-01-15 13:05 ` Alexander Shishkin
2016-01-15 13:09 ` Peter Zijlstra
2016-01-15 14:07 ` [PATCH] perf: Synchronously cleanup " Alexander Shishkin
2016-01-15 17:57 ` Peter Zijlstra
2016-01-18 12:07 ` Alexander Shishkin
2016-01-18 12:37 ` Alexander Shishkin
2016-01-18 14:44 ` Peter Zijlstra
2016-01-19 15:12 ` [PATCH v2] " Alexander Shishkin
2016-01-19 20:05 ` Peter Zijlstra
2016-01-19 21:58 ` Alexei Starovoitov
2016-01-20 8:32 ` Peter Zijlstra
2016-01-21 4:55 ` Alexei Starovoitov
2016-01-20 7:04 ` Alexander Shishkin
2016-01-20 8:03 ` Peter Zijlstra
2016-01-22 11:35 ` Alexander Shishkin
2016-01-22 12:12 ` Peter Zijlstra
2016-01-22 12:38 ` Peter Zijlstra
2016-01-22 19:44 ` Alexei Starovoitov
2016-01-25 11:48 ` Peter Zijlstra
2016-01-25 14:54 ` Peter Zijlstra
2016-01-25 21:04 ` Peter Zijlstra
2016-01-26 4:59 ` Alexei Starovoitov
2016-01-26 16:16 ` Peter Zijlstra
2016-01-26 17:24 ` Peter Zijlstra
2016-01-26 23:31 ` Alexei Starovoitov [this message]
2016-01-27 9:58 ` Peter Zijlstra
2016-01-27 17:52 ` Alexei Starovoitov
2016-01-29 11:28 ` [tip:perf/urgent] perf/bpf: Convert perf_event_array to use struct file tip-bot for Alexei Starovoitov
2016-01-29 20:01 ` Alexei Starovoitov
2016-01-19 20:07 ` [PATCH v2] perf: Synchronously cleanup child events Peter Zijlstra
2016-01-19 7:45 ` [PATCH] " Ingo Molnar
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=20160126233158.GA45142@ast-mbp.thefacebook.com \
--to=alexei.starovoitov@gmail.com \
--cc=acme@infradead.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=daniel@iogearbox.net \
--cc=eranian@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=vince@deater.net \
--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 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.