[PATCH 0/2 v6] add ioctl/sysfs to donate file-backed pages

Jaegeuk Kim posted 2 patches 2 weeks, 4 days ago
There is a newer version of this series
Documentation/ABI/testing/sysfs-fs-f2fs |  7 +++
fs/f2fs/debug.c                         |  3 ++
fs/f2fs/f2fs.h                          | 14 +++++-
fs/f2fs/file.c                          | 65 +++++++++++++++++++++++++
fs/f2fs/inode.c                         | 14 ++++++
fs/f2fs/shrinker.c                      | 27 ++++++++++
fs/f2fs/super.c                         |  1 +
fs/f2fs/sysfs.c                         |  8 +++
include/uapi/linux/f2fs.h               |  7 +++
9 files changed, 145 insertions(+), 1 deletion(-)
[PATCH 0/2 v6] add ioctl/sysfs to donate file-backed pages
Posted by Jaegeuk Kim 2 weeks, 4 days ago
If users clearly know which file-backed pages to reclaim in system view, they
can use this ioctl() to register in advance and reclaim all at once later.

To MM and others,

I'd like to propose this API in F2FS only, since
1) the use-case is quite limited in Android at the moment. Once it's generall
accepted with more use-cases, happy to propose a generic API such as fadvise.
Please chime in, if there's any needs.

2) it's file-backed pages which requires to maintain the list of inode objects.
I'm not sure this fits in MM tho, also happy to listen to any feedback.

Jaegeuk Kim (2):
  f2fs: register inodes which is able to donate pages
  f2fs: add a sysfs entry to request donate file-backed pages

 Documentation/ABI/testing/sysfs-fs-f2fs |  7 +++
 fs/f2fs/debug.c                         |  3 ++
 fs/f2fs/f2fs.h                          | 14 +++++-
 fs/f2fs/file.c                          | 65 +++++++++++++++++++++++++
 fs/f2fs/inode.c                         | 14 ++++++
 fs/f2fs/shrinker.c                      | 27 ++++++++++
 fs/f2fs/super.c                         |  1 +
 fs/f2fs/sysfs.c                         |  8 +++
 include/uapi/linux/f2fs.h               |  7 +++
 9 files changed, 145 insertions(+), 1 deletion(-)

-- 
2.48.0.rc2.279.g1de40edade-goog
Re: [PATCH 0/2 v6] add ioctl/sysfs to donate file-backed pages
Posted by Matthew Wilcox 2 weeks, 4 days ago
On Fri, Jan 17, 2025 at 04:41:16PM +0000, Jaegeuk Kim wrote:
> If users clearly know which file-backed pages to reclaim in system view, they
> can use this ioctl() to register in advance and reclaim all at once later.
> 
> To MM and others,
> 
> I'd like to propose this API in F2FS only, since
> 1) the use-case is quite limited in Android at the moment. Once it's generall
> accepted with more use-cases, happy to propose a generic API such as fadvise.
> Please chime in, if there's any needs.
> 
> 2) it's file-backed pages which requires to maintain the list of inode objects.
> I'm not sure this fits in MM tho, also happy to listen to any feedback.

You didn't cc the patches to linux-mm, so that's a bad start.

I don't understand how this is different from MADV_COLD.  Please
explain.
Re: [PATCH 0/2 v6] add ioctl/sysfs to donate file-backed pages
Posted by Jaegeuk Kim 2 weeks, 4 days ago
On 01/17, Matthew Wilcox wrote:
> On Fri, Jan 17, 2025 at 04:41:16PM +0000, Jaegeuk Kim wrote:
> > If users clearly know which file-backed pages to reclaim in system view, they
> > can use this ioctl() to register in advance and reclaim all at once later.
> > 
> > To MM and others,
> > 
> > I'd like to propose this API in F2FS only, since
> > 1) the use-case is quite limited in Android at the moment. Once it's generall
> > accepted with more use-cases, happy to propose a generic API such as fadvise.
> > Please chime in, if there's any needs.
> > 
> > 2) it's file-backed pages which requires to maintain the list of inode objects.
> > I'm not sure this fits in MM tho, also happy to listen to any feedback.
> 
> You didn't cc the patches to linux-mm, so that's a bad start.

Because #1.

> 
> I don't understand how this is different from MADV_COLD.  Please
> explain.

MADV_COLD is a vma range, while this is a file range. So, it's more close to
fadvise(POSIX_FADV_DONTNEED) which tries to reclaim the file-backed pages
at the time when it's called. The idea is to keep the hints only, and try to
reclaim all later when admin expects system memory pressure soon.
Re: [PATCH 0/2 v6] add ioctl/sysfs to donate file-backed pages
Posted by Matthew Wilcox 2 weeks, 4 days ago
On Fri, Jan 17, 2025 at 06:48:55PM +0000, Jaegeuk Kim wrote:
> > I don't understand how this is different from MADV_COLD.  Please
> > explain.
> 
> MADV_COLD is a vma range, while this is a file range. So, it's more close to
> fadvise(POSIX_FADV_DONTNEED) which tries to reclaim the file-backed pages
> at the time when it's called. The idea is to keep the hints only, and try to
> reclaim all later when admin expects system memory pressure soon.

So you're saying you want POSIX_FADV_COLD?
Re: [PATCH 0/2 v6] add ioctl/sysfs to donate file-backed pages
Posted by Jaegeuk Kim 2 weeks, 4 days ago
On 01/17, Matthew Wilcox wrote:
> On Fri, Jan 17, 2025 at 06:48:55PM +0000, Jaegeuk Kim wrote:
> > > I don't understand how this is different from MADV_COLD.  Please
> > > explain.
> > 
> > MADV_COLD is a vma range, while this is a file range. So, it's more close to
> > fadvise(POSIX_FADV_DONTNEED) which tries to reclaim the file-backed pages
> > at the time when it's called. The idea is to keep the hints only, and try to
> > reclaim all later when admin expects system memory pressure soon.
> 
> So you're saying you want POSIX_FADV_COLD?

Yeah, the intention looks similar like marking it cold and paging out later.
Re: [PATCH 0/2 v6] add ioctl/sysfs to donate file-backed pages
Posted by Jaegeuk Kim 18 hours ago
On 01/17, Jaegeuk Kim wrote:
> On 01/17, Matthew Wilcox wrote:
> > On Fri, Jan 17, 2025 at 06:48:55PM +0000, Jaegeuk Kim wrote:
> > > > I don't understand how this is different from MADV_COLD.  Please
> > > > explain.
> > > 
> > > MADV_COLD is a vma range, while this is a file range. So, it's more close to
> > > fadvise(POSIX_FADV_DONTNEED) which tries to reclaim the file-backed pages
> > > at the time when it's called. The idea is to keep the hints only, and try to
> > > reclaim all later when admin expects system memory pressure soon.
> > 
> > So you're saying you want POSIX_FADV_COLD?
> 
> Yeah, the intention looks similar like marking it cold and paging out later.

Kindly ping, for the feedback on the direction. If there's demand for something
generalized api, I'm happy to explore.