BPF List
 help / color / mirror / Atom feed
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Dmitry Dolgov <9erthalion6@gmail.com>
Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>,
	"linux-perf-use." <linux-perf-users@vger.kernel.org>,
	bpf <bpf@vger.kernel.org>, Song Liu <songliubraving@fb.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>
Subject: Re: [PATCH] perf/kprobe: maxactive for fd-based kprobe
Date: Sun, 19 Jun 2022 01:15:21 +0900	[thread overview]
Message-ID: <20220619011521.4fc56a8bdac451a4f4f6cd13@kernel.org> (raw)
In-Reply-To: <20220615200029.ngyayghtnma3ywnb@erthalion.local>

On Wed, 15 Jun 2022 22:00:29 +0200
Dmitry Dolgov <9erthalion6@gmail.com> wrote:

> > On Sun, Jun 12, 2022 at 09:12:32PM +0900, Masami Hiramatsu wrote:
> > On Sat, 11 Jun 2022 11:28:36 -0700
> > Alexei Starovoitov <alexei.starovoitov@gmail.com> wrote:
> >
> > > On Thu, Jun 9, 2022 at 1:14 PM Dmitry Dolgov <9erthalion6@gmail.com> wrote:
> > > >
> > > > > On Thu, Jun 09, 2022 at 09:29:36PM +0200, Dmitrii Dolgov wrote:
> > > > >
> > > > > Enable specifying maxactive for fd based kretprobe. This will be useful
> > > > > for tracing tools like bcc and bpftrace (see for example discussion [1]).
> > > > > Use highest 12 bit (bit 52-63) to allow maximal maxactive of 4095.
> > > > >
> > > > > The original patch [2] seems to be fallen through the cracks and wasn't
> > > > > applied. I've merely rebased the work done by Song Liu and verififed it
> > > > > still works.
> > > > >
> > > > > [1]: https://github.com/iovisor/bpftrace/issues/835
> > > > > [2]: https://lore.kernel.org/all/20191007223111.1142454-1-songliubraving@fb.com/
> > > >
> > > > I've recently stumbled upon this seemingly lost topic, and wanted to raise it
> > > > again. Please let me know if there is a more appropriate way to do so.
> > >
> > > With kretprobe using rethook the maxactive limit is no longer used.
> > > So we probably don't need this patch.
> > >
> > > Masami, wdyt?
> >
> > No, rethook is just a library version of kretprobe return hook,
> > so the maxactive is still alive. I would like to make the rethook
> > to use(share with) function graph's per-task shadow stack. When
> > that is done, the maxactive will be removed.
> 
> Thanks for clarification! Does it mean that the possibility of setting
> maxactive still makes sense, until the rethook changes you've mentioned
> will land?

Yes, unfortunatelly, there is no magic. We need a shadow stack without
runtime allocation for this purpose. Thus what we can do is to use
a per-task pre-allocated shadow stack page or make a common pool of nodes
for variable-length shadow-stack. Both has pros and cons (depends on the
system configuration).

> 
> On a side note, is it possible to somehow follow/review/test the work
> about rethook and function graph's shadow stack?

Hmm, good question. It should work theoletically, but it is easy to be
tested by ftrace tracefs interface on x86. Just enable function-graph
tracer and add a kretprobe event on some fucntion. E.g.

echo function-graph > current_tracer
echo r:test vfs_read >> kprobe_events
echo 1 > events/kprobes/enable

Thank you,


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

  reply	other threads:[~2022-06-18 16:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-09 19:29 [PATCH] perf/kprobe: maxactive for fd-based kprobe Dmitrii Dolgov
2022-06-09 19:30 ` Dmitry Dolgov
2022-06-11 18:28   ` Alexei Starovoitov
2022-06-12 12:12     ` Masami Hiramatsu
2022-06-15 20:00       ` Dmitry Dolgov
2022-06-18 16:15         ` Masami Hiramatsu [this message]
2022-06-15 18:20 ` Song Liu
2022-06-15 19:57   ` Dmitry Dolgov

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=20220619011521.4fc56a8bdac451a4f4f6cd13@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=9erthalion6@gmail.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=songliubraving@fb.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