Re: [PATCH v4] zram: extend zero pages to same element pages

From: Minchan Kim
Date: Tue Feb 07 2017 - 01:58:08 EST


Hi Andrew,

On Mon, Feb 06, 2017 at 12:16:44AM +0900, Minchan Kim wrote:
> From: zhouxianrong <zhouxianrong@xxxxxxxxxx>
>
> the idea is that without doing more calculations we extend zero pages
> to same element pages for zram. zero page is special case of
> same element page with zero element.
>
> 1. the test is done under android 7.0
> 2. startup too many applications circularly
> 3. sample the zero pages, same pages (none-zero element)
> and total pages in function page_zero_filled
>
> the result is listed as below:
>
> ZERO SAME TOTAL
> 36214 17842 598196
>
> ZERO/TOTAL SAME/TOTAL (ZERO+SAME)/TOTAL ZERO/SAME
> AVERAGE 0.060631909 0.024990816 0.085622726 2.663825038
> STDEV 0.00674612 0.005887625 0.009707034 2.115881328
> MAX 0.069698422 0.030046087 0.094975336 7.56043956
> MIN 0.03959586 0.007332205 0.056055193 1.928985507
>
> from above data, the benefit is about 2.5% and up to 3% of total
> swapout pages.
>
> the defect of the patch is that when we recovery a page from
> non-zero element the operations are low efficient for partial
> read.
>
> This patch extend zero_page to same_page so if there is any user to have
> monitored zero_pages, he will be surprised if the number is increased
> but it's no harmful, I believe.
>
> Link: http://lkml.kernel.org/r/1483692145-75357-1-git-send-email-zhouxianrong@xxxxxxxxxx
> Signed-off-by: zhouxianrong <zhouxianrong@xxxxxxxxxx>
> Signed-off-by: Minchan Kim <minchan@xxxxxxxxxx>

zhouxianrong pointed out we shouldn't free same element pages in zram_meta_free.
Otherwise, it can encounter oops due to invalid handle passed into zram_free.
This patch fixes it. Please fold this patch into zram-extend-zero-pages-to-same-element-pages.patch.

Thanks.