lkml.org 
[lkml]   [2023]   [Mar]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH 2/5] mm/unmapped_alloc: add debugfs file similar to /proc/pagetypeinfo
Date
From: "Mike Rapoport (IBM)" <rppt@kernel.org>

Present statistics about unmapped_alloc in debugfs

Signed-off-by: Mike Rapoport (IBM) <rppt@kernel.org>
---
mm/unmapped-alloc.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)

diff --git a/mm/unmapped-alloc.c b/mm/unmapped-alloc.c
index fb2d54204a3c..f74640e9ce9f 100644
--- a/mm/unmapped-alloc.c
+++ b/mm/unmapped-alloc.c
@@ -3,6 +3,7 @@
#include <linux/gfp.h>
#include <linux/mmzone.h>
#include <linux/printk.h>
+#include <linux/debugfs.h>
#include <linux/spinlock.h>
#include <linux/set_memory.h>

@@ -213,3 +214,37 @@ int unmapped_alloc_init(void)

return 0;
}
+
+static int unmapped_alloc_debug_show(struct seq_file *m, void *private)
+{
+ int order;
+
+ seq_printf(m, "MAX_ORDER: %d\n", MAX_ORDER);
+ seq_putc(m, '\n');
+
+ seq_printf(m, "%-10s", "Order:");
+ for (order = 0; order < MAX_ORDER; ++order)
+ seq_printf(m, "%5d ", order);
+ seq_putc(m, '\n');
+
+ seq_printf(m, "%-10s", "Free:");
+ for (order = 0; order < MAX_ORDER; ++order)
+ seq_printf(m, "%5lu ", free_area[order].nr_free);
+ seq_putc(m, '\n');
+
+ seq_printf(m, "%-10s", "Cached:");
+ for (order = 0; order < MAX_ORDER; ++order)
+ seq_printf(m, "%5lu ", free_area[order].nr_cached);
+ seq_putc(m, '\n');
+
+ return 0;
+}
+DEFINE_SHOW_ATTRIBUTE(unmapped_alloc_debug);
+
+static int __init unmapped_alloc_init_late(void)
+{
+ debugfs_create_file("unmapped_alloc", 0444, NULL,
+ NULL, &unmapped_alloc_debug_fops);
+ return 0;
+}
+late_initcall(unmapped_alloc_init_late);
--
2.35.1
\
 
 \ /
  Last update: 2023-03-27 00:49    [W:0.273 / U:0.232 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site