staging: ramster: Move debugfs code out of ramster.c file

Note that at this point there is no CONFIG_RAMSTER_DEBUG
option in the Kconfig. So in effect all of the counters
are nop until that option gets introduced in patch:
ramster/debug: Add CONFIG_RAMSTER_DEBUG Kconfig entry

Acked-by: Dan Magenheimer <dan.magenheimer@oracle.com>
Signed-off-by: Wanpeng Li <liwanp@linux.vnet.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Wanpeng Li 2013-04-13 21:01:27 +08:00 committed by Greg Kroah-Hartman
parent c067ad1124
commit df73554300
4 changed files with 154 additions and 110 deletions

View File

@ -1,5 +1,6 @@
zcache-y := zcache-main.o tmem.o zbud.o
zcache-$(CONFIG_ZCACHE_DEBUG) += debug.o
zcache-$(CONFIG_RAMSTER) += ramster/debug.o
zcache-$(CONFIG_RAMSTER) += ramster/ramster.o ramster/r2net.o
zcache-$(CONFIG_RAMSTER) += ramster/nodemanager.o ramster/tcp.o
zcache-$(CONFIG_RAMSTER) += ramster/heartbeat.o ramster/masklog.o

View File

@ -0,0 +1,70 @@
#include <linux/atomic.h>
#include "debug.h"
#ifdef CONFIG_DEBUG_FS
#include <linux/debugfs.h>
#define zdfs debugfs_create_size_t
#define zdfs64 debugfs_create_u64
ssize_t ramster_eph_pages_remoted;
ssize_t ramster_pers_pages_remoted;
ssize_t ramster_eph_pages_remote_failed;
ssize_t ramster_pers_pages_remote_failed;
ssize_t ramster_remote_eph_pages_succ_get;
ssize_t ramster_remote_pers_pages_succ_get;
ssize_t ramster_remote_eph_pages_unsucc_get;
ssize_t ramster_remote_pers_pages_unsucc_get;
ssize_t ramster_pers_pages_remote_nomem;
ssize_t ramster_remote_objects_flushed;
ssize_t ramster_remote_object_flushes_failed;
ssize_t ramster_remote_pages_flushed;
ssize_t ramster_remote_page_flushes_failed;
int __init ramster_debugfs_init(void)
{
struct dentry *root = debugfs_create_dir("ramster", NULL);
if (root == NULL)
return -ENXIO;
zdfs("eph_pages_remoted", S_IRUGO, root, &ramster_eph_pages_remoted);
zdfs("pers_pages_remoted", S_IRUGO, root, &ramster_pers_pages_remoted);
zdfs("eph_pages_remote_failed", S_IRUGO, root,
&ramster_eph_pages_remote_failed);
zdfs("pers_pages_remote_failed", S_IRUGO, root,
&ramster_pers_pages_remote_failed);
zdfs("remote_eph_pages_succ_get", S_IRUGO, root,
&ramster_remote_eph_pages_succ_get);
zdfs("remote_pers_pages_succ_get", S_IRUGO, root,
&ramster_remote_pers_pages_succ_get);
zdfs("remote_eph_pages_unsucc_get", S_IRUGO, root,
&ramster_remote_eph_pages_unsucc_get);
zdfs("remote_pers_pages_unsucc_get", S_IRUGO, root,
&ramster_remote_pers_pages_unsucc_get);
zdfs("pers_pages_remote_nomem", S_IRUGO, root,
&ramster_pers_pages_remote_nomem);
zdfs("remote_objects_flushed", S_IRUGO, root,
&ramster_remote_objects_flushed);
zdfs("remote_pages_flushed", S_IRUGO, root,
&ramster_remote_pages_flushed);
zdfs("remote_object_flushes_failed", S_IRUGO, root,
&ramster_remote_object_flushes_failed);
zdfs("remote_page_flushes_failed", S_IRUGO, root,
&ramster_remote_page_flushes_failed);
zdfs("foreign_eph_pages", S_IRUGO, root,
&ramster_foreign_eph_pages);
zdfs("foreign_eph_pages_max", S_IRUGO, root,
&ramster_foreign_eph_pages_max);
zdfs("foreign_pers_pages", S_IRUGO, root,
&ramster_foreign_pers_pages);
zdfs("foreign_pers_pages_max", S_IRUGO, root,
&ramster_foreign_pers_pages_max);
return 0;
}
#undef zdebugfs
#undef zdfs64
#else
static inline int ramster_debugfs_init(void)
{
return 0;
}
#endif

View File

