aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/xen
diff options
context:
space:
mode:
authorDan Magenheimer <dan.magenheimer@oracle.com>2013-04-30 18:27:00 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-04-30 20:04:01 -0400
commit10a7a0771399a57a297fca9615450dbb3f88081a (patch)
tree7c8564daf7ce2698277a4a38edb9ef0f636cb429 /drivers/xen
parentff610a1d55da22bf95bbc6a8b193e052169b34b7 (diff)
xen: tmem: enable Xen tmem shim to be built/loaded as a module
Allow Xen tmem shim to be built/loaded as a module. Xen self-ballooning and frontswap-selfshrinking are now also "lazily" initialized when the Xen tmem shim is loaded as a module, unless explicitly disabled by module parameters. 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: Removed the [CLEANCACHE|FRONTSWAP]_HAS_LAZY_INIT ifdef] [v2: Squashed the xen/tmem: Remove the subsys call patch in] [akpm@linux-foundation.org: fix build (disable_frontswap_selfshrinking undeclared)] Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Signed-off-by: Bob 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> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/xen')
-rw-r--r--drivers/xen/Kconfig4
-rw-r--r--drivers/xen/tmem.c40
-rw-r--r--drivers/xen/xen-selfballoon.c13
3 files changed, 38 insertions, 19 deletions
diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig
index 67af155cf602..dd4d9cb86243 100644
--- a/drivers/xen/Kconfig
+++ b/drivers/xen/Kconfig
@@ -145,9 +145,9 @@ config SWIOTLB_XEN
145 select SWIOTLB 145 select SWIOTLB
146 146
147config XEN_TMEM 147config XEN_TMEM
148 bool 148 tristate
149 depends on !ARM 149 depends on !ARM
150 default y if (CLEANCACHE || FRONTSWAP) 150 default m if (CLEANCACHE || FRONTSWAP)
151 help 151 help
152 Shim to interface in-kernel Transcendent Memory hooks 152 Shim to interface in-kernel Transcendent Memory hooks
153 (e.g. cleancache and frontswap) to Xen tmem hypercalls. 153 (e.g. cleancache and frontswap) to Xen tmem hypercalls.
diff --git a/drivers/xen/tmem.c b/drivers/xen/tmem.c
index fd79eab08368..8adde8e8428c 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,14 +230,19 @@ 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 tmem_cleancache_ops = { 247static struct cleancache_ops tmem_cleancache_ops = {
240 .put_page = tmem_cleancache_put_page, 248 .put_page = tmem_cleancache_put_page,
@@ -353,14 +361,19 @@ 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 tmem_frontswap_ops = { 378static struct frontswap_ops tmem_frontswap_ops = {
366 .store = tmem_frontswap_store, 379 .store = tmem_frontswap_store,
@@ -369,14 +382,16 @@ static struct frontswap_ops tmem_frontswap_ops = {
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);
@@ -390,7 +405,7 @@ static int __init xen_tmem_init(void)
390#endif 405#endif
391#ifdef CONFIG_CLEANCACHE 406#ifdef CONFIG_CLEANCACHE
392 BUG_ON(sizeof(struct cleancache_filekey) != sizeof(struct tmem_oid)); 407 BUG_ON(sizeof(struct cleancache_filekey) != sizeof(struct tmem_oid));
393 if (tmem_enabled && use_cleancache) { 408 if (tmem_enabled && !disable_cleancache) {
394 char *s = ""; 409 char *s = "";
395 struct cleancache_ops *old_ops = 410 struct cleancache_ops *old_ops =
396 cleancache_register_ops(&tmem_cleancache_ops); 411 cleancache_register_ops(&tmem_cleancache_ops);
@@ -400,7 +415,14 @@ static int __init xen_tmem_init(void)
400 "Xen Transcendent Memory%s\n", s); 415 "Xen Transcendent Memory%s\n", s);
401 } 416 }
402#endif 417#endif
418#ifdef CONFIG_XEN_SELFBALLOONING
419 xen_selfballoon_init(!disable_selfballooning,
420 !disable_frontswap_selfshrinking);
421#endif
403 return 0; 422 return 0;
404} 423}
405 424
406module_init(xen_tmem_init) 425module_init(xen_tmem_init)
426MODULE_LICENSE("GPL");
427MODULE_AUTHOR("Dan Magenheimer <dan.magenheimer@oracle.com>");
428MODULE_DESCRIPTION("Shim to Xen transcendent memory");
diff --git a/drivers/xen/xen-selfballoon.c b/drivers/xen/xen-selfballoon.c
index 2552d3e0a70f..f2ef569c7cc1 100644
--- a/drivers/xen/xen-selfballoon.c
+++ b/drivers/xen/xen-selfballoon.c
@@ -121,7 +121,7 @@ static DECLARE_DELAYED_WORK(selfballoon_worker, selfballoon_process);
121static bool frontswap_selfshrinking __read_mostly; 121static bool frontswap_selfshrinking __read_mostly;
122 122
123/* Enable/disable with kernel boot option. */ 123/* Enable/disable with kernel boot option. */
124static bool use_frontswap_selfshrink __initdata = true; 124static bool use_frontswap_selfshrink = true;
125 125
126/* 126/*
127 * The default values for the following parameters were deemed reasonable 127 * The default values for the following parameters were deemed reasonable
@@ -185,7 +185,7 @@ static int __init xen_nofrontswap_selfshrink_setup(char *s)
185__setup("noselfshrink", xen_nofrontswap_selfshrink_setup); 185__setup("noselfshrink", xen_nofrontswap_selfshrink_setup);
186 186
187/* Disable with kernel boot option. */ 187/* Disable with kernel boot option. */
188static bool use_selfballooning __initdata = true; 188static bool use_selfballooning = true;
189 189
190static int __init xen_noselfballooning_setup(char *s) 190static int __init xen_noselfballooning_setup(char *s)
191{ 191{
@@ -196,7 +196,7 @@ static int __init xen_noselfballooning_setup(char *s)
196__setup("noselfballooning", xen_noselfballooning_setup); 196__setup("noselfballooning", xen_noselfballooning_setup);
197#else /* !CONFIG_FRONTSWAP */ 197#else /* !CONFIG_FRONTSWAP */
198/* Enable with kernel boot option. */ 198/* Enable with kernel boot option. */
199static bool use_selfballooning __initdata = false; 199static bool use_selfballooning;
200 200
201static int __init xen_selfballooning_setup(char *s) 201static int __init xen_selfballooning_setup(char *s)
202{ 202{
@@ -537,7 +537,7 @@ int register_xen_selfballooning(struct device *dev)
537} 537}
538EXPORT_SYMBOL(register_xen_selfballooning); 538EXPORT_SYMBOL(register_xen_selfballooning);
539 539
540static int __init xen_selfballoon_init(void) 540int xen_selfballoon_init(bool use_selfballooning, bool use_frontswap_selfshrink)
541{ 541{
542 bool enable = false; 542 bool enable = false;
543 543
@@ -571,7 +571,4 @@ static int __init xen_selfballoon_init(void)
571 571
572 return 0; 572 return 0;
573} 573}
574 574EXPORT_SYMBOL(xen_selfballoon_init);
575subsys_initcall(xen_selfballoon_init);
576
577MODULE_LICENSE("GPL");