[Devel] [PATCH rh7] tswap: Add support for zero-filled pages

Andrey Ryabinin aryabinin at virtuozzo.com
Thu Aug 31 16:45:43 MSK 2017


On 08/03/2017 12:54 PM, Kirill Tkhai wrote:
>  static int tswap_frontswap_store(unsigned type, pgoff_t offset,
>  				 struct page *page)
>  {
>  	swp_entry_t entry = swp_entry(type, offset);
> +	int zero_filled = -1, err = 0;
>  	struct page *cache_page;
> -	int err = 0;
>  
>  	if (!tswap_active)
>  		return -1;
>  
>  	cache_page = tswap_lookup_page(entry);
> -	if (cache_page)
> -		goto copy;
> +	if (cache_page) {
> +		zero_filled = is_zero_filled_page(page);
> +		/* If type of page has not changed, just reuse it */
> +		if (zero_filled == (cache_page == ZERO_PAGE(0)))
> +			goto copy;
> +		tswap_delete_page(entry, NULL);
> +		put_page(cache_page);

I think if we race with tswap_frontswap_load() this will lead to double put_page().

> +	}
>  
>  	if (!(current->flags & PF_MEMCG_RECLAIM))
>  		return -1;
>  


More information about the Devel mailing list