@ -0,0 +1,78 @@
#include <linux/bug.h>
#ifdef CONFIG_RAMSTER
extern long ramster_flnodes;
static atomic_t ramster_flnodes_atomic = ATOMIC_INIT(0);
static unsigned long ramster_flnodes_max;
static inline void inc_ramster_flnodes(void)
{
ramster_flnodes = atomic_inc_return(&ramster_flnodes_atomic);
if (ramster_flnodes > ramster_flnodes_max)
ramster_flnodes_max = ramster_flnodes;
}
static inline void dec_ramster_flnodes(void)
{
ramster_flnodes = atomic_dec_return(&ramster_flnodes_atomic);
}
extern ssize_t ramster_foreign_eph_pages;
static atomic_t ramster_foreign_eph_pages_atomic = ATOMIC_INIT(0);
static ssize_t ramster_foreign_eph_pages_max;
static inline void inc_ramster_foreign_eph_pages(void)
{
ramster_foreign_eph_pages = atomic_inc_return(
&ramster_foreign_eph_pages_atomic);
if (ramster_foreign_eph_pages > ramster_foreign_eph_pages_max)
ramster_foreign_eph_pages_max = ramster_foreign_eph_pages;
}
static inline void dec_ramster_foreign_eph_pages(void)
{
ramster_foreign_eph_pages = atomic_dec_return(
&ramster_foreign_eph_pages_atomic);
}
extern ssize_t ramster_foreign_pers_pages;
static atomic_t ramster_foreign_pers_pages_atomic = ATOMIC_INIT(0);
static ssize_t ramster_foreign_pers_pages_max;
static inline void inc_ramster_foreign_pers_pages(void)
{
ramster_foreign_pers_pages = atomic_inc_return(
&ramster_foreign_pers_pages_atomic);
if (ramster_foreign_pers_pages > ramster_foreign_pers_pages_max)
ramster_foreign_pers_pages_max = ramster_foreign_pers_pages;
}
static inline void dec_ramster_foreign_pers_pages(void)
{
ramster_foreign_pers_pages = atomic_dec_return(
&ramster_foreign_pers_pages_atomic);
}
extern ssize_t ramster_eph_pages_remoted;
extern ssize_t ramster_pers_pages_remoted;
extern ssize_t ramster_eph_pages_remote_failed;
extern ssize_t ramster_pers_pages_remote_failed;
extern ssize_t ramster_remote_eph_pages_succ_get;
extern ssize_t ramster_remote_pers_pages_succ_get;
extern ssize_t ramster_remote_eph_pages_unsucc_get;
extern ssize_t ramster_remote_pers_pages_unsucc_get;
extern ssize_t ramster_pers_pages_remote_nomem;
extern ssize_t ramster_remote_objects_flushed;
extern ssize_t ramster_remote_object_flushes_failed;
extern ssize_t ramster_remote_pages_flushed;
extern ssize_t ramster_remote_page_flushes_failed;
int ramster_debugfs_init(void);
#else
static inline void inc_ramster_flnodes(void) { };
static inline void dec_ramster_flnodes(void) { };
static inline void inc_ramster_foreign_eph_pages(void) { };
static inline void dec_ramster_foreign_eph_pages(void) { };
static inline void inc_ramster_foreign_pers_pages(void) { };
static inline void dec_ramster_foreign_pers_pages(void) { };
static inline int ramster_debugfs_init(void)
{
return 0;
}
#endif

View File

