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@xxxxxxx> 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 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/devel