All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jaegeuk Kim via Linux-f2fs-devel <linux-f2fs-devel@lists.sourceforge.net>
To: Matthew Wilcox <willy@infradead.org>
Cc: Christian Brauner <brauner@kernel.org>,
	linux-kernel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH] [RFC] mm/fadvise: introduce POSIX_FADV_MLOCK
Date: Fri, 21 Nov 2025 21:32:12 +0000	[thread overview]
Message-ID: <aSDaXN-JhhfljCeT@google.com> (raw)
In-Reply-To: <aSDEU_C5QaSXD18x@casper.infradead.org>

On 11/21, Matthew Wilcox wrote:
> On Fri, Nov 21, 2025 at 07:52:02PM +0000, Jaegeuk Kim wrote:
> > On 11/21, Jaegeuk Kim wrote:
> > > On 11/21, Matthew Wilcox wrote:
> > > > On Fri, Nov 21, 2025 at 04:46:14AM +0000, Jaegeuk Kim wrote:
> > > > > On 11/21, Matthew Wilcox wrote:
> > > > > > On Fri, Nov 21, 2025 at 03:27:18AM +0000, Jaegeuk Kim wrote:
> > > > > > > This patch introduces a new POSIX_FADV_MLOCK which 1) invalidates the range of
> > > > > > > cached pages, 2) sets the mapping as inaccessible, 3) POSIX_FADV_WILLNEED loads
> > > > > > > pages directly to the inaccessible mapping.
> > > > > > 
> > > > > > ... what?
> > > > > > 
> > > > > > This seems like something which is completely different from mlock().
> > > > > > So it needs a different name.
> > > > > > 
> > > > > > But I don't understand the point of this, whatever it's called.  Need
> > > > > > more information.
> > > > > 
> > > > > So, the sequence that I'd like to optimize is mmap(MAP_POPULATE) followed
> > > > > by  mlock(). For example, mmap() takes 1 second to load 4GB data, and mlock()
> > > > > takes 330ms additionally in order to migrate all the pages into inaccessible
> > > > > map, IIUC.
> > > > 
> > > > Oh, so the MLOCK part is right, but the inaccessible() part is wrong.
> > > > Inaccessible is special weird guest_memfd crap that has all kinds of
> > > > side-effects that you don't want.
> > > > 
> > > > Wouldn't you get the same effect by calling mlock2(MLOCK_ONFAULT) and
> > > > then calling readahead() for the desired range?
> > > 
> > > Oh, thank you. Let me try.
> > 
> > After checking the code and experiment, I don't think that gives what we need.
> > That flag skips populate_vma_page_range only, but we need to allocate pages
> > in the inaccessible mapping and fill the pages afterwards.
> 
> Then either I don't understand what you're trying to do, or you don't
> understand what the inaccessible mapping is for.  Is this just for
> speeding up mlock() as you suggested earlier, or are you genuinely
> trying to do something with the inaccessible mapping?

The latter. I'd like to propose a new read flow with the inaccessible mapping.

As-Is:
 mmap() -> fadvise(fd, POSIX_FADV_WILLNEED) -> mlock()

1. fadvise() proposal
 mmap() -> fadvise(fd, POSIX_FADV_MLOCK)
 : all the pages will be loaded into inaccessible page cache directly

2. mlock2() proposal
 mmap() -> mlock2(MLOCK_ONFAULT) -> madvise(MADV_POPULATE_READ)

If you mean #2, I need to find whether we can get the space for madvise, since
we have only fd when reading the pages. And, also I need to find a way to handle
the folio order directly instead of starging from 0 in madvise() path.
Let me think about it.


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

WARNING: multiple messages have this Message-ID (diff)
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Matthew Wilcox <willy@infradead.org>
Cc: linux-kernel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net,
	Christian Brauner <brauner@kernel.org>
Subject: Re: [PATCH] [RFC] mm/fadvise: introduce POSIX_FADV_MLOCK
Date: Fri, 21 Nov 2025 21:32:12 +0000	[thread overview]
Message-ID: <aSDaXN-JhhfljCeT@google.com> (raw)
In-Reply-To: <aSDEU_C5QaSXD18x@casper.infradead.org>

