From: Amir Goldstein <amir73il@gmail.com>
To: Miklos Szeredi <miklos@szeredi.hu>, Al Viro <viro@zeniv.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org
Subject: [RFC PATCH 3/3] fs: report per-mount io stats
Date: Thu, 7 Jan 2021 23:44:01 +0200 [thread overview]
Message-ID: <20210107214401.249416-4-amir73il@gmail.com> (raw)
In-Reply-To: <20210107214401.249416-1-amir73il@gmail.com>
Show optional collected per-mount io stats in /proc/<pid>/mountstats
for filesystems that do not implement their own show_stats() method.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
See following snippet from mountstats example report:
device overlay mounted on /mnt with fstype overlay
times: 125 153
rchar: 12
wchar: 0
syscr: 2
syscw: 0
Thanks,
Amir.
fs/mount.h | 1 +
fs/namespace.c | 2 ++
fs/proc_namespace.c | 13 +++++++++++++
3 files changed, 16 insertions(+)
diff --git a/fs/mount.h b/fs/mount.h
index 81db83c36140..1f262892a6ed 100644
--- a/fs/mount.h
+++ b/fs/mount.h
@@ -91,6 +91,7 @@ struct mount {
int mnt_id; /* mount identifier */
int mnt_group_id; /* peer group identifier */
int mnt_expiry_mark; /* true if marked for expiry */
+ time64_t mnt_time; /* time of mount */
struct hlist_head mnt_pins;
struct hlist_head mnt_stuck_children;
} __randomize_layout;
diff --git a/fs/namespace.c b/fs/namespace.c
index 04b35dfcc71f..3a91234e5fd0 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -198,6 +198,8 @@ static struct mount *alloc_vfsmnt(const char *name)
mnt->mnt_count = 1;
mnt->mnt_writers = 0;
#endif
+ /* For proc/<pid>/mountstats */
+ mnt->mnt_time = ktime_get_seconds();
INIT_HLIST_NODE(&mnt->mnt_hash);
INIT_LIST_HEAD(&mnt->mnt_child);
diff --git a/fs/proc_namespace.c b/fs/proc_namespace.c
index eafb75755fa3..34aea7f3f550 100644
--- a/fs/proc_namespace.c
+++ b/fs/proc_namespace.c
@@ -229,6 +229,19 @@ static int show_vfsstat(struct seq_file *m, struct vfsmount *mnt)
if (sb->s_op->show_stats) {
seq_putc(m, ' ');
err = sb->s_op->show_stats(m, mnt_path.dentry);
+ } else if (mnt_has_stats(mnt)) {
+ /* Similar to /proc/<pid>/io */
+ seq_printf(m, "\n"
+ "\ttimes: %lld %lld\n"
+ "\trchar: %lld\n"
+ "\twchar: %lld\n"
+ "\tsyscr: %lld\n"
+ "\tsyscw: %lld\n",
+ r->mnt_time, ktime_get_seconds(),
+ mnt_iostats_counter_read(r, MNTIOS_CHARS_RD),
+ mnt_iostats_counter_read(r, MNTIOS_CHARS_WR),
+ mnt_iostats_counter_read(r, MNTIOS_SYSCALLS_RD),
+ mnt_iostats_counter_read(r, MNTIOS_SYSCALLS_WR));
}
seq_putc(m, '\n');
--
2.25.1
next prev parent reply other threads:[~2021-01-07 21:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-07 21:43 [RFC PATCH 0/3] Generic per-mount io stats Amir Goldstein
2021-01-07 21:43 ` [RFC PATCH 1/3] fs: add iostats counters to struct mount Amir Goldstein
2021-01-07 21:44 ` [RFC PATCH 2/3] fs: collect per-mount io stats Amir Goldstein
2021-01-07 21:44 ` Amir Goldstein [this message]
2021-01-08 16:41 ` [RFC PATCH 0/3] Generic " Amir Goldstein
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=20210107214401.249416-4-amir73il@gmail.com \
--to=amir73il@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=viro@zeniv.linux.org.uk \
/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).