From: Gao Xiang <hsiangkao@linux.alibaba.com>
To: Hongbo Li <lihongbo22@huawei.com>,
chao@kernel.org, brauner@kernel.org, djwong@kernel.org,
amir73il@gmail.com, joannelkoong@gmail.com
Cc: linux-fsdevel@vger.kernel.org, linux-erofs@lists.ozlabs.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v8 7/9] erofs: support unencoded inodes for page cache share
Date: Mon, 17 Nov 2025 11:44:16 +0800 [thread overview]
Message-ID: <40b291a4-ea32-4450-ab67-0c9c96a3d601@linux.alibaba.com> (raw)
In-Reply-To: <20251114095516.207555-8-lihongbo22@huawei.com>
On 2025/11/14 17:55, Hongbo Li wrote:
> This patch adds inode page cache sharing functionality for unencoded
> files.
>
> I conducted experiments in the container environment. Below is the
> memory usage for reading all files in two different minor versions
> of container images:
>
> +-------------------+------------------+-------------+---------------+
> | Image | Page Cache Share | Memory (MB) | Memory |
> | | | | Reduction (%) |
> +-------------------+------------------+-------------+---------------+
> | | No | 241 | - |
> | redis +------------------+-------------+---------------+
> | 7.2.4 & 7.2.5 | Yes | 163 | 33% |
> +-------------------+------------------+-------------+---------------+
> | | No | 872 | - |
> | postgres +------------------+-------------+---------------+
> | 16.1 & 16.2 | Yes | 630 | 28% |
> +-------------------+------------------+-------------+---------------+
> | | No | 2771 | - |
> | tensorflow +------------------+-------------+---------------+
> | 2.11.0 & 2.11.1 | Yes | 2340 | 16% |
> +-------------------+------------------+-------------+---------------+
> | | No | 926 | - |
> | mysql +------------------+-------------+---------------+
> | 8.0.11 & 8.0.12 | Yes | 735 | 21% |
> +-------------------+------------------+-------------+---------------+
> | | No | 390 | - |
> | nginx +------------------+-------------+---------------+
> | 7.2.4 & 7.2.5 | Yes | 219 | 44% |
> +-------------------+------------------+-------------+---------------+
> | tomcat | No | 924 | - |
> | 10.1.25 & 10.1.26 +------------------+-------------+---------------+
> | | Yes | 474 | 49% |
> +-------------------+------------------+-------------+---------------+
>
> Additionally, the table below shows the runtime memory usage of the
> container:
>
> +-------------------+------------------+-------------+---------------+
> | Image | Page Cache Share | Memory (MB) | Memory |
> | | | | Reduction (%) |
> +-------------------+------------------+-------------+---------------+
> | | No | 35 | - |
> | redis +------------------+-------------+---------------+
> | 7.2.4 & 7.2.5 | Yes | 28 | 20% |
> +-------------------+------------------+-------------+---------------+
> | | No | 149 | - |
> | postgres +------------------+-------------+---------------+
> | 16.1 & 16.2 | Yes | 95 | 37% |
> +-------------------+------------------+-------------+---------------+
> | | No | 1028 | - |
> | tensorflow +------------------+-------------+---------------+
> | 2.11.0 & 2.11.1 | Yes | 930 | 10% |
> +-------------------+------------------+-------------+---------------+
> | | No | 155 | - |
> | mysql +------------------+-------------+---------------+
> | 8.0.11 & 8.0.12 | Yes | 132 | 15% |
> +-------------------+------------------+-------------+---------------+
> | | No | 25 | - |
> | nginx +------------------+-------------+---------------+
> | 7.2.4 & 7.2.5 | Yes | 20 | 20% |
> +-------------------+------------------+-------------+---------------+
> | tomcat | No | 186 | - |
> | 10.1.25 & 10.1.26 +------------------+-------------+---------------+
> | | Yes | 98 | 48% |
> +-------------------+------------------+-------------+---------------+
>
> Co-developed-by: Hongzhen Luo <hongzhen@linux.alibaba.com>
> Signed-off-by: Hongzhen Luo <hongzhen@linux.alibaba.com>
> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
> ---
> fs/erofs/data.c | 38 +++++++++++++++---
> fs/erofs/inode.c | 5 +++
> fs/erofs/internal.h | 4 ++
> fs/erofs/ishare.c | 98 ++++++++++++++++++++++++++++++++++++++++++++-
> fs/erofs/ishare.h | 18 +++++++++
> fs/erofs/super.c | 11 +++--
> 6 files changed, 163 insertions(+), 11 deletions(-)
>
> diff --git a/fs/erofs/data.c b/fs/erofs/data.c
> index bd3d85c61341..c459104e4734 100644
> --- a/fs/erofs/data.c
> +++ b/fs/erofs/data.c
> @@ -5,6 +5,7 @@
> * Copyright (C) 2021, Alibaba Cloud
> */
> #include "internal.h"
> +#include "ishare.h"
Can we just get rid of another "ishare.h", these can be moved into
internal.h:
#ifdef CONFIG_EROFS_FS_INODE_SHARE
int erofs_ishare_init(struct super_block *sb);
void erofs_ishare_exit(struct super_block *sb);
bool erofs_ishare_fill_inode(struct inode *inode);
void erofs_ishare_free_inode(struct inode *inode);
#else
static inline int erofs_ishare_init(struct super_block *sb) { return 0; }
static inline void erofs_ishare_exit(struct super_block *sb) {}
static inline bool erofs_ishare_fill_inode(struct inode *inode) { return false; }
static inline void erofs_ishare_free_inode(struct inode *inode) {}
#endif // CONFIG_EROFS_FS_INODE_SHARE
> #include <linux/sched/mm.h>
> #include <trace/events/erofs.h>
>
> @@ -269,23 +270,27 @@ void erofs_onlinefolio_end(struct folio *folio, int err, bool dirty)
> struct erofs_iomap_iter_ctx {
> struct page *page;
> void *base;
> + struct inode *realinode;
> };
>
> static int erofs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
> unsigned int flags, struct iomap *iomap, struct iomap *srcmap)
> {
> - int ret;
> struct erofs_iomap_iter_ctx *ctx;
> - struct super_block *sb = inode->i_sb;
> struct erofs_map_blocks map;
> struct erofs_map_dev mdev;
> struct iomap_iter *iter;
> + struct inode *realinode;
> + struct super_block *sb;
struct inode *realinode = ctx ? ctx->realinode : inode;
struct super_block *sb = realinode->i_sb;
> + int ret;
>
> iter = container_of(iomap, struct iomap_iter, iomap);
> ctx = iter->private;
> + realinode = ctx ? ctx->realinode : inode;
> + sb = realinode->i_sb;
> map.m_la = offset;
> map.m_llen = length;
> - ret = erofs_map_blocks(inode, &map);
> + ret = erofs_map_blocks(realinode, &map);
> if (ret < 0)
> return ret;
>
> @@ -300,7 +305,7 @@ static int erofs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
> return 0;
> }
>
> - if (!(map.m_flags & EROFS_MAP_META) || !erofs_inode_in_metabox(inode)) {
> + if (!(map.m_flags & EROFS_MAP_META) || !erofs_inode_in_metabox(realinode)) {
> mdev = (struct erofs_map_dev) {
> .m_deviceid = map.m_deviceid,
> .m_pa = map.m_pa,
> @@ -326,7 +331,7 @@ static int erofs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
> struct erofs_buf buf = __EROFS_BUF_INITIALIZER;
>
> ptr = erofs_read_metabuf(&buf, sb, map.m_pa,
> - erofs_inode_in_metabox(inode));
> + erofs_inode_in_metabox(realinode));
> if (IS_ERR(ptr))
> return PTR_ERR(ptr);
> iomap->inline_data = ptr;
...
>
> @@ -234,3 +248,83 @@ const struct file_operations erofs_ishare_fops = {
> .get_unmapped_area = thp_get_unmapped_area,
> .splice_read = filemap_splice_read,
> };
> +
> +void erofs_read_begin(struct erofs_read_ctx *rdctx)
I think if backing_head, backing_link (although I don't like
the naming) is valid, erofs_read_begin() and erofs_read_end()
is unneeded here.
Since we maintain the backing validity using .open() and
.release() hooks.
the odd erofs_read_{begin,end} can be avoided then...
Thanks,
Gao Xiang
next prev parent reply other threads:[~2025-11-17 3:44 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-14 9:55 [PATCH v8 0/9] erofs: inode page cache share feature Hongbo Li
2025-11-14 9:55 ` [PATCH v8 1/9] iomap: stash iomap read ctx in the private field of iomap_iter Hongbo Li
2025-11-16 11:53 ` Gao Xiang
2025-11-16 11:54 ` Gao Xiang
2025-11-14 9:55 ` [PATCH v8 2/9] erofs: hold read context in iomap_iter if needed Hongbo Li
2025-11-16 12:01 ` Gao Xiang
2025-11-17 1:45 ` Hongbo Li
2025-11-14 9:55 ` [PATCH v8 3/9] erofs: move `struct erofs_anon_fs_type` to super.c Hongbo Li
2025-11-16 12:02 ` Gao Xiang
2025-11-14 9:55 ` [PATCH v8 4/9] erofs: support user-defined fingerprint name Hongbo Li
2025-11-17 2:54 ` Gao Xiang
2025-11-17 7:41 ` Hongbo Li
2025-11-14 9:55 ` [PATCH v8 5/9] erofs: support domain-specific page cache share Hongbo Li
2025-11-14 9:55 ` [PATCH v8 6/9] erofs: introduce the page cache share feature Hongbo Li
2025-11-17 3:06 ` Gao Xiang
2025-11-17 3:14 ` Hongbo Li
2025-11-17 3:18 ` Hongbo Li
2025-11-17 3:30 ` Gao Xiang
2025-11-14 9:55 ` [PATCH v8 7/9] erofs: support unencoded inodes for page cache share Hongbo Li
2025-11-17 3:44 ` Gao Xiang [this message]
2025-11-14 9:55 ` [PATCH v8 8/9] erofs: support compressed " Hongbo Li
2025-11-14 9:55 ` [PATCH v8 9/9] erofs: implement .fadvise " Hongbo Li
2025-11-17 3:48 ` Gao Xiang
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=40b291a4-ea32-4450-ab67-0c9c96a3d601@linux.alibaba.com \
--to=hsiangkao@linux.alibaba.com \
--cc=amir73il@gmail.com \
--cc=brauner@kernel.org \
--cc=chao@kernel.org \
--cc=djwong@kernel.org \
--cc=joannelkoong@gmail.com \
--cc=lihongbo22@huawei.com \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).