linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Srividya Desireddy" <srividya.dr@samsung.com>
To: sjenning@redhat.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: "Dinakar Reddy Pathireddy" <dinakar.p@samsung.com>,
	샤란 <sharan.allur@samsung.com>,
	"SUNEEL KUMAR SURIMANI" <suneel@samsung.com>,
	김주훈 <juhunkim@samsung.com>
Subject: [PATCH 2/4] zswap: Enable or disable sharing of duplicate pages at runtime
Date: Wed, 17 Aug 2016 10:16:37 +0000	[thread overview]
Message-ID: <304959240.35175.1471428997505.JavaMail.weblogic@epwas3e2> (raw)
In-Reply-To: CGME20160817101637epcms5p1a4e58b022c0044b7802a1bfdacd0b0b7@epcms5p1

[-- Attachment #1: Type: text/plain, Size: 3336 bytes --]

From: Srividya Desireddy <srividya.dr@samsung.com>
Date: Wed, 17 Aug 2016 14:32:24 +0530
Subject: [PATCH 2/4] zswap: Enable or disable sharing of duplicate pages at
 runtime

Enable or disable the sharing of duplicate zswap pages at runtime.
To enable sharing of duplicate zswap pages set 'same_page_sharing' sysfs
attribute. By default it is disabled.

In zswap_frontswap_store(), duplicate pages are searched in zswap only
when same_page_sharing is set. When zswap same page sharing is
disabled at runtime it will stop sharing the new duplicate pages. However,
the existing duplicate pages will keep sharing the compressed memory pool
until they are faulted back or invalidated.

Signed-off-by: Srividya Desireddy <srividya.dr@samsung.com>
---
 mm/zswap.c |   42 +++++++++++++++++++++++++-----------------
 1 file changed, 25 insertions(+), 17 deletions(-)

diff --git a/mm/zswap.c b/mm/zswap.c
index f7efede..ae39c77 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -116,6 +116,10 @@ module_param_cb(zpool, &zswap_zpool_param_ops, &zswap_zpool_type, 0644);
 static unsigned int zswap_max_pool_percent = 20;
 module_param_named(max_pool_percent, zswap_max_pool_percent, uint, 0644);
 
+/* Enable/disable zswap same page sharing feature (disabled by default) */
+static bool zswap_same_page_sharing;
+module_param_named(same_page_sharing, zswap_same_page_sharing, bool, 0644);
+
 /*********************************
 * data structures
 **********************************/
@@ -1180,20 +1184,22 @@ static int zswap_frontswap_store(unsigned type, pgoff_t offset,
 
 	src = kmap_atomic(page);
 
-	checksum = jhash2((const u32 *)src, PAGE_SIZE / 4, 17);
-	spin_lock(&tree->lock);
-	zhandle = zswap_same_page_search(tree, src, checksum);
-	if (zhandle) {
-		entry->offset = offset;
-		entry->zhandle = zhandle;
-		entry->pool = zhandle->pool;
-		entry->zhandle->ref_count++;
+	if (zswap_same_page_sharing) {
+		checksum = jhash2((const u32 *)src, PAGE_SIZE / 4, 17);
+		spin_lock(&tree->lock);
+		zhandle = zswap_same_page_search(tree, src, checksum);
+		if (zhandle) {
+			entry->offset = offset;
+			entry->zhandle = zhandle;
+			entry->pool = zhandle->pool;
+			entry->zhandle->ref_count++;
+			spin_unlock(&tree->lock);
+			kunmap_atomic(src);
+			atomic_inc(&zswap_duplicate_pages);
+			goto insert_entry;
+		}
 		spin_unlock(&tree->lock);
-		kunmap_atomic(src);
-		atomic_inc(&zswap_duplicate_pages);
-		goto insert_entry;
 	}
-	spin_unlock(&tree->lock);
 
 	/* if entry is successfully added, it keeps the reference */
 	entry->pool = zswap_pool_current_get();
@@ -1245,12 +1251,14 @@ static int zswap_frontswap_store(unsigned type, pgoff_t offset,
 	entry->zhandle = zhandle;
 	entry->zhandle->handle = handle;
 	entry->zhandle->length = dlen;
-	entry->zhandle->checksum = checksum;
-	entry->zhandle->pool = entry->pool;
-	spin_lock(&tree->lock);
-	ret = zswap_handle_rb_insert(&tree->zhandleroot, entry->zhandle,
+	if (zswap_same_page_sharing) {
+		entry->zhandle->checksum = checksum;
+		entry->zhandle->pool = entry->pool;
+		spin_lock(&tree->lock);
+		ret = zswap_handle_rb_insert(&tree->zhandleroot, entry->zhandle,
 								&duphandle);
-	spin_unlock(&tree->lock);
+		spin_unlock(&tree->lock);
+	}
 
 insert_entry:
 	/* map */
-- 
1.7.9.5


           reply	other threads:[~2016-08-17 10:16 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <CGME20160817101637epcms5p1a4e58b022c0044b7802a1bfdacd0b0b7@epcms5p1>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=304959240.35175.1471428997505.JavaMail.weblogic@epwas3e2 \
    --to=srividya.dr@samsung.com \
    --cc=dinakar.p@samsung.com \
    --cc=juhunkim@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=sharan.allur@samsung.com \
    --cc=sjenning@redhat.com \
    --cc=suneel@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).