lkml.org 
[lkml]   [2013]   [Jan]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/3] staging, zcache: use zs_mem_[read/write]
Date
Now, we have newly introduced APIs which reduce copy overhead of
zsmalloc for objects on page boundary.
So use it in zcache.

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

diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c
index 52b43b7..d1dee76 100644
--- a/drivers/staging/zcache/zcache-main.c
+++ b/drivers/staging/zcache/zcache-main.c
@@ -704,7 +704,7 @@ static unsigned long zv_create(struct zs_pool *pool, uint32_t pool_id,
struct tmem_oid *oid, uint32_t index,
void *cdata, unsigned clen)
{
- struct zv_hdr *zv;
+ struct zv_hdr zv;
u32 size = clen + sizeof(struct zv_hdr);
int chunks = (size + (CHUNK_SIZE - 1)) >> CHUNK_SHIFT;
unsigned long handle = 0;
@@ -716,14 +716,13 @@ static unsigned long zv_create(struct zs_pool *pool, uint32_t pool_id,
goto out;
atomic_inc(&zv_curr_dist_counts[chunks]);
atomic_inc(&zv_cumul_dist_counts[chunks]);
- zv = zs_map_object(pool, handle, ZS_MM_WO);
- zv->index = index;
- zv->oid = *oid;
- zv->pool_id = pool_id;
- zv->size = clen;
- SET_SENTINEL(zv, ZVH);
- memcpy((char *)zv + sizeof(struct zv_hdr), cdata, clen);
- zs_unmap_object(pool, handle);
+ zv.index = index;
+ zv.oid = *oid;
+ zv.pool_id = pool_id;
+ zv.size = clen;
+ SET_SENTINEL((&zv), ZVH);
+ zs_mem_write(pool, handle, &zv, 0, sizeof(struct zv_hdr));
+ zs_mem_write(pool, handle, cdata, sizeof(struct zv_hdr), clen);
out:
return handle;
}
@@ -731,15 +730,13 @@ out:
static void zv_free(struct zs_pool *pool, unsigned long handle)
{
unsigned long flags;
- struct zv_hdr *zv;
+ struct zv_hdr zv;
uint16_t size;
int chunks;

- zv = zs_map_object(pool, handle, ZS_MM_RW);
- ASSERT_SENTINEL(zv, ZVH);
- size = zv->size + sizeof(struct zv_hdr);
- INVERT_SENTINEL(zv, ZVH);
- zs_unmap_object(pool, handle);
+ zs_mem_read(pool, handle, &zv, 0, sizeof(struct zv_hdr));
+ ASSERT_SENTINEL((&zv), ZVH);
+ size = zv.size + sizeof(struct zv_hdr);

chunks = (size + (CHUNK_SIZE - 1)) >> CHUNK_SHIFT;
BUG_ON(chunks >= NCHUNKS);
--
1.7.9.5


\
 
 \ /
  Last update: 2013-01-16 10:01    [W:0.253 / U:0.188 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site