mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joonsoo Kim <iamjoonsoo.kim@lge.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org,
	js1304@gmail.com, Seth Jennings <sjenning@linux.vnet.ibm.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>,
	Dan Magenheimer <dan.magenheimer@oracle.com>,
	Nitin Gupta <ngupta@vflare.org>, Minchan Kim <minchan@kernel.org>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>
Subject: [PATCH 3/3] staging, zram: use zs_mem_[read/write]
Date: Wed, 16 Jan 2013 17:08:57 +0900	[thread overview]
Message-ID: <1358323737-13396-3-git-send-email-iamjoonsoo.kim@lge.com> (raw)
In-Reply-To: <1358323737-13396-1-git-send-email-iamjoonsoo.kim@lge.com>

Now, we have newly introduced APIs which reduce copy overhead of
zsmalloc for objects on page boundary.
So use it in zram.

Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>

diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c
index fb4a7c9..554a742 100644
--- a/drivers/staging/zram/zram_drv.c
+++ b/drivers/staging/zram/zram_drv.c
@@ -195,13 +195,14 @@ static int zram_decompress_page(struct zram *zram, char *mem, u32 index)
 		return 0;
 	}
 
-	cmem = zs_map_object(zram->mem_pool, handle, ZS_MM_RO);
 	if (zram->table[index].size == PAGE_SIZE)
-		memcpy(mem, cmem, PAGE_SIZE);
-	else
+		zs_mem_read(zram->mem_pool, handle, mem, 0, PAGE_SIZE);
+	else {
+		cmem = zs_map_object(zram->mem_pool, handle, ZS_MM_RO);
 		ret = lzo1x_decompress_safe(cmem, zram->table[index].size,
 						mem, &clen);
-	zs_unmap_object(zram->mem_pool, handle);
+		zs_unmap_object(zram->mem_pool, handle);
+	}
 
 	/* Should NEVER happen. Return bio error if it does. */
 	if (unlikely(ret != LZO_E_OK)) {
@@ -269,7 +270,7 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
 	size_t clen;
 	unsigned long handle;
 	struct page *page;
-	unsigned char *user_mem, *cmem, *src, *uncmem = NULL;
+	unsigned char *user_mem, *src, *uncmem = NULL;
 
 	page = bvec->bv_page;
 	src = zram->compress_buffer;
@@ -343,11 +344,8 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
 		ret = -ENOMEM;
 		goto out;
 	}
-	cmem = zs_map_object(zram->mem_pool, handle, ZS_MM_WO);
-
-	memcpy(cmem, src, clen);
 
-	zs_unmap_object(zram->mem_pool, handle);
+	zs_mem_write(zram->mem_pool, handle, src, 0, clen);
 
 	zram->table[index].handle = handle;
 	zram->table[index].size = clen;
-- 
1.7.9.5


  parent reply	other threads:[~2013-01-16  8:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-16  8:08 [RFC PATCH 1/3] staging, zsmalloc: introduce zs_mem_[read/write] Joonsoo Kim
2013-01-16  8:08 ` [PATCH 2/3] staging, zcache: use zs_mem_[read/write] Joonsoo Kim
2013-01-16  8:08 ` Joonsoo Kim [this message]
2013-01-16 23:59 ` [RFC PATCH 1/3] staging, zsmalloc: introduce zs_mem_[read/write] Minchan Kim
2013-01-21  7:16   ` Joonsoo Kim
2013-01-22 20:32   ` Konrad Rzeszutek Wilk

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=1358323737-13396-3-git-send-email-iamjoonsoo.kim@lge.com \
    --to=iamjoonsoo.kim@lge.com \
    --cc=dan.magenheimer@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=js1304@gmail.com \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=minchan@kernel.org \
    --cc=ngupta@vflare.org \
    --cc=sjenning@linux.vnet.ibm.com \
    --cc=xiaoguangrong@linux.vnet.ibm.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

all inboxes | Powered by JetHome®