From: Igor Belousov <igor.b@beldev.am>
To: linux-kernel@vger.kernel.org, linux-mm@kvack.org
Cc: akpm@linux-foundation.org, hannes@cmpxchg.org,
minchan@kernel.org, nphamcs@gmail.com, senozhatsky@chromium.org,
shakeel.butt@linux.dev, yosry.ahmed@linux.dev,
Igor Belousov <igor.b@beldev.am>
Subject: [PATCH mm-new v2] mm/zblock: add debugfs
Date: Mon, 28 Apr 2025 08:49:24 +0200 [thread overview]
Message-ID: <20250428064924.53496-1-igor.b@beldev.am> (raw)
Add debugfs entry to monitor number of blocks allocated for different
block sizes.
Signed-off-by: Igor Belousov <igor.b@beldev.am>
---
mm/zblock.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/mm/zblock.c b/mm/zblock.c
index 6afe6986260d..e2036a6e1617 100644
--- a/mm/zblock.c
+++ b/mm/zblock.c
@@ -17,6 +17,7 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/atomic.h>
+#include <linux/debugfs.h>
#include <linux/list.h>
#include <linux/mm.h>
#include <linux/module.h>
@@ -27,6 +28,7 @@
#include "zblock.h"
static struct rb_root block_desc_tree = RB_ROOT;
+static struct dentry *zblock_debugfs_root;
/* Encode handle of a particular slot in the pool using metadata */
static inline unsigned long metadata_to_handle(struct zblock_block *block,
@@ -111,6 +113,22 @@ static struct zblock_block *alloc_block(struct zblock_pool *pool,
return block;
}
+static int zblock_blocks_show(struct seq_file *s, void *v)
+{
+ struct zblock_pool *pool = s->private;
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(block_desc); i++) {
+ struct block_list *block_list = &pool->block_lists[i];
+
+ seq_printf(s, "%d: %ld blocks of %d pages (total %ld pages)\n",
+ i, block_list->block_count, 1 << block_desc[i].order,
+ block_list->block_count << block_desc[i].order);
+ }
+ return 0;
+}
+DEFINE_SHOW_ATTRIBUTE(zblock_blocks);
+
/*****************
* API Functions
*****************/
@@ -140,6 +158,9 @@ static struct zblock_pool *zblock_create_pool(gfp_t gfp)
INIT_LIST_HEAD(&block_list->active_list);
block_list->block_count = 0;
}
+
+ debugfs_create_file("blocks", S_IFREG | 0444, zblock_debugfs_root,
+ pool, &zblock_blocks_fops);
return pool;
}
@@ -426,12 +447,15 @@ static int __init init_zblock(void)
return ret;
zpool_register_driver(&zblock_zpool_driver);
+
+ zblock_debugfs_root = debugfs_create_dir("zblock", NULL);
return 0;
}
static void __exit exit_zblock(void)
{
zpool_unregister_driver(&zblock_zpool_driver);
+ debugfs_remove_recursive(zblock_debugfs_root);
delete_rbtree();
}
--
2.49.0
reply other threads:[~2025-04-28 6:49 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20250428064924.53496-1-igor.b@beldev.am \
--to=igor.b@beldev.am \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=nphamcs@gmail.com \
--cc=senozhatsky@chromium.org \
--cc=shakeel.butt@linux.dev \
--cc=yosry.ahmed@linux.dev \
/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