From: Jiri Olsa <olsajiri@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>,
Oleg Nesterov <oleg@redhat.com>
Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>,
Jiri Olsa <olsajiri@gmail.com>,
Andrii Nakryiko <andrii@kernel.org>, bpf <bpf@vger.kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Martin KaFai Lau <martin.lau@kernel.org>,
Kernel Team <kernel-team@meta.com>
Subject: Re: [PATCH bpf-next] selftests/bpf: make use of PROCMAP_QUERY ioctl if available
Date: Fri, 23 Aug 2024 23:31:58 +0200 [thread overview]
Message-ID: <Zsj_zl3ODn2JHzYk@krava> (raw)
In-Reply-To: <CAEf4Bzb8vSYVYqcoSVicFOVkpeAdd+MmC56m7o7KipnycWbq4w@mail.gmail.com>
On Fri, Aug 23, 2024 at 09:53:03AM -0700, Andrii Nakryiko wrote:
> On Fri, Aug 23, 2024 at 7:48 AM Alexei Starovoitov
> <alexei.starovoitov@gmail.com> wrote:
> >
> > On Wed, Aug 7, 2024 at 8:17 AM Andrii Nakryiko
> > <andrii.nakryiko@gmail.com> wrote:
> > >
> > > On Wed, Aug 7, 2024 at 2:07 AM Jiri Olsa <olsajiri@gmail.com> wrote:
> > > >
> > > > On Tue, Aug 06, 2024 at 04:03:19PM -0700, Andrii Nakryiko wrote:
> > > >
> > > > SNIP
> > > >
> > > > > ssize_t get_uprobe_offset(const void *addr)
> > > > > {
> > > > > - size_t start, end, base;
> > > > > - char buf[256];
> > > > > - bool found = false;
> > > > > + size_t start, base, end;
> > > > > FILE *f;
> > > > > + char buf[256];
> > > > > + int err, flags;
> > > > >
> > > > > f = fopen("/proc/self/maps", "r");
> > > > > if (!f)
> > > > > return -errno;
> > > > >
> > > > > - while (fscanf(f, "%zx-%zx %s %zx %*[^\n]\n", &start, &end, buf, &base) == 4) {
> > > > > - if (buf[2] == 'x' && (uintptr_t)addr >= start && (uintptr_t)addr < end) {
> > > > > - found = true;
> > > > > - break;
> > > > > + /* requested executable VMA only */
> > > > > + err = procmap_query(fileno(f), addr, PROCMAP_QUERY_VMA_EXECUTABLE, &start, &base, &flags);
> > > > > + if (err == -EOPNOTSUPP) {
> > > > > + bool found = false;
> > > > > +
> > > > > + while (fscanf(f, "%zx-%zx %s %zx %*[^\n]\n", &start, &end, buf, &base) == 4) {
> > > > > + if (buf[2] == 'x' && (uintptr_t)addr >= start && (uintptr_t)addr < end) {
> > > > > + found = true;
> > > > > + break;
> > > > > + }
> > > > > + }
> > > > > + if (!found) {
> > > > > + fclose(f);
> > > > > + return -ESRCH;
> > > > > }
> > > > > + } else if (err) {
> > > > > + fclose(f);
> > > > > + return err;
> > > >
> > > > I feel like I commented on this before, so feel free to ignore me,
> > > > but this seems similar to the code below, could be in one function
> > >
> > > Do you mean get_rel_offset()? That one is for data symbols (USDT
> > > semaphores), so it a) doesn't do arch-specific adjustments and b)
> > > doesn't filter by executable flag. So while the logic of parsing and
> > > finding VMA is similar, conditions and adjustments are different. It
> > > feels not worth combining them, tbh.
> > >
> > > >
> > > > anyway it's good for follow up
> > > >
> > > > there was another selftest in the original patchset adding benchmark
> > > > for the procfs query interface, is it coming in as well?
> > >
> > > I didn't plan to send it, given it's not really a test. But I can put
> > > it on Github somewhere, probably, if it's useful.
> >
> > With and without this selftest applied I see:
> > ./test_progs -t uprobe
> > #416 uprobe:OK
> > #417 uprobe_autoattach:OK
> > [ 47.448908] ref_ctr_offset mismatch. inode: 0x16b5f921 offset:
> > 0x2d4297 ref_ctr_offset(old): 0x45e8b56 ref_ctr_offset(new): 0x45e8b54
> > #418/1 uprobe_multi_test/skel_api:OK
> >
> > Is this a known issue?
>
> Yeah, that's not due to my changes. It's an old warning in uprobe
> internals, but I think we should remove it, because it can trivially
> be triggered by a user. Which is what Jiri is doing intentionally in
> one of selftests to test uprobe failure handling.
>
> Jiri, maybe let's get rid of this warning?
fine with me.. or change to pr_debug if that makes sense for anyone,
Oleg, any idea/preference?
jirka
>
> >
> > Applied anyway.
>
> Thanks! I just found another auto-archived patch of mine, the one
> adding multi-uprobe benchmarks (see patchworks). Please take a look
> and maybe apply, when you get a chance.
next prev parent reply other threads:[~2024-08-23 21:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-06 23:03 [PATCH bpf-next] selftests/bpf: make use of PROCMAP_QUERY ioctl if available Andrii Nakryiko
2024-08-07 9:07 ` Jiri Olsa
2024-08-07 15:17 ` Andrii Nakryiko
2024-08-23 14:47 ` Alexei Starovoitov
2024-08-23 16:53 ` Andrii Nakryiko
2024-08-23 21:31 ` Jiri Olsa [this message]
2024-08-23 14:50 ` patchwork-bot+netdevbpf
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=Zsj_zl3ODn2JHzYk@krava \
--to=olsajiri@gmail.com \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@meta.com \
--cc=martin.lau@kernel.org \
--cc=oleg@redhat.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