Fixes and cleanups to the tmem driver. (v1)
Subsystems (2)
RFC PATCH 1/1 Fixes and cleanups to the tmem driver. (v1)
These patches are RFC - I hadn't yet completly tested them. But they
fix the annoying:
drivers/xen/tmem.c:365:13: warning: 'disable_frontswap_selfshrinking' defined but not used [-Wunused-variable]
(patch #4: [PATCH 4/8] xen/tmem: Fix compile warning. does it).
The rest are cleanups and removes some of the #ifdef machinary.
I hadn't yet the full testing and I am sure I am missing some other documentation I should update.
Documentation/kernel-parameters.txt | 20 ++++++++++ drivers/xen/Kconfig | 7 ++-- drivers/xen/tmem.c | 79 +++++++++++++++---------------------- drivers/xen/xen-selfballoon.c | 36 +---------------- 4 files changed, 56 insertions(+), 86 deletions(-)
(Yeey! More deletions!)
Konrad Rzeszutek Wilk (8):
xen/tmem: Cleanup. Remove the parts that say temporary.
xen/tmem: Move all of the boot and module parameters to the top of the file. xen/tmem: Split out the different module/boot options.
xen/tmem: Fix compile warning.
xen/tmem: s/disable_// and change the logic.
xen/tmem: Remove the boot options and fold them in the tmem.X parameters. xen/tmem: Remove the usage of 'noselfshrink' and use 'tmem.selfshrink' bool instead. xen/tmem: Remove the usage of 'noselfballoon','selfballoon' and use 'tmem.selfballon' bool instead.
PATCH 1/8 xen/tmem: Cleanup. Remove the parts that say temporary.
Frontswap is upstream, no need for this #ifdef.
--- drivers/xen/tmem.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/xen/tmem.c +0 -4
@@ -11,11 +11,7 @@#include <linux/init.h> #include <linux/pagemap.h> #include <linux/cleancache.h> - -/* temporary ifdef until include/linux/frontswap.h is upstream */ -#ifdef CONFIG_FRONTSWAP #include <linux/frontswap.h> -#endif #include <xen/xen.h> #include <xen/interface/xen.h>
Signature · 1 line
1.8.1.4
PATCH 2/8 xen/tmem: Move all of the boot and module parameters to the top of the file.
In reply to Konrad Rzeszutek WilkJust code movement to see the different boot or module parameters.
--- drivers/xen/tmem.c | 85 +++++++++++++++++++++++++++++------------------------- 1 file changed, 45 insertions(+), 40 deletions(-)
drivers/xen/tmem.c +45 -40
@@ -20,6 +20,51 @@#include <asm/xen/hypervisor.h> #include <xen/tmem.h> +#ifndef CONFIG_XEN_TMEM_MODULE +bool __read_mostly tmem_enabled = false; + +static int __init enable_tmem (char *s) +{ + tmem_enabled = true; +return 1 ; +} +__setup ("tmem" , enable_tmem); +#endif + +#ifdef CONFIG_CLEANCACHE +static bool disable_cleancache__read_mostly ; +static bool disable_selfballooning__read_mostly ; +#ifdef CONFIG_XEN_TMEM_MODULE +module_param (disable_cleancache, bool,S_IRUGO ); +module_param (disable_selfballooning, bool,S_IRUGO ); +#else +static int __init no_cleancache (char *s) +{ + disable_cleancache = true; +return 1 ; +} +__setup ("nocleancache" , no_cleancache); +#endif +#endif /* CONFIG_CLEANCACHE */ + +#ifdef CONFIG_FRONTSWAP +static bool disable_frontswap__read_mostly ; +static bool disable_frontswap_selfshrinking__read_mostly ; +#ifdef CONFIG_XEN_TMEM_MODULE +module_param (disable_frontswap, bool,S_IRUGO ); +module_param (disable_frontswap_selfshrinking, bool,S_IRUGO ); +#else +static int __init no_frontswap (char *s) +{ + disable_frontswap = true; +return 1 ; +} +__setup ("nofrontswap" , no_frontswap); +#endif +#else /* CONFIG_FRONTSWAP */ +#define disable_frontswap_selfshrinking 1 +#endif /* CONFIG_FRONTSWAP */ +#define TMEM_CONTROL 0#define TMEM_NEW_POOL 1#define TMEM_DESTROY_POOL 2
@@ -125,16 +170,6 @@ static int xen_tmem_flush_object(u32 pool_id, struct tmem_oid oid)return xen_tmem_op (TMEM_FLUSH_OBJECT , pool_id, oid,0 ,0 ,0 ,0 ,0 ); } -#ifndef CONFIG_XEN_TMEM_MODULE -bool __read_mostly tmem_enabled = false; - -static int __init enable_tmem (char *s) -{ - tmem_enabled = true; -return 1 ; -} -__setup ("tmem" , enable_tmem); -#endif #ifdef CONFIG_CLEANCACHE static int xen_tmem_destroy_pool (u32 pool_id)
@@ -226,20 +261,6 @@ static int tmem_cleancache_init_shared_fs(char *uuid, size_t pagesize)return xen_tmem_new_pool (shared_uuid,TMEM_POOL_SHARED , pagesize); } -static bool disable_cleancache__read_mostly ; -static bool disable_selfballooning__read_mostly ; -#ifdef CONFIG_XEN_TMEM_MODULE -module_param (disable_cleancache, bool,S_IRUGO ); -module_param (disable_selfballooning, bool,S_IRUGO ); -#else -static int __init no_cleancache (char *s) -{ - disable_cleancache = true; -return 1 ; -} -__setup ("nocleancache" , no_cleancache); -#endif -static struct cleancache_ops tmem_cleancache_ops = { .put_page = tmem_cleancache_put_page, .get_page = tmem_cleancache_get_page,
@@ -357,20 +378,6 @@ static void tmem_frontswap_init(unsigned ignored)xen_tmem_new_pool (private,TMEM_POOL_PERSIST ,PAGE_SIZE ); } -static bool disable_frontswap__read_mostly ; -static bool disable_frontswap_selfshrinking__read_mostly ; -#ifdef CONFIG_XEN_TMEM_MODULE -module_param (disable_frontswap, bool,S_IRUGO ); -module_param (disable_frontswap_selfshrinking, bool,S_IRUGO ); -#else -static int __init no_frontswap (char *s) -{ - disable_frontswap = true; -return 1 ; -} -__setup ("nofrontswap" , no_frontswap); -#endif -static struct frontswap_ops tmem_frontswap_ops = { .store = tmem_frontswap_store, .load = tmem_frontswap_load,
@@ -378,8 +385,6 @@ static struct frontswap_ops tmem_frontswap_ops = { .invalidate_area = tmem_frontswap_flush_area, .init = tmem_frontswap_init }; -#else /* CONFIG_FRONTSWAP */ -#define disable_frontswap_selfshrinking 1#endif static int xen_tmem_init (void )
Signature · 1 line
1.8.1.4
PATCH 3/8 xen/tmem: Split out the different module/boot options.
In reply to Konrad Rzeszutek WilkThere are three options - depending on what combination of CONFIG_FRONTSWAP, CONFIG_CLEANCACHE and CONFIG_XEN_SELFBALLOONING is used. Lets split them out nicely out in three groups to make it easier to clean up.
--- drivers/xen/tmem.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/xen/tmem.c +8 -3
@@ -49,10 +49,8 @@ __setup("nocleancache", no_cleancache); #ifdef CONFIG_FRONTSWAP static bool disable_frontswap __read_mostly; -static bool disable_frontswap_selfshrinking __read_mostly; #ifdef CONFIG_XEN_TMEM_MODULE module_param(disable_frontswap, bool, S_IRUGO); -module_param(disable_frontswap_selfshrinking, bool, S_IRUGO); #else static int __init no_frontswap(char *s) {
@@ -61,8 +59,15 @@ static int __init no_frontswap(char *s) }__setup ("nofrontswap" , no_frontswap);#endif -#else /* CONFIG_FRONTSWAP */ +#endif /* CONFIG_FRONTSWAP */ + +#ifdef CONFIG_FRONTSWAP +static bool disable_frontswap_selfshrinking__read_mostly ; +#ifdef CONFIG_XEN_TMEM_MODULE +module_param (disable_frontswap_selfshrinking, bool,S_IRUGO ); +#else #define disable_frontswap_selfshrinking 1 +#endif #endif /* CONFIG_FRONTSWAP */ #define TMEM_CONTROL 0
Signature · 1 line
1.8.1.4
PATCH 4/8 xen/tmem: Fix compile warning.
In reply to Konrad Rzeszutek WilkWe keep on getting:drivers/xen/tmem.c:65:13: warning: ‘disable_frontswap_selfshrinking’ defined but not used [-Wunused-variable]
if CONFIG_FRONTSWAP=y and # CONFIG_CLEANCACHE is not set
--- drivers/xen/tmem.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/xen/tmem.c +2 -4
@@ -61,14 +61,12 @@ __setup("nofrontswap", no_frontswap);#endif #endif /* CONFIG_FRONTSWAP */ -#ifdef CONFIG_FRONTSWAP +#ifdef CONFIG_XEN_SELFBALLOONING static bool disable_frontswap_selfshrinking__read_mostly ;#ifdef CONFIG_XEN_TMEM_MODULE module_param (disable_frontswap_selfshrinking, bool,S_IRUGO ); -#else -#define disable_frontswap_selfshrinking 1#endif -#endif /* CONFIG_FRONTSWAP */ +#endif /* CONFIG_XEN_SELFBALLOONING */ #define TMEM_CONTROL 0#define TMEM_NEW_POOL 1
Signature · 7 lines
1.8.1.4 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH 5/8 xen/tmem: s/disable_// and change the logic.
In reply to Konrad Rzeszutek WilkThe variety of disable_[cleancache|frontswap|selfshrinking] are making this a bit complex. Just remove the "disable_" part and change the logic around for the "nofrontswap" and "nocleancache" parameters.
--- drivers/xen/tmem.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-)
drivers/xen/tmem.c +13 -14
@@ -32,15 +32,15 @@ __setup("tmem", enable_tmem);#endif #ifdef CONFIG_CLEANCACHE -static bool disable_cleancache__read_mostly ; -static bool disable_selfballooning__read_mostly ; +static bool cleancache__read_mostly = true; +static bool selfballooning__read_mostly = true;#ifdef CONFIG_XEN_TMEM_MODULE -module_param (disable_cleancache, bool,S_IRUGO ); -module_param (disable_selfballooning, bool,S_IRUGO ); +module_param (cleancache, bool,S_IRUGO ); +module_param (selfballooning, bool,S_IRUGO );#else static int __init no_cleancache (char *s) { - disable_cleancache = true; + cleancache = false;return 1 ; }__setup ("nocleancache" , no_cleancache);
@@ -48,13 +48,13 @@ __setup("nocleancache", no_cleancache);#endif /* CONFIG_CLEANCACHE */ #ifdef CONFIG_FRONTSWAP -static bool disable_frontswap__read_mostly ; +static bool frontswap__read_mostly = true;#ifdef CONFIG_XEN_TMEM_MODULE -module_param (disable_frontswap, bool,S_IRUGO ); +module_param (frontswap, bool,S_IRUGO );#else static int __init no_frontswap (char *s) { - disable_frontswap = true; + frontswap = false;return 1 ; }__setup ("nofrontswap" , no_frontswap);
@@ -62,9 +62,9 @@ __setup("nofrontswap", no_frontswap);#endif /* CONFIG_FRONTSWAP */ #ifdef CONFIG_XEN_SELFBALLOONING -static bool disable_frontswap_selfshrinking__read_mostly ; +static bool frontswap_selfshrinking__read_mostly = true;#ifdef CONFIG_XEN_TMEM_MODULE -module_param (disable_frontswap_selfshrinking, bool,S_IRUGO ); +module_param (frontswap_selfshrinking, bool,S_IRUGO );#endif #endif /* CONFIG_XEN_SELFBALLOONING */
@@ -395,7 +395,7 @@ static int xen_tmem_init(void)if (!xen_domain ())return 0 ;#ifdef CONFIG_FRONTSWAP -if (tmem_enabled && !disable_frontswap) { +if (tmem_enabled && frontswap) {char *s ="" ;struct frontswap_ops *old_ops =frontswap_register_ops (&tmem_frontswap_ops);
@@ -412,7 +412,7 @@ static int xen_tmem_init(void)#endif #ifdef CONFIG_CLEANCACHE BUG_ON (sizeof (struct cleancache_filekey ) !=sizeof (struct tmem_oid )); -if (tmem_enabled && !disable_cleancache) { +if (tmem_enabled && cleancache) {char *s ="" ;struct cleancache_ops *old_ops =cleancache_register_ops (&tmem_cleancache_ops);
@@ -423,8 +423,7 @@ static int xen_tmem_init(void) }#endif #ifdef CONFIG_XEN_SELFBALLOONING -xen_selfballoon_init (!disable_selfballooning, - !disable_frontswap_selfshrinking); +xen_selfballoon_init (selfballooning, frontswap_selfshrinking);#endif return 0 ; }
Signature · 1 line
1.8.1.4
PATCH 6/8 xen/tmem: Remove the boot options and fold them in the tmem.X parameters.
In reply to Konrad Rzeszutek WilkIf tmem is built-in or a module, the user has the option on the command line to influence it by doing: tmem.<some option> instead of having a variety of "nocleancache", and "nofrontswap". The others: "noselfballooning" and "selfballooning"; and "noselfshrink" are in a different driver xen-selfballoon.c and the patches:
xen/tmem: Remove the usage of 'noselfshrink' and use 'tmem.selfshrink' bool instead. xen/tmem: Remove the usage of 'noselfballoon','selfballoon' and use 'tmem.selfballon' bool instead.
removes them.
Also add documentation.
--- Documentation/kernel-parameters.txt | 20 ++++++++++++++++++++ drivers/xen/tmem.c | 28 ++++------------------------ 2 files changed, 24 insertions(+), 24 deletions(-)
Documentation/kernel-parameters.txt +20 -0
@@ -3005,6 +3005,26 @@ bytes respectively. Such letter suffixes can also be entirely omitted. Force threading of all interrupt handlers except those marked explicitly IRQF_NO_THREAD. + tmem [KNL,XEN] + Enable the Transcendent memory driver if built-in. + + tmem.cleancache=0|1 [KNL, XEN] + Default is on (1). Disable the usage of the cleancache + API to send anonymous pages to the hypervisor. + + tmem.frontswap=0|1 [KNL, XEN] + Default is on (1). Disable the usage of the frontswap + API to send swap pages to the hypervisor. + + tmem.selfballooning=0|1 [KNL, XEN] + Default is on (1). Disable the driving of swap pages + to the hypervisor. + + tmem.selfshrinking=0|1 [KNL, XEN] + Default is on (1). Partial swapoff that immediately + transfers pages from Xen hypervisor back to the + kernel based on different criteria. + topology= [S390] Format: {off | on} Specify if the kernel should make use of the cpu
drivers/xen/tmem.c +4 -24
@@ -33,39 +33,19 @@ __setup("tmem", enable_tmem);#ifdef CONFIG_CLEANCACHE static bool cleancache__read_mostly = true; -static bool selfballooning__read_mostly = true; -#ifdef CONFIG_XEN_TMEM_MODULE module_param (cleancache, bool,S_IRUGO ); +static bool selfballooning__read_mostly = true;module_param (selfballooning, bool,S_IRUGO ); -#else -static int __init no_cleancache (char *s) -{ - cleancache = false; -return 1 ; -} -__setup ("nocleancache" , no_cleancache); -#endif #endif /* CONFIG_CLEANCACHE */ #ifdef CONFIG_FRONTSWAP static bool frontswap__read_mostly = true; -#ifdef CONFIG_XEN_TMEM_MODULE module_param (frontswap, bool,S_IRUGO ); -#else -static int __init no_frontswap (char *s) -{ - frontswap = false; -return 1 ; -} -__setup ("nofrontswap" , no_frontswap); -#endif #endif /* CONFIG_FRONTSWAP */ #ifdef CONFIG_XEN_SELFBALLOONING -static bool frontswap_selfshrinking__read_mostly = true; -#ifdef CONFIG_XEN_TMEM_MODULE -module_param (frontswap_selfshrinking, bool,S_IRUGO ); -#endif +static bool selfshrinking__read_mostly = true; +module_param (selfshrinking, bool,S_IRUGO );#endif /* CONFIG_XEN_SELFBALLOONING */ #define TMEM_CONTROL 0
@@ -423,7 +403,7 @@ static int xen_tmem_init(void) }#endif #ifdef CONFIG_XEN_SELFBALLOONING -xen_selfballoon_init (selfballooning, frontswap_selfshrinking); +xen_selfballoon_init (selfballooning, selfshrinking);#endif return 0 ; }
Signature · 1 line
1.8.1.4
PATCH 7/8 xen/tmem: Remove the usage of 'noselfshrink' and use 'tmem.selfshrink' bool instead.
In reply to Konrad Rzeszutek WilkAs the 'tmem' driver is the one that actually sets whether it will use it or not so might as well make tmem responsible for this knob.
--- drivers/xen/Kconfig | 2 +- drivers/xen/xen-selfballoon.c | 15 ++------------- 2 files changed, 3 insertions(+), 14 deletions(-)
drivers/xen/Kconfig +1 -1
@@ -22,7 +22,7 @@ config XEN_SELFBALLOONING ballooning is disabled by default but can be enabled with the 'selfballooning' kernel boot parameter. If FRONTSWAP is configured, frontswap-selfshrinking is enabled by default but can be disabled - with the 'noselfshrink' kernel boot parameter; and self-ballooning + with the 'tmem.selfshrink=0' kernel boot parameter; and self-ballooning is enabled by default but can be disabled with the 'noselfballooning' kernel boot parameter. Note that systems without a sufficiently large swap device should not enable self-ballooning.
drivers/xen/xen-selfballoon.c +2 -13
@@ -60,8 +60,8 @@* be enabled with the "selfballooning" kernel boot option; similarly * selfballooning is enabled by default if frontswap is configured and * can be disabled with the "noselfballooning" kernel boot option. Finally, -* when frontswap is configured, frontswap-selfshrinking can be disabled -* with the "noselfshrink" kernel boot option. +* when frontswap is configured,frontswap-selfshrinking can be disabled +* with the "tmem.selfshrink=0" kernel boot option. * * Selfballooning is disallowed in domain0 and force-disabled. *
@@ -120,9 +120,6 @@ static DECLARE_DELAYED_WORK(selfballoon_worker, selfballoon_process);/* Enable/disable with sysfs. */ static bool frontswap_selfshrinking__read_mostly ; -/* Enable/disable with kernel boot option. */ -static bool use_frontswap_selfshrink = true; -/* * The default values for the following parameters were deemed reasonable * by experimentation, may be workload-dependent, and can all be
@@ -176,14 +173,6 @@ static void frontswap_selfshrink(void)frontswap_shrink (tgt_frontswap_pages); } -static int __init xen_nofrontswap_selfshrink_setup (char *s) -{ - use_frontswap_selfshrink = false; -return 1 ; -} - -__setup ("noselfshrink" , xen_nofrontswap_selfshrink_setup); -/* Disable with kernel boot option. */ static bool use_selfballooning = true;
Signature · 1 line
1.8.1.4
PATCH 8/8 xen/tmem: Remove the usage of 'noselfballoon','selfballoon' and use 'tmem.selfballon' bool instead.
In reply to Konrad Rzeszutek WilkAs the 'tmem' driver is the one that actually sets whether it will use it or not so might as well make tmem responsible for this knob.
--- drivers/xen/Kconfig | 5 ++--- drivers/xen/xen-selfballoon.c | 21 --------------------- 2 files changed, 2 insertions(+), 24 deletions(-)
drivers/xen/Kconfig +2 -3
@@ -19,11 +19,10 @@ config XEN_SELFBALLOONING by the current usage of anonymous memory ("committed AS") and controlled by various sysfs-settable parameters. Configuring FRONTSWAP is highly recommended; if it is not configured, self- - ballooning is disabled by default but can be enabled with the - 'selfballooning' kernel boot parameter. If FRONTSWAP is configured, + ballooning is disabled by default. If FRONTSWAP is configured, frontswap-selfshrinking is enabled by default but can be disabled with the 'tmem.selfshrink=0' kernel boot parameter; and self-ballooning - is enabled by default but can be disabled with the 'noselfballooning' + is enabled by default but can be disabled with the 'tmem.selfballooning=0' kernel boot parameter. Note that systems without a sufficiently large swap device should not enable self-ballooning.
drivers/xen/xen-selfballoon.c +0 -21
@@ -173,27 +173,6 @@ static void frontswap_selfshrink(void) frontswap_shrink(tgt_frontswap_pages); } -/* Disable with kernel boot option. */ -static bool use_selfballooning = true; - -static int __init xen_noselfballooning_setup (char *s) -{ - use_selfballooning = false; -return 1 ; -} - -__setup ("noselfballooning" , xen_noselfballooning_setup); -#else /* !CONFIG_FRONTSWAP */ -/* Enable with kernel boot option. */ -static bool use_selfballooning; - -static int __init xen_selfballooning_setup (char *s) -{ - use_selfballooning = true; -return 1 ; -} - -__setup ("selfballooning" , xen_selfballooning_setup);#endif /* CONFIG_FRONTSWAP */ #define MB2PAGES (mb) ((mb) << (20 - PAGE_SHIFT))
Signature · 1 line
1.8.1.4