Re: [RFC PATCH 7/7] mm: zswap: Use acomp virtual address interface

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On (25/03/04 14:10), Herbert Xu wrote:
> +static void zs_map_object_sg(struct zs_pool *pool, unsigned long handle,
> +			     enum zs_mapmode mm, struct scatterlist sg[2])
> +{
[..]
> +	sg_init_table(sg, 2);
> +	sg_set_page(sg, zpdesc_page(zpdescs[0]),
> +		    PAGE_SIZE - off - handle_size, off + handle_size);
> +	sg_set_page(&sg[1], zpdesc_page(zpdescs[1]),
> +		    class->size - (PAGE_SIZE - off - handle_size), 0);
> +}
> +
> +static void zs_unmap_object_sg(struct zs_pool *pool, unsigned long handle)
> +{
> +	struct zspage *zspage;
> +	struct zpdesc *zpdesc;
> +	unsigned int obj_idx;
> +	unsigned long obj;
> +
> +	obj = handle_to_obj(handle);
> +	obj_to_location(obj, &zpdesc, &obj_idx);
> +	zspage = get_zspage(zpdesc);
> +	migrate_read_unlock(zspage);
> +}

One thing to notice is that these functions don't actually map/unmap.

And the handling is spread out over different parts of the stack,
sg list is set in zsmalloc, but the actual zsmalloc map local page is
done in crypto, and then zswap does memcpy() to write to object and so
on.  The "new" zsmalloc map API, which we plan on landing soon, handles
most of the things within zsmalloc.  Would it be possible to do something
similar with the sg API?

> @@ -928,9 +929,9 @@ static bool zswap_compress(struct page *page, struct zswap_entry *entry,
>  	struct scatterlist input, output;
>  	int comp_ret = 0, alloc_ret = 0;
>  	unsigned int dlen = PAGE_SIZE;
> +	struct scatterlist sg[2];
>  	unsigned long handle;
>  	struct zpool *zpool;
> -	char *buf;
>  	gfp_t gfp;
>  	u8 *dst;
>  
> @@ -972,9 +973,9 @@ static bool zswap_compress(struct page *page, struct zswap_entry *entry,
>  	if (alloc_ret)
>  		goto unlock;
>  
> -	buf = zpool_map_handle(zpool, handle, ZPOOL_MM_WO);
> -	memcpy(buf, dst, dlen);
> -	zpool_unmap_handle(zpool, handle);
> +	zpool_map_sg(zpool, handle, ZPOOL_MM_WO, sg);
> +	memcpy_to_sglist(sg, 0, dst, dlen);
> +	zpool_unmap_sg(zpool, handle);

You can give zsmalloc a handle and a compressed buffer (u8) and
zsmalloc should be able to figure it out.  WO direction map()
seems, a bit, like an extra step.




[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]
  Powered by Linux