mbox series

[RFC,0/3] Generic per-mount io stats

Message ID 20210107214401.249416-1-amir73il@gmail.com (mailing list archive)
Headers show
Series Generic per-mount io stats | expand

Message

Amir Goldstein Jan. 7, 2021, 9:43 p.m. UTC
Miklos,

I was trying to address the lack of iostat report for non-blockdev
filesystems such as overlayfs and fuse.

NFS has already addressed this with it own custom stats collection,
which is displayed in /proc/<pid>/mountstats.

When looking at the options, I found that a generic solution is quite
simple and could serve all filesystems that opt-in to use it.

This short patch set results in the following mountstats example report:

device overlay mounted on /mnt with fstype overlay
	times: 125 153
	rchar: 12
	wchar: 0
	syscr: 2
	syscw: 0

The choise to collect and report io stats by mount and not by sb is
quite arbitrary, because it was quite easy to implement and is natural
to the existing mountstats proc file.

I used the arbirtaty flag FS_USERNS_MOUNT as an example for a way for
filesystem to opt-in to mount io stats, but it could be either an FS_
SB_ or MNT_ flag.  I do not anticipate shortage of opinions on this
matter.

As for performance, the io accounting hooks are the existing hooks for
task io accounting.  mount io stats add a dereference to mnt_pcp for
the filesystems that opt-in and one per-cpu var update.  The dereference
to mnt_sb->s_type->fs_flags is temporary as we will probably want to
use an MNT_ flag, whether kernel internal or user controlled.

What do everyone think about this?

Al,

did I break any subtle rules of the vfs?

Thanks,
Amir.

Amir Goldstein (3):
  fs: add iostats counters to struct mount
  fs: collect per-mount io stats
  fs: report per-mount io stats

 fs/Kconfig          |  9 +++++
 fs/mount.h          | 54 ++++++++++++++++++++++++++++
 fs/namespace.c      | 19 ++++++++++
 fs/proc_namespace.c | 13 +++++++
 fs/read_write.c     | 87 ++++++++++++++++++++++++++++++++-------------
 5 files changed, 158 insertions(+), 24 deletions(-)

Comments

Amir Goldstein Jan. 8, 2021, 4:41 p.m. UTC | #1
On Thu, Jan 7, 2021 at 11:44 PM Amir Goldstein <amir73il@gmail.com> wrote:
>
> Miklos,
>
> I was trying to address the lack of iostat report for non-blockdev
> filesystems such as overlayfs and fuse.
>
> NFS has already addressed this with it own custom stats collection,
> which is displayed in /proc/<pid>/mountstats.
>
> When looking at the options, I found that a generic solution is quite
> simple and could serve all filesystems that opt-in to use it.
>
> This short patch set results in the following mountstats example report:
>
> device overlay mounted on /mnt with fstype overlay
>         times: 125 153
>         rchar: 12
>         wchar: 0
>         syscr: 2
>         syscw: 0
>
> The choise to collect and report io stats by mount and not by sb is
> quite arbitrary, because it was quite easy to implement and is natural
> to the existing mountstats proc file.
>
> I used the arbirtaty flag FS_USERNS_MOUNT as an example for a way for
> filesystem to opt-in to mount io stats, but it could be either an FS_
> SB_ or MNT_ flag.  I do not anticipate shortage of opinions on this
> matter.
>
> As for performance, the io accounting hooks are the existing hooks for
> task io accounting.  mount io stats add a dereference to mnt_pcp for
> the filesystems that opt-in and one per-cpu var update.  The dereference
> to mnt_sb->s_type->fs_flags is temporary as we will probably want to
> use an MNT_ flag, whether kernel internal or user controlled.
>
> What do everyone think about this?
>
> Al,
>
> did I break any subtle rules of the vfs?
>

That is besides dereferencing a NULL file pointer when getting EBADF
in p/readv/writev...

Thanks,
Amir.