aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/xen/tmem.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/xen/tmem.c')
-rw-r--r--drivers/xen/tmem.c55
1 files changed, 40 insertions, 15 deletions
diff --git a/drivers/xen/tmem.c b/drivers/xen/tmem.c
index 3ee836d42581..e3600be4e7fa 100644
--- a/drivers/xen/tmem.c
+++ b/drivers/xen/tmem.c
@@ -5,6 +5,7 @@
5 * Author: Dan Magenheimer 5 * Author: Dan Magenheimer
6 */ 6 */
7 7
8#include <linux/module.h>
8#include <linux/kernel.h> 9#include <linux/kernel.h>
9#include <linux/types.h> 10#include <linux/types.h>
10#include <linux/init.h> 11#include <linux/init.h>
@@ -128,6 +129,7 @@ static int xen_tmem_flush_object(u32 pool_id, struct tmem_oid oid)
128 return xen_tmem_op(TMEM_FLUSH_OBJECT, pool_id, oid, 0, 0, 0, 0, 0); 129 return xen_tmem_op(TMEM_FLUSH_OBJECT, pool_id, oid, 0, 0, 0, 0, 0);
129} 130}
130 131
132#ifndef CONFIG_XEN_TMEM_MODULE
131bool __read_mostly tmem_enabled = false; 133bool __read_mostly tmem_enabled = false;
132 134
133static int __init enable_tmem(char *s) 135static int __init enable_tmem(char *s)
@@ -136,6 +138,7 @@ static int __init enable_tmem(char *s)
136 return 1; 138 return 1;
137} 139}
138__setup("tmem", enable_tmem); 140__setup("tmem", enable_tmem);
141#endif
139 142
140#ifdef CONFIG_CLEANCACHE 143#ifdef CONFIG_CLEANCACHE
141static int xen_tmem_destroy_pool(u32 pool_id) 144static int xen_tmem_destroy_pool(u32 pool_id)
@@ -227,16 +230,21 @@ static int tmem_cleancache_init_shared_fs(char *uuid, size_t pagesize)
227 return xen_tmem_new_pool(shared_uuid, TMEM_POOL_SHARED, pagesize); 230 return xen_tmem_new_pool(shared_uuid, TMEM_POOL_SHARED, pagesize);
228} 231}
229 232
230static bool __initdata use_cleancache = true; 233static bool disable_cleancache __read_mostly;
231 234static bool disable_selfballooning __read_mostly;
235#ifdef CONFIG_XEN_TMEM_MODULE
236module_param(disable_cleancache, bool, S_IRUGO);
237module_param(disable_selfballooning, bool, S_IRUGO);
238#else
232static int __init no_cleancache(char *s) 239static int __init no_cleancache(char *s)
233{ 240{
234 use_cleancache = false; 241 disable_cleancache = true;
235 return 1; 242 return 1;
236} 243}
237__setup("nocleancache", no_cleancache); 244__setup("nocleancache", no_cleancache);
245#endif
238 246
239static struct cleancache_ops __initdata tmem_cleancache_ops = { 247static struct cleancache_ops tmem_cleancache_ops = {
240 .put_page = tmem_cleancache_put_page, 248 .put_page = tmem_cleancache_put_page,
241 .get_page = tmem_cleancache_get_page, 249 .get_page = tmem_cleancache_get_page,
242 .invalidate_page = tmem_cleancache_flush_page, 250 .invalidate_page = tmem_cleancache_flush_page,
@@ -353,54 +361,71 @@ static void tmem_frontswap_init(unsigned ignored)
353 xen_tmem_new_pool(private, TMEM_POOL_PERSIST, PAGE_SIZE); 361 xen_tmem_new_pool(private, TMEM_POOL_PERSIST, PAGE_SIZE);
354} 362}
355 363
356static bool __initdata use_frontswap = true; 364static bool disable_frontswap __read_mostly;
357 365static bool disable_frontswap_selfshrinking __read_mostly;
366#ifdef CONFIG_XEN_TMEM_MODULE
367module_param(disable_frontswap, bool, S_IRUGO);
368module_param(disable_frontswap_selfshrinking, bool, S_IRUGO);
369#else
358static int __init no_frontswap(char *s) 370static int __init no_frontswap(char *s)
359{ 371{
360 use_frontswap = false; 372 disable_frontswap = true;
361 return 1; 373 return 1;
362} 374}
363__setup("nofrontswap", no_frontswap); 375__setup("nofrontswap", no_frontswap);
376#endif
364 377
365static struct frontswap_ops __initdata tmem_frontswap_ops = { 378static struct frontswap_ops tmem_frontswap_ops = {
366 .store = tmem_frontswap_store, 379 .store = tmem_frontswap_store,
367 .load = tmem_frontswap_load, 380 .load = tmem_frontswap_load,
368 .invalidate_page = tmem_frontswap_flush_page, 381 .invalidate_page = tmem_frontswap_flush_page,
369 .invalidate_area = tmem_frontswap_flush_area, 382 .invalidate_area = tmem_frontswap_flush_area,
370 .init = tmem_frontswap_init 383 .init = tmem_frontswap_init
371}; 384};
385#else /* CONFIG_FRONTSWAP */
386#define disable_frontswap_selfshrinking 1
372#endif 387#endif
373 388
374static int __init xen_tmem_init(void) 389static int xen_tmem_init(void)
375{ 390{
376 if (!xen_domain()) 391 if (!xen_domain())
377 return 0; 392 return 0;
378#ifdef CONFIG_FRONTSWAP 393#ifdef CONFIG_FRONTSWAP
379 if (tmem_enabled && use_frontswap) { 394 if (tmem_enabled && !disable_frontswap) {
380 char *s = ""; 395 char *s = "";
381 struct frontswap_ops old_ops = 396 struct frontswap_ops *old_ops =
382 frontswap_register_ops(&tmem_frontswap_ops); 397 frontswap_register_ops(&tmem_frontswap_ops);
383 398
384 tmem_frontswap_poolid = -1; 399 tmem_frontswap_poolid = -1;
385 if (old_ops.init != NULL) 400 if (IS_ERR(old_ops) || old_ops) {
401 if (IS_ERR(old_ops))
402 return PTR_ERR(old_ops);
386 s = " (WARNING: frontswap_ops overridden)"; 403 s = " (WARNING: frontswap_ops overridden)";
404 }
387 printk(KERN_INFO "frontswap enabled, RAM provided by " 405 printk(KERN_INFO "frontswap enabled, RAM provided by "
388 "Xen Transcendent Memory%s\n", s); 406 "Xen Transcendent Memory%s\n", s);
389 } 407 }
390#endif 408#endif
391#ifdef CONFIG_CLEANCACHE 409#ifdef CONFIG_CLEANCACHE
392 BUG_ON(sizeof(struct cleancache_filekey) != sizeof(struct tmem_oid)); 410 BUG_ON(sizeof(struct cleancache_filekey) != sizeof(struct tmem_oid));
393 if (tmem_enabled && use_cleancache) { 411 if (tmem_enabled && !disable_cleancache) {
394 char *s = ""; 412 char *s = "";
395 struct cleancache_ops old_ops = 413 struct cleancache_ops *old_ops =
396 cleancache_register_ops(&tmem_cleancache_ops); 414 cleancache_register_ops(&tmem_cleancache_ops);
397 if (old_ops.init_fs != NULL) 415 if (old_ops)
398 s = " (WARNING: cleancache_ops overridden)"; 416 s = " (WARNING: cleancache_ops overridden)";
399 printk(KERN_INFO "cleancache enabled, RAM provided by " 417 printk(KERN_INFO "cleancache enabled, RAM provided by "
400 "Xen Transcendent Memory%s\n", s); 418 "Xen Transcendent Memory%s\n", s);
401 } 419 }
402#endif 420#endif
421#ifdef CONFIG_XEN_SELFBALLOONING
422 xen_selfballoon_init(!disable_selfballooning,
423 !disable_frontswap_selfshrinking);
424#endif
403 return 0; 425 return 0;
404} 426}
405 427
406module_init(xen_tmem_init) 428module_init(xen_tmem_init)
429MODULE_LICENSE("GPL");
430MODULE_AUTHOR("Dan Magenheimer <dan.magenheimer@oracle.com>");
431MODULE_DESCRIPTION("Shim to Xen transcendent memory");