From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752431AbdBGG5v (ORCPT ); Tue, 7 Feb 2017 01:57:51 -0500 Received: from LGEAMRELO13.lge.com ([156.147.23.53]:54293 "EHLO lgeamrelo13.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751416AbdBGG5u (ORCPT ); Tue, 7 Feb 2017 01:57:50 -0500 X-Original-SENDERIP: 156.147.1.151 X-Original-MAILFROM: minchan@kernel.org X-Original-SENDERIP: 165.244.249.26 X-Original-MAILFROM: minchan@kernel.org X-Original-SENDERIP: 10.177.223.161 X-Original-MAILFROM: minchan@kernel.org Date: Tue, 7 Feb 2017 15:57:41 +0900 From: Minchan Kim To: Andrew Morton CC: , , , , , , , , , , Subject: Re: [PATCH v4] zram: extend zero pages to same element pages Message-ID: <20170207065741.GA2567@bbox> References: <1486307804-27903-1-git-send-email-minchan@kernel.org> MIME-Version: 1.0 In-Reply-To: <1486307804-27903-1-git-send-email-minchan@kernel.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-MIMETrack: Itemize by SMTP Server on LGEKRMHUB01/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2017/02/07 15:57:44, Serialize by Router on LGEKRMHUB01/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2017/02/07 15:57:44, Serialize complete at 2017/02/07 15:57:44 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andrew, On Mon, Feb 06, 2017 at 12:16:44AM +0900, Minchan Kim wrote: > From: zhouxianrong > > 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@huawei.com > Signed-off-by: zhouxianrong > Signed-off-by: Minchan Kim 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. >>From e5a2a1dac4783f29d028170724578c0d11c80975 Mon Sep 17 00:00:00 2001 From: Minchan Kim Date: Tue, 7 Feb 2017 12:00:05 +0900 Subject: [PATCH] zram: do not free same element pages in zram_meta_free zhouxianrong pointed out that we shouldn't free same element pages in zram_meta_free. Otherwise, it will encounter oops due to invalid handle value. Signed-off-by: Minchan Kim --- Andrew, Please fold it to zram-extend-zero-pages-to-same-element-pages.patch. Thanks. drivers/block/zram/zram_drv.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index c20b05a84f21..a25d34a8af19 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -425,8 +425,11 @@ static void zram_meta_free(struct zram_meta *meta, u64 disksize) /* Free all pages that are still in this zram device */ for (index = 0; index < num_pages; index++) { unsigned long handle = meta->table[index].handle; - - if (!handle) + /* + * No memory is allocated for same element filled pages. + * Simply clear same page flag. + */ + if (!handle || zram_test_flag(meta, index, ZRAM_SAME)) continue; zs_free(meta->mem_pool, handle); -- 2.7.4