* [PATCH mm-new v2] mm/zblock: add debugfs
@ 2025-04-28 6:49 Igor Belousov
0 siblings, 0 replies; only message in thread
From: Igor Belousov @ 2025-04-28 6:49 UTC (permalink / raw)
To: linux-kernel, linux-mm
Cc: akpm, hannes, minchan, nphamcs, senozhatsky, shakeel.butt,
yosry.ahmed, Igor Belousov
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-04-28 6:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-28 6:49 [PATCH mm-new v2] mm/zblock: add debugfs Igor Belousov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox