From: Masami Hiramatsu <mhiramat@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Ingo Molnar <mingo@redhat.com>,
Alban Crequy <alban.crequy@gmail.com>,
Alban Crequy <alban@kinvolk.io>,
Alexei Starovoitov <ast@kernel.org>,
Jonathan Corbet <corbet@lwn.net>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Omar Sandoval <osandov@fb.com>,
linux-doc@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, iago@kinvolk.io,
michael@kinvolk.io, Dorau Lukasz <lukasz.dorau@intel.com>,
systemtap@sourceware.org
Subject: Re: [RFC PATCH tip/master 2/3] kprobes: Allocate kretprobe instance if its free list is empty
Date: Thu, 30 Mar 2017 22:01:34 +0900 [thread overview]
Message-ID: <20170330220134.448b65b9102edcf8ba1a2c81@kernel.org> (raw)
In-Reply-To: <20170330065332.GA30148@gmail.com>
On Thu, 30 Mar 2017 08:53:32 +0200
Ingo Molnar <mingo@kernel.org> wrote:
>
> * Masami Hiramatsu <mhiramat@kernel.org> wrote:
>
> > > So this is something I missed while the original code was merged, but the concept
> > > looks a bit weird: why do we do any "allocation" while a handler is executing?
> > >
> > > That's fundamentally fragile. What's the maximum number of parallel
> > > 'kretprobe_instance' required per kretprobe - one per CPU?
> >
> > It depends on the place where we put the probe. If the probed function will be
> > blocked (yield to other tasks), then we need a same number of threads on
> > the system which can invoke the function. So, ultimately, it is same
> > as function_graph tracer, we need it for each thread.
>
> So then put it into task_struct (assuming there's no kretprobe-inside-kretprobe
> nesting allowed).
No, that is possible to put several kretprobes on same thread, e.g.
the func1() is called from func2(), user can put kretprobes for each
function at same time.
So the possible solution is to allocate new return-stack for each task_struct,
and that is what the function-graph tracer did.
Anyway, I'm considering to integrate kretprobe_instance with the ret_stack.
It will increase memory usage for kretprobes, but can provide safer way
to allocate kretprobe_instance.
> There's just no way in hell we should be calling any complex
> kernel function from kernel probes!
OK, so let's drop this, since it may easily cause deadlock...
> I mean, think about it, a kretprobe can be installed in a lot of places, and now
> we want to call get_free_pages() from it?? This would add a massive amount of
> fragility.
I thought it was safe because GFP_ATOMIC is safe at interrupt handler.
> Instrumentation must be _simple_, every patch that adds more complexity to the
> most fundamental code path of it should raise a red flag ...
>
> So let's make this more robust, ok?
Yeah, in that case, I think Alban's patch is enough at this point since
it gives user to tune their kretprobe events not to be missed.
Thank you,
>
> Thanks,
>
> Ingo
--
Masami Hiramatsu <mhiramat@kernel.org>
next prev parent reply other threads:[~2017-03-30 13:01 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-29 5:20 [RFC PATCH tip/master 0/3] kprobes: tracing: kretprobe_instance dynamic allocation Masami Hiramatsu
2017-03-29 5:22 ` [RFC PATCH tip/master 1/3] trace: kprobes: Show sum of probe/retprobe nmissed count Masami Hiramatsu
2017-03-31 9:45 ` Alban Crequy
2017-03-29 5:23 ` [RFC PATCH tip/master 2/3] kprobes: Allocate kretprobe instance if its free list is empty Masami Hiramatsu
2017-03-29 6:30 ` Ingo Molnar
2017-03-29 8:25 ` Masami Hiramatsu
2017-03-29 17:18 ` Josh Stone
2017-03-30 0:39 ` Masami Hiramatsu
2017-03-30 6:53 ` Ingo Molnar
2017-03-30 13:01 ` Masami Hiramatsu [this message]
2017-04-12 6:42 ` Ingo Molnar
2017-03-30 13:03 ` Alban Crequy
2017-03-29 5:24 ` [RFC PATCH tip/master 3/3] kprobes: Limit kretprobe maximum instances Masami Hiramatsu
2017-03-29 13:27 ` [RFC PATCH tip/master 0/3] kprobes: tracing: kretprobe_instance dynamic allocation Frank Ch. Eigler
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=20170330220134.448b65b9102edcf8ba1a2c81@kernel.org \
--to=mhiramat@kernel.org \
--cc=acme@redhat.com \
--cc=alban.crequy@gmail.com \
--cc=alban@kinvolk.io \
--cc=ast@kernel.org \
--cc=corbet@lwn.net \
--cc=iago@kinvolk.io \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lukasz.dorau@intel.com \
--cc=michael@kinvolk.io \
--cc=mingo@kernel.org \
--cc=mingo@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=osandov@fb.com \
--cc=rostedt@goodmis.org \
--cc=systemtap@sourceware.org \
/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).