@ -42,6 +42,7 @@
#include "ramster.h"
#include "ramster_nodemanager.h"
#include "tcp.h"
#include "debug.h"
#define RAMSTER_TESTING
@ -63,118 +64,12 @@ static atomic_t ramster_remote_pers_pages = ATOMIC_INIT(0);
static bool ramster_nodes_manual_up[MANUAL_NODES] __read_mostly;
static int ramster_remote_target_nodenum __read_mostly = -1;
/* these counters are made available via debugfs */
static long ramster_flnodes;
static atomic_t ramster_flnodes_atomic = ATOMIC_INIT(0);
static unsigned long ramster_flnodes_max;
static inline void inc_ramster_flnodes(void)
{
ramster_flnodes = atomic_inc_return(&ramster_flnodes_atomic);
if (ramster_flnodes > ramster_flnodes_max)
ramster_flnodes_max = ramster_flnodes;
}
static inline void dec_ramster_flnodes(void)
{
ramster_flnodes = atomic_dec_return(&ramster_flnodes_atomic);
}
static ssize_t ramster_foreign_eph_pages;
static atomic_t ramster_foreign_eph_pages_atomic = ATOMIC_INIT(0);
static ssize_t ramster_foreign_eph_pages_max;
static inline void inc_ramster_foreign_eph_pages(void)
{
ramster_foreign_eph_pages = atomic_inc_return(
&ramster_foreign_eph_pages_atomic);
if (ramster_foreign_eph_pages > ramster_foreign_eph_pages_max)
ramster_foreign_eph_pages_max = ramster_foreign_eph_pages;
}
static inline void dec_ramster_foreign_eph_pages(void)
{
ramster_foreign_eph_pages = atomic_dec_return(
&ramster_foreign_eph_pages_atomic);
}
static ssize_t ramster_foreign_pers_pages;
static atomic_t ramster_foreign_pers_pages_atomic = ATOMIC_INIT(0);
static ssize_t ramster_foreign_pers_pages_max;
static inline void inc_ramster_foreign_pers_pages(void)
{
ramster_foreign_pers_pages = atomic_inc_return(
&ramster_foreign_pers_pages_atomic);
if (ramster_foreign_pers_pages > ramster_foreign_pers_pages_max)
ramster_foreign_pers_pages_max = ramster_foreign_pers_pages;
}
static inline void dec_ramster_foreign_pers_pages(void)
{
ramster_foreign_pers_pages = atomic_dec_return(
&ramster_foreign_pers_pages_atomic);
}
static ssize_t ramster_eph_pages_remoted;
static ssize_t ramster_pers_pages_remoted;
static ssize_t ramster_eph_pages_remote_failed;
static ssize_t ramster_pers_pages_remote_failed;
static ssize_t ramster_remote_eph_pages_succ_get;
static ssize_t ramster_remote_pers_pages_succ_get;
static ssize_t ramster_remote_eph_pages_unsucc_get;
static ssize_t ramster_remote_pers_pages_unsucc_get;
static ssize_t ramster_pers_pages_remote_nomem;
static ssize_t ramster_remote_objects_flushed;
static ssize_t ramster_remote_object_flushes_failed;
static ssize_t ramster_remote_pages_flushed;
static ssize_t ramster_remote_page_flushes_failed;
/* Used by this code. */
long ramster_flnodes;
ssize_t ramster_foreign_eph_pages;
ssize_t ramster_foreign_pers_pages;
/* FIXME frontswap selfshrinking knobs in debugfs? */
#ifdef CONFIG_DEBUG_FS
#include <linux/debugfs.h>
#define zdfs debugfs_create_size_t
#define zdfs64 debugfs_create_u64
static int __init ramster_debugfs_init(void)
{
struct dentry *root = debugfs_create_dir("ramster", NULL);
if (root == NULL)
return -ENXIO;
zdfs("eph_pages_remoted", S_IRUGO, root, &ramster_eph_pages_remoted);
zdfs("pers_pages_remoted", S_IRUGO, root, &ramster_pers_pages_remoted);
zdfs("eph_pages_remote_failed", S_IRUGO, root,
&ramster_eph_pages_remote_failed);
zdfs("pers_pages_remote_failed", S_IRUGO, root,
&ramster_pers_pages_remote_failed);
zdfs("remote_eph_pages_succ_get", S_IRUGO, root,
&ramster_remote_eph_pages_succ_get);
zdfs("remote_pers_pages_succ_get", S_IRUGO, root,
&ramster_remote_pers_pages_succ_get);
zdfs("remote_eph_pages_unsucc_get", S_IRUGO, root,
&ramster_remote_eph_pages_unsucc_get);
zdfs("remote_pers_pages_unsucc_get", S_IRUGO, root,
&ramster_remote_pers_pages_unsucc_get);
zdfs("pers_pages_remote_nomem", S_IRUGO, root,
&ramster_pers_pages_remote_nomem);
zdfs("remote_objects_flushed", S_IRUGO, root,
&ramster_remote_objects_flushed);
zdfs("remote_pages_flushed", S_IRUGO, root,
&ramster_remote_pages_flushed);
zdfs("remote_object_flushes_failed", S_IRUGO, root,
&ramster_remote_object_flushes_failed);
zdfs("remote_page_flushes_failed", S_IRUGO, root,
&ramster_remote_page_flushes_failed);
zdfs("foreign_eph_pages", S_IRUGO, root,
&ramster_foreign_eph_pages);
zdfs("foreign_eph_pages_max", S_IRUGO, root,
&ramster_foreign_eph_pages_max);
zdfs("foreign_pers_pages", S_IRUGO, root,
&ramster_foreign_pers_pages);
zdfs("foreign_pers_pages_max", S_IRUGO, root,
&ramster_foreign_pers_pages_max);
return 0;
}
#undef zdebugfs
#undef zdfs64
#else
static inline int ramster_debugfs_init(void)
{
return 0;
}
#endif
static LIST_HEAD(ramster_rem_op_list);
static DEFINE_SPINLOCK(ramster_rem_op_list_lock);
static DEFINE_PER_CPU(struct ramster_preload, ramster_preloads);