All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gao Xiang <hsiangkao@linux.alibaba.com>
To: Hongzhen Luo <hongzhen@linux.alibaba.com>,
	Christian Brauner <brauner@kernel.org>,
	Gao Xiang <xiang@kernel.org>, Jan Kara <jack@suse.cz>,
	Amir Goldstein <amir73il@gmail.com>,
	Jeff Layton <jlayton@kernel.org>,
	Matthew Wilcox <willy@infradead.org>
Cc: "Daan De Meyer" <daan.j.demeyer@gmail.com>,
	"Lennart Poettering" <lennart@poettering.net>,
	"Mike Yuan" <me@yhndnzj.com>,
	"Zbigniew Jędrzejewski-Szmek" <zbyszek@in.waw.pl>,
	lihongbo22@huawei.com, linux-erofs@lists.ozlabs.org
Subject: Re: [PATCH RFC 4/4] erofs: introduce .fadvise for page cache share
Date: Sat, 5 Jul 2025 09:25:30 +0800	[thread overview]
Message-ID: <ca2fbae3-92ce-4198-bb06-a267f9db071b@linux.alibaba.com> (raw)
In-Reply-To: <b7f66641-b749-4b8f-9b30-f9ac143c507e@linux.alibaba.com>



On 2025/7/5 09:15, Hongzhen Luo wrote:
> 
> On 2025/7/5 05:09, Gao Xiang wrote:
>>
>>
>> On 2025/7/3 20:23, Christian Brauner wrote:
>>> From: Hongzhen Luo <hongzhen@linux.alibaba.com>
>>>
>>> When using .fadvise to release a file's page cache, it frees page cache
>>> pages that were first read by this file. To achieve this, an interval
>>> tree is added in the inode of that file to track the segments first
>>> read by that inode.
>>>
>>> Signed-off-by: Hongzhen Luo <hongzhen@linux.alibaba.com>
>>> Link: https://lore.kernel.org/20240902110620.2202586-5-hongzhen@linux.alibaba.com
>>> Signed-off-by: Christian Brauner <brauner@kernel.org>
>>> ---
>>>   fs/erofs/data.c            | 38 ++++++++++++++++++++--
>>>   fs/erofs/internal.h        |  5 +++
>>>   fs/erofs/pagecache_share.c | 81 ++++++++++++++++++++++++++++++++++++++++++++--
>>>   fs/erofs/pagecache_share.h |  2 ++
>>>   fs/erofs/super.c           |  9 ++++++
>>>   5 files changed, 131 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/fs/erofs/data.c b/fs/erofs/data.c
>>> index fb54162f4c54..61a42a95d26b 100644
>>> --- a/fs/erofs/data.c
>>> +++ b/fs/erofs/data.c
>>> @@ -7,6 +7,7 @@
>>>   #include "internal.h"
>>>   #include <linux/sched/mm.h>
>>>   #include <trace/events/erofs.h>
>>> +#include "pagecache_share.h"
>>>     void erofs_unmap_metabuf(struct erofs_buf *buf)
>>>   {
>>> @@ -353,6 +354,7 @@ static int erofs_read_folio(struct file *file, struct folio *folio)
>>>   {
>>>   #ifdef CONFIG_EROFS_FS_PAGE_CACHE_SHARE
>>>       struct erofs_inode *vi = NULL;
>>> +    struct interval_tree_node *seg;
>>>       int ret;
>>>         if (file && file->private_data) {
>>> @@ -363,8 +365,22 @@ static int erofs_read_folio(struct file *file, struct folio *folio)
>>>               vi = NULL;
>>>       }
>>>       ret = iomap_read_folio(folio, &erofs_iomap_ops);
>>> -    if (vi)
>>> +    if (vi) {
>>>           folio->mapping->host = file_inode(file);
>>> +        seg = erofs_pcs_alloc_seg();
>>> +        if (!seg)
>>> +            return -ENOMEM;
>>> +        seg->start = folio->index;
>>> +        seg->last = seg->start + (folio_size(folio) >> PAGE_SHIFT);
>>> +        if (seg->last > (vi->vfs_inode.i_size >> PAGE_SHIFT))
>>> +            seg->last = vi->vfs_inode.i_size >> PAGE_SHIFT;
>>> +        if (seg->last >= seg->start) {
>>> +            mutex_lock(&vi->segs_mutex);
>>> +            interval_tree_insert(seg, &vi->segs);
>>> +            mutex_unlock(&vi->segs_mutex);
>>> +        } else
>>> +            erofs_pcs_free_seg(seg);
>>> +    }
>>
>> I don't know what Hongzhen is trying to do in this patch and
>> it seems too odd on my side, maybe it needs to reimplement
>> this patch later but we should support .fadvise().
> 
> The original approach aimed to maintain a first-read interval tree per inode, ensuring
> 
> that .fadvise would only release cached pages within its own mapped ranges, thereby
> 
> preventing interference with other file operations. However, this introduced unnecessary
> 
> complexity. The latest patch series adopts overlayfs-style handling:
> https://lore.kernel.org/all/20250301145002.2420830-8-hongzhen@linux.alibaba.com/

Yes, that patch makes more sense for me since mm
code will handle it as page cache ops.

Thanks,
Gao Xiang


  reply	other threads:[~2025-07-05  1:25 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-03 12:23 [PATCH RFC 0/4] erofs: allow page cache sharing Christian Brauner
2025-07-03 12:23 ` [PATCH RFC 1/4] erofs: move `struct erofs_anon_fs_type` to super.c Christian Brauner
2025-07-03 12:23 ` [PATCH RFC 2/4] erofs: introduce page cache share feature Christian Brauner
2025-07-04 21:06   ` Gao Xiang
2025-07-05  0:54     ` Hongzhen Luo
2025-07-05  8:25     ` Amir Goldstein
2025-07-05 10:58       ` Gao Xiang
2025-07-05 12:34         ` Amir Goldstein
2025-07-05 12:53           ` Gao Xiang
2025-07-05 13:53             ` Amir Goldstein
2025-07-05 15:14               ` Gao Xiang
2025-07-05  1:09   ` Hongzhen Luo
2025-07-03 12:23 ` [PATCH RFC 3/4] erofs: apply the " Christian Brauner
2025-07-04 20:45   ` Gao Xiang
2025-07-03 12:23 ` [PATCH RFC 4/4] erofs: introduce .fadvise for page cache share Christian Brauner
2025-07-04 21:09   ` Gao Xiang
2025-07-05  1:15     ` Hongzhen Luo
2025-07-05  1:25       ` Gao Xiang [this message]
2025-07-03 12:53 ` [PATCH RFC 0/4] erofs: allow page cache sharing Gao Xiang
2025-07-05  0:51 ` Hongzhen Luo

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=ca2fbae3-92ce-4198-bb06-a267f9db071b@linux.alibaba.com \
    --to=hsiangkao@linux.alibaba.com \
    --cc=amir73il@gmail.com \
    --cc=brauner@kernel.org \
    --cc=daan.j.demeyer@gmail.com \
    --cc=hongzhen@linux.alibaba.com \
    --cc=jack@suse.cz \
    --cc=jlayton@kernel.org \
    --cc=lennart@poettering.net \
    --cc=lihongbo22@huawei.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=me@yhndnzj.com \
    --cc=willy@infradead.org \
    --cc=xiang@kernel.org \
    --cc=zbyszek@in.waw.pl \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.