On Fri, Aug 23, 2024 at 7:48 AM Alexei Starovoitov <alexei.starovoitov@xxxxxxxxx> wrote: > > On Wed, Aug 7, 2024 at 8:17 AM Andrii Nakryiko > <andrii.nakryiko@xxxxxxxxx> wrote: > > > > On Wed, Aug 7, 2024 at 2:07 AM Jiri Olsa <olsajiri@xxxxxxxxx> 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? > > 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.