summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2015-09-29 13:20:52 +0200
committerJustus Winter <4winter@informatik.uni-hamburg.de>2015-09-29 13:20:52 +0200
commitb64c73ca13beef304e86753b78f8079faa885989 (patch)
treea239c36cbf131a72af6494a868771db520d54d59
parent5e8955c2ad4b51acc96fdb671c4fef924dbc7f82 (diff)
ddb: add new command `show slabinfo'
* ddb/db_command.c (db_show_cmds): Add `slabinfo'. * kern/slab.c (slab_info): Generalize so that it can be used with different printf-like functions, and turn it into a static function. (slab_info): New wrapper retaining the old behaviour. (db_show_slab_info): New wrapper that uses `db_printf' instead. * kern/slab.h (db_show_slab_info): New declaration.
-rw-r--r--ddb/db_command.c2
-rw-r--r--kern/slab.c21
-rw-r--r--kern/slab.h4
3 files changed, 24 insertions, 3 deletions
diff --git a/ddb/db_command.c b/ddb/db_command.c
index 56516672..721f04fe 100644
--- a/ddb/db_command.c
+++ b/ddb/db_command.c
@@ -57,6 +57,7 @@
#include <machine/db_interface.h>
#include <kern/debug.h>
#include <kern/thread.h>
+#include <kern/slab.h>
#include <ipc/ipc_pset.h> /* 4proto */
#include <ipc/ipc_port.h> /* 4proto */
@@ -327,6 +328,7 @@ struct db_command db_show_cmds[] = {
{ "kmsg", ipc_kmsg_print, 0, 0 },
{ "msg", ipc_msg_print, 0, 0 },
{ "ipc_port", db_show_port_id, 0, 0 },
+ { "slabinfo", db_show_slab_info, 0, 0 },
{ (char *)0, }
};
diff --git a/kern/slab.c b/kern/slab.c
index 1114cfa3..8a98aa59 100644
--- a/kern/slab.c
+++ b/kern/slab.c
@@ -1433,12 +1433,12 @@ void kfree(vm_offset_t data, vm_size_t size)
}
}
-void slab_info(void)
+static void _slab_info(int (printx)(const char *fmt, ...))
{
struct kmem_cache *cache;
vm_size_t mem_usage, mem_reclaimable;
- printf("cache obj slab bufs objs bufs "
+ printx("cache obj slab bufs objs bufs "
" total reclaimable\n"
"name size size /slab usage count "
" memory memory\n");
@@ -1451,7 +1451,7 @@ void slab_info(void)
mem_usage = (cache->nr_slabs * cache->slab_size) >> 10;
mem_reclaimable = (cache->nr_free_slabs * cache->slab_size) >> 10;
- printf("%-19s %6lu %3luk %4lu %6lu %6lu %7uk %10uk\n",
+ printx("%-19s %6lu %3luk %4lu %6lu %6lu %7uk %10uk\n",
cache->name, cache->obj_size, cache->slab_size >> 10,
cache->bufs_per_slab, cache->nr_objs, cache->nr_bufs,
mem_usage, mem_reclaimable);
@@ -1462,6 +1462,21 @@ void slab_info(void)
simple_unlock(&kmem_cache_list_lock);
}
+void slab_info(void)
+{
+ _slab_info(printf);
+}
+
+#if MACH_KDB
+#include <ddb/db_output.h>
+
+ void db_show_slab_info(void)
+{
+ _slab_info(db_printf);
+}
+
+#endif /* MACH_KDB */
+
#if MACH_DEBUG
kern_return_t host_slab_info(host_t host, cache_info_array_t *infop,
unsigned int *infoCntp)
diff --git a/kern/slab.h b/kern/slab.h
index c7be1692..77db7c1b 100644
--- a/kern/slab.h
+++ b/kern/slab.h
@@ -253,4 +253,8 @@ void slab_collect(void);
*/
void slab_info(void);
+#if MACH_KDB
+void db_show_slab_info(void);
+#endif /* MACH_KDB */
+
#endif /* _KERN_SLAB_H */