[Devel] tswap: Add check_zero parameter

Submitted by Kirill Tkhai on Sept. 19, 2017, 2:57 p.m.

Details

Message ID 150583302495.25926.10418121313230856371.stgit@localhost.localdomain
State New
Series "tswap: Add check_zero parameter"
Headers show

Commit Message

Kirill Tkhai Sept. 19, 2017, 2:57 p.m.
This adds a parameter, which allows to switch zero page
functionality off.

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

Patch hide | download patch | download mbox

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) {