From 11d6d15339c993da5196150ee7b38e51655e73e0 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Mon, 14 Dec 2009 17:01:13 -0800 Subject: [PATCH] ceph bookkeeper: show memory footprint --- fs/ceph/bookkeeper.c | 10 ++++++++++ fs/ceph/bookkeeper.h | 1 + fs/ceph/debugfs.c | 17 +++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/fs/ceph/bookkeeper.c b/fs/ceph/bookkeeper.c index 8edfac9dc662..98051b7cc38c 100644 --- a/fs/ceph/bookkeeper.c +++ b/fs/ceph/bookkeeper.c @@ -257,6 +257,15 @@ char *ceph_kstrndup(char *fname, int line, const char *src, int n, gfp_t flags) return dst; } +size_t ceph_bookkeeper_get_footprint(void) +{ + size_t footprint; + spin_lock(&_bk_lock); + footprint = _total_alloc - _total_free; + spin_unlock(&_bk_lock); + return footprint; +} + void ceph_bookkeeper_init(void) { printk(KERN_ERR "bookkeeper: start\n"); @@ -273,3 +282,4 @@ void ceph_bookkeeper_finalize(void) { ceph_bookkeeper_dump(); } + diff --git a/fs/ceph/bookkeeper.h b/fs/ceph/bookkeeper.h index db7f9738d97a..70bd32926121 100644 --- a/fs/ceph/bookkeeper.h +++ b/fs/ceph/bookkeeper.h @@ -24,6 +24,7 @@ extern void *ceph_kmem_cache_alloc(char *fname, int line, struct kmem_cache *cac gfp_t flags); extern void ceph_kmem_cache_free(struct kmem_cache *cachep, void *objp); +extern size_t ceph_bookkeeper_get_footprint(void); #endif diff --git a/fs/ceph/debugfs.c b/fs/ceph/debugfs.c index 21a8b4212105..5ddea948c89e 100644 --- a/fs/ceph/debugfs.c +++ b/fs/ceph/debugfs.c @@ -29,6 +29,7 @@ static struct dentry *ceph_debugfs_dir; #ifdef CONFIG_CEPH_BOOKKEEPER static struct dentry *ceph_debugfs_bookkeeper; +static struct dentry *ceph_debugfs_footprint; #endif static int monmap_show(struct seq_file *s, void *p) @@ -335,8 +336,16 @@ static int debugfs_bookkeeper_get(void *data, u64 *val) return 0; } +static int debugfs_footprint_get(void *data, u64 *val) +{ + *val = (u64)ceph_bookkeeper_get_footprint(); + return 0; +} + DEFINE_SIMPLE_ATTRIBUTE(bookkeeper_fops, debugfs_bookkeeper_get, debugfs_bookkeeper_set, "%llu\n"); +DEFINE_SIMPLE_ATTRIBUTE(footprint_fops, debugfs_footprint_get, + NULL, "%llu\n"); #endif int __init ceph_debugfs_init(void) @@ -436,6 +445,14 @@ int ceph_debugfs_client_init(struct ceph_client *client) &bookkeeper_fops); if (!ceph_debugfs_bookkeeper) goto out; + + ceph_debugfs_footprint = debugfs_create_file("ceph_footprint", + 0600, + ceph_debugfs_dir, + NULL, + &footprint_fops); + if (!ceph_debugfs_footprint) + goto out; #endif return 0; -- 2.47.3