* [PATCH 0/2 v9] reclaim file-backed pages given POSIX_FADV_NOREUSE
@ 2025-02-12 2:31 Jaegeuk Kim
2025-02-12 2:31 ` [PATCH 1/2] f2fs: keep POSIX_FADV_NOREUSE ranges Jaegeuk Kim
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Jaegeuk Kim @ 2025-02-12 2:31 UTC (permalink / raw)
To: linux-kernel, linux-f2fs-devel; +Cc: Jaegeuk Kim
This patch series does not add new API, but implements POSIX_FADV_NOREUSE where
it keeps the page ranges in the f2fs superblock and add a way for users to
reclaim the pages manually.
Change log from v8:
- remove new APIs, but use fadvise(POSIX_FADV_NOREUSE)
Jaegeuk Kim (2):
f2fs: keep POSIX_FADV_NOREUSE ranges
f2fs: add a sysfs entry to reclaim POSIX_FADV_NOREUSE pages
Documentation/ABI/testing/sysfs-fs-f2fs | 7 ++
fs/f2fs/debug.c | 3 +
fs/f2fs/f2fs.h | 14 +++-
fs/f2fs/file.c | 60 +++++++++++++++--
fs/f2fs/inode.c | 14 ++++
fs/f2fs/shrinker.c | 90 +++++++++++++++++++++++++
fs/f2fs/super.c | 1 +
fs/f2fs/sysfs.c | 63 +++++++++++++++++
8 files changed, 246 insertions(+), 6 deletions(-)
--
2.48.1.601.g30ceb7b040-goog
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/2] f2fs: keep POSIX_FADV_NOREUSE ranges
2025-02-12 2:31 [PATCH 0/2 v9] reclaim file-backed pages given POSIX_FADV_NOREUSE Jaegeuk Kim
@ 2025-02-12 2:31 ` Jaegeuk Kim
2025-02-13 2:14 ` [f2fs-dev] " Chao Yu
2025-02-12 2:31 ` [PATCH 2/2] f2fs: add a sysfs entry to reclaim POSIX_FADV_NOREUSE pages Jaegeuk Kim
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Jaegeuk Kim @ 2025-02-12 2:31 UTC (permalink / raw)
To: linux-kernel, linux-f2fs-devel; +Cc: Jaegeuk Kim
This patch records POSIX_FADV_NOREUSE ranges for users to reclaim the caches
instantly off from LRU.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fs/f2fs/debug.c | 3 +++
fs/f2fs/f2fs.h | 12 +++++++++-
fs/f2fs/file.c | 60 ++++++++++++++++++++++++++++++++++++++++++++-----
fs/f2fs/inode.c | 14 ++++++++++++
fs/f2fs/super.c | 1 +
5 files changed, 84 insertions(+), 6 deletions(-)
diff --git a/fs/f2fs/debug.c b/fs/f2fs/debug.c
index 468828288a4a..16c2dfb4f595 100644
--- a/fs/f2fs/debug.c
+++ b/fs/f2fs/debug.c
@@ -164,6 +164,7 @@ static void update_general_status(struct f2fs_sb_info *sbi)
si->ndirty_imeta = get_pages(sbi, F2FS_DIRTY_IMETA);
si->ndirty_dirs = sbi->ndirty_inode[DIR_INODE];
si->ndirty_files = sbi->ndirty_inode[FILE_INODE];
+ si->ndonate_files = sbi->donate_files;
si->nquota_files = sbi->nquota_files;
si->ndirty_all = sbi->ndirty_inode[DIRTY_META];
si->aw_cnt = atomic_read(&sbi->atomic_files);
@@ -501,6 +502,8 @@ static int stat_show(struct seq_file *s, void *v)
si->compr_inode, si->compr_blocks);
seq_printf(s, " - Swapfile Inode: %u\n",
si->swapfile_inode);
+ seq_printf(s, " - Donate Inode: %u\n",
+ si->ndonate_files);
seq_printf(s, " - Orphan/Append/Update Inode: %u, %u, %u\n",
si->orphans, si->append, si->update);
seq_printf(s, "\nMain area: %d segs, %d secs %d zones\n",
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 395f9d37449c..3abcb84a0d47 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -850,6 +850,11 @@ struct f2fs_inode_info {
#endif
struct list_head dirty_list; /* dirty list for dirs and files */
struct list_head gdirty_list; /* linked in global dirty list */
+
+ /* linked in global inode list for cache donation */
+ struct list_head gdonate_list;
+ pgoff_t donate_start, donate_end; /* inclusive */
+
struct task_struct *atomic_write_task; /* store atomic write task */
struct extent_tree *extent_tree[NR_EXTENT_CACHES];
/* cached extent_tree entry */
@@ -1274,6 +1279,7 @@ enum inode_type {
DIR_INODE, /* for dirty dir inode */
FILE_INODE, /* for dirty regular/symlink inode */
DIRTY_META, /* for all dirtied inode metadata */
+ DONATE_INODE, /* for all inode to donate pages */
NR_INODE_TYPE,
};
@@ -1629,6 +1635,9 @@ struct f2fs_sb_info {
unsigned int warm_data_age_threshold;
unsigned int last_age_weight;
+ /* control donate caches */
+ unsigned int donate_files;
+
/* basic filesystem units */
unsigned int log_sectors_per_block; /* log2 sectors per block */
unsigned int log_blocksize; /* log2 block size */
@@ -3968,7 +3977,8 @@ struct f2fs_stat_info {
unsigned long long allocated_data_blocks;
int ndirty_node, ndirty_dent, ndirty_meta, ndirty_imeta;
int ndirty_data, ndirty_qdata;
- unsigned int ndirty_dirs, ndirty_files, nquota_files, ndirty_all;
+ unsigned int ndirty_dirs, ndirty_files, ndirty_all;
+ unsigned int nquota_files, ndonate_files;
int nats, dirty_nats, sits, dirty_sits;
int free_nids, avail_nids, alloc_nids;
int total_count, utilization;
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index f2f298c75921..014cb7660a9a 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -2450,6 +2450,52 @@ static int f2fs_ioc_shutdown(struct file *filp, unsigned long arg)
return ret;
}
+static void f2fs_keep_noreuse_range(struct inode *inode,
+ loff_t offset, loff_t len)
+{
+ struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
+ u64 max_bytes = F2FS_BLK_TO_BYTES(max_file_blocks(inode));
+ u64 start, end;
+
+ if (!S_ISREG(inode->i_mode))
+ return;
+
+ if (offset >= max_bytes || len > max_bytes ||
+ (offset + len) > max_bytes)
+ return;
+
+ start = offset >> PAGE_SHIFT;
+ end = DIV_ROUND_UP(offset + len, PAGE_SIZE);
+
+ inode_lock(inode);
+ if (f2fs_is_atomic_file(inode)) {
+ inode_unlock(inode);
+ return;
+ }
+
+ spin_lock(&sbi->inode_lock[DONATE_INODE]);
+ /* let's remove the range, if len = 0 */
+ if (!len) {
+ if (!list_empty(&F2FS_I(inode)->gdonate_list)) {
+ list_del_init(&F2FS_I(inode)->gdonate_list);
+ sbi->donate_files--;
+ }
+ } else {
+ if (list_empty(&F2FS_I(inode)->gdonate_list)) {
+ list_add_tail(&F2FS_I(inode)->gdonate_list,
+ &sbi->inode_list[DONATE_INODE]);
+ sbi->donate_files++;
+ } else {
+ list_move_tail(&F2FS_I(inode)->gdonate_list,
+ &sbi->inode_list[DONATE_INODE]);
+ }
+ F2FS_I(inode)->donate_start = start;
+ F2FS_I(inode)->donate_end = end - 1;
+ }
+ spin_unlock(&sbi->inode_lock[DONATE_INODE]);
+ inode_unlock(inode);
+}
+
static int f2fs_ioc_fitrim(struct file *filp, unsigned long arg)
{
struct inode *inode = file_inode(filp);
@@ -5168,12 +5214,16 @@ static int f2fs_file_fadvise(struct file *filp, loff_t offset, loff_t len,
}
err = generic_fadvise(filp, offset, len, advice);
- if (!err && advice == POSIX_FADV_DONTNEED &&
- test_opt(F2FS_I_SB(inode), COMPRESS_CACHE) &&
- f2fs_compressed_file(inode))
- f2fs_invalidate_compress_pages(F2FS_I_SB(inode), inode->i_ino);
+ if (err)
+ return err;
- return err;
+ if (advice == POSIX_FADV_DONTNEED &&
+ (test_opt(F2FS_I_SB(inode), COMPRESS_CACHE) &&
+ f2fs_compressed_file(inode)))
+ f2fs_invalidate_compress_pages(F2FS_I_SB(inode), inode->i_ino);
+ else if (advice == POSIX_FADV_NOREUSE)
+ f2fs_keep_noreuse_range(inode, offset, len);
+ return 0;
}
#ifdef CONFIG_COMPAT
diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
index 3f03b1c9b7f1..543fb942bec1 100644
--- a/fs/f2fs/inode.c
+++ b/fs/f2fs/inode.c
@@ -814,6 +814,19 @@ int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc)
return 0;
}
+static void f2fs_remove_donate_inode(struct inode *inode)
+{
+ struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
+
+ if (list_empty(&F2FS_I(inode)->gdonate_list))
+ return;
+
+ spin_lock(&sbi->inode_lock[DONATE_INODE]);
+ list_del_init(&F2FS_I(inode)->gdonate_list);
+ sbi->donate_files--;
+ spin_unlock(&sbi->inode_lock[DONATE_INODE]);
+}
+
/*
* Called at the last iput() if i_nlink is zero
*/
@@ -848,6 +861,7 @@ void f2fs_evict_inode(struct inode *inode)
f2fs_bug_on(sbi, get_dirty_pages(inode));
f2fs_remove_dirty_inode(inode);
+ f2fs_remove_donate_inode(inode);
if (!IS_DEVICE_ALIASING(inode))
f2fs_destroy_extent_tree(inode);
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 759b642991d4..f5c69cc2de72 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1441,6 +1441,7 @@ static struct inode *f2fs_alloc_inode(struct super_block *sb)
spin_lock_init(&fi->i_size_lock);
INIT_LIST_HEAD(&fi->dirty_list);
INIT_LIST_HEAD(&fi->gdirty_list);
+ INIT_LIST_HEAD(&fi->gdonate_list);
init_f2fs_rwsem(&fi->i_gc_rwsem[READ]);
init_f2fs_rwsem(&fi->i_gc_rwsem[WRITE]);
init_f2fs_rwsem(&fi->i_xattr_sem);
--
2.48.1.601.g30ceb7b040-goog
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] f2fs: add a sysfs entry to reclaim POSIX_FADV_NOREUSE pages
2025-02-12 2:31 [PATCH 0/2 v9] reclaim file-backed pages given POSIX_FADV_NOREUSE Jaegeuk Kim
2025-02-12 2:31 ` [PATCH 1/2] f2fs: keep POSIX_FADV_NOREUSE ranges Jaegeuk Kim
@ 2025-02-12 2:31 ` Jaegeuk Kim
2025-02-13 2:15 ` [f2fs-dev] " Chao Yu
2025-02-18 8:26 ` [PATCH 0/2 v9] reclaim file-backed pages given POSIX_FADV_NOREUSE Christoph Hellwig
2025-02-21 2:17 ` [f2fs-dev] " patchwork-bot+f2fs
3 siblings, 1 reply; 8+ messages in thread
From: Jaegeuk Kim @ 2025-02-12 2:31 UTC (permalink / raw)
To: linux-kernel, linux-f2fs-devel; +Cc: Jaegeuk Kim
1. fadvise(fd1, POSIX_FADV_NOREUSE, {0,3});
2. fadvise(fd2, POSIX_FADV_NOREUSE, {1,2});
3. fadvise(fd3, POSIX_FADV_NOREUSE, {3,1});
4. echo 1024 > /sys/fs/f2fs/tuning/reclaim_caches_kb
This gives a way to reclaim file-backed pages by iterating all f2fs mounts until
reclaiming 1MB page cache ranges, registered by #1, #2, and #3.
5. cat /sys/fs/f2fs/tuning/reclaim_caches_kb
-> gives total number of registered file ranges.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
Documentation/ABI/testing/sysfs-fs-f2fs | 7 ++
fs/f2fs/f2fs.h | 2 +
fs/f2fs/shrinker.c | 90 +++++++++++++++++++++++++
fs/f2fs/sysfs.c | 63 +++++++++++++++++
4 files changed, 162 insertions(+)
diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs
index 3e1630c70d8a..81deae2af84d 100644
--- a/Documentation/ABI/testing/sysfs-fs-f2fs
+++ b/Documentation/ABI/testing/sysfs-fs-f2fs
@@ -828,3 +828,10 @@ Date: November 2024
Contact: "Chao Yu" <chao@kernel.org>
Description: It controls max read extent count for per-inode, the value of threshold
is 10240 by default.
+
+What: /sys/fs/f2fs/tuning/reclaim_caches_kb
+Date: February 2025
+Contact: "Jaegeuk Kim" <jaegeuk@kernel.org>
+Description: It reclaims the given KBs of file-backed pages registered by
+ ioctl(F2FS_IOC_DONATE_RANGE).
+ For example, writing N tries to drop N KBs spaces in LRU.
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 3abcb84a0d47..05879c6dc4d6 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -4243,6 +4243,8 @@ unsigned long f2fs_shrink_count(struct shrinker *shrink,
struct shrink_control *sc);
unsigned long f2fs_shrink_scan(struct shrinker *shrink,
struct shrink_control *sc);
+unsigned int f2fs_donate_files(void);
+void f2fs_reclaim_caches(unsigned int reclaim_caches_kb);
void f2fs_join_shrinker(struct f2fs_sb_info *sbi);
void f2fs_leave_shrinker(struct f2fs_sb_info *sbi);
diff --git a/fs/f2fs/shrinker.c b/fs/f2fs/shrinker.c
index fc1bbef418ce..9c8d3aee89af 100644
--- a/fs/f2fs/shrinker.c
+++ b/fs/f2fs/shrinker.c
@@ -130,6 +130,96 @@ unsigned long f2fs_shrink_scan(struct shrinker *shrink,
return freed;
}
+unsigned int f2fs_donate_files(void)
+{
+ struct f2fs_sb_info *sbi;
+ struct list_head *p;
+ unsigned int donate_files = 0;
+
+ spin_lock(&f2fs_list_lock);
+ p = f2fs_list.next;
+ while (p != &f2fs_list) {
+ sbi = list_entry(p, struct f2fs_sb_info, s_list);
+
+ /* stop f2fs_put_super */
+ if (!mutex_trylock(&sbi->umount_mutex)) {
+ p = p->next;
+ continue;
+ }
+ spin_unlock(&f2fs_list_lock);
+
+ donate_files += sbi->donate_files;
+
+ spin_lock(&f2fs_list_lock);
+ p = p->next;
+ mutex_unlock(&sbi->umount_mutex);
+ }
+ spin_unlock(&f2fs_list_lock);
+
+ return donate_files;
+}
+
+static unsigned int do_reclaim_caches(struct f2fs_sb_info *sbi,
+ unsigned int reclaim_caches_kb)
+{
+ struct inode *inode;
+ struct f2fs_inode_info *fi;
+ unsigned int nfiles = sbi->donate_files;
+ pgoff_t npages = reclaim_caches_kb >> (PAGE_SHIFT - 10);
+
+ while (npages && nfiles--) {
+ pgoff_t len;
+
+ spin_lock(&sbi->inode_lock[DONATE_INODE]);
+ if (list_empty(&sbi->inode_list[DONATE_INODE])) {
+ spin_unlock(&sbi->inode_lock[DONATE_INODE]);
+ break;
+ }
+ fi = list_first_entry(&sbi->inode_list[DONATE_INODE],
+ struct f2fs_inode_info, gdonate_list);
+ list_move_tail(&fi->gdonate_list, &sbi->inode_list[DONATE_INODE]);
+ inode = igrab(&fi->vfs_inode);
+ spin_unlock(&sbi->inode_lock[DONATE_INODE]);
+
+ if (!inode)
+ continue;
+
+ len = fi->donate_end - fi->donate_start + 1;
+ npages = npages < len ? 0 : npages - len;
+ invalidate_inode_pages2_range(inode->i_mapping,
+ fi->donate_start, fi->donate_end);
+ iput(inode);
+ cond_resched();
+ }
+ return npages << (PAGE_SHIFT - 10);
+}
+
+void f2fs_reclaim_caches(unsigned int reclaim_caches_kb)
+{
+ struct f2fs_sb_info *sbi;
+ struct list_head *p;
+
+ spin_lock(&f2fs_list_lock);
+ p = f2fs_list.next;
+ while (p != &f2fs_list && reclaim_caches_kb) {
+ sbi = list_entry(p, struct f2fs_sb_info, s_list);
+
+ /* stop f2fs_put_super */
+ if (!mutex_trylock(&sbi->umount_mutex)) {
+ p = p->next;
+ continue;
+ }
+ spin_unlock(&f2fs_list_lock);
+
+ reclaim_caches_kb = do_reclaim_caches(sbi, reclaim_caches_kb);
+
+ spin_lock(&f2fs_list_lock);
+ p = p->next;
+ mutex_unlock(&sbi->umount_mutex);
+ }
+ spin_unlock(&f2fs_list_lock);
+}
+
void f2fs_join_shrinker(struct f2fs_sb_info *sbi)
{
spin_lock(&f2fs_list_lock);
diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
index b419555e1ea7..b27336acf519 100644
--- a/fs/f2fs/sysfs.c
+++ b/fs/f2fs/sysfs.c
@@ -916,6 +916,39 @@ static struct f2fs_base_attr f2fs_base_attr_##_name = { \
.show = f2fs_feature_show, \
}
+static ssize_t f2fs_tune_show(struct f2fs_base_attr *a, char *buf)
+{
+ unsigned int res = 0;
+
+ if (!strcmp(a->attr.name, "reclaim_caches_kb"))
+ res = f2fs_donate_files();
+
+ return sysfs_emit(buf, "%u\n", res);
+}
+
+static ssize_t f2fs_tune_store(struct f2fs_base_attr *a,
+ const char *buf, size_t count)
+{
+ unsigned long t;
+ int ret;
+
+ ret = kstrtoul(skip_spaces(buf), 0, &t);
+ if (ret)
+ return ret;
+
+ if (!strcmp(a->attr.name, "reclaim_caches_kb"))
+ f2fs_reclaim_caches(t);
+
+ return count;
+}
+
+#define F2FS_TUNE_RW_ATTR(_name) \
+static struct f2fs_base_attr f2fs_base_attr_##_name = { \
+ .attr = {.name = __stringify(_name), .mode = 0644 }, \
+ .show = f2fs_tune_show, \
+ .store = f2fs_tune_store, \
+}
+
static ssize_t f2fs_sb_feature_show(struct f2fs_attr *a,
struct f2fs_sb_info *sbi, char *buf)
{
@@ -1368,6 +1401,14 @@ static struct attribute *f2fs_sb_feat_attrs[] = {
};
ATTRIBUTE_GROUPS(f2fs_sb_feat);
+F2FS_TUNE_RW_ATTR(reclaim_caches_kb);
+
+static struct attribute *f2fs_tune_attrs[] = {
+ BASE_ATTR_LIST(reclaim_caches_kb),
+ NULL,
+};
+ATTRIBUTE_GROUPS(f2fs_tune);
+
static const struct sysfs_ops f2fs_attr_ops = {
.show = f2fs_attr_show,
.store = f2fs_attr_store,
@@ -1401,6 +1442,20 @@ static struct kobject f2fs_feat = {
.kset = &f2fs_kset,
};
+static const struct sysfs_ops f2fs_tune_attr_ops = {
+ .show = f2fs_base_attr_show,
+ .store = f2fs_base_attr_store,
+};
+
+static const struct kobj_type f2fs_tune_ktype = {
+ .default_groups = f2fs_tune_groups,
+ .sysfs_ops = &f2fs_tune_attr_ops,
+};
+
+static struct kobject f2fs_tune = {
+ .kset = &f2fs_kset,
+};
+
static ssize_t f2fs_stat_attr_show(struct kobject *kobj,
struct attribute *attr, char *buf)
{
@@ -1637,6 +1692,11 @@ int __init f2fs_init_sysfs(void)
if (ret)
goto put_kobject;
+ ret = kobject_init_and_add(&f2fs_tune, &f2fs_tune_ktype,
+ NULL, "tuning");
+ if (ret)
+ goto put_kobject;
+
f2fs_proc_root = proc_mkdir("fs/f2fs", NULL);
if (!f2fs_proc_root) {
ret = -ENOMEM;
@@ -1644,7 +1704,9 @@ int __init f2fs_init_sysfs(void)
}
return 0;
+
put_kobject:
+ kobject_put(&f2fs_tune);
kobject_put(&f2fs_feat);
kset_unregister(&f2fs_kset);
return ret;
@@ -1652,6 +1714,7 @@ int __init f2fs_init_sysfs(void)
void f2fs_exit_sysfs(void)
{
+ kobject_put(&f2fs_tune);
kobject_put(&f2fs_feat);
kset_unregister(&f2fs_kset);
remove_proc_entry("fs/f2fs", NULL);
--
2.48.1.601.g30ceb7b040-goog
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [f2fs-dev] [PATCH 1/2] f2fs: keep POSIX_FADV_NOREUSE ranges
2025-02-12 2:31 ` [PATCH 1/2] f2fs: keep POSIX_FADV_NOREUSE ranges Jaegeuk Kim
@ 2025-02-13 2:14 ` Chao Yu
0 siblings, 0 replies; 8+ messages in thread
From: Chao Yu @ 2025-02-13 2:14 UTC (permalink / raw)
To: Jaegeuk Kim, linux-kernel, linux-f2fs-devel; +Cc: chao
On 2/12/25 10:31, Jaegeuk Kim via Linux-f2fs-devel wrote:
> This patch records POSIX_FADV_NOREUSE ranges for users to reclaim the caches
> instantly off from LRU.
>
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [f2fs-dev] [PATCH 2/2] f2fs: add a sysfs entry to reclaim POSIX_FADV_NOREUSE pages
2025-02-12 2:31 ` [PATCH 2/2] f2fs: add a sysfs entry to reclaim POSIX_FADV_NOREUSE pages Jaegeuk Kim
@ 2025-02-13 2:15 ` Chao Yu
0 siblings, 0 replies; 8+ messages in thread
From: Chao Yu @ 2025-02-13 2:15 UTC (permalink / raw)
To: Jaegeuk Kim, linux-kernel, linux-f2fs-devel; +Cc: chao
On 2/12/25 10:31, Jaegeuk Kim via Linux-f2fs-devel wrote:
> 1. fadvise(fd1, POSIX_FADV_NOREUSE, {0,3});
> 2. fadvise(fd2, POSIX_FADV_NOREUSE, {1,2});
> 3. fadvise(fd3, POSIX_FADV_NOREUSE, {3,1});
> 4. echo 1024 > /sys/fs/f2fs/tuning/reclaim_caches_kb
>
> This gives a way to reclaim file-backed pages by iterating all f2fs mounts until
> reclaiming 1MB page cache ranges, registered by #1, #2, and #3.
>
> 5. cat /sys/fs/f2fs/tuning/reclaim_caches_kb
> -> gives total number of registered file ranges.
>
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/2 v9] reclaim file-backed pages given POSIX_FADV_NOREUSE
2025-02-12 2:31 [PATCH 0/2 v9] reclaim file-backed pages given POSIX_FADV_NOREUSE Jaegeuk Kim
2025-02-12 2:31 ` [PATCH 1/2] f2fs: keep POSIX_FADV_NOREUSE ranges Jaegeuk Kim
2025-02-12 2:31 ` [PATCH 2/2] f2fs: add a sysfs entry to reclaim POSIX_FADV_NOREUSE pages Jaegeuk Kim
@ 2025-02-18 8:26 ` Christoph Hellwig
2025-02-19 9:38 ` Jaegeuk Kim
2025-02-21 2:17 ` [f2fs-dev] " patchwork-bot+f2fs
3 siblings, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2025-02-18 8:26 UTC (permalink / raw)
To: Jaegeuk Kim
Cc: linux-kernel, linux-f2fs-devel, linux-fsdevel, linux-mm,
linux-api
This still has a file system sysfs HACK, you're still not Ccing the
right list, etc.
Can you pleae at least try to get it right?
On Wed, Feb 12, 2025 at 02:31:55AM +0000, Jaegeuk Kim wrote:
> This patch series does not add new API, but implements POSIX_FADV_NOREUSE where
> it keeps the page ranges in the f2fs superblock and add a way for users to
> reclaim the pages manually.
>
> Change log from v8:
> - remove new APIs, but use fadvise(POSIX_FADV_NOREUSE)
>
> Jaegeuk Kim (2):
> f2fs: keep POSIX_FADV_NOREUSE ranges
> f2fs: add a sysfs entry to reclaim POSIX_FADV_NOREUSE pages
>
> Documentation/ABI/testing/sysfs-fs-f2fs | 7 ++
> fs/f2fs/debug.c | 3 +
> fs/f2fs/f2fs.h | 14 +++-
> fs/f2fs/file.c | 60 +++++++++++++++--
> fs/f2fs/inode.c | 14 ++++
> fs/f2fs/shrinker.c | 90 +++++++++++++++++++++++++
> fs/f2fs/super.c | 1 +
> fs/f2fs/sysfs.c | 63 +++++++++++++++++
> 8 files changed, 246 insertions(+), 6 deletions(-)
>
> --
> 2.48.1.601.g30ceb7b040-goog
>
>
---end quoted text---
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/2 v9] reclaim file-backed pages given POSIX_FADV_NOREUSE
2025-02-18 8:26 ` [PATCH 0/2 v9] reclaim file-backed pages given POSIX_FADV_NOREUSE Christoph Hellwig
@ 2025-02-19 9:38 ` Jaegeuk Kim
0 siblings, 0 replies; 8+ messages in thread
From: Jaegeuk Kim @ 2025-02-19 9:38 UTC (permalink / raw)
To: Christoph Hellwig
Cc: linux-kernel, linux-f2fs-devel, linux-fsdevel, linux-mm,
linux-api
On 02/18, Christoph Hellwig wrote:
> This still has a file system sysfs HACK, you're still not Ccing the
> right list, etc.
>
> Can you pleae at least try to get it right?
I was modifying the patch having 1) declaring a static global list, 2) adding
some fields to superblock and inode structures to keep the given range in the
inode through fadvise, 3) adding hooks in evict_inode to handle the list, 4)
exploring which sysfs entry in MM to reclaim them explicitly.
But, I stopped at some point, as it looks not good at all. Moreover, I started
to be questioning why not just doing in F2FS back, given sementically I didn't
change anything on general behavior of fadvise(POSIX_FADV_NOREUSE), IIUC, which
moves pages back to LRU. In addiiton to that, I'd like to keep the range hint in
a filesystem and provide a sysfs entry to manage the hints additionally.
In addition, I don't think there's rule that filesystem cannot reclaim file-back
pages, as it just uses the exported symbol that all filesystems are using in
various different purpose. Hence, I don't get the point which is wrong.
Thanks,
>
> On Wed, Feb 12, 2025 at 02:31:55AM +0000, Jaegeuk Kim wrote:
> > This patch series does not add new API, but implements POSIX_FADV_NOREUSE where
> > it keeps the page ranges in the f2fs superblock and add a way for users to
> > reclaim the pages manually.
> >
> > Change log from v8:
> > - remove new APIs, but use fadvise(POSIX_FADV_NOREUSE)
> >
> > Jaegeuk Kim (2):
> > f2fs: keep POSIX_FADV_NOREUSE ranges
> > f2fs: add a sysfs entry to reclaim POSIX_FADV_NOREUSE pages
> >
> > Documentation/ABI/testing/sysfs-fs-f2fs | 7 ++
> > fs/f2fs/debug.c | 3 +
> > fs/f2fs/f2fs.h | 14 +++-
> > fs/f2fs/file.c | 60 +++++++++++++++--
> > fs/f2fs/inode.c | 14 ++++
> > fs/f2fs/shrinker.c | 90 +++++++++++++++++++++++++
> > fs/f2fs/super.c | 1 +
> > fs/f2fs/sysfs.c | 63 +++++++++++++++++
> > 8 files changed, 246 insertions(+), 6 deletions(-)
> >
> > --
> > 2.48.1.601.g30ceb7b040-goog
> >
> >
> ---end quoted text---
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [f2fs-dev] [PATCH 0/2 v9] reclaim file-backed pages given POSIX_FADV_NOREUSE
2025-02-12 2:31 [PATCH 0/2 v9] reclaim file-backed pages given POSIX_FADV_NOREUSE Jaegeuk Kim
` (2 preceding siblings ...)
2025-02-18 8:26 ` [PATCH 0/2 v9] reclaim file-backed pages given POSIX_FADV_NOREUSE Christoph Hellwig
@ 2025-02-21 2:17 ` patchwork-bot+f2fs
3 siblings, 0 replies; 8+ messages in thread
From: patchwork-bot+f2fs @ 2025-02-21 2:17 UTC (permalink / raw)
To: Jaegeuk Kim; +Cc: linux-kernel, linux-f2fs-devel
Hello:
This series was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <jaegeuk@kernel.org>:
On Wed, 12 Feb 2025 02:31:55 +0000 you wrote:
> This patch series does not add new API, but implements POSIX_FADV_NOREUSE where
> it keeps the page ranges in the f2fs superblock and add a way for users to
> reclaim the pages manually.
>
> Change log from v8:
> - remove new APIs, but use fadvise(POSIX_FADV_NOREUSE)
>
> [...]
Here is the summary with links:
- [f2fs-dev,1/2] f2fs: keep POSIX_FADV_NOREUSE ranges
https://git.kernel.org/jaegeuk/f2fs/c/ef0c333cad8d
- [f2fs-dev,2/2] f2fs: add a sysfs entry to reclaim POSIX_FADV_NOREUSE pages
https://git.kernel.org/jaegeuk/f2fs/c/a907f3a68ee2
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-02-21 2:17 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-12 2:31 [PATCH 0/2 v9] reclaim file-backed pages given POSIX_FADV_NOREUSE Jaegeuk Kim
2025-02-12 2:31 ` [PATCH 1/2] f2fs: keep POSIX_FADV_NOREUSE ranges Jaegeuk Kim
2025-02-13 2:14 ` [f2fs-dev] " Chao Yu
2025-02-12 2:31 ` [PATCH 2/2] f2fs: add a sysfs entry to reclaim POSIX_FADV_NOREUSE pages Jaegeuk Kim
2025-02-13 2:15 ` [f2fs-dev] " Chao Yu
2025-02-18 8:26 ` [PATCH 0/2 v9] reclaim file-backed pages given POSIX_FADV_NOREUSE Christoph Hellwig
2025-02-19 9:38 ` Jaegeuk Kim
2025-02-21 2:17 ` [f2fs-dev] " patchwork-bot+f2fs
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox