Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp3603346rwe; Mon, 17 Apr 2023 00:08:55 -0700 (PDT) X-Google-Smtp-Source: AKy350aH5uLXLGpF9gFJ5MfYJ+p/dDl7+qDB+v2EfCiDAAg7cTg6dU2e/udFW37M4tE3c+z6Szg7 X-Received: by 2002:a05:6a00:2409:b0:63b:2102:9fc8 with SMTP id z9-20020a056a00240900b0063b21029fc8mr18861451pfh.21.1681715334998; Mon, 17 Apr 2023 00:08:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681715334; cv=none; d=google.com; s=arc-20160816; b=USWN0E+p0n3FV80jBKQr3WEuNGcUPoUvEe3G5u6uW4K1w4vFS35JYdgku2DWuI9B6H mkt/WnoWbKrW8zwOsO6w6PJQjms7+bkycoFJkckMNAItoON35G9N/c+UazWmobVAPSCI OwhASnR4biZtQfVCQ1+R9hYW2YGRFRYmnQaHr/W9EOGxMHpK6SfHiKt/66AfrhIAgy6H 76RDED13KTibs+MkC2XY8IDaGlZKCY9W+8sIXCMoAy1bTpNdqjIDXJ+SF/armm5WDvTa MoFTqeirPgxb+69JwNOVOU/mUioXE43CGFj8q2GMUf28ZbJnVgTYXWHIPtMoTODTc9/i Qx9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:subject:user-agent:mime-version:date:message-id; bh=WILKqNl7mogQIYreYN8V01ezc5Wi4W4nS0g1psoE8F0=; b=ACFC6wMAPDhSzjeV3KoZf26D93BA7ucv4HiCVEkY4RR6vwSs88ZqZE5VmqlgeY+UGq jDSB4gMS+fYcb6pnOed6kVYYR0rPOJychGk4cfGdxc+Rj3FmvwuPXb/bjwX4AhKUZ9GW FPHvuTusP6L++oWWbv+KVBXdedqLG+2egQQwb8IDvmfHGpdog52+DR6R7xTFwnPOKdM/ GGvdlKmBbuAliC5Sabu67GwAR40193beUZYUFLGk2goh5OD85SP2jjUjKQOtWbFoZIN3 b2ayMjUAlNZO7B5oeQxaNWeiBcOIyabT/YtP80Lv92Q5yJTHKie1XU9Bk17tP5QAIDnh 2H9A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z16-20020aa79490000000b0063b870e736csi4212786pfk.199.2023.04.17.00.08.41; Mon, 17 Apr 2023 00:08:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230046AbjDQHAd (ORCPT + 99 others); Mon, 17 Apr 2023 03:00:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229690AbjDQHAb (ORCPT ); Mon, 17 Apr 2023 03:00:31 -0400 Received: from out30-119.freemail.mail.aliyun.com (out30-119.freemail.mail.aliyun.com [115.124.30.119]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32480199E for ; Mon, 17 Apr 2023 00:00:29 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R951e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046059;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0VgF9ZB1_1681714825; Received: from 30.97.49.3(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0VgF9ZB1_1681714825) by smtp.aliyun-inc.com; Mon, 17 Apr 2023 15:00:26 +0800 Message-ID: Date: Mon, 17 Apr 2023 15:00:25 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: [PATCH] erofs: remove unneeded icur field from struct z_erofs_decompress_frontend From: Gao Xiang To: Yue Hu , xiang@kernel.org, chao@kernel.org, linux-erofs@lists.ozlabs.org Cc: jefflexu@linux.alibaba.com, linux-kernel@vger.kernel.org, huyue2@coolpad.com, zhangwen@coolpad.com References: <20230417064136.5890-1-zbestahu@gmail.com> <26cdf7b0-5d7d-68ba-da76-1ad800708946@linux.alibaba.com> In-Reply-To: <26cdf7b0-5d7d-68ba-da76-1ad800708946@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/4/17 14:52, Gao Xiang wrote: > > > On 2023/4/17 14:41, Yue Hu wrote: >> From: Yue Hu >> >> The icur field is only used in z_erofs_try_inplace_io(). Let's just use >> a local variable instead. And no need to check if the pcluster is inline >> when setting icur since inline page cannot be used for inplace I/O. Where do we check if the pcluster is inline? >> >> Signed-off-by: Yue Hu > > Nope, it's a behavior change. > Other users could feed more inplace I/O pages before I/O submission > to reduce memory consumption, it's common when applying stress model > in low memory scenarios. Oh, I misread it. I think it can be done in this way although each following users will now rescan the whole array all the time. Reviewed-by: Gao Xiang > > Thanks, > Gao Xiang > >> --- >>   fs/erofs/zdata.c | 13 +++++-------- >>   1 file changed, 5 insertions(+), 8 deletions(-) >> >> diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c >> index f759152feffa..f8bf2b227942 100644 >> --- a/fs/erofs/zdata.c >> +++ b/fs/erofs/zdata.c >> @@ -554,9 +554,6 @@ struct z_erofs_decompress_frontend { >>       /* used for applying cache strategy on the fly */ >>       bool backmost; >>       erofs_off_t headoffset; >> - >> -    /* a pointer used to pick up inplace I/O pages */ >> -    unsigned int icur; >>   }; >>   #define DECOMPRESS_FRONTEND_INIT(__i) { \ >> @@ -707,11 +704,13 @@ static bool z_erofs_try_inplace_io(struct z_erofs_decompress_frontend *fe, >>                      struct z_erofs_bvec *bvec) >>   { >>       struct z_erofs_pcluster *const pcl = fe->pcl; >> +    /* file-backed online pages are traversed in reverse order */ Although please help refine the comment below: /* scan & fill inplace I/O pages in the reverse order */ Thanks, Gao Xiang >> +    unsigned int icur = pcl->pclusterpages; >> -    while (fe->icur > 0) { >> -        if (!cmpxchg(&pcl->compressed_bvecs[--fe->icur].page, >> +    while (icur > 0) { >> +        if (!cmpxchg(&pcl->compressed_bvecs[--icur].page, >>                    NULL, bvec->page)) { >> -            pcl->compressed_bvecs[fe->icur] = *bvec; >> +            pcl->compressed_bvecs[icur] = *bvec; >>               return true; >>           } >>       } >> @@ -877,8 +876,6 @@ static int z_erofs_collector_begin(struct z_erofs_decompress_frontend *fe) >>       } >>       z_erofs_bvec_iter_begin(&fe->biter, &fe->pcl->bvset, >>                   Z_EROFS_INLINE_BVECS, fe->pcl->vcnt); >> -    /* since file-backed online pages are traversed in reverse order */ >> -    fe->icur = z_erofs_pclusterpages(fe->pcl); >>       return 0; >>   }