* [PATCH] fs/drop_caches: skip filesystems without fs writeback
@ 2026-09-23 7:01 Huang Shijie
2026-09-23 11:04 ` Jan Kara
2026-09-25 6:57 ` Christoph Hellwig
0 siblings, 2 replies; 3+ messages in thread
From: Huang Shijie @ 2026-09-23 7:01 UTC (permalink / raw)
To: viro, brauner
Cc: zhongyuan, fangbaoshun, yingzhiwei, jack, linux-fsdevel,
linux-kernel, yefan, Huang Shijie, Christoph Hellwig
Filesystems backed by the noop backing device (procfs, sysfs, kernfs,
tmpfs, ramfs, etc.) have no fs page-cache writeback. Skip them in
drop_pagecache_sb() instead of walking their inode lists.
This also skips tmpfs/ramfs. tmpfs has clean folios which are
zero-filled pages from reading holes, which are trivially recreatable.
Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Huang Shijie <huangsj@hygon.cn>
---
The RFC mails:
https://lore.kernel.org/all/arIVBpMZk5-O2AZc@infradead.org/
---
fs/drop_caches.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/drop_caches.c b/fs/drop_caches.c
index 49f56a598ecb..28c5fb9c7357 100644
--- a/fs/drop_caches.c
+++ b/fs/drop_caches.c
@@ -7,6 +7,7 @@
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/fs.h>
+#include <linux/backing-dev.h>
#include <linux/writeback.h>
#include <linux/sysctl.h>
#include <linux/gfp.h>
@@ -20,6 +21,9 @@ static void drop_pagecache_sb(struct super_block *sb, void *unused)
{
struct inode *inode, *toput_inode = NULL;
+ if (sb->s_bdi == &noop_backing_dev_info)
+ return;
+
spin_lock(&sb->s_inode_list_lock);
list_for_each_entry(inode, &sb->s_inodes, i_sb_list) {
spin_lock(&inode->i_lock);
--
2.53.0
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] fs/drop_caches: skip filesystems without fs writeback
2026-09-23 7:01 [PATCH] fs/drop_caches: skip filesystems without fs writeback Huang Shijie
@ 2026-09-23 11:04 ` Jan Kara
2026-09-25 6:57 ` Christoph Hellwig
1 sibling, 0 replies; 3+ messages in thread
From: Jan Kara @ 2026-09-23 11:04 UTC (permalink / raw)
To: Huang Shijie
Cc: viro, brauner, zhongyuan, fangbaoshun, yingzhiwei, jack,
linux-fsdevel, linux-kernel, yefan, Christoph Hellwig
On Wed 23-09-26 15:01:16, Huang Shijie wrote:
> Filesystems backed by the noop backing device (procfs, sysfs, kernfs,
> tmpfs, ramfs, etc.) have no fs page-cache writeback. Skip them in
> drop_pagecache_sb() instead of walking their inode lists.
>
> This also skips tmpfs/ramfs. tmpfs has clean folios which are
> zero-filled pages from reading holes, which are trivially recreatable.
>
> Suggested-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Huang Shijie <huangsj@hygon.cn>
This looks indeed nice & simple. I'm slightly wondering if there isn't some
exotic read-only fs somewhere which doesn't set sb->s_bdi but so far I'm
not aware of anything (even MTD filesystems do properly setup bdi) so feel
free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> The RFC mails:
> https://lore.kernel.org/all/arIVBpMZk5-O2AZc@infradead.org/
> ---
> fs/drop_caches.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/fs/drop_caches.c b/fs/drop_caches.c
> index 49f56a598ecb..28c5fb9c7357 100644
> --- a/fs/drop_caches.c
> +++ b/fs/drop_caches.c
> @@ -7,6 +7,7 @@
> #include <linux/kernel.h>
> #include <linux/mm.h>
> #include <linux/fs.h>
> +#include <linux/backing-dev.h>
> #include <linux/writeback.h>
> #include <linux/sysctl.h>
> #include <linux/gfp.h>
> @@ -20,6 +21,9 @@ static void drop_pagecache_sb(struct super_block *sb, void *unused)
> {
> struct inode *inode, *toput_inode = NULL;
>
> + if (sb->s_bdi == &noop_backing_dev_info)
> + return;
> +
> spin_lock(&sb->s_inode_list_lock);
> list_for_each_entry(inode, &sb->s_inodes, i_sb_list) {
> spin_lock(&inode->i_lock);
> --
> 2.53.0
>
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] fs/drop_caches: skip filesystems without fs writeback
2026-09-23 7:01 [PATCH] fs/drop_caches: skip filesystems without fs writeback Huang Shijie
2026-09-23 11:04 ` Jan Kara
@ 2026-09-25 6:57 ` Christoph Hellwig
1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2026-09-25 6:57 UTC (permalink / raw)
To: Huang Shijie
Cc: viro, brauner, zhongyuan, fangbaoshun, yingzhiwei, jack,
linux-fsdevel, linux-kernel, yefan, Christoph Hellwig
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-25 6:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-23 7:01 [PATCH] fs/drop_caches: skip filesystems without fs writeback Huang Shijie
2026-09-23 11:04 ` Jan Kara
2026-09-25 6:57 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®