On 11/21, Matthew Wilcox wrote:
> On Fri, Nov 21, 2025 at 07:52:02PM +0000, Jaegeuk Kim wrote:
> > On 11/21, Jaegeuk Kim wrote:
> > > On 11/21, Matthew Wilcox wrote:
> > > > On Fri, Nov 21, 2025 at 04:46:14AM +0000, Jaegeuk Kim wrote:
> > > > > On 11/21, Matthew Wilcox wrote:
> > > > > > On Fri, Nov 21, 2025 at 03:27:18AM +0000, Jaegeuk Kim wrote:
> > > > > > > This patch introduces a new POSIX_FADV_MLOCK which 1) invalidates the range of
> > > > > > > cached pages, 2) sets the mapping as inaccessible, 3) POSIX_FADV_WILLNEED loads
> > > > > > > pages directly to the inaccessible mapping.
> > > > > > 
> > > > > > ... what?
> > > > > > 
> > > > > > This seems like something which is completely different from mlock().
> > > > > > So it needs a different name.
> > > > > > 
> > > > > > But I don't understand the point of this, whatever it's called.  Need
> > > > > > more information.
> > > > > 
> > > > > So, the sequence that I'd like to optimize is mmap(MAP_POPULATE) followed
> > > > > by  mlock(). For example, mmap() takes 1 second to load 4GB data, and mlock()
> > > > > takes 330ms additionally in order to migrate all the pages into inaccessible
> > > > > map, IIUC.
> > > > 
> > > > Oh, so the MLOCK part is right, but the inaccessible() part is wrong.
> > > > Inaccessible is special weird guest_memfd crap that has all kinds of
> > > > side-effects that you don't want.
> > > > 
> > > > Wouldn't you get the same effect by calling mlock2(MLOCK_ONFAULT) and
> > > > then calling readahead() for the desired range?
> > > 
> > > Oh, thank you. Let me try.
> > 
> > After checking the code and experiment, I don't think that gives what we need.
> > That flag skips populate_vma_page_range only, but we need to allocate pages
> > in the inaccessible mapping and fill the pages afterwards.
> 
> Then either I don't understand what you're trying to do, or you don't
> understand what the inaccessible mapping is for.  Is this just for
> speeding up mlock() as you suggested earlier, or are you genuinely
> trying to do something with the inaccessible mapping?

The latter. I'd like to propose a new read flow with the inaccessible mapping.

As-Is:
 mmap() -> fadvise(fd, POSIX_FADV_WILLNEED) -> mlock()

1. fadvise() proposal
 mmap() -> fadvise(fd, POSIX_FADV_MLOCK)
 : all the pages will be loaded into inaccessible page cache directly

2. mlock2() proposal
 mmap() -> mlock2(MLOCK_ONFAULT) -> madvise(MADV_POPULATE_READ)

If you mean #2, I need to find whether we can get the space for madvise, since
we have only fd when reading the pages. And, also I need to find a way to handle
the folio order directly instead of starging from 0 in madvise() path.
Let me think about it.

  reply	other threads:[~2025-11-21 21:32 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-21  3:27 [f2fs-dev] [PATCH] [RFC] mm/fadvise: introduce POSIX_FADV_MLOCK Jaegeuk Kim via Linux-f2fs-devel
2025-11-21  3:27 ` Jaegeuk Kim
2025-11-21  4:22 ` [f2fs-dev] " Matthew Wilcox
2025-11-21  4:22   ` Matthew Wilcox
2025-11-21  4:46   ` [f2fs-dev] " Jaegeuk Kim via Linux-f2fs-devel
2025-11-21  4:46     ` Jaegeuk Kim
2025-11-21 14:27     ` [f2fs-dev] " Matthew Wilcox
2025-11-21 14:27       ` Matthew Wilcox
2025-11-21 18:02       ` [f2fs-dev] " Jaegeuk Kim via Linux-f2fs-devel
2025-11-21 18:02         ` Jaegeuk Kim
2025-11-21 19:52         ` [f2fs-dev] " Jaegeuk Kim via Linux-f2fs-devel
2025-11-21 19:52           ` Jaegeuk Kim
2025-11-21 19:58           ` [f2fs-dev] " Matthew Wilcox
2025-11-21 19:58             ` Matthew Wilcox
2025-11-21 21:32             ` Jaegeuk Kim via Linux-f2fs-devel [this message]
2025-11-21 21:32               ` Jaegeuk Kim
2025-11-22  2:47               ` [f2fs-dev] " Matthew Wilcox
2025-11-22  2:47                 ` Matthew Wilcox

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=aSDaXN-JhhfljCeT@google.com \
    --to=linux-f2fs-devel@lists.sourceforge.net \
    --cc=brauner@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=willy@infradead.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 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.