[Devel] [PATCH] tswap: Add check_zero parameter

Kirill Tkhai ktkhai at virtuozzo.com
Tue Sep 19 17:57:24 MSK 2017


This adds a parameter, which allows to switch zero page
functionality off.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 mm/tswap.c |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/mm/tswap.c b/mm/tswap.c
index 6a3cb917059..38a389fb0ca 100644
--- a/mm/tswap.c
+++ b/mm/tswap.c
@@ -45,6 +45,10 @@ module_param_named(active, tswap_active, bool, 0644);
 static unsigned long tswap_nr_pages;
 module_param_named(nr_pages, tswap_nr_pages, ulong, 0444);
 
+/* Enable/disable zero pages */
+static bool tswap_check_zero __read_mostly = true;
+module_param_named(check_zero, tswap_check_zero, bool, 0644);
+
 unsigned long get_nr_tswap_pages(void)
 {
 	return tswap_nr_pages;
@@ -285,6 +289,9 @@ static bool is_zero_filled_page(struct page *page)
 	unsigned long *v;
 	int i;
 
+	if (!tswap_check_zero)
+		return false;
+
 	v = kmap_atomic(page);
 	for (i = 0; i < PAGE_SIZE / sizeof(*v); i++) {
 		if (v[i] != 0) {



More information about the Devel mailing list