Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2190822pxb; Tue, 23 Feb 2021 00:15:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJw5aw09fyr6Fc59e03hfa3WTj+WZCkwvGjShTMLlts3LbaTmq/Bf5NwSLmYwva5sZFqXa+N X-Received: by 2002:a17:906:c44d:: with SMTP id ck13mr342047ejb.103.1614068155174; Tue, 23 Feb 2021 00:15:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614068155; cv=none; d=google.com; s=arc-20160816; b=RxKBwUQMr5pujzFNzSSMRsoOHu9Acm+7DleBn7gbDohxd9eVFuiTfcrlPiABONcTN9 7hmjaihVzD8M5rBJy5OI6ZSR7g/+uMSsjpW1983Ho77OtqyoUBhNnWOZ95o4rKP4NENP nKhSumkoB4Yic5DAghXOjGigyTBRf5ydhELrRaMTAiMC9DU/QOe9I2EJjJhsKR8Fe4bt J7ZVQ1M/kNul+FW/ZVQE6HInSljYYzMo9/0TcdFoVbcEU4XRoZ41IFoWfzamDO6XGlJ7 QGtJy/deW7zcOoWHDnSdL8eq82uHlYfaE3UHelsbkN9/fZAnzZof8mtA+a/BRLZoeizN kDKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=VgRaNiXmS+fHUI7DmYXUl0ZOy1q455DZjxEhf4VEPXs=; b=K7swDHF9+iLW7OKkk6fetqFt4k5sQQ+QmgK95e9cie1+IDY6LUWBlq9KosuGK3Z6fW YcGqJGOy2k7hNpP3Q2cKu7RJNj3gOU/rENYlRdYBzEOsXc9Lc3TWigQopIDxeSqYI+Kf laJy5ivsQU4xiQslMf9HnlnxLAlfGxTpIaA/bC00M4piL3sFqJsCPp/7GCiCOQH6Aywq 1shalA4vgqSvT9L/Huo4GoLK0rzOj9cLivbxx5EhOhiJHf6lhWwNeLGb6bRo6f37GkZR ILc9eW20JgenNBhYMNux6ReU+BqxsSTbwrf4t0oZ2ELsjanaWYEAiqb/23zNGQ6yYKZ0 twtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@aol.com header.s=a2048 header.b="ahpk7S/v"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=aol.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q9si4869248edn.413.2021.02.23.00.15.28; Tue, 23 Feb 2021 00:15:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@aol.com header.s=a2048 header.b="ahpk7S/v"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=aol.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231190AbhBWIO5 (ORCPT + 99 others); Tue, 23 Feb 2021 03:14:57 -0500 Received: from sonic305-19.consmr.mail.gq1.yahoo.com ([98.137.64.82]:46020 "EHLO sonic305-19.consmr.mail.gq1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230060AbhBWIO4 (ORCPT ); Tue, 23 Feb 2021 03:14:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1614068030; bh=VgRaNiXmS+fHUI7DmYXUl0ZOy1q455DZjxEhf4VEPXs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From:Subject:Reply-To; b=ahpk7S/v1mR5uLk8S/KdDNybLS+h6w7wC8zHcf0KPxalKtZM6BREr8IQ5jW6BCOn9AanykAKw3ep/8Rd/N1OoGCP+Sa/cM/zwL1xhrDDhZyrdQ7u5UO6mTnwQIHHoFXKCSNr3vFLQGhN7+Sna8hMuN+x6SKNGVHd561J4Te7stKE2B4sy4/Pkl/sNkGRDKPAlsgzX6cYLRHSP6fWUK4yC7WAvXru8wbh40PW8wJrsvHyXLsbpAToppuVWUiojThd30Wgj7/aBIIXyieYfL0aJGD601Mk3NZOOQI0xVE0Z2Uw6Mm0ldkyg5Di8fZ8Tch8q6mGdOEyzDQizH1WBs2JBQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1614068030; bh=FVnb1PG+YppfkV46CJalLyQRXxdyypGCCqCP4Bm+kbw=; h=X-Sonic-MF:Date:From:To:Subject:From:Subject; b=WgAef68o9i3vsUCVcRVYnZ4TiVpIR92x3702QTxgT+TGVP4Fg8c98qbYwAvlF6IboqNlRkeE+deIWUxD111o7pPtysXjUFD9552Oc/RB5KmheuMXApBSEDRuY1MEoD0WA8Yu2vvs2C2MLpoYsvjXApgOgyQmNuhb7AwM3NXfWDnL9PBNIYARilhpSvZrmXk3acw48dBwvCPxXBh19OgwFLWUB58YcQVOimbTfH1/9owCNV+T9tYCjQtO2YIPnE4oW00Zdow8+ZRpoQKax6JQT0mOU0torpQcnRCnKAyAFWaclFbMbPNQ+t37jVyBgZ6PwnPBi9AWGTYhCZq4bCOprQ== X-YMail-OSG: 2g6jPhQVM1mMw6MW0uill92AcbruD0.qNLKiBq9lnIsAwaCU6a3CK4JSTRXwPD. YV3AMK.HMHvvKlmhuMWrMf7089jcAuRY2HtHq2E7AosEdDWVRrFTVlvv5IueDDF5Adt8hzdvdcy1 e5tSwqZStbiDfdOe5903zNrgaCkZiNb16d3NfsQNSS9DK7CP3Qai7kXT9g1ORepY5pxNPRe6AfUV lLUj_0fq0uNd8zKwhXkbJuBT6Jc7J6nNVYUyckzYoPtXeXKbOvxfLBKxypemeLiG7FYa0g02vPSv sn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RYcVV28BRw0FHy8Yd5RMc6E1weasb9dNS.LUfOiwu0mmebT6TAsu vsLkHZtspciL5l_TXjNhSroPKmVdWUjLrgW8X61e0BFQj8lxpkMOOCT.1HTBMbG3DME9hzWGGfwc FFLNeGPKDQylf_rVp7d.fPGM4SaXyiVhxyjuOIema8r6vKT9siUlq5L7.ffeJwgzxrQkEytpKe4u PGAGZYjXiFNevdKD5Ih9GcGizK7nxuRU33.DhKjlKcnpWerTCaKhJMSSyTRoHziAybGZQfQsoOsG 9kqisFGgp5a4TfDc45A-- X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic305.consmr.mail.gq1.yahoo.com with HTTP; Tue, 23 Feb 2021 08:13:50 +0000 Received: by smtp407.mail.gq1.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID c8a8e7ed1d54030eb2a1fabfc0c47f76; Tue, 23 Feb 2021 08:13:42 +0000 (UTC) Date: Tue, 23 Feb 2021 16:13:24 +0800 From: Gao Xiang To: Huang Jianan Cc: zhangshiming@oppo.com, guoweichao@oppo.com, linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] erofs: support adjust lz4 history window size Message-ID: <20210223081323.GA21197@hsiangkao-HP-ZHAN-66-Pro-G1> References: <20210223073119.69232-1-huangjianan@oppo.com> <20210223074418.GA1269766@xiangao.remote.csb> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210223074418.GA1269766@xiangao.remote.csb> User-Agent: Mutt/1.10.1 (2018-07-13) X-Mailer: WebService/1.1.17712 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.aol Apache-HttpAsyncClient/4.1.4 (Java/11.0.9.1) Content-Length: 4160 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 23, 2021 at 03:44:18PM +0800, Gao Xiang wrote: > On Tue, Feb 23, 2021 at 03:31:19PM +0800, Huang Jianan via Linux-erofs wrote: > > lz4 uses LZ4_DISTANCE_MAX to record history preservation. When > > using rolling decompression, a block with a higher compression > > ratio will cause a larger memory allocation (up to 64k). It may > > cause a large resource burden in extreme cases on devices with > > small memory and a large number of concurrent IOs. So appropriately > > reducing this value can improve performance. > > > > Decreasing this value will reduce the compression ratio (except > > when input_size > currently only supports 4k output, reducing this value will not > > significantly reduce the compression benefits. > > > > The maximum value of LZ4_DISTANCE_MAX defined by lz4 is 64k, and > > we can only reduce this value. For the old kernel, it just can't > > reduce the memory allocation during rolling decompression without > > affecting the decompression result. > > > > Signed-off-by: Huang Jianan > > Signed-off-by: Guo Weichao > > --- > > > > change since v2: > > - use z_erofs_load_lz4_config to calculate lz4_distance_pages > > - add description about the compatibility of the old kernel version > > - drop useless comment > > > > fs/erofs/decompressor.c | 22 ++++++++++++++++++---- > > fs/erofs/erofs_fs.h | 3 ++- > > fs/erofs/internal.h | 7 +++++++ > > fs/erofs/super.c | 2 ++ > > 4 files changed, 29 insertions(+), 5 deletions(-) > > > > diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c > > index 1cb1ffd10569..0bb7903e3f9b 100644 > > --- a/fs/erofs/decompressor.c > > +++ b/fs/erofs/decompressor.c > > @@ -28,6 +28,18 @@ struct z_erofs_decompressor { > > char *name; > > }; > > > > +int z_erofs_load_lz4_config(struct erofs_sb_info *sbi, > > + struct erofs_super_block *dsb) > > +{ > > + u16 distance = le16_to_cpu(dsb->lz4_max_distance); > > + > > + sbi->lz4_max_distance_pages = distance ? > > + (DIV_ROUND_UP(distance, PAGE_SIZE) + 1) : > > Unneeded parentheses here (I'll update it when applying). > Otherwise it looks good to me. > > Reviewed-by: Gao Xiang > > Thanks, > Gao Xiang Applied to dev-test temporarily with the following diff (fix 80 char limitation, etc): diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c index 0bb7903e3f9b..49347e681a53 100644 --- a/fs/erofs/decompressor.c +++ b/fs/erofs/decompressor.c @@ -34,9 +34,8 @@ int z_erofs_load_lz4_config(struct erofs_sb_info *sbi, u16 distance = le16_to_cpu(dsb->lz4_max_distance); sbi->lz4_max_distance_pages = distance ? - (DIV_ROUND_UP(distance, PAGE_SIZE) + 1) : + DIV_ROUND_UP(distance, PAGE_SIZE) + 1 : LZ4_MAX_DISTANCE_PAGES; - return 0; } diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index 4cb2395db45c..77965490dced 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -433,7 +433,7 @@ static inline void erofs_exit_shrinker(void) {} static inline int z_erofs_init_zip_subsystem(void) { return 0; } static inline void z_erofs_exit_zip_subsystem(void) {} static inline int z_erofs_load_lz4_config(struct erofs_sb_info *sbi, - struct erofs_super_block *dsb) { return 0; } + struct erofs_super_block *dsb) { return 0; } #endif /* !CONFIG_EROFS_FS_ZIP */ #define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */ diff --git a/fs/erofs/super.c b/fs/erofs/super.c index 11bc51e488dd..025c25d6e0f3 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -166,8 +166,6 @@ static int erofs_read_superblock(struct super_block *sb) if (!check_layout_compatibility(sb, dsb)) goto out; - z_erofs_load_lz4_config(sbi, dsb); - sbi->blocks = le32_to_cpu(dsb->blocks); sbi->meta_blkaddr = le32_to_cpu(dsb->meta_blkaddr); #ifdef CONFIG_EROFS_FS_XATTR @@ -189,6 +187,9 @@ static int erofs_read_superblock(struct super_block *sb) ret = -EFSCORRUPTED; goto out; } + + /* parse on-disk compression configurations */ + z_erofs_load_lz4_config(sbi, dsb); ret = 0; out: kunmap(page);