Message ID | 20230417064136.5890-1-zbestahu@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1930838vqo; Mon, 17 Apr 2023 00:04:15 -0700 (PDT) X-Google-Smtp-Source: AKy350a2LmAu4oeMg0QhbeohMA9+ZZOdX7NiUFvKRX/5wmipknxI8O0fuIAPykldzKsU2ZtFuUA/ X-Received: by 2002:a05:6a20:5493:b0:f0:3917:5b20 with SMTP id i19-20020a056a20549300b000f039175b20mr294114pzk.31.1681715055484; Mon, 17 Apr 2023 00:04:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681715055; cv=none; d=google.com; s=arc-20160816; b=uZDhhWlDS9ncLcy/MTofHyrEGEfvDJnIOCBZEHaHxP0RlRzRVqDMnFP8xyAW2I2joz GwJIGxCFQW/DriVI+VULF6EDcELRiDnfhP3voSh/hL5V3tVU8Jc6L8ZYbDtkK2IAB9V9 I7K4Ywfg8ycJ5b3+LKMXoeDEC5DtfY+rHEX4Jcz+GEqKzdGgScmT3vOT1DSsSYJN8R/0 7dS02QjFgI7KV2UEUqE/i8/QvtMEgAo6lvWWaaMnff180b6Etsvb1huvTmkaEJV3/zRd gzGGBs+MUsw9IrD2Q1MBn3JULcXU0hWIzQhwE4uTs0bbnYyggx+UXCh0TztFACShkjnp G6rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=QHGyWlcoQD9UeffDXzUOvm+FtnM3Ld1GsqM2RKnrFyc=; b=fpD2yDYclmPg+iDh9UbySWU225KnCMURUm7V07CTuxKjKOJT2kcpxHnjW2t/CAE43v KIoZ7lC+jmppEtAOi2Jdkh3Nmyt9/xAbYm3iO+K6wJuTwN7g0TVOFg/gTHx8rTDM0Oyn cmDvJ0xCoDP3UMquiGkLNrML3SKsPwvTZUVSY+7uC8a28CWQsRss89hJKkoNn6zQyHDR CwDxxknAHWHXO/MD93dDWvTPgA06WWK6WgOcgziK1VRSxI6EoFWChwNxUVxfYFiG/eNk xHvZfpj16DH3cK1cHuh9Uf6FiY54zHVZGfDX6MXNhLtG3im3jfXFuLgs7NeRK55seYg2 G6CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=exAhRPnq; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z38-20020a630a66000000b0050fbc594e1asi11339420pgk.207.2023.04.17.00.04.03; Mon, 17 Apr 2023 00:04:15 -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; dkim=pass header.i=@gmail.com header.s=20221208 header.b=exAhRPnq; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229771AbjDQGmK (ORCPT <rfc822;leviz.kernel.dev@gmail.com> + 99 others); Mon, 17 Apr 2023 02:42:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229519AbjDQGmG (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 17 Apr 2023 02:42:06 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 906A126AE for <linux-kernel@vger.kernel.org>; Sun, 16 Apr 2023 23:42:05 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id p8so24623308plk.9 for <linux-kernel@vger.kernel.org>; Sun, 16 Apr 2023 23:42:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681713725; x=1684305725; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QHGyWlcoQD9UeffDXzUOvm+FtnM3Ld1GsqM2RKnrFyc=; b=exAhRPnqf1otSCxJRXagmwhR/d7yMDEjNw/kOlbIsgCnTfYzFkuqXuzM358CnunZTJ nq4uL/PXp0JIV1IPC9XURHdKoikyWadpWZ/z9J+oR+wZGHy6ktIggsVYk3oN9HRza+4i yFpOJORSSMO8t+iyn8vgvV2MWl9KNyNZzR3tBobP/SQcZmsL/5z7khjfo39gRSnOjHYG u9pFWDCBedrlQyxGLDA9LX6PDOJG25CSisAXNs25vP2S7F07/pP+5X+9zABOqxowhUv8 bXpyahKyD1mXl5CLNzxqKf/k6+32CWg5X2eiesaBOuhU+ujRoKxc5diQfv0kse6XSHnM mJGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681713725; x=1684305725; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QHGyWlcoQD9UeffDXzUOvm+FtnM3Ld1GsqM2RKnrFyc=; b=Lym3ykvb11yQIrB1dTs7KjbvuEneBvkSQp7FH3X33uBEsZOnGdioGRY4rvbrNgE7Lw yJC1Y3MQg63y3WI54qgu/hZVFp6eIGYU+6XzYsriT+idIRI+ex+9/sZPjb8L7aOgQyWl ccmeuACFxnAizH5xYeE19s5JEPV7juKEIcIw0odMbFAqoVncw76MBvtHFC6FhEeQ7AU5 NYm/18fLV4S0Szypc72HrjMKzBKIdSeTXQk7i9LshUdHCZx/XhvM9bVdzrRr3wHFcaUX MKUc4v5Z9UnXUA143mcQL0jhgvItpTlMjW3mLpOrbYXIcGqdc61Ywg92l4F9/367NPi/ Tk8w== X-Gm-Message-State: AAQBX9fC3oqvq9uyhhqce0PEgpagbAVLN/pUOhQ7GtuWHdH9pDqUmGbY vUqVQUx39UKx7qfpKKP3TSBEXIqM/O3HKg== X-Received: by 2002:a05:6a20:748b:b0:ef:2d6:446c with SMTP id p11-20020a056a20748b00b000ef02d6446cmr7924499pzd.17.1681713724956; Sun, 16 Apr 2023 23:42:04 -0700 (PDT) Received: from localhost.localdomain ([156.236.96.165]) by smtp.gmail.com with ESMTPSA id l15-20020a654c4f000000b0051a3c744256sm6337824pgr.93.2023.04.16.23.42.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Apr 2023 23:42:04 -0700 (PDT) From: Yue Hu <zbestahu@gmail.com> To: 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 Subject: [PATCH] erofs: remove unneeded icur field from struct z_erofs_decompress_frontend Date: Mon, 17 Apr 2023 14:41:35 +0800 Message-Id: <20230417064136.5890-1-zbestahu@gmail.com> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763406046043171971?= X-GMAIL-MSGID: =?utf-8?q?1763406046043171971?= |
Series |
erofs: remove unneeded icur field from struct z_erofs_decompress_frontend
|
|
Commit Message
Yue Hu
April 17, 2023, 6:41 a.m. UTC
From: Yue Hu <huyue2@coolpad.com> 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. Signed-off-by: Yue Hu <huyue2@coolpad.com> --- fs/erofs/zdata.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
Comments
On 2023/4/17 14:41, Yue Hu wrote: > From: Yue Hu <huyue2@coolpad.com> > > 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. > > Signed-off-by: Yue Hu <huyue2@coolpad.com> 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. 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 */ > + 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; > } >
On 2023/4/17 14:52, Gao Xiang wrote: > > > On 2023/4/17 14:41, Yue Hu wrote: >> From: Yue Hu <huyue2@coolpad.com> >> >> 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 <huyue2@coolpad.com> > > 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 <hsiangkao@linux.alibaba.com> > > 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; >> }
On 2023/4/17 15:15, Yue Hu wrote: > On Mon, 17 Apr 2023 15:00:25 +0800 > Gao Xiang <hsiangkao@linux.alibaba.com> wrote: > .. >> >> Although please help refine the comment below: >> >> /* scan & fill inplace I/O pages in the reverse order */ > > Ok, will refine it in v2. I rethink this, I don't want to go far in this way, and this makes a O(n) scan into O(n^2) when a single inplace I/O page is added. So sorry, I don't think it's a good way, although I also don't think `icur` is a good name and we might need to find a better name. Thanks, Gao Xiang > >> >> 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; >>>> }
On Mon, 17 Apr 2023 15:00:25 +0800 Gao Xiang <hsiangkao@linux.alibaba.com> wrote: > On 2023/4/17 14:52, Gao Xiang wrote: > > > > > > On 2023/4/17 14:41, Yue Hu wrote: > >> From: Yue Hu <huyue2@coolpad.com> > >> > >> 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? /* since file-backed online pages are traversed in reverse order */ fe->icur = z_erofs_pclusterpages(fe->pcl); static inline unsigned int z_erofs_pclusterpages(struct z_erofs_pcluster *pcl) { if (z_erofs_is_inline_pcluster(pcl)) return 1; [...] > > >> > >> Signed-off-by: Yue Hu <huyue2@coolpad.com> > > > > 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 <hsiangkao@linux.alibaba.com> > > > > > 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 */ Ok, will refine it in v2. > > 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; > >> }
On Mon, 17 Apr 2023 15:12:31 +0800 Gao Xiang <hsiangkao@linux.alibaba.com> wrote: > On 2023/4/17 15:15, Yue Hu wrote: > > On Mon, 17 Apr 2023 15:00:25 +0800 > > Gao Xiang <hsiangkao@linux.alibaba.com> wrote: > > > > .. > > >> > >> Although please help refine the comment below: > >> > >> /* scan & fill inplace I/O pages in the reverse order */ > > > > Ok, will refine it in v2. > > I rethink this, I don't want to go far in this way, and this makes a > O(n) scan into O(n^2) when a single inplace I/O page is added. Yeah, i misread that, it should be global before submission, just ignore the change. > > So sorry, I don't think it's a good way, although I also don't think > `icur` is a good name and we might need to find a better name. > > Thanks, > Gao Xiang > > > > >> > >> 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; > >>>> }
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 */ + 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; }