Skip to contentSkip to conversation

add support for drop_caches for individual filesystem

PATCH In review Ye Bin 5 participants 16 messages Feb 27 – Mar 16

Subsystems (7)
lore
Share & tools
lore

Ye Bin

author
#0 lore raw

v3 cover add support for drop_caches for individual filesystem

From: Ye Bin <[email protected]>

In order to better analyze the issue of file system uninstallation caused by kernel module opening files, it is necessary to perform dentry recycling on a single file system. But now, apart from global dentry recycling, it is not supported to do dentry recycling on a single file system separately. This feature has usage scenarios in problem localization scenarios.At the same time, it also provides users with a slightly fine-grained pagecache/entry recycling mechanism.
This patchset supports the recycling of pagecache/entry for individual file systems.

Diff v3 vs v2
1. Introduce introduce drop_sb_dentry_inode() helper instead of reclaim_dcache_sb()/reclaim_icache_sb() helper for reclaim dentry/inode.
2. Fixing compilation issues in specific architectures and configurations.

Diff v2 vs v1:
1. Fix possible live lock for shrink_icache_sb().
2. Introduce reclaim_dcache_sb() for reclaim dentry.
3. Fix potential deadlocks as follows:
https://lore.kernel.org/linux-fsdevel/[email protected]/
After some consideration, it was decided that this feature would primarily be used for debugging purposes. Instead of adding a new IOCTL command, the task_work mechanism was employed to address potential deadlock issues.

Ye Bin (3):
mm/vmscan: introduce drop_sb_dentry_inode() helper
sysctl: add support for drop_caches for individual filesystem
Documentation: add instructions for using 'drop_fs_caches sysctl'
sysctl

 Documentation/admin-guide/sysctl/vm.rst |  44 +++++++++
 fs/drop_caches.c                        | 125 ++++++++++++++++++++++++
 include/linux/mm.h                      |   1 +
 mm/internal.h                           |   3 +
 mm/shrinker.c                           |   4 +-
 mm/vmscan.c                             |  50 ++++++++++
 6 files changed, 225 insertions(+), 2 deletions(-)
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH v3 1/3 mm/vmscan: introduce drop_sb_dentry_inode() helper

From: Ye Bin <[email protected]>

This patch is prepare for support drop_caches for specify file system.

---
 include/linux/mm.h |  1 +
 mm/internal.h      |  3 +++
 mm/shrinker.c      |  4 ++--
 mm/vmscan.c        | 50 ++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 56 insertions(+), 2 deletions(-)
include/linux/mm.h +1 -0
index 5be3d8a8f806..5bab9472a758 100644
@@ -4470,6 +4470,7 @@ static inline int in_gate_area(struct mm_struct *mm, unsigned long addr)
 bool process_shares_mm(const struct task_struct *p, const struct mm_struct *mm);
 
 void drop_slab(void);
+void drop_sb_dentry_inode(struct super_block *sb);
 
 #ifndef CONFIG_MMU
 #define randomize_va_space 0
mm/internal.h +3 -0
index cb0af847d7d9..4690a58c4820 100644
@@ -1662,6 +1662,9 @@ void __meminit __init_page_from_nid(unsigned long pfn, int nid);
 unsigned long shrink_slab(gfp_t gfp_mask, int nid, struct mem_cgroup *memcg,
 			  int priority);
 
+unsigned long do_shrink_slab(struct shrink_control *shrinkctl,
+			     struct shrinker *shrinker, int priority);
+
 int shmem_add_to_page_cache(struct folio *folio,
 			    struct address_space *mapping,
 			    pgoff_t index, void *expected, gfp_t gfp);
