Commit 1ac37bee authored by Dan Magenheimer's avatar Dan Magenheimer Committed by Linus Torvalds

staging: zcache: enable ramster to be built/loaded as a module

Enable module support for ramster.  Note runtime dependency disallows
loading if cleancache/frontswap lazy initialization patches are not
present.

If built-in (not built as a module), the original mechanism of enabling
via a kernel boot parameter is retained, but this should be considered
deprecated.

Note that module unload is explicitly not yet supported.

[v1: Fixed compile issues since ramster_init now has four arguments]
[v2: Fixed rebase on ramster->zcache move]
[akpm@linux-foundation.org: use_frontswap_selfshrink cannot be __initdata]
Signed-off-by: default avatarDan Magenheimer <dan.magenheimer@oracle.com>
Signed-off-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: default avatarBob Liu <lliubbo@gmail.com>
Cc: Wanpeng Li <liwanp@linux.vnet.ibm.com>
Cc: Andor Daam <andor.daam@googlemail.com>
Cc: Florian Schmaus <fschmaus@gmail.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Stefan Hengelein <ilendir@googlemail.com>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent f42158fe
...@@ -11,10 +11,14 @@ ...@@ -11,10 +11,14 @@
#ifndef _ZCACHE_RAMSTER_H_ #ifndef _ZCACHE_RAMSTER_H_
#define _ZCACHE_RAMSTER_H_ #define _ZCACHE_RAMSTER_H_
#ifdef CONFIG_RAMSTER_MODULE
#define CONFIG_RAMSTER
#endif
#ifdef CONFIG_RAMSTER #ifdef CONFIG_RAMSTER
#include "ramster/ramster.h" #include "ramster/ramster.h"
#else #else
static inline void ramster_init(bool x, bool y, bool z) static inline void ramster_init(bool x, bool y, bool z, bool w)
{ {
} }
......
...@@ -43,7 +43,7 @@ static struct debug_entry { ...@@ -43,7 +43,7 @@ static struct debug_entry {
}; };
#undef ATTR #undef ATTR
int __init ramster_debugfs_init(void) int ramster_debugfs_init(void)
{ {
int i; int i;
struct dentry *root = debugfs_create_dir("ramster", NULL); struct dentry *root = debugfs_create_dir("ramster", NULL);
......
...@@ -949,7 +949,7 @@ static void __exit exit_r2nm(void) ...@@ -949,7 +949,7 @@ static void __exit exit_r2nm(void)
r2hb_exit(); r2hb_exit();
} }
static int __init init_r2nm(void) int r2nm_init(void)
{ {
int ret = -1; int ret = -1;
...@@ -986,10 +986,11 @@ static int __init init_r2nm(void) ...@@ -986,10 +986,11 @@ static int __init init_r2nm(void)
out: out:
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(r2nm_init);
MODULE_AUTHOR("Oracle"); MODULE_AUTHOR("Oracle");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
/* module_init(init_r2nm) */ #ifndef CONFIG_RAMSTER_MODULE
late_initcall(init_r2nm); late_initcall(r2nm_init);
/* module_exit(exit_r2nm) */ #endif
...@@ -121,6 +121,7 @@ int ramster_do_preload_flnode(struct tmem_pool *pool) ...@@ -121,6 +121,7 @@ int ramster_do_preload_flnode(struct tmem_pool *pool)
kmem_cache_free(ramster_flnode_cache, flnode); kmem_cache_free(ramster_flnode_cache, flnode);
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(ramster_do_preload_flnode);
/* /*
* Called by the message handler after a (still compressed) page has been * Called by the message handler after a (still compressed) page has been
...@@ -388,6 +389,7 @@ void *ramster_pampd_free(void *pampd, struct tmem_pool *pool, ...@@ -388,6 +389,7 @@ void *ramster_pampd_free(void *pampd, struct tmem_pool *pool,
} }
return local_pampd; return local_pampd;
} }
EXPORT_SYMBOL_GPL(ramster_pampd_free);
void ramster_count_foreign_pages(bool eph, int count) void ramster_count_foreign_pages(bool eph, int count)
{ {
...@@ -408,6 +410,7 @@ void ramster_count_foreign_pages(bool eph, int count) ...@@ -408,6 +410,7 @@ void ramster_count_foreign_pages(bool eph, int count)
} }
} }
} }
EXPORT_SYMBOL_GPL(ramster_count_foreign_pages);
/* /*
* For now, just push over a few pages every few seconds to * For now, just push over a few pages every few seconds to
...@@ -593,7 +596,7 @@ static void ramster_remotify_process(struct work_struct *work) ...@@ -593,7 +596,7 @@ static void ramster_remotify_process(struct work_struct *work)
ramster_remotify_queue_delayed_work(HZ); ramster_remotify_queue_delayed_work(HZ);
} }
void __init ramster_remotify_init(void) void ramster_remotify_init(void)
{ {
unsigned long n = 60UL; unsigned long n = 60UL;
ramster_remotify_workqueue = ramster_remotify_workqueue =
...@@ -768,8 +771,10 @@ static bool frontswap_selfshrinking __read_mostly; ...@@ -768,8 +771,10 @@ static bool frontswap_selfshrinking __read_mostly;
static void selfshrink_process(struct work_struct *work); static void selfshrink_process(struct work_struct *work);
static DECLARE_DELAYED_WORK(selfshrink_worker, selfshrink_process); static DECLARE_DELAYED_WORK(selfshrink_worker, selfshrink_process);
#ifndef CONFIG_RAMSTER_MODULE
/* Enable/disable with kernel boot option. */ /* Enable/disable with kernel boot option. */
static bool use_frontswap_selfshrink __initdata = true; static bool use_frontswap_selfshrink = true;
#endif
/* /*
* The default values for the following parameters were deemed reasonable * The default values for the following parameters were deemed reasonable
...@@ -824,6 +829,7 @@ static void frontswap_selfshrink(void) ...@@ -824,6 +829,7 @@ static void frontswap_selfshrink(void)
frontswap_shrink(tgt_frontswap_pages); frontswap_shrink(tgt_frontswap_pages);
} }
#ifndef CONFIG_RAMSTER_MODULE
static int __init ramster_nofrontswap_selfshrink_setup(char *s) static int __init ramster_nofrontswap_selfshrink_setup(char *s)
{ {
use_frontswap_selfshrink = false; use_frontswap_selfshrink = false;
...@@ -831,6 +837,7 @@ static int __init ramster_nofrontswap_selfshrink_setup(char *s) ...@@ -831,6 +837,7 @@ static int __init ramster_nofrontswap_selfshrink_setup(char *s)
} }
__setup("noselfshrink", ramster_nofrontswap_selfshrink_setup); __setup("noselfshrink", ramster_nofrontswap_selfshrink_setup);
#endif
static void selfshrink_process(struct work_struct *work) static void selfshrink_process(struct work_struct *work)
{ {
...@@ -849,6 +856,7 @@ void ramster_cpu_up(int cpu) ...@@ -849,6 +856,7 @@ void ramster_cpu_up(int cpu)
per_cpu(ramster_remoteputmem1, cpu) = p1; per_cpu(ramster_remoteputmem1, cpu) = p1;
per_cpu(ramster_remoteputmem2, cpu) = p2; per_cpu(ramster_remoteputmem2, cpu) = p2;
} }
EXPORT_SYMBOL_GPL(ramster_cpu_up);
void ramster_cpu_down(int cpu) void ramster_cpu_down(int cpu)
{ {
...@@ -864,6 +872,7 @@ void ramster_cpu_down(int cpu) ...@@ -864,6 +872,7 @@ void ramster_cpu_down(int cpu)
kp->flnode = NULL; kp->flnode = NULL;
} }
} }
EXPORT_SYMBOL_GPL(ramster_cpu_down);
void ramster_register_pamops(struct tmem_pamops *pamops) void ramster_register_pamops(struct tmem_pamops *pamops)
{ {
...@@ -874,9 +883,11 @@ void ramster_register_pamops(struct tmem_pamops *pamops) ...@@ -874,9 +883,11 @@ void ramster_register_pamops(struct tmem_pamops *pamops)
pamops->repatriate = ramster_pampd_repatriate; pamops->repatriate = ramster_pampd_repatriate;
pamops->repatriate_preload = ramster_pampd_repatriate_preload; pamops->repatriate_preload = ramster_pampd_repatriate_preload;
} }
EXPORT_SYMBOL_GPL(ramster_register_pamops);
void __init ramster_init(bool cleancache, bool frontswap, void ramster_init(bool cleancache, bool frontswap,
bool frontswap_exclusive_gets) bool frontswap_exclusive_gets,
bool frontswap_selfshrink)
{ {
int ret = 0; int ret = 0;
...@@ -891,10 +902,17 @@ void __init ramster_init(bool cleancache, bool frontswap, ...@@ -891,10 +902,17 @@ void __init ramster_init(bool cleancache, bool frontswap,
if (ret) if (ret)
pr_err("ramster: can't create sysfs for ramster\n"); pr_err("ramster: can't create sysfs for ramster\n");
(void)r2net_register_handlers(); (void)r2net_register_handlers();
#ifdef CONFIG_RAMSTER_MODULE
ret = r2nm_init();
if (ret)
pr_err("ramster: can't init r2net\n");
frontswap_selfshrinking = frontswap_selfshrink;
#else
frontswap_selfshrinking = use_frontswap_selfshrink;
#endif
INIT_LIST_HEAD(&ramster_rem_op_list); INIT_LIST_HEAD(&ramster_rem_op_list);
ramster_flnode_cache = kmem_cache_create("ramster_flnode", ramster_flnode_cache = kmem_cache_create("ramster_flnode",
sizeof(struct flushlist_node), 0, 0, NULL); sizeof(struct flushlist_node), 0, 0, NULL);
frontswap_selfshrinking = use_frontswap_selfshrink;
if (frontswap_selfshrinking) { if (frontswap_selfshrinking) {
pr_info("ramster: Initializing frontswap selfshrink driver.\n"); pr_info("ramster: Initializing frontswap selfshrink driver.\n");
schedule_delayed_work(&selfshrink_worker, schedule_delayed_work(&selfshrink_worker,
...@@ -902,3 +920,4 @@ void __init ramster_init(bool cleancache, bool frontswap, ...@@ -902,3 +920,4 @@ void __init ramster_init(bool cleancache, bool frontswap,
} }
ramster_remotify_init(); ramster_remotify_init();
} }
EXPORT_SYMBOL_GPL(ramster_init);
...@@ -147,7 +147,7 @@ extern int r2net_register_handlers(void); ...@@ -147,7 +147,7 @@ extern int r2net_register_handlers(void);
extern int r2net_remote_target_node_set(int); extern int r2net_remote_target_node_set(int);
extern int ramster_remotify_pageframe(bool); extern int ramster_remotify_pageframe(bool);
extern void ramster_init(bool, bool, bool); extern void ramster_init(bool, bool, bool, bool);
extern void ramster_register_pamops(struct tmem_pamops *); extern void ramster_register_pamops(struct tmem_pamops *);
extern int ramster_localify(int, struct tmem_oid *oidp, uint32_t, char *, extern int ramster_localify(int, struct tmem_oid *oidp, uint32_t, char *,
unsigned int, void *); unsigned int, void *);
......
...@@ -36,4 +36,6 @@ ...@@ -36,4 +36,6 @@
/* host name, group name, cluster name all 64 bytes */ /* host name, group name, cluster name all 64 bytes */
#define R2NM_MAX_NAME_LEN 64 /* __NEW_UTS_LEN */ #define R2NM_MAX_NAME_LEN 64 /* __NEW_UTS_LEN */
extern int r2nm_init(void);
#endif /* _RAMSTER_NODEMANAGER_H */ #endif /* _RAMSTER_NODEMANAGER_H */
...@@ -1894,7 +1894,7 @@ static int __init zcache_init(void) ...@@ -1894,7 +1894,7 @@ static int __init zcache_init(void)
} }
if (ramster_enabled) if (ramster_enabled)
ramster_init(!disable_cleancache, !disable_frontswap, ramster_init(!disable_cleancache, !disable_frontswap,
frontswap_has_exclusive_gets); frontswap_has_exclusive_gets, false);
out: out:
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment