All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andriin@fb.com>,
	kernel test robot <lkp@intel.com>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	netdev@vger.kernel.org, bpf@vger.kernel.org,
	Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
	Yonghong Song <yhs@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@chromium.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Alan Maguire <alan.maguire@oracle.com>
Subject: Re: [PATCHv3 bpf-next 3/7] bpf: Add bpf_get_func_ip helper for tracing programs
Date: Sun, 11 Jul 2021 16:48:00 +0200	[thread overview]
Message-ID: <YOsEoLogYRy7TiJg@krava> (raw)
In-Reply-To: <20210708021123.w4smo42jml57iowl@ast-mbp.dhcp.thefacebook.com>

On Wed, Jul 07, 2021 at 07:11:23PM -0700, Alexei Starovoitov wrote:
> On Wed, Jul 07, 2021 at 11:47:47PM +0200, Jiri Olsa wrote:
> >  
> > +static bool allow_get_func_ip_tracing(struct bpf_verifier_env *env)
> > +{
> > +	return env->prog->jit_requested && IS_ENABLED(CONFIG_X86_64);
> 
> Why does it have to be gated by 'jited && x86_64' ?
> It's gated by bpf trampoline and it's only implemented on x86_64 so far.
> The trampoline has plenty of features. I would expect bpf trampoline
> for arm64 to implement all of them. If not the func_ip would be just
> one of the trampoline features that couldn't be implemented and at that
> time we'd need a flag mask of a sort, but I'd rather push of feature
> equivalence between trampoline implementations.

ok, check for trampoline's prog types should be enough

> 
> Then jited part also doesn't seem to be necessary.
> The trampoline passed pointer to a stack in R1.
> Interpreter should deal with BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -8) insn
> the same way and it should work, since trampoline prepared it.
> What did I miss?

ah right.. will remove that

SNIP

> > diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
> > index 64bd2d84367f..9edd3b1a00ad 100644
> > --- a/kernel/trace/bpf_trace.c
> > +++ b/kernel/trace/bpf_trace.c
> > @@ -948,6 +948,19 @@ const struct bpf_func_proto bpf_snprintf_btf_proto = {
> >  	.arg5_type	= ARG_ANYTHING,
> >  };
> >  
> > +BPF_CALL_1(bpf_get_func_ip_tracing, void *, ctx)
> > +{
> > +	/* Stub, the helper call is inlined in the program. */
> > +	return 0;
> > +}
> 
> may be add a WARN in here that it should never be executed ?
> Or may be add an actual implementation:
>  return ((u64 *)ctx)[-1];
> and check that it works without inlining by the verifier?
> 

sure, but having tracing program with this helper, it will be
always inlined, right? I can't see how it could be skipped

thanks,
jirka


  reply	other threads:[~2021-07-11 14:48 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-07 21:47 [PATCHv3 bpf-next 0/7] bpf, x86: Add bpf_get_func_ip helper Jiri Olsa
2021-07-07 21:47 ` [PATCHv3 bpf-next 1/7] bpf, x86: Store caller's ip in trampoline stack Jiri Olsa
2021-07-07 21:47 ` [PATCHv3 bpf-next 2/7] bpf: Enable BPF_TRAMP_F_IP_ARG for trampolines with call_get_func_ip Jiri Olsa
2021-07-07 21:47 ` [PATCHv3 bpf-next 3/7] bpf: Add bpf_get_func_ip helper for tracing programs Jiri Olsa
2021-07-08  0:06   ` Andrii Nakryiko
2021-07-11 14:48     ` Jiri Olsa
2021-07-08  2:11   ` Alexei Starovoitov
2021-07-11 14:48     ` Jiri Olsa [this message]
2021-07-07 21:47 ` [PATCHv3 bpf-next 4/7] bpf: Add bpf_get_func_ip helper for kprobe programs Jiri Olsa
2021-07-10  7:55   ` Masami Hiramatsu
2021-07-11 14:48     ` Jiri Olsa
2021-07-07 21:47 ` [PATCHv3 bpf-next 5/7] selftests/bpf: Add test for bpf_get_func_ip helper Jiri Olsa
2021-07-08  0:12   ` Andrii Nakryiko
2021-07-11 14:48     ` Jiri Olsa
2021-07-07 21:47 ` [PATCHv3 bpf-next 6/7] libbpf: allow specification of "kprobe/function+offset" Jiri Olsa
2021-07-08  0:14   ` Andrii Nakryiko
2021-07-11 14:48     ` Jiri Olsa
2021-07-07 21:47 ` [PATCHv3 bpf-next 7/7] selftests/bpf: Add test for bpf_get_func_ip in kprobe+offset probe Jiri Olsa
2021-07-08  0:18   ` Andrii Nakryiko
2021-07-11 14:48     ` Jiri Olsa
2021-07-12 23:32       ` Andrii Nakryiko
2021-07-13 14:15         ` Jiri Olsa

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=YOsEoLogYRy7TiJg@krava \
    --to=jolsa@redhat.com \
    --cc=alan.maguire@oracle.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andriin@fb.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=dan.carpenter@oracle.com \
    --cc=daniel@iogearbox.net \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@chromium.org \
    --cc=lkp@intel.com \
    --cc=mhiramat@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=songliubraving@fb.com \
    --cc=yhs@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 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.