mm/shrinker.c +2 -2
index 4a93fd433689..075e4393da9c 100644
@@ -368,8 +368,8 @@ static long add_nr_deferred(long nr, struct shrinker *shrinker,
 
 #define SHRINK_BATCH 128
 
-static unsigned long do_shrink_slab(struct shrink_control *shrinkctl,
-				    struct shrinker *shrinker, int priority)
+unsigned long do_shrink_slab(struct shrink_control *shrinkctl,
+			     struct shrinker *shrinker, int priority)
 {
 	unsigned long freed = 0;
 	unsigned long long delta;
mm/vmscan.c +50 -0

56 lines not on this page · raw message

Signature · 1 line
2.34.1
author
#2 lore raw

PATCH v3 2/3 sysctl: add support for drop_caches for individual filesystem

In reply to Ye Bin

From: Ye Bin <[email protected]>

In order to better analyze the issue of file system uninstallation caused by kernel module opening files, it is necessary to perform dentry recycling on a single file system. But now, apart from global dentry recycling, it is not supported to do dentry recycling on a single file system separately. This feature has usage scenarios in problem localization scenarios.At the same time, it also provides users with a slightly fine-grained pagecache/entry recycling mechanism.
This patch supports the recycling of pagecache/entry for individual file systems.

---
 fs/drop_caches.c | 125 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 125 insertions(+)
fs/drop_caches.c +125 -0
index 49f56a598ecb..0cd8ad9df07a 100644
@@ -11,6 +11,8 @@
 #include <linux/sysctl.h>
 #include <linux/gfp.h>
 #include <linux/swap.h>
+#include <linux/task_work.h>
+#include <linux/namei.h>
 #include "internal.h"
 
 /* A global variable is a bit ugly, but it keeps the code simple */
@@ -78,6 +80,124 @@ static int drop_caches_sysctl_handler(const struct ctl_table *table, int write,
 	return 0;
 }
 
+struct drop_fs_caches_work {
+	struct callback_head task_work;
+	dev_t dev;
+	char *path;
+	unsigned int ctl;
+};
+
+static void drop_fs_caches(struct callback_head *twork)
+{
+	int ret;
+	struct super_block *sb;
+	static bool suppress;
+	struct drop_fs_caches_work *work = container_of(twork,
+			struct drop_fs_caches_work, task_work);
+	unsigned int ctl = work->ctl;
+	dev_t dev = work->dev;
+
+	if (work->path) {
+		struct path path;
+
+		ret = kern_path(work->path, LOOKUP_FOLLOW, &path);
+		if (ret) {
+			pr_err("%s (%d): %s: failed to get path(%s) %d\n",
+			       current->comm, task_pid_nr(current),
+			       __func__, work->path, ret);
+			goto out;
+		}
+		dev = path.dentry->d_sb->s_dev;
+		/* Make this file's dentry and inode recyclable */
+		path_put(&path);
+	}
+
+	sb = user_get_super(dev, false);
+	if (!sb) {
+		pr_err("%s (%d): %s: failed to get dev(%u:%u)'s sb\n",
+		       current->comm, task_pid_nr(current), __func__,
+		       MAJOR(dev), MINOR(dev));
+		goto out;
+	}
+
+	if (ctl & BIT(0)) {
+		lru_add_drain_all();
+		drop_pagecache_sb(sb, NULL);
+		count_vm_event(DROP_PAGECACHE);
+	}
+
+	if (ctl & BIT(1)) {
+		drop_sb_dentry_inode(sb);
+		count_vm_event(DROP_SLAB);
+	}
+
+	if (!READ_ONCE(suppress)) {
+		pr_info("%s (%d): %s: %d %u:%u\n", current->comm,
+			task_pid_nr(current), __func__, ctl,
+			MAJOR(sb->s_dev), MINOR(sb->s_dev));
+
+		if (ctl & BIT(2))
+			WRITE_ONCE(suppress, true);
+	}
+
+	drop_super(sb);
+out:
+	kfree(work->path);
+	kfree(work);
+}
+
+static int drop_fs_caches_sysctl_handler(const struct ctl_table *table,
+					 int write, void *buffer,
+					 size_t *length, loff_t *ppos)
+{
+	struct drop_fs_caches_work *work = NULL;
+	unsigned int major, minor;
+	unsigned int ctl;
+	int ret;
+	char *path = NULL;
+
+	if (!write)
+		return 0;
+
+	if (sscanf(buffer, "%u %u:%u", &ctl, &major, &minor) != 3) {
+		path = kstrdup(buffer, GFP_NOFS);
+		if (!path) {
+			ret = -ENOMEM;
+			goto out;
+		}
+
+		if (sscanf(buffer, "%u %s", &ctl, path) != 2) {
+			ret = -EINVAL;
+			goto out;
+		}
+	}
+
+	if (ctl < 1 || ctl > 7) {
+		ret = -EINVAL;
+		goto out;
+	}
+
+	work = kzalloc(sizeof(*work), GFP_KERNEL);
+	if (!work) {
+		ret = -ENOMEM;
+		goto out;
+	}
+
+	init_task_work(&work->task_work, drop_fs_caches);
+	if (!path)
+		work->dev = MKDEV(major, minor);
+	work->path = path;
+	work->ctl = ctl;
+	ret = task_work_add(current, &work->task_work, TWA_RESUME);
+out:
+	if (ret) {
+		kfree(path);
+		kfree(work);
+	}
+
+	return ret;
+}
+
 static const struct ctl_table drop_caches_table[] = {
 	{
 		.procname	= "drop_caches",
@@ -88,6 +208,11 @@ static const struct ctl_table drop_caches_table[] = {
 		.extra1		= SYSCTL_ONE,
 		.extra2		= SYSCTL_FOUR,
 	},
+	{
+		.procname	= "drop_fs_caches",
+		.mode		= 0200,
+		.proc_handler	= drop_fs_caches_sysctl_handler,
+	},
 };
 
 static int __init init_vm_drop_caches_sysctls(void)
Signature · 1 line
2.34.1
author
#3 lore raw

PATCH v3 3/3 Documentation: add instructions for using 'drop_fs_caches sysctl' sysctl

In reply to Ye Bin

From: Ye Bin <[email protected]>

Add instructions for 'drop_fs_caches sysctl' sysctl in 'vm.rst'.

---
 Documentation/admin-guide/sysctl/vm.rst | 44 +++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
Documentation/admin-guide/sysctl/vm.rst +44 -0
index 97e12359775c..76545da53e20 100644
@@ -37,6 +37,7 @@ Currently, these files are in /proc/sys/vm:
 - dirtytime_expire_seconds
 - dirty_writeback_centisecs
 - drop_caches
+- drop_fs_caches
 - enable_soft_offline
 - extfrag_threshold
 - highmem_is_dirtyable
@@ -286,6 +287,49 @@ used::
 These are informational only.  They do not mean that anything is wrong
 with your system.  To disable them, echo 4 (bit 2) into drop_caches.
 
+drop_fs_caches
+==============
+
+Writing to this will cause the kernel to drop clean for a specific file system
+caches, as well as reclaimable slab objects like dentries and inodes. Once
+dropped, their memory becomes free. Except for specifying the device number
+or file path for a specific file system, everything else is consistent with
+drop_caches. The device number can be viewed through "cat /proc/self/montinfo"
+or 'lsblk'.
+
+To free pagecache::
+
+	echo "1 MAJOR:MINOR" > /proc/sys/vm/drop_fs_caches
+Or
+	echo "1 /mnt/XX" > /proc/sys/vm/drop_fs_caches
+
+To free reclaimable slab objects (includes dentries and inodes)::
+
+	echo "2 MAJOR:MINOR" > /proc/sys/vm/drop_fs_caches
+Or
+	echo "2 /mnt/XX" > /proc/sys/vm/drop_fs_caches
+
+To free slab objects and pagecache::
+
+	echo "3 MAJOR:MINOR" > /proc/sys/vm/drop_fs_caches
+Or
+	echo "3 /mnt/XX" > /proc/sys/vm/drop_fs_caches
+
+You may see error messages in your kernel log when incorrect path or device
+number provided::
+
+	echo (1234): drop_fs_caches: failed to get path(/mnt/XX) ERRNO
+Or
+	echo (1234): drop_fs_caches: failed to get dev(MAJOR:MINOR)'s sb
+
+You may see informational messages in your kernel log when this file is
+used::
+
+	echo (1234): drop_fs_caches: 3 MAJOR:MINOR
+
+These are informational only. They do not mean that anything is wrong
+with your system. To disable them, echo 4 (bit 2) into drop_fs_caches.
+
 enable_soft_offline
 ===================
 Correctable memory errors are very common on servers. Soft-offline is kernel's
Signature · 1 line
2.34.1
reviewer
#4 lore raw
In reply to Ye Bin
Quoted 10 lines · Ye Bin

From: Ye Bin <[email protected]>

In order to better analyze the issue of file system uninstallation caused by kernel module opening files, it is necessary to perform dentry recycling on a single file system. But now, apart from global dentry recycling, it is not supported to do dentry recycling on a single file system separately.

Would shrinker-debugfs satisfy your needs (See Documentation/admin-guide/mm/shrinker_debugfs.rst)?

Thanks,
Muchun

Quoted 37 lines

This feature has usage scenarios in problem localization scenarios.At the same time, it also provides users with a slightly fine-grained pagecache/entry recycling mechanism.
This patchset supports the recycling of pagecache/entry for individual file systems.

Diff v3 vs v2
1. Introduce introduce drop_sb_dentry_inode() helper instead of reclaim_dcache_sb()/reclaim_icache_sb() helper for reclaim dentry/inode.
2. Fixing compilation issues in specific architectures and configurations.

Diff v2 vs v1:
1. Fix possible live lock for shrink_icache_sb().
2. Introduce reclaim_dcache_sb() for reclaim dentry.
3. Fix potential deadlocks as follows:
https://lore.kernel.org/linux-fsdevel/[email protected]/
After some consideration, it was decided that this feature would primarily be used for debugging purposes. Instead of adding a new IOCTL command, the task_work mechanism was employed to address potential deadlock issues.

Ye Bin (3):
mm/vmscan: introduce drop_sb_dentry_inode() helper
sysctl: add support for drop_caches for individual filesystem
Documentation: add instructions for using 'drop_fs_caches sysctl'
sysctl

Documentation/admin-guide/sysctl/vm.rst |  44 +++++++++
fs/drop_caches.c                        | 125 ++++++++++++++++++++++++
include/linux/mm.h                      |   1 +
mm/internal.h                           |   3 +
mm/shrinker.c                           |   4 +-
mm/vmscan.c                             |  50 ++++++++++
6 files changed, 225 insertions(+), 2 deletions(-)
Signature · 1 line
2.34.1
#5 lore raw
Quoted 11 lines · Muchun Song
Quoted 10 lines · Ye Bin

From: Ye Bin <[email protected]>

In order to better analyze the issue of file system uninstallation caused by kernel module opening files, it is necessary to perform dentry recycling on a single file system. But now, apart from global dentry recycling, it is not supported to do dentry recycling on a single file system separately.

Quoted 5 lines

Would shrinker-debugfs satisfy your needs (See Documentation/admin-guide/mm/shrinker_debugfs.rst)?

Thanks,
Muchun

Thank you for the reminder. The reclamation of dentries and nodes can meet my needs. However, the reclamation of the page cache alone does not satisfy my requirements. I have reviewed the code of shrinker_debugfs_scan_write() and found that it does not support batch deletion of all dentries/inode for all nodes/memcgs,instead, users need to traverse through them one by one, which is not very convenient. Based on my previous experience, I have always performed dentry/inode reclamation at the file system level.

Thanks,
Ye Bin

Quoted 40 lines
Quoted 34 lines

This feature has usage scenarios in problem localization scenarios.At the same time, it also provides users with a slightly fine-grained pagecache/entry recycling mechanism.
This patchset supports the recycling of pagecache/entry for individual file systems.

Diff v3 vs v2
1. Introduce introduce drop_sb_dentry_inode() helper instead of reclaim_dcache_sb()/reclaim_icache_sb() helper for reclaim dentry/inode.
2. Fixing compilation issues in specific architectures and configurations.

Diff v2 vs v1:
1. Fix possible live lock for shrink_icache_sb().
2. Introduce reclaim_dcache_sb() for reclaim dentry.
3. Fix potential deadlocks as follows:
https://lore.kernel.org/linux-fsdevel/[email protected]/
After some consideration, it was decided that this feature would primarily be used for debugging purposes. Instead of adding a new IOCTL command, the task_work mechanism was employed to address potential deadlock issues.

Ye Bin (3):
mm/vmscan: introduce drop_sb_dentry_inode() helper
sysctl: add support for drop_caches for individual filesystem
Documentation: add instructions for using 'drop_fs_caches sysctl'
sysctl

Documentation/admin-guide/sysctl/vm.rst |  44 +++++++++
fs/drop_caches.c                        | 125 ++++++++++++++++++++++++
include/linux/mm.h                      |   1 +
mm/internal.h                           |   3 +
mm/shrinker.c                           |   4 +-
mm/vmscan.c                             |  50 ++++++++++
6 files changed, 225 insertions(+), 2 deletions(-)
Quoted 3 lines

--
2.34.1

.

reviewer
#6 lore raw
Quoted 14 lines · yebin (H)
Quoted 11 lines · Muchun Song
Quoted 10 lines · Ye Bin

From: Ye Bin <[email protected]>

In order to better analyze the issue of file system uninstallation caused by kernel module opening files, it is necessary to perform dentry recycling on a single file system. But now, apart from global dentry recycling, it is not supported to do dentry recycling on a single file system separately.

Quoted 6 lines
Quoted 5 lines

Would shrinker-debugfs satisfy your needs (See Documentation/admin- guide/mm/shrinker_debugfs.rst)?

Thanks,
Muchun

Thank you for the reminder. The reclamation of dentries and nodes can meet my needs. However, the reclamation of the page cache alone does not satisfy my requirements. I have reviewed the code of shrinker_debugfs_scan_write() and found that it does not support batch deletion of all dentries/inode for all nodes/memcgs,instead, users need to traverse through them one by one, which is not very convenient. Based on my previous experience, I have always performed dentry/inode reclamation at the file system level.

Using shrinker-debugfs allows users to specify the size of a single reclaim cycle (nr_to_scan), which controls the strength of each reclaim cycle to adapt to different workloads. Can the new drop_fs_caches support a similar approach?

Thanks,
Qi

Quoted 43 lines

Thanks,
Ye Bin

Quoted 40 lines
Quoted 26 lines

This feature has usage scenarios in problem localization scenarios.At the same time, it also provides users with a slightly fine-grained pagecache/entry recycling mechanism.
This patchset supports the recycling of pagecache/entry for individual file systems.

Diff v3 vs v2
1. Introduce introduce drop_sb_dentry_inode() helper instead of reclaim_dcache_sb()/reclaim_icache_sb() helper for reclaim dentry/inode.
2. Fixing compilation issues in specific architectures and configurations.

Diff v2 vs v1:
1. Fix possible live lock for shrink_icache_sb().
2. Introduce reclaim_dcache_sb() for reclaim dentry.
3. Fix potential deadlocks as follows:
https://lore.kernel.org/linux- fsdevel/[email protected]/ After some consideration, it was decided that this feature would primarily be used for debugging purposes. Instead of adding a new IOCTL command, the task_work mechanism was employed to address potential deadlock issues.

Ye Bin (3):
  mm/vmscan: introduce drop_sb_dentry_inode() helper
  sysctl: add support for drop_caches for individual filesystem
  Documentation: add instructions for using 'drop_fs_caches sysctl' sysctl

Quoted 11 lines

Documentation/admin-guide/sysctl/vm.rst |  44 +++++++++ fs/drop_caches.c                        | 125 ++++++++++++++++++++++++ include/linux/mm.h                      |   1 + mm/internal.h                           |   3 + mm/shrinker.c                           |   4 +- mm/vmscan.c                             |  50 ++++++++++

6 files changed, 225 insertions(+), 2 deletions(-)
Signature · 1 line
2.34.1

.

#7 lore raw
Quoted 36 lines · Qi Zheng
Quoted 24 lines · yebin (H)
Quoted 15 lines · Muchun Song
Quoted 14 lines · Ye Bin

From: Ye Bin <[email protected]>

In order to better analyze the issue of file system uninstallation caused
by kernel module opening files, it is necessary to perform dentry recycling
on a single file system. But now, apart from global dentry recycling, it is
not supported to do dentry recycling on a single file system separately.

Quoted 6 lines

Would shrinker-debugfs satisfy your needs (See Documentation/admin- guide/mm/shrinker_debugfs.rst)?

Thanks,
Muchun

Quoted 8 lines

Thank you for the reminder. The reclamation of dentries and nodes can meet my needs. However, the reclamation of the page cache alone does not satisfy my requirements. I have reviewed the code of shrinker_debugfs_scan_write() and found that it does not support batch deletion of all dentries/inode for all nodes/memcgs,instead, users need to traverse through them one by one, which is not very convenient. Based on my previous experience, I have always performed dentry/inode reclamation at the file system level.

Quoted 8 lines

Using shrinker-debugfs allows users to specify the size of a single reclaim cycle (nr_to_scan), which controls the strength of each reclaim cycle to adapt to different workloads. Can the new drop_fs_caches support a similar approach?

Thanks,
Qi

"drop_fs_caches" is similar to "drop_caches," but it only operates on the specified file system. It does not support specifying the number of pages to scan (nr_to_scan).

Quoted 53 lines
Quoted 50 lines

Thanks,
Ye Bin

Quoted 47 lines
Quoted 41 lines

This feature has usage scenarios in problem localization scenarios.At the
same time, it also provides users with a slightly fine-grained pagecache/entry recycling mechanism.
This patchset supports the recycling of pagecache/entry for individual file
systems.

Diff v3 vs v2
1. Introduce introduce drop_sb_dentry_inode() helper instead of reclaim_dcache_sb()/reclaim_icache_sb() helper for reclaim dentry/inode.
2. Fixing compilation issues in specific architectures and configurations.

Diff v2 vs v1:
1. Fix possible live lock for shrink_icache_sb().
2. Introduce reclaim_dcache_sb() for reclaim dentry.
3. Fix potential deadlocks as follows:
https://lore.kernel.org/linux-
fsdevel/[email protected]/
After some consideration, it was decided that this feature would primarily
be used for debugging purposes. Instead of adding a new IOCTL command, the
task_work mechanism was employed to address potential deadlock issues.

Ye Bin (3):
mm/vmscan: introduce drop_sb_dentry_inode() helper
sysctl: add support for drop_caches for individual filesystem
Documentation: add instructions for using 'drop_fs_caches sysctl'
sysctl

Documentation/admin-guide/sysctl/vm.rst |  44 +++++++++
fs/drop_caches.c                        | 125 ++++++++++++++++++++++++
include/linux/mm.h                      |   1 +
mm/internal.h                           |   3 +
mm/shrinker.c                           |   4 +-
mm/vmscan.c                             |  50 ++++++++++
6 files changed, 225 insertions(+), 2 deletions(-)
Quoted 3 lines

--
2.34.1

.

.

reviewer
#8 lore raw
In reply to yebin (H)
Quoted 18 lines · yebin (H)
Quoted 11 lines · Muchun Song
Quoted 10 lines · Ye Bin

From: Ye Bin <[email protected]>

In order to better analyze the issue of file system uninstallation caused by kernel module opening files, it is necessary to perform dentry recycling on a single file system. But now, apart from global dentry recycling, it is not supported to do dentry recycling on a single file system separately.

Quoted 6 lines
Quoted 5 lines

Would shrinker-debugfs satisfy your needs (See Documentation/admin-guide/mm/shrinker_debugfs.rst)?

Thanks,
Muchun

Thank you for the reminder. The reclamation of dentries and nodes can meet my needs. However, the reclamation of the page cache alone does not satisfy my requirements. I have reviewed the code of shrinker_debugfs_scan_write() and found that it does not support batch deletion of all dentries/inode for all nodes/memcgs,instead, users need to traverse through them one by one, which is not very convenient. Based on my previous experience, I have always performed dentry/inode reclamation at the file system level.

I don't really like that you're implementing another mechanism with duplicate functionality. If you'd like, you could write a script to iterate through them and execute it that way—I don't think that would be particularly inconvenient, would it? If the iteration operation of memcg is indeed quite cumbersome, I think extending the shrinker debugfs functionality would be more appropriate.

Quoted 43 lines

Thanks,
Ye Bin

Quoted 40 lines
Quoted 34 lines

This feature has usage scenarios in problem localization scenarios.At the same time, it also provides users with a slightly fine-grained pagecache/entry recycling mechanism.
This patchset supports the recycling of pagecache/entry for individual file systems.

Diff v3 vs v2
1. Introduce introduce drop_sb_dentry_inode() helper instead of reclaim_dcache_sb()/reclaim_icache_sb() helper for reclaim dentry/inode.
2. Fixing compilation issues in specific architectures and configurations.

Diff v2 vs v1:
1. Fix possible live lock for shrink_icache_sb().
2. Introduce reclaim_dcache_sb() for reclaim dentry.
3. Fix potential deadlocks as follows:
https://lore.kernel.org/linux-fsdevel/[email protected]/
After some consideration, it was decided that this feature would primarily be used for debugging purposes. Instead of adding a new IOCTL command, the task_work mechanism was employed to address potential deadlock issues.

Ye Bin (3):
mm/vmscan: introduce drop_sb_dentry_inode() helper
sysctl: add support for drop_caches for individual filesystem
Documentation: add instructions for using 'drop_fs_caches sysctl'
sysctl

Documentation/admin-guide/sysctl/vm.rst |  44 +++++++++
fs/drop_caches.c                        | 125 ++++++++++++++++++++++++
include/linux/mm.h                      |   1 +
mm/internal.h                           |   3 +
mm/shrinker.c                           |   4 +-
mm/vmscan.c                             |  50 ++++++++++
6 files changed, 225 insertions(+), 2 deletions(-)
Quoted 3 lines

--
2.34.1

.

#9 lore raw
Quoted 23 lines · Muchun Song
Quoted 23 lines · yebin (H)
Quoted 16 lines · Muchun Song
Quoted 10 lines · Ye Bin

From: Ye Bin <[email protected]>

In order to better analyze the issue of file system uninstallation caused by kernel module opening files, it is necessary to perform dentry recycling on a single file system. But now, apart from global dentry recycling, it is not supported to do dentry recycling on a single file system separately.

Would shrinker-debugfs satisfy your needs (See Documentation/admin-guide/mm/shrinker_debugfs.rst)?

Thanks,
Muchun

Quoted 8 lines
Quoted 1 line

Thank you for the reminder. The reclamation of dentries and nodes can meet my needs. However, the reclamation of the page cache alone does not satisfy my requirements. I have reviewed the code of shrinker_debugfs_scan_write() and found that it does not support batch deletion of all dentries/inode for all nodes/memcgs,instead, users need to traverse through them one by one, which is not very convenient. Based on my previous experience, I have always performed dentry/inode reclamation at the file system level.

I don't really like that you're implementing another mechanism with duplicate functionality. If you'd like, you could write a script to iterate through them and execute it that way—I don't think that would be particularly inconvenient, would it? If the iteration operation of memcg is indeed quite cumbersome, I think extending the shrinker debugfs functionality would be more appropriate.

The shrinker_debugfs can be extended to support node/memcg/fs granularity reclamation, similar to the extended function of echo " 0 - X" > count /echo " - 0 X" > count /echo " - - X" > count. This only solves the problem of reclaiming dentries/inode based on a single file system. However, the page cache reclamation based on a single file system cannot be implemented by using shrinker_debugfs. If the extended function is implemented by shrinker_debugfs, drop_fs_caches can reuse the same interface and maintain the same semantics as drop_caches.

Quoted 46 lines
Quoted 43 lines

Thanks,
Ye Bin

Quoted 40 lines
Quoted 34 lines

This feature has usage scenarios in problem localization scenarios.At the same time, it also provides users with a slightly fine-grained pagecache/entry recycling mechanism.
This patchset supports the recycling of pagecache/entry for individual file systems.

Diff v3 vs v2
1. Introduce introduce drop_sb_dentry_inode() helper instead of reclaim_dcache_sb()/reclaim_icache_sb() helper for reclaim dentry/inode.
2. Fixing compilation issues in specific architectures and configurations.

Diff v2 vs v1:
1. Fix possible live lock for shrink_icache_sb().
2. Introduce reclaim_dcache_sb() for reclaim dentry.
3. Fix potential deadlocks as follows:
https://lore.kernel.org/linux-fsdevel/[email protected]/
After some consideration, it was decided that this feature would primarily be used for debugging purposes. Instead of adding a new IOCTL command, the task_work mechanism was employed to address potential deadlock issues.

Ye Bin (3):
mm/vmscan: introduce drop_sb_dentry_inode() helper
sysctl: add support for drop_caches for individual filesystem
Documentation: add instructions for using 'drop_fs_caches sysctl'
sysctl

Documentation/admin-guide/sysctl/vm.rst |  44 +++++++++
fs/drop_caches.c                        | 125 ++++++++++++++++++++++++
include/linux/mm.h                      |   1 +
mm/internal.h                           |   3 +
mm/shrinker.c                           |   4 +-
mm/vmscan.c                             |  50 ++++++++++
6 files changed, 225 insertions(+), 2 deletions(-)
Quoted 3 lines

--
2.34.1

.

.

reviewer
#10 lore raw
Quoted 32 lines · yebin (H)
Quoted 25 lines · Muchun Song
Quoted 24 lines · yebin (H)
Quoted 11 lines · Muchun Song
Quoted 10 lines · Ye Bin

From: Ye Bin <[email protected]>

In order to better analyze the issue of file system uninstallation caused by kernel module opening files, it is necessary to perform dentry recycling on a single file system. But now, apart from global dentry recycling, it is not supported to do dentry recycling on a single file system separately.

Quoted 5 lines

Would shrinker-debugfs satisfy your needs (See Documentation/admin-guide/mm/shrinker_debugfs.rst)?

Thanks,
Muchun

Thank you for the reminder. The reclamation of dentries and nodes can meet my needs. However, the reclamation of the page cache alone does not satisfy my requirements. I have reviewed the code of shrinker_debugfs_scan_write() and found that it does not support batch deletion of all dentries/inode for all nodes/memcgs,instead, users need to traverse through them one by one, which is not very convenient. Based on my previous experience, I have always performed dentry/inode reclamation at the file system level.

Quoted 7 lines
Quoted 6 lines

I don't really like that you're implementing another mechanism with duplicate functionality. If you'd like, you could write a script to iterate through them and execute it that way—I don't think that would be particularly inconvenient, would it? If the iteration operation of memcg is indeed quite cumbersome, I think extending the shrinker debugfs functionality would be more appropriate.

The shrinker_debugfs can be extended to support node/memcg/fs granularity reclamation, similar to the extended function of echo " 0 - X" > count /echo " - 0 X" > count /echo " - - X" > count. This only solves the problem of reclaiming dentries/inode based on a single file system. However, the page cache reclamation based on a single file system cannot be implemented by using shrinker_debugfs. If the extended function is implemented by shrinker_debugfs, drop_fs_caches can reuse the same interface and maintain the same semantics as drop_caches.

If the inode is evicted, the page cache is evicted as well. It cannot evict page cache alone. Why you want to evict cache alone?

Quoted 45 lines
Quoted 45 lines
Quoted 43 lines

Thanks,
Ye Bin

Quoted 40 lines
Quoted 34 lines

This feature has usage scenarios in problem localization scenarios.At the same time, it also provides users with a slightly fine-grained pagecache/entry recycling mechanism.
This patchset supports the recycling of pagecache/entry for individual file systems.

Diff v3 vs v2
1. Introduce introduce drop_sb_dentry_inode() helper instead of reclaim_dcache_sb()/reclaim_icache_sb() helper for reclaim dentry/inode.
2. Fixing compilation issues in specific architectures and configurations.

Diff v2 vs v1:
1. Fix possible live lock for shrink_icache_sb().
2. Introduce reclaim_dcache_sb() for reclaim dentry.
3. Fix potential deadlocks as follows:
https://lore.kernel.org/linux-fsdevel/[email protected]/
After some consideration, it was decided that this feature would primarily be used for debugging purposes. Instead of adding a new IOCTL command, the task_work mechanism was employed to address potential deadlock issues.

Ye Bin (3):
mm/vmscan: introduce drop_sb_dentry_inode() helper
sysctl: add support for drop_caches for individual filesystem
Documentation: add instructions for using 'drop_fs_caches sysctl'
sysctl

Documentation/admin-guide/sysctl/vm.rst |  44 +++++++++
fs/drop_caches.c                        | 125 ++++++++++++++++++++++++
include/linux/mm.h                      |   1 +
mm/internal.h                           |   3 +
mm/shrinker.c                           |   4 +-
mm/vmscan.c                             |  50 ++++++++++
6 files changed, 225 insertions(+), 2 deletions(-)
Quoted 3 lines

--
2.34.1

.

.

#11 lore raw
Quoted 38 lines · Muchun Song
Quoted 38 lines · yebin (H)
Quoted 31 lines · Muchun Song
Quoted 18 lines · yebin (H)
Quoted 11 lines · Muchun Song
Quoted 10 lines · Ye Bin

From: Ye Bin <[email protected]>

In order to better analyze the issue of file system uninstallation caused by kernel module opening files, it is necessary to perform dentry recycling on a single file system. But now, apart from global dentry recycling, it is not supported to do dentry recycling on a single file system separately.

Quoted 6 lines
Quoted 5 lines

Would shrinker-debugfs satisfy your needs (See Documentation/admin-guide/mm/shrinker_debugfs.rst)?

Thanks,
Muchun

Thank you for the reminder. The reclamation of dentries and nodes can meet my needs. However, the reclamation of the page cache alone does not satisfy my requirements. I have reviewed the code of shrinker_debugfs_scan_write() and found that it does not support batch deletion of all dentries/inode for all nodes/memcgs,instead, users need to traverse through them one by one, which is not very convenient. Based on my previous experience, I have always performed dentry/inode reclamation at the file system level.

I don't really like that you're implementing another mechanism with duplicate functionality. If you'd like, you could write a script to iterate through them and execute it that way—I don't think that would be particularly inconvenient, would it? If the iteration operation of memcg is indeed quite cumbersome, I think extending the shrinker debugfs functionality would be more appropriate.

Quoted 5 lines
Quoted 1 line

The shrinker_debugfs can be extended to support node/memcg/fs granularity reclamation, similar to the extended function of echo " 0 - X" > count /echo " - 0 X" > count /echo " - - X" > count. This only solves the problem of reclaiming dentries/inode based on a single file system. However, the page cache reclamation based on a single file system cannot be implemented by using shrinker_debugfs. If the extended function is implemented by shrinker_debugfs, drop_fs_caches can reuse the same interface and maintain the same semantics as drop_caches.

If the inode is evicted, the page cache is evicted as well. It cannot evict page cache alone. Why you want to evict cache alone?

The condition for dentry/inode to be reclaimed is that there are no references to them. Therefore, relying on inode reclamation for page cache reclamation has limitations. Additionally, there is currently no usage statistics for the page cache based on a single file system. By comparing the page cache usage before and after reclamation, we can roughly estimate the amount of page cache used by a file system.

Quoted 51 lines
Quoted 37 lines
Quoted 37 lines
Quoted 37 lines

Thanks,
Ye Bin

Quoted 34 lines
Quoted 34 lines

This feature has usage scenarios in problem localization scenarios.At the same time, it also provides users with a slightly fine-grained pagecache/entry recycling mechanism.
This patchset supports the recycling of pagecache/entry for individual file systems.

Diff v3 vs v2
1. Introduce introduce drop_sb_dentry_inode() helper instead of reclaim_dcache_sb()/reclaim_icache_sb() helper for reclaim dentry/inode.
2. Fixing compilation issues in specific architectures and configurations.

Diff v2 vs v1:
1. Fix possible live lock for shrink_icache_sb().
2. Introduce reclaim_dcache_sb() for reclaim dentry.
3. Fix potential deadlocks as follows:
https://lore.kernel.org/linux-fsdevel/[email protected]/
After some consideration, it was decided that this feature would primarily be used for debugging purposes. Instead of adding a new IOCTL command, the task_work mechanism was employed to address potential deadlock issues.

Ye Bin (3):
mm/vmscan: introduce drop_sb_dentry_inode() helper
sysctl: add support for drop_caches for individual filesystem
Documentation: add instructions for using 'drop_fs_caches sysctl'
sysctl

Documentation/admin-guide/sysctl/vm.rst |  44 +++++++++
fs/drop_caches.c                        | 125 ++++++++++++++++++++++++
include/linux/mm.h                      |   1 +
mm/internal.h                           |   3 +
mm/shrinker.c                           |   4 +-
mm/vmscan.c                             |  50 ++++++++++
6 files changed, 225 insertions(+), 2 deletions(-)
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

--
2.34.1

.

.

.

reviewer
#12 lore raw
Quoted 45 lines · yebin (H)
Quoted 38 lines · Muchun Song
Quoted 38 lines · yebin (H)
Quoted 31 lines · Muchun Song
Quoted 18 lines · yebin (H)
Quoted 11 lines · Muchun Song
Quoted 10 lines · Ye Bin

From: Ye Bin <[email protected]>

In order to better analyze the issue of file system uninstallation caused by kernel module opening files, it is necessary to perform dentry recycling on a single file system. But now, apart from global dentry recycling, it is not supported to do dentry recycling on a single file system separately.

Quoted 6 lines
Quoted 5 lines

Would shrinker-debugfs satisfy your needs (See Documentation/admin-guide/mm/shrinker_debugfs.rst)?

Thanks,
Muchun

Thank you for the reminder. The reclamation of dentries and nodes can meet my needs. However, the reclamation of the page cache alone does not satisfy my requirements. I have reviewed the code of shrinker_debugfs_scan_write() and found that it does not support batch deletion of all dentries/inode for all nodes/memcgs,instead, users need to traverse through them one by one, which is not very convenient. Based on my previous experience, I have always performed dentry/inode reclamation at the file system level.

I don't really like that you're implementing another mechanism with duplicate functionality. If you'd like, you could write a script to iterate through them and execute it that way—I don't think that would be particularly inconvenient, would it? If the iteration operation of memcg is indeed quite cumbersome, I think extending the shrinker debugfs functionality would be more appropriate.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

The shrinker_debugfs can be extended to support node/memcg/fs granularity reclamation, similar to the extended function of echo " 0 - X" > count /echo " - 0 X" > count /echo " - - X" > count. This only solves the problem of reclaiming dentries/inode based on a single file system. However, the page cache reclamation based on a single file system cannot be implemented by using shrinker_debugfs. If the extended function is implemented by shrinker_debugfs, drop_fs_caches can reuse the same interface and maintain the same semantics as drop_caches.

If the inode is evicted, the page cache is evicted as well. It cannot evict page cache alone. Why you want to evict cache alone?

The condition for dentry/inode to be reclaimed is that there are no references to them. Therefore, relying on inode reclamation for page cache reclamation has limitations. Additionally, there is currently no

What limit?

Quoted 3 lines

usage statistics for the page cache based on a single file system. By comparing the page cache usage before and after reclamation, we can roughly estimate the amount of page cache used by a file system.

I'm curious why dropping inodes doesn't show a noticeable difference in page cache usage before and after?

Quoted 51 lines
Quoted 51 lines
Quoted 38 lines
Quoted 38 lines
Quoted 38 lines

Thanks,
Ye Bin

Quoted 34 lines
Quoted 34 lines

This feature has usage scenarios in problem localization scenarios.At the same time, it also provides users with a slightly fine-grained pagecache/entry recycling mechanism.
This patchset supports the recycling of pagecache/entry for individual file systems.

Diff v3 vs v2
1. Introduce introduce drop_sb_dentry_inode() helper instead of reclaim_dcache_sb()/reclaim_icache_sb() helper for reclaim dentry/inode.
2. Fixing compilation issues in specific architectures and configurations.

Diff v2 vs v1:
1. Fix possible live lock for shrink_icache_sb().
2. Introduce reclaim_dcache_sb() for reclaim dentry.
3. Fix potential deadlocks as follows:
https://lore.kernel.org/linux-fsdevel/[email protected]/
After some consideration, it was decided that this feature would primarily be used for debugging purposes. Instead of adding a new IOCTL command, the task_work mechanism was employed to address potential deadlock issues.

Ye Bin (3):
mm/vmscan: introduce drop_sb_dentry_inode() helper
sysctl: add support for drop_caches for individual filesystem
Documentation: add instructions for using 'drop_fs_caches sysctl'
sysctl

Documentation/admin-guide/sysctl/vm.rst |  44 +++++++++
fs/drop_caches.c                        | 125 ++++++++++++++++++++++++
include/linux/mm.h                      |   1 +
mm/internal.h                           |   3 +
mm/shrinker.c                           |   4 +-
mm/vmscan.c                             |  50 ++++++++++
6 files changed, 225 insertions(+), 2 deletions(-)
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

--
2.34.1

.

.

.

#13 lore raw
Quoted 47 lines · Muchun Song
Quoted 47 lines · yebin (H)
Quoted 40 lines · Muchun Song
Quoted 39 lines · yebin (H)
Quoted 23 lines · Muchun Song
Quoted 23 lines · yebin (H)
Quoted 16 lines · Muchun Song
Quoted 10 lines · Ye Bin

From: Ye Bin <[email protected]>

In order to better analyze the issue of file system uninstallation caused by kernel module opening files, it is necessary to perform dentry recycling on a single file system. But now, apart from global dentry recycling, it is not supported to do dentry recycling on a single file system separately.

Would shrinker-debugfs satisfy your needs (See Documentation/admin-guide/mm/shrinker_debugfs.rst)?

Thanks,
Muchun

Quoted 8 lines
Quoted 1 line

Thank you for the reminder. The reclamation of dentries and nodes can meet my needs. However, the reclamation of the page cache alone does not satisfy my requirements. I have reviewed the code of shrinker_debugfs_scan_write() and found that it does not support batch deletion of all dentries/inode for all nodes/memcgs,instead, users need to traverse through them one by one, which is not very convenient. Based on my previous experience, I have always performed dentry/inode reclamation at the file system level.

I don't really like that you're implementing another mechanism with duplicate functionality. If you'd like, you could write a script to iterate through them and execute it that way—I don't think that would be particularly inconvenient, would it? If the iteration operation of memcg is indeed quite cumbersome, I think extending the shrinker debugfs functionality would be more appropriate.

The shrinker_debugfs can be extended to support node/memcg/fs granularity reclamation, similar to the extended function of echo " 0 - X" > count /echo " - 0 X" > count /echo " - - X" > count. This only solves the problem of reclaiming dentries/inode based on a single file system. However, the page cache reclamation based on a single file system cannot be implemented by using shrinker_debugfs. If the extended function is implemented by shrinker_debugfs, drop_fs_caches can reuse the same interface and maintain the same semantics as drop_caches.

Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

If the inode is evicted, the page cache is evicted as well. It cannot evict page cache alone. Why you want to evict cache alone?

The condition for dentry/inode to be reclaimed is that there are no references to them. Therefore, relying on inode reclamation for page cache reclamation has limitations. Additionally, there is currently no

What limit?

If the file is occupied, the page cache cannot be reclaimed through inode reclamation.

Quoted 62 lines
Quoted 3 lines

usage statistics for the page cache based on a single file system. By comparing the page cache usage before and after reclamation, we can roughly estimate the amount of page cache used by a file system.

I'm curious why dropping inodes doesn't show a noticeable difference in page cache usage before and after?

Quoted 45 lines
Quoted 45 lines
Quoted 45 lines
Quoted 45 lines
Quoted 44 lines

Thanks,
Ye Bin

Quoted 40 lines
Quoted 34 lines

This feature has usage scenarios in problem localization scenarios.At the same time, it also provides users with a slightly fine-grained pagecache/entry recycling mechanism.
This patchset supports the recycling of pagecache/entry for individual file systems.

Diff v3 vs v2
1. Introduce introduce drop_sb_dentry_inode() helper instead of reclaim_dcache_sb()/reclaim_icache_sb() helper for reclaim dentry/inode.
2. Fixing compilation issues in specific architectures and configurations.

Diff v2 vs v1:
1. Fix possible live lock for shrink_icache_sb().
2. Introduce reclaim_dcache_sb() for reclaim dentry.
3. Fix potential deadlocks as follows:
https://lore.kernel.org/linux-fsdevel/[email protected]/
After some consideration, it was decided that this feature would primarily be used for debugging purposes. Instead of adding a new IOCTL command, the task_work mechanism was employed to address potential deadlock issues.

Ye Bin (3):
mm/vmscan: introduce drop_sb_dentry_inode() helper
sysctl: add support for drop_caches for individual filesystem
Documentation: add instructions for using 'drop_fs_caches sysctl'
sysctl

Documentation/admin-guide/sysctl/vm.rst |  44 +++++++++
fs/drop_caches.c                        | 125 ++++++++++++++++++++++++
include/linux/mm.h                      |   1 +
mm/internal.h                           |   3 +
mm/shrinker.c                           |   4 +-
mm/vmscan.c                             |  50 ++++++++++
6 files changed, 225 insertions(+), 2 deletions(-)
Quoted 3 lines

--
2.34.1

.

Quoted 6 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line

.

.

.

#14 lore raw
In reply to Muchun Song
Quoted 47 lines · Muchun Song
Quoted 47 lines · yebin (H)
Quoted 40 lines · Muchun Song
Quoted 39 lines · yebin (H)
Quoted 23 lines · Muchun Song
Quoted 23 lines · yebin (H)
Quoted 16 lines · Muchun Song
Quoted 10 lines · Ye Bin

From: Ye Bin <[email protected]>

In order to better analyze the issue of file system uninstallation caused by kernel module opening files, it is necessary to perform dentry recycling on a single file system. But now, apart from global dentry recycling, it is not supported to do dentry recycling on a single file system separately.

Would shrinker-debugfs satisfy your needs (See Documentation/admin-guide/mm/shrinker_debugfs.rst)?

Thanks,
Muchun

Quoted 8 lines
Quoted 1 line

Thank you for the reminder. The reclamation of dentries and nodes can meet my needs. However, the reclamation of the page cache alone does not satisfy my requirements. I have reviewed the code of shrinker_debugfs_scan_write() and found that it does not support batch deletion of all dentries/inode for all nodes/memcgs,instead, users need to traverse through them one by one, which is not very convenient. Based on my previous experience, I have always performed dentry/inode reclamation at the file system level.

I don't really like that you're implementing another mechanism with duplicate functionality. If you'd like, you could write a script to iterate through them and execute it that way—I don't think that would be particularly inconvenient, would it? If the iteration operation of memcg is indeed quite cumbersome, I think extending the shrinker debugfs functionality would be more appropriate.

The shrinker_debugfs can be extended to support node/memcg/fs granularity reclamation, similar to the extended function of echo " 0 - X" > count /echo " - 0 X" > count /echo " - - X" > count. This only solves the problem of reclaiming dentries/inode based on a single file system. However, the page cache reclamation based on a single file system cannot be implemented by using shrinker_debugfs. If the extended function is implemented by shrinker_debugfs, drop_fs_caches can reuse the same interface and maintain the same semantics as drop_caches.

Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

If the inode is evicted, the page cache is evicted as well. It cannot evict page cache alone. Why you want to evict cache alone?

The condition for dentry/inode to be reclaimed is that there are no references to them. Therefore, relying on inode reclamation for page cache reclamation has limitations. Additionally, there is currently no

What limit?

Perhaps I didn't explain it clearly earlier. What I want to achieve is the ability to perform memory reclamation (pagecache/dentry/inode) based on a single file system. In the current network environment, when troubleshooting issues, I want to control the impact of operations and only perform memory reclamation on specific file systems. Therefore, some files might be in an occupied state, and relying on dentry/inode to reclaim pagecache will not achieve the desired effect. Additionally, I have encountered some users who periodically run drop_caches, mainly to clear the pagecache. If we rely on dentry/inode to release resources, there will be issues where the pagecache cannot be fully cleared. This level of granularity is actually unnecessary because in some scenarios, users know which partitions they use more frequently, so they only need to clear the pagecache for specific partitions.

Quoted 62 lines
Quoted 3 lines

usage statistics for the page cache based on a single file system. By comparing the page cache usage before and after reclamation, we can roughly estimate the amount of page cache used by a file system.

I'm curious why dropping inodes doesn't show a noticeable difference in page cache usage before and after?

Quoted 45 lines
Quoted 45 lines
Quoted 45 lines
Quoted 45 lines
Quoted 44 lines

Thanks,
Ye Bin

Quoted 40 lines
Quoted 34 lines

This feature has usage scenarios in problem localization scenarios.At the same time, it also provides users with a slightly fine-grained pagecache/entry recycling mechanism.
This patchset supports the recycling of pagecache/entry for individual file systems.

Diff v3 vs v2
1. Introduce introduce drop_sb_dentry_inode() helper instead of reclaim_dcache_sb()/reclaim_icache_sb() helper for reclaim dentry/inode.
2. Fixing compilation issues in specific architectures and configurations.

Diff v2 vs v1:
1. Fix possible live lock for shrink_icache_sb().
2. Introduce reclaim_dcache_sb() for reclaim dentry.
3. Fix potential deadlocks as follows:
https://lore.kernel.org/linux-fsdevel/[email protected]/
After some consideration, it was decided that this feature would primarily be used for debugging purposes. Instead of adding a new IOCTL command, the task_work mechanism was employed to address potential deadlock issues.

Ye Bin (3):
mm/vmscan: introduce drop_sb_dentry_inode() helper
sysctl: add support for drop_caches for individual filesystem
Documentation: add instructions for using 'drop_fs_caches sysctl'
sysctl

Documentation/admin-guide/sysctl/vm.rst |  44 +++++++++
fs/drop_caches.c                        | 125 ++++++++++++++++++++++++
include/linux/mm.h                      |   1 +
mm/internal.h                           |   3 +
mm/shrinker.c                           |   4 +-
mm/vmscan.c                             |  50 ++++++++++
6 files changed, 225 insertions(+), 2 deletions(-)
Quoted 3 lines

--
2.34.1

.

Quoted 6 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line

.

.

.

reviewer
#15 lore raw
Quoted 40 lines · yebin (H)
Quoted 30 lines · Muchun Song
Quoted 30 lines · yebin (H)
Quoted 28 lines · Muchun Song
Quoted 27 lines · yebin (H)
Quoted 16 lines · Muchun Song
Quoted 16 lines · yebin (H)
Quoted 14 lines · Muchun Song
Quoted 8 lines · Ye Bin

From: Ye Bin <[email protected]>

In order to better analyze the issue of file system uninstallation caused by kernel module opening files, it is necessary to perform dentry recycling on a single file system. But now, apart from global dentry recycling, it is not supported to do dentry recycling on a single file system separately.

Would shrinker-debugfs satisfy your needs (See Documentation/admin-guide/mm/shrinker_debugfs.rst)?

Thanks,
Muchun

Quoted 8 lines
Quoted 1 line

Thank you for the reminder. The reclamation of dentries and nodes can meet my needs. However, the reclamation of the page cache alone does not satisfy my requirements. I have reviewed the code of shrinker_debugfs_scan_write() and found that it does not support batch deletion of all dentries/inode for all nodes/memcgs,instead, users need to traverse through them one by one, which is not very convenient. Based on my previous experience, I have always performed dentry/inode reclamation at the file system level.

I don't really like that you're implementing another mechanism with duplicate functionality. If you'd like, you could write a script to iterate through them and execute it that way—I don't think that would be particularly inconvenient, would it? If the iteration operation of memcg is indeed quite cumbersome, I think extending the shrinker debugfs functionality would be more appropriate.

The shrinker_debugfs can be extended to support node/memcg/fs granularity reclamation, similar to the extended function of echo " 0 - X" > count /echo " - 0 X" > count /echo " - - X" > count. This only solves the problem of reclaiming dentries/inode based on a single file system. However, the page cache reclamation based on a single file system cannot be implemented by using shrinker_debugfs. If the extended function is implemented by shrinker_debugfs, drop_fs_caches can reuse the same interface and maintain the same semantics as drop_caches.

Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

If the inode is evicted, the page cache is evicted as well. It cannot evict page cache alone. Why you want to evict cache alone?

The condition for dentry/inode to be reclaimed is that there are no references to them. Therefore, relying on inode reclamation for page cache reclamation has limitations. Additionally, there is currently no

What limit?

Quoted 13 lines

Perhaps I didn't explain it clearly earlier. What I want to achieve is the ability to perform memory reclamation (pagecache/dentry/inode) based on a single file system. In the current network environment, when troubleshooting issues, I want to control the impact of operations and only perform memory reclamation on specific file systems. Therefore, some files might be in an occupied state, and relying on dentry/inode to reclaim pagecache will not achieve the desired effect. Additionally, I have encountered some users who periodically run drop_caches, mainly to clear the pagecache. If we rely on dentry/inode to release resources, there will be issues where the pagecache cannot be fully cleared. This level of granularity is actually unnecessary because in some scenarios, users know which partitions they use more frequently, so they only need to clear the pagecache for specific partitions.

Let me revive this thread :) I agree with Ye Bin - the more interesting part of this functionality is actually giving userspace a way to effectively trigger drop_pagecache_sb() only for one superblock and inode / dentry shrinkers have no chance to do that. In particular because for example drop_pagecache_sb() will also discard page cache of currently open files but the inodes / dentries are used (struct file pins them in memory) so shrinker doesn't even consider them.

I don't have a strong preference whether the API for triggering page cache reclaim for one sb will be through /proc/sys/vm/<some_new_file> or through debugfs (possibly <debugfs>/shrinkers/page_cache or something like that) but this functionality definitely cannot be achieved by just triggering some shrinkers.

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR