Re: [PATCH v4 0/7] ioctl()-based API to query VMAs from /proc/<pid>/maps

From: Andrii Nakryiko
Date: Wed Jun 12 2024 - 02:59:13 EST


On Tue, Jun 11, 2024 at 7:59 PM Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
>
>
> (Please cc Alexey on procfs changes)

ack, will do

>
> On Tue, 11 Jun 2024 04:00:48 -0700 Andrii Nakryiko <andrii@xxxxxxxxxx> wrote:
>
> > Implement binary ioctl()-based interface to /proc/<pid>/maps file to allow
> > applications to query VMA information more efficiently than reading *all* VMAs
> > nonselectively through text-based interface of /proc/<pid>/maps file.
>
> Looks nice but I'll await further reviewer input.
>

Thanks! I'll work on adding more tests meanwhile.

> >
> > ...
> >
> > Documentation/filesystems/proc.rst | 9 +
> > fs/proc/task_mmu.c | 366 +++++++++++--
> > include/uapi/linux/fs.h | 156 +++++-
> > tools/include/uapi/linux/fs.h | 550 ++++++++++++++++++++
> > tools/testing/selftests/bpf/.gitignore | 1 +
> > tools/testing/selftests/bpf/Makefile | 2 +-
> > tools/testing/selftests/bpf/procfs_query.c | 386 ++++++++++++++
> > tools/testing/selftests/bpf/test_progs.c | 3 +
> > tools/testing/selftests/bpf/test_progs.h | 2 +
> > tools/testing/selftests/bpf/trace_helpers.c | 104 +++-
> > 10 files changed, 1508 insertions(+), 71 deletions(-)
> > create mode 100644 tools/include/uapi/linux/fs.h
> > create mode 100644 tools/testing/selftests/bpf/procfs_query.c
>
> Should the selftests be under bpf/? This is a procfs feature which
> could be used by many things apart from bpf and it really isn't a bpf
> thing at all. Wouldn't tools/testing/selftests/proc/ be a more
> appropriate place?
>

Yep, agreed. I used BPF selftests as a quick and simple way to
validate it's working end-to-end (because we use /proc/<pid>/maps
across a bunch of pre-existing BPF selftests, so that gave me good
coverage and signal). I'll look into adding more tests under
selftests/proc for the next revision.

As for the procfs_query.c, it's not really a test, rather a custom
testing/benchmarking tool convenient for development, so I think I'll
drop it from the patch set for the next revision (and maybe will put
it up in a separate repo on Github or something).