From: Gao Xiang <hsiangkao@aol.com>
To: linux-erofs@lists.ozlabs.org
Cc: Chao Yu <yuchao0@huawei.com>, Chao Yu <chao@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Gao Xiang <hsiangkao@redhat.com>
Subject: [PATCH 4/4] erofs: complete a missing case for inplace I/O
Date: Thu, 22 Oct 2020 22:57:24 +0800 [thread overview]
Message-ID: <20201022145724.27284-4-hsiangkao@aol.com> (raw)
In-Reply-To: <20201022145724.27284-1-hsiangkao@aol.com>
From: Gao Xiang <hsiangkao@redhat.com>
Add a missing case which could cause unnecessary page allocation
but not directly use inplace I/O instead, which increases runtime
extra memory footprint.
The detail is, considering a file-backed page, the right half of
the page is chosen to be cached (e.g. the end page) and some of
its data doesn't exist in managed cache, so the pcluster will be
kept in the submission chain. (In other words, it cannot be
decompressed in advance, for example, due to the bypass chain).
Currently, the pcluster for this case is downgraded as NOINPLACE,
and stop the left half of the page from doing inplace I/O (so an
extra page allocation is needed then.)
Let's avoid such unnecessary downgrade instead.
Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
---
fs/erofs/zdata.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c
index edd7325570e1..ef12275f7fcc 100644
--- a/fs/erofs/zdata.c
+++ b/fs/erofs/zdata.c
@@ -160,7 +160,8 @@ static void preload_compressed_pages(struct z_erofs_collector *clt,
const unsigned int clusterpages = BIT(pcl->clusterbits);
struct page **pages = clt->compressedpages;
pgoff_t index = pcl->obj.index + (pages - pcl->compressed_pages);
- bool standalone = true;
+ bool io_cant_bypass = false;
+ bool updated = false;
if (clt->mode < COLLECT_PRIMARY_FOLLOWED)
return;
@@ -180,20 +181,31 @@ static void preload_compressed_pages(struct z_erofs_collector *clt,
} else if (type == DELAYEDALLOC) {
t = tagptr_init(compressed_page_t, PAGE_UNALLOCATED);
} else { /* DONTALLOC */
- if (standalone)
+ /* update to first inplace I/O page */
+ if (!updated) {
clt->compressedpages = pages;
- standalone = false;
+ updated = true;
+ }
+ io_cant_bypass = true;
continue;
}
- if (!cmpxchg_relaxed(pages, NULL, tagptr_cast_ptr(t)))
+ if (!cmpxchg_relaxed(pages, NULL, tagptr_cast_ptr(t))) {
+ if (type == DELAYEDALLOC)
+ io_cant_bypass = true;
continue;
+ }
if (page)
put_page(page);
}
- if (standalone) /* downgrade to PRIMARY_FOLLOWED_NOINPLACE */
+ /*
+ * for COLLECT_PRIMARY_FOLLOWED pcluster, if all managed pages have
+ * been found (which means it can be handled without submittng I/O)
+ * it's unsafe to do inplace I/O. let's downgrade to NOINPLACE instead.
+ */
+ if (!io_cant_bypass)
clt->mode = COLLECT_PRIMARY_FOLLOWED_NOINPLACE;
}
--
2.24.0
next prev parent reply other threads:[~2020-10-22 14:58 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20201022145724.27284-1-hsiangkao.ref@aol.com>
2020-10-22 14:57 ` [PATCH 1/4] erofs: fix setting up pcluster for temporary pages Gao Xiang
2020-10-22 14:57 ` [PATCH 2/4] erofs: get rid of magical Z_EROFS_MAPPING_STAGING Gao Xiang
2020-10-22 14:57 ` [PATCH 3/4] erofs: insert to managed cache after adding to pcl Gao Xiang
2020-10-22 14:57 ` Gao Xiang [this message]
2020-10-30 12:20 ` [PATCH 1/4] erofs: fix setting up pcluster for temporary pages Vladimir Zapolskiy
2020-10-30 12:47 ` Gao Xiang
2020-10-30 13:32 ` Vladimir Zapolskiy
2020-10-30 14:10 ` Gao Xiang
2020-11-04 1:05 ` Chao Yu
2020-11-04 1:11 ` Gao Xiang
2020-11-04 1:44 ` Chao Yu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201022145724.27284-4-hsiangkao@aol.com \
--to=hsiangkao@aol.com \
--cc=chao@kernel.org \
--cc=hsiangkao@redhat.com \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=yuchao0@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®