Re: [PATCH v2 1/4] introduce zero filled pages handler

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

 



On Thu, Mar 14, 2013 at 06:08:14PM +0800, Wanpeng Li wrote:
> Introduce zero-filled pages handler to capture and handle zero pages.
> 
> Acked-by: Dan Magenheimer <dan.magenheimer@xxxxxxxxxx>
> Signed-off-by: Wanpeng Li <liwanp@xxxxxxxxxxxxxxxxxx>
> ---
>  drivers/staging/zcache/zcache-main.c |   26 ++++++++++++++++++++++++++
>  1 files changed, 26 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c
> index 328898e..b71e033 100644
> --- a/drivers/staging/zcache/zcache-main.c
> +++ b/drivers/staging/zcache/zcache-main.c
> @@ -460,6 +460,32 @@ static void zcache_obj_free(struct tmem_obj *obj, struct tmem_pool *pool)
>  	kmem_cache_free(zcache_obj_cache, obj);
>  }
>  
> +static bool page_zero_filled(void *ptr)

Shouldn't this be 'struct page *p' ?
> +{
> +	unsigned int pos;
> +	unsigned long *page;
> +
> +	page = (unsigned long *)ptr;

That way you can avoid this casting.
> +
> +	for (pos = 0; pos < PAGE_SIZE / sizeof(*page); pos++) {
> +		if (page[pos])
> +			return false;

Perhaps allocate a static page filled with zeros and just do memcmp?
> +	}
> +
> +	return true;
> +}
> +
> +static void handle_zero_page(void *page)
> +{
> +	void *user_mem;
> +
> +	user_mem = kmap_atomic(page);
> +	memset(user_mem, 0, PAGE_SIZE);
> +	kunmap_atomic(user_mem);
> +
> +	flush_dcache_page(page);

This is new. Could you kindly explain why it is needed? Thanks.
> +}
> +
>  static struct tmem_hostops zcache_hostops = {
>  	.obj_alloc = zcache_obj_alloc,
>  	.obj_free = zcache_obj_free,
> -- 
> 1.7.7.6
> 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]