diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-11-28 21:04:59 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2025-04-29 13:44:30 -0400 |
commit | c9f0683bf3d571b61399670fe2ced6a9971d1ac8 (patch) | |
tree | 4aea63d82d4691734034e749244a067237235c1b | |
parent | 80f10f8f630549ecf870e70dab06531837e99f70 (diff) |
fs: super_cache_to_text()
Implement shrinker.to_text() for the superblock shrinker: print out nr
of dentries and inodes, total and shrinkable.
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Dave Chinner <david@fromorbit.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
From david@fromorbit.com Tue Aug 27 23:43:19 2024
> Also, list_lru_count() only counts root memcg objects, so any inodes
> and dentries accounted to memcgs and are freeable will not be
> included in this output. For systems with lots of memcgs, that will
> result in the superblock reporting lots of inodes and dentries, but
> almost nothing being freeable. hence to do this correctly, there
> needs to be per-node, per-memcg list_lru_count_one() iteration here...
>
> -Dave.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r-- | fs/super.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/fs/super.c b/fs/super.c index b9163aea216b..4a81d2c98125 100644 --- a/fs/super.c +++ b/fs/super.c @@ -36,6 +36,7 @@ #include <linux/lockdep.h> #include <linux/user_namespace.h> #include <linux/fs_context.h> +#include <linux/seq_buf.h> #include <uapi/linux/mount.h> #include "internal.h" @@ -270,6 +271,17 @@ static unsigned long super_cache_count(struct shrinker *shrink, return total_objects; } +static void super_cache_to_text(struct seq_buf *out, struct shrinker *shrink) +{ + struct super_block *sb = shrink->private_data; + + seq_buf_printf(out, "sb: %s\n", sb->s_id); + seq_buf_printf(out, "inodes: total %zu shrinkable %lu\n", + per_cpu_sum(*sb->s_inodes_nr), list_lru_count(&sb->s_inode_lru)); + seq_buf_printf(out, "dentries: toal %zu shrinkbale %lu\n", + per_cpu_sum(*sb->s_dentry_nr), list_lru_count(&sb->s_dentry_lru)); +} + static void destroy_super_work(struct work_struct *work) { struct super_block *s = container_of(work, struct super_block, @@ -396,6 +408,7 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags, s->s_shrink->scan_objects = super_cache_scan; s->s_shrink->count_objects = super_cache_count; + s->s_shrink->to_text = super_cache_to_text; s->s_shrink->batch = 1024; s->s_shrink->private_data = s; |