From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6AC6EC47097 for ; Thu, 3 Jun 2021 16:13:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 51E59613F4 for ; Thu, 3 Jun 2021 16:13:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230053AbhFCQPk (ORCPT ); Thu, 3 Jun 2021 12:15:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:58816 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229656AbhFCQPk (ORCPT ); Thu, 3 Jun 2021 12:15:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2CBA66135D; Thu, 3 Jun 2021 16:13:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622736835; bh=oy5ydTPfTDR/G+eayzloFwE8KarET66/fooyad/r0Bk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=aDjtSKf8Cb4W8yoI2XuWwrxNuaQ4ONoW2FCxFQSXyXlTD2C5nLj8QlLrSt/jI8xkS Cu6AoXvceAhkY1nO3PrwZLKgpKAu+pB6tDsuKIFnXVUCeFurzaRULQxS3yAzD0nO7c R2uZdDqAopmGGq6p9lgQUCsBhg3G5MoL2uhz9tZtqavoO1TxbotibiZNlPDhtrYEY8 JTdaU/LmPhJ85QVm4CdG9qxoIvTChtQpWr+0c1Xl6jJRq5jD7Q4W78mUl7+xLMaBon JWy+a08agfrAllB/iNZUDooko+StGEU3UyA3nCxr3aKw64OtFZ7NOZio9X53jXxaC7 //00yhaf4coSw== Date: Thu, 3 Jun 2021 09:13:53 -0700 From: Jaegeuk Kim To: Chao Yu Cc: Chao Yu , linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Subject: Re: [f2fs-dev] [PATCH v6] f2fs: compress: add compress_inode to cache compressed blocks Message-ID: References: <2c4db877-b5e6-1139-98b5-be2d9e7872be@kernel.org> <5140516c-e4c6-fd6a-69b2-7566c903cb53@kernel.org> <09fa74d3-a9df-028f-3ebc-2b845e5cd609@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/03, Chao Yu wrote: > On 2021/6/2 23:34, Jaegeuk Kim wrote: > > On 06/02, Chao Yu wrote: > > > On 2021/6/2 1:27, Jaegeuk Kim wrote: > > > > On 06/01, Jaegeuk Kim wrote: > > > > > On 05/26, Chao Yu wrote: > > > > > > On 2021/5/26 21:26, Jaegeuk Kim wrote: > > > > > > > On 05/26, Chao Yu wrote: > > > > > > > > On 2021/5/25 22:01, Jaegeuk Kim wrote: > > > > > > > > > On 05/25, Chao Yu wrote: > > > > > > > > > > On 2021/5/25 21:02, Jaegeuk Kim wrote: > > > > > > > > > > > On 05/25, Jaegeuk Kim wrote: > > > > > > > > > > > > On 05/25, Chao Yu wrote: > > > > > > > > > > > > > Also, and queue this? > > > > > > > > > > > > > > > > > > > > > > > > Easy to get this? > > > > > > > > > > > > > > > > > > > > > > need GFP_NOFS? > > > > > > > > > > > > > > > > > > > > Not sure, I use __GFP_IO intentionally here to avoid __GFP_RECLAIM from > > > > > > > > > > GFP_NOFS, because in low memory case, I don't want to instead page cache > > > > > > > > > > of normal file with page cache of sbi->compress_inode. > > > > > > > > > > > > > > > > > > > > What is memory size in your vm? > > > > > > > > > > > > > > > > > > 4GB. If I set GFP_NOFS, I don't see the error anymore, at least. > > > > > > > > > > > > > > > > I applied below patch and don't see the warning message anymore. > > > > > > > > > > > > > > > > --- > > > > > > > > fs/f2fs/compress.c | 2 +- > > > > > > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > > > > > > > > > > > diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c > > > > > > > > index 701dd0f6f4ec..ed5b7fabc604 100644 > > > > > > > > --- a/fs/f2fs/compress.c > > > > > > > > +++ b/fs/f2fs/compress.c > > > > > > > > @@ -1703,7 +1703,7 @@ void f2fs_cache_compressed_page(struct f2fs_sb_info *sbi, struct page *page, > > > > > > > > avail_ram = si.totalram - si.totalhigh; > > > > > > > > > > > > > > > > /* free memory is lower than watermark, deny caching compress page */ > > > > > > > > - if (free_ram <= sbi->compress_watermark / 100 * avail_ram) > > > > > > > > > > > > This is buggy, because sbi->compress_watermark equals to 20, so that > > > > > > sbi->compress_watermark / 100 * avail_ram always be zero... > > > > > > > > > > > > After this change, if free ram is lower, we may just skip caching > > > > > > compressed blocks here. > > > > > > > > > > Can we move this in f2fs_available_free_memory()? > > > > > > More clean. > > > > > > One comment below: > > > > > > > > > > > Testing this. > > > > > > > > --- > > > > fs/f2fs/compress.c | 14 +------------- > > > > fs/f2fs/node.c | 11 ++++++++++- > > > > fs/f2fs/node.h | 1 + > > > > 3 files changed, 12 insertions(+), 14 deletions(-) > > > > > > > > diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c > > > > index 9fd62a0a646b..455561826c7d 100644 > > > > --- a/fs/f2fs/compress.c > > > > +++ b/fs/f2fs/compress.c > > > > @@ -1688,8 +1688,6 @@ void f2fs_cache_compressed_page(struct f2fs_sb_info *sbi, struct page *page, > > > > { > > > > struct page *cpage; > > > > int ret; > > > > - struct sysinfo si; > > > > - unsigned long free_ram, avail_ram; > > > > if (!test_opt(sbi, COMPRESS_CACHE)) > > > > return; > > > > @@ -1697,17 +1695,7 @@ void f2fs_cache_compressed_page(struct f2fs_sb_info *sbi, struct page *page, > > > > if (!f2fs_is_valid_blkaddr(sbi, blkaddr, DATA_GENERIC_ENHANCE_READ)) > > > > return; > > > > - si_meminfo(&si); > > > > - free_ram = si.freeram; > > > > - avail_ram = si.totalram - si.totalhigh; > > > > - > > > > - /* free memory is lower than watermark, deny caching compress page */ > > > > - if (free_ram <= sbi->compress_watermark / 100 * avail_ram) > > > > - return; > > > > - > > > > - /* cached page count exceed threshold, deny caching compress page */ > > > > - if (COMPRESS_MAPPING(sbi)->nrpages >= > > > > > > Need to cover COMPRESS_MAPPING() with CONFIG_F2FS_FS_COMPRESSION. > > > > Added like this. > > > > --- a/fs/f2fs/node.c > > +++ b/fs/f2fs/node.c > > @@ -99,6 +99,7 @@ bool f2fs_available_free_memory(struct f2fs_sb_info *sbi, int type) > > sizeof(struct discard_cmd)) >> PAGE_SHIFT; > > res = mem_size < (avail_ram * nm_i->ram_thresh / 100); > > } else if (type == COMPRESS_PAGE) { > > +#ifdef CONFIG_F2FS_FS_COMPRESSION > > How about adding free_ram definition and assigment here? > > unsigned long free_ram = val.freeram; Done. > > Thanks, > > > /* > > * free memory is lower than watermark or cached page count > > * exceed threshold, deny caching compress page. > > @@ -106,6 +107,9 @@ bool f2fs_available_free_memory(struct f2fs_sb_info *sbi, int type) > > res = (free_ram > avail_ram * sbi->compress_watermark / 100) && > > (COMPRESS_MAPPING(sbi)->nrpages < > > free_ram * sbi->compress_percent / 100); > > +#else > > + res = false; > > +#endif > > } else { > > if (!sbi->sb->s_bdi->wb.dirty_exceeded) > > return true; > > > > > > > > Thanks, > > > > > > > - free_ram / 100 * sbi->compress_percent) > > > > + if (!f2fs_available_free_memory(sbi, COMPRESS_PAGE)) > > > > return; > > > > cpage = find_get_page(COMPRESS_MAPPING(sbi), blkaddr); > > > > diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c > > > > index 3a8f7afa5059..67093416ce9c 100644 > > > > --- a/fs/f2fs/node.c > > > > +++ b/fs/f2fs/node.c > > > > @@ -45,7 +45,7 @@ bool f2fs_available_free_memory(struct f2fs_sb_info *sbi, int type) > > > > struct f2fs_nm_info *nm_i = NM_I(sbi); > > > > struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info; > > > > struct sysinfo val; > > > > - unsigned long avail_ram; > > > > + unsigned long avail_ram, free_ram; > > > > unsigned long mem_size = 0; > > > > bool res = false; > > > > @@ -56,6 +56,7 @@ bool f2fs_available_free_memory(struct f2fs_sb_info *sbi, int type) > > > > /* only uses low memory */ > > > > avail_ram = val.totalram - val.totalhigh; > > > > + free_ram = val.freeram; > > > > /* > > > > * give 25%, 25%, 50%, 50%, 50% memory for each components respectively > > > > @@ -97,6 +98,14 @@ bool f2fs_available_free_memory(struct f2fs_sb_info *sbi, int type) > > > > mem_size = (atomic_read(&dcc->discard_cmd_cnt) * > > > > sizeof(struct discard_cmd)) >> PAGE_SHIFT; > > > > res = mem_size < (avail_ram * nm_i->ram_thresh / 100); > > > > + } else if (type == COMPRESS_PAGE) { > > > > + /* > > > > + * free memory is lower than watermark or cached page count > > > > + * exceed threshold, deny caching compress page. > > > > + */ > > > > + res = (free_ram > avail_ram * sbi->compress_watermark / 100) && > > > > + (COMPRESS_MAPPING(sbi)->nrpages < > > > > + free_ram * sbi->compress_percent / 100); > > > > } else { > > > > if (!sbi->sb->s_bdi->wb.dirty_exceeded) > > > > return true; > > > > diff --git a/fs/f2fs/node.h b/fs/f2fs/node.h > > > > index d85e8659cfda..84d45385d1f2 100644 > > > > --- a/fs/f2fs/node.h > > > > +++ b/fs/f2fs/node.h > > > > @@ -148,6 +148,7 @@ enum mem_type { > > > > EXTENT_CACHE, /* indicates extent cache */ > > > > INMEM_PAGES, /* indicates inmemory pages */ > > > > DISCARD_CACHE, /* indicates memory of cached discard cmds */ > > > > + COMPRESS_PAGE, /* indicates memory of cached compressed pages */ > > > > BASE_CHECK, /* check kernel status */ > > > > }; > > > > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E222C47096 for ; Thu, 3 Jun 2021 16:14:16 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D64926135D for ; Thu, 3 Jun 2021 16:14:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D64926135D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-f2fs-devel-bounces@lists.sourceforge.net Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1lopz4-0000Y8-FK; Thu, 03 Jun 2021 16:14:14 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lopz3-0000Xu-IL for linux-f2fs-devel@lists.sourceforge.net; Thu, 03 Jun 2021 16:14:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=In-Reply-To:Content-Type:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=VdhFa9boMMDhjxYUC+4aqMcFom/Bo4vPV/52Bq4YAUY=; b=WNoOkgcfWmz/Iy830p2toh+aGs poQC/peqfhXqrHyRj4oN3olc75ZROe9xbZGIGSyP/9K8L+3LTtBwW257uC6edn34y49+wkuMUuoUH /dV4jGx68xoWy/Yu+hnCgrPPd92i2deV+61/cKAbcVHCm+oFwh8kB8LcXUUGYbsQh85c=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To :From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=VdhFa9boMMDhjxYUC+4aqMcFom/Bo4vPV/52Bq4YAUY=; b=HtVdlraFa3hCuynR5L+SjdS+Nf baxIeapI4Fg9rMI1inXVFrCRCskN/JmSSG+9Ii7fOXYfxSWy0MzM6oFCfipk5QXf3rdoQ54TwwXhA mvT9xa5WqbN4l1cyffDK9T68ACF6wTj5kwHZugf1lQRQLpaSSv2dJXjJEMHwfPV08pZM=; Received: from mail.kernel.org ([198.145.29.99]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.3) id 1lopyp-0007ro-VH for linux-f2fs-devel@lists.sourceforge.net; Thu, 03 Jun 2021 16:14:13 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2CBA66135D; Thu, 3 Jun 2021 16:13:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622736835; bh=oy5ydTPfTDR/G+eayzloFwE8KarET66/fooyad/r0Bk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=aDjtSKf8Cb4W8yoI2XuWwrxNuaQ4ONoW2FCxFQSXyXlTD2C5nLj8QlLrSt/jI8xkS Cu6AoXvceAhkY1nO3PrwZLKgpKAu+pB6tDsuKIFnXVUCeFurzaRULQxS3yAzD0nO7c R2uZdDqAopmGGq6p9lgQUCsBhg3G5MoL2uhz9tZtqavoO1TxbotibiZNlPDhtrYEY8 JTdaU/LmPhJ85QVm4CdG9qxoIvTChtQpWr+0c1Xl6jJRq5jD7Q4W78mUl7+xLMaBon JWy+a08agfrAllB/iNZUDooko+StGEU3UyA3nCxr3aKw64OtFZ7NOZio9X53jXxaC7 //00yhaf4coSw== Date: Thu, 3 Jun 2021 09:13:53 -0700 From: Jaegeuk Kim To: Chao Yu Message-ID: References: <2c4db877-b5e6-1139-98b5-be2d9e7872be@kernel.org> <5140516c-e4c6-fd6a-69b2-7566c903cb53@kernel.org> <09fa74d3-a9df-028f-3ebc-2b845e5cd609@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Headers-End: 1lopyp-0007ro-VH Subject: Re: [f2fs-dev] [PATCH v6] f2fs: compress: add compress_inode to cache compressed blocks X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net On 06/03, Chao Yu wrote: > On 2021/6/2 23:34, Jaegeuk Kim wrote: > > On 06/02, Chao Yu wrote: > > > On 2021/6/2 1:27, Jaegeuk Kim wrote: > > > > On 06/01, Jaegeuk Kim wrote: > > > > > On 05/26, Chao Yu wrote: > > > > > > On 2021/5/26 21:26, Jaegeuk Kim wrote: > > > > > > > On 05/26, Chao Yu wrote: > > > > > > > > On 2021/5/25 22:01, Jaegeuk Kim wrote: > > > > > > > > > On 05/25, Chao Yu wrote: > > > > > > > > > > On 2021/5/25 21:02, Jaegeuk Kim wrote: > > > > > > > > > > > On 05/25, Jaegeuk Kim wrote: > > > > > > > > > > > > On 05/25, Chao Yu wrote: > > > > > > > > > > > > > Also, and queue this? > > > > > > > > > > > > > > > > > > > > > > > > Easy to get this? > > > > > > > > > > > > > > > > > > > > > > need GFP_NOFS? > > > > > > > > > > > > > > > > > > > > Not sure, I use __GFP_IO intentionally here to avoid __GFP_RECLAIM from > > > > > > > > > > GFP_NOFS, because in low memory case, I don't want to instead page cache > > > > > > > > > > of normal file with page cache of sbi->compress_inode. > > > > > > > > > > > > > > > > > > > > What is memory size in your vm? > > > > > > > > > > > > > > > > > > 4GB. If I set GFP_NOFS, I don't see the error anymore, at least. > > > > > > > > > > > > > > > > I applied below patch and don't see the warning message anymore. > > > > > > > > > > > > > > > > --- > > > > > > > > fs/f2fs/compress.c | 2 +- > > > > > > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > > > > > > > > > > > diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c > > > > > > > > index 701dd0f6f4ec..ed5b7fabc604 100644 > > > > > > > > --- a/fs/f2fs/compress.c > > > > > > > > +++ b/fs/f2fs/compress.c > > > > > > > > @@ -1703,7 +1703,7 @@ void f2fs_cache_compressed_page(struct f2fs_sb_info *sbi, struct page *page, > > > > > > > > avail_ram = si.totalram - si.totalhigh; > > > > > > > > > > > > > > > > /* free memory is lower than watermark, deny caching compress page */ > > > > > > > > - if (free_ram <= sbi->compress_watermark / 100 * avail_ram) > > > > > > > > > > > > This is buggy, because sbi->compress_watermark equals to 20, so that > > > > > > sbi->compress_watermark / 100 * avail_ram always be zero... > > > > > > > > > > > > After this change, if free ram is lower, we may just skip caching > > > > > > compressed blocks here. > > > > > > > > > > Can we move this in f2fs_available_free_memory()? > > > > > > More clean. > > > > > > One comment below: > > > > > > > > > > > Testing this. > > > > > > > > --- > > > > fs/f2fs/compress.c | 14 +------------- > > > > fs/f2fs/node.c | 11 ++++++++++- > > > > fs/f2fs/node.h | 1 + > > > > 3 files changed, 12 insertions(+), 14 deletions(-) > > > > > > > > diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c > > > > index 9fd62a0a646b..455561826c7d 100644 > > > > --- a/fs/f2fs/compress.c > > > > +++ b/fs/f2fs/compress.c > > > > @@ -1688,8 +1688,6 @@ void f2fs_cache_compressed_page(struct f2fs_sb_info *sbi, struct page *page, > > > > { > > > > struct page *cpage; > > > > int ret; > > > > - struct sysinfo si; > > > > - unsigned long free_ram, avail_ram; > > > > if (!test_opt(sbi, COMPRESS_CACHE)) > > > > return; > > > > @@ -1697,17 +1695,7 @@ void f2fs_cache_compressed_page(struct f2fs_sb_info *sbi, struct page *page, > > > > if (!f2fs_is_valid_blkaddr(sbi, blkaddr, DATA_GENERIC_ENHANCE_READ)) > > > > return; > > > > - si_meminfo(&si); > > > > - free_ram = si.freeram; > > > > - avail_ram = si.totalram - si.totalhigh; > > > > - > > > > - /* free memory is lower than watermark, deny caching compress page */ > > > > - if (free_ram <= sbi->compress_watermark / 100 * avail_ram) > > > > - return; > > > > - > > > > - /* cached page count exceed threshold, deny caching compress page */ > > > > - if (COMPRESS_MAPPING(sbi)->nrpages >= > > > > > > Need to cover COMPRESS_MAPPING() with CONFIG_F2FS_FS_COMPRESSION. > > > > Added like this. > > > > --- a/fs/f2fs/node.c > > +++ b/fs/f2fs/node.c > > @@ -99,6 +99,7 @@ bool f2fs_available_free_memory(struct f2fs_sb_info *sbi, int type) > > sizeof(struct discard_cmd)) >> PAGE_SHIFT; > > res = mem_size < (avail_ram * nm_i->ram_thresh / 100); > > } else if (type == COMPRESS_PAGE) { > > +#ifdef CONFIG_F2FS_FS_COMPRESSION > > How about adding free_ram definition and assigment here? > > unsigned long free_ram = val.freeram; Done. > > Thanks, > > > /* > > * free memory is lower than watermark or cached page count > > * exceed threshold, deny caching compress page. > > @@ -106,6 +107,9 @@ bool f2fs_available_free_memory(struct f2fs_sb_info *sbi, int type) > > res = (free_ram > avail_ram * sbi->compress_watermark / 100) && > > (COMPRESS_MAPPING(sbi)->nrpages < > > free_ram * sbi->compress_percent / 100); > > +#else > > + res = false; > > +#endif > > } else { > > if (!sbi->sb->s_bdi->wb.dirty_exceeded) > > return true; > > > > > > > > Thanks, > > > > > > > - free_ram / 100 * sbi->compress_percent) > > > > + if (!f2fs_available_free_memory(sbi, COMPRESS_PAGE)) > > > > return; > > > > cpage = find_get_page(COMPRESS_MAPPING(sbi), blkaddr); > > > > diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c > > > > index 3a8f7afa5059..67093416ce9c 100644 > > > > --- a/fs/f2fs/node.c > > > > +++ b/fs/f2fs/node.c > > > > @@ -45,7 +45,7 @@ bool f2fs_available_free_memory(struct f2fs_sb_info *sbi, int type) > > > > struct f2fs_nm_info *nm_i = NM_I(sbi); > > > > struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info; > > > > struct sysinfo val; > > > > - unsigned long avail_ram; > > > > + unsigned long avail_ram, free_ram; > > > > unsigned long mem_size = 0; > > > > bool res = false; > > > > @@ -56,6 +56,7 @@ bool f2fs_available_free_memory(struct f2fs_sb_info *sbi, int type) > > > > /* only uses low memory */ > > > > avail_ram = val.totalram - val.totalhigh; > > > > + free_ram = val.freeram; > > > > /* > > > > * give 25%, 25%, 50%, 50%, 50% memory for each components respectively > > > > @@ -97,6 +98,14 @@ bool f2fs_available_free_memory(struct f2fs_sb_info *sbi, int type) > > > > mem_size = (atomic_read(&dcc->discard_cmd_cnt) * > > > > sizeof(struct discard_cmd)) >> PAGE_SHIFT; > > > > res = mem_size < (avail_ram * nm_i->ram_thresh / 100); > > > > + } else if (type == COMPRESS_PAGE) { > > > > + /* > > > > + * free memory is lower than watermark or cached page count > > > > + * exceed threshold, deny caching compress page. > > > > + */ > > > > + res = (free_ram > avail_ram * sbi->compress_watermark / 100) && > > > > + (COMPRESS_MAPPING(sbi)->nrpages < > > > > + free_ram * sbi->compress_percent / 100); > > > > } else { > > > > if (!sbi->sb->s_bdi->wb.dirty_exceeded) > > > > return true; > > > > diff --git a/fs/f2fs/node.h b/fs/f2fs/node.h > > > > index d85e8659cfda..84d45385d1f2 100644 > > > > --- a/fs/f2fs/node.h > > > > +++ b/fs/f2fs/node.h > > > > @@ -148,6 +148,7 @@ enum mem_type { > > > > EXTENT_CACHE, /* indicates extent cache */ > > > > INMEM_PAGES, /* indicates inmemory pages */ > > > > DISCARD_CACHE, /* indicates memory of cached discard cmds */ > > > > + COMPRESS_PAGE, /* indicates memory of cached compressed pages */ > > > > BASE_CHECK, /* check kernel status */ > > > > }; > > > > _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel