linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hou Tao <houtao@huaweicloud.com>
To: bpf@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org,
	Alexei Starovoitov <alexei.starovoitov@gmail.com>,
	Yonghong Song <yhs@fb.com>,
	Andrii Nakryiko <andrii.nakryiko@gmail.com>,
	Viacheslav Dubeyko <slava@dubeyko.com>,
	Amir Goldstein <amir73il@gmail.com>,
	houtao1@huawei.com
Subject: [RFC PATCH bpf-next 0/4] Introduce bpf iterators for file-system
Date: Sun,  7 May 2023 12:01:03 +0800	[thread overview]
Message-ID: <20230507040107.3755166-1-houtao@huaweicloud.com> (raw)

From: Hou Tao <houtao1@huawei.com>

Hi,

The patchset is in a hurry and far from complete, but it is better to
provide some code/demo first for disussion in LSF/MM/BPF.

The patchset attempts to provide more observability for the file-system
as proposed in [0]. Compared to drgn [1], the bpf iterator for file-system
has fewer dependencies (e.g., no need for vmlinux) and more accurate
results.

Two types of file-system iterator are provided: fs_inode and fs_mnt.
fs_inode is for a specific inode and fs_mnt is for a specifc mount. More
type (e.g., all inodes in a file-system) could be added if in need. Both
of these two iterators work by getting a file-description and a bpf
program as the input. BPF iterator will pass the fd-related inode or
mount to the bpf program, the bpf program can dump the needed
information of the inode or mount to a seq_file owned by iterator fd
by using all kinds of bpf helpers and the user can read the iterator fd
to get the final information. The following is an example when trying to
dump the detailed information of a XFS inode:

  sb: bsize 4096 s_op xfs_super_operations s_type xfs_fs_type name xfs
  ino: inode nlink 1 inum 131 size 10485760, name inode.test
  cache: cached 2560 dirty 0 wb 0 evicted 0
  orders:
    page offset 0 order 2
    page offset 4 order 2
    page offset 8 order 2
    page offset 12 order 2
    page offset 16 order 4
    page offset 32 order 4
    page offset 48 order 4
    page offset 64 order 5
    page offset 96 order 4
    page offset 112 order 4
    page offset 128 order 5
    page offset 160 order 4
    page offset 176 order 0
    ...

More details can be found in the individual patches. And suggestions and
comments are always welcome.

[0]: https://lore.kernel.org/bpf/0a6f0513-b4b3-9349-cee5-b0ad38c81d2e@huaweicloud.com
[1]: https://github.com/osandov/drgn

Hou Tao (4):
  bpf: Introduce bpf iterator for file-system inode
  bpf: Add three kfunc helpers for bpf fs inode iterator
  bpf: Introduce bpf iterator for file system mount
  selftests/bpf: Add test cases for bpf file-system iterator

 include/linux/bpf.h                           |   2 +
 include/linux/btf_ids.h                       |   6 +-
 include/linux/fs.h                            |   4 +
 include/uapi/linux/bpf.h                      |   9 +
 include/uapi/linux/mman.h                     |   8 +
 kernel/bpf/Makefile                           |   1 +
 kernel/bpf/fs_iter.c                          | 216 ++++++++++++++++++
 kernel/bpf/helpers.c                          |  26 +++
 mm/filemap.c                                  |  77 +++++++
 tools/include/uapi/linux/bpf.h                |   9 +
 .../selftests/bpf/prog_tests/bpf_iter_fs.c    | 184 +++++++++++++++
 .../testing/selftests/bpf/progs/bpf_iter_fs.c | 122 ++++++++++
 12 files changed, 663 insertions(+), 1 deletion(-)
 create mode 100644 kernel/bpf/fs_iter.c
 create mode 100644 tools/testing/selftests/bpf/prog_tests/bpf_iter_fs.c
 create mode 100644 tools/testing/selftests/bpf/progs/bpf_iter_fs.c

-- 
2.29.2


             reply	other threads:[~2023-05-07  3:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-07  4:01 Hou Tao [this message]
2023-05-07  4:01 ` [RFC PATCH bpf-next 1/4] bpf: Introduce bpf iterator for file-system inode Hou Tao
2023-05-07  4:01 ` [RFC PATCH bpf-next 2/4] bpf: Add three kfunc helpers for bpf fs inode iterator Hou Tao
2023-05-07  4:01 ` [RFC PATCH bpf-next 3/4] bpf: Introduce bpf iterator for file system mount Hou Tao
2023-05-07  4:01 ` [RFC PATCH bpf-next 4/4] selftests/bpf: Add test cases for bpf file-system iterator Hou Tao

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=20230507040107.3755166-1-houtao@huaweicloud.com \
    --to=houtao@huaweicloud.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=amir73il@gmail.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=houtao1@huawei.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=slava@dubeyko.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).