linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drop caches: skip tmpfs and ramfs
@ 2022-06-24 18:21 cgel.zte
  2022-06-25  9:19 ` Christoph Hellwig
  2022-06-25  9:31 ` Gao Xiang
  0 siblings, 2 replies; 3+ messages in thread
From: cgel.zte @ 2022-06-24 18:21 UTC (permalink / raw)
  To: viro, hughd; +Cc: ran.xiaokai, linux-fsdevel, linux-kernel, linux-mm

From: Ran Xiaokai <ran.xiaokai@zte.com.cn>

All tmpfs and ramfs pages have PG_dirty bit set
once they are allocated and added to the pagecache。So pages
can not be freed from tmpfs or ramfs. So skip tmpfs and ramfs
when drop caches.

Signed-off-by: Ran Xiaokai <ran.xiaokai@zte.com.cn>
---
 fs/drop_caches.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/drop_caches.c b/fs/drop_caches.c
index e619c31b6bd9..600c043c1eb7 100644
--- a/fs/drop_caches.c
+++ b/fs/drop_caches.c
@@ -10,6 +10,7 @@
 #include <linux/writeback.h>
 #include <linux/sysctl.h>
 #include <linux/gfp.h>
+#include <linux/magic.h>
 #include "internal.h"
 
 /* A global variable is a bit ugly, but it keeps the code simple */
@@ -19,6 +20,9 @@ static void drop_pagecache_sb(struct super_block *sb, void *unused)
 {
 	struct inode *inode, *toput_inode = NULL;
 
+	if (sb->s_magic == TMPFS_MAGIC || sb->s_magic == RAMFS_MAGIC)
+		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.15.2



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drop caches: skip tmpfs and ramfs
  2022-06-24 18:21 [PATCH] drop caches: skip tmpfs and ramfs cgel.zte
@ 2022-06-25  9:19 ` Christoph Hellwig
  2022-06-25  9:31 ` Gao Xiang
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2022-06-25  9:19 UTC (permalink / raw)
  To: cgel.zte; +Cc: viro, hughd, ran.xiaokai, linux-fsdevel, linux-kernel, linux-mm

On Fri, Jun 24, 2022 at 06:21:21PM +0000, cgel.zte@gmail.com wrote:
> From: Ran Xiaokai <ran.xiaokai@zte.com.cn>
> 
> All tmpfs and ramfs pages have PG_dirty bit set
> once they are allocated and added to the pagecache。So pages
> can not be freed from tmpfs or ramfs. So skip tmpfs and ramfs
> when drop caches.

Hard coding magic constants in VFS code is a bad idea.  If you have
numbers to justify this change (which should go into this commit log),
it can be properly solved by a flag on the super block,
file_system_type or even better bdi.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drop caches: skip tmpfs and ramfs
  2022-06-24 18:21 [PATCH] drop caches: skip tmpfs and ramfs cgel.zte
  2022-06-25  9:19 ` Christoph Hellwig
@ 2022-06-25  9:31 ` Gao Xiang
  1 sibling, 0 replies; 3+ messages in thread
From: Gao Xiang @ 2022-06-25  9:31 UTC (permalink / raw)
  To: cgel.zte; +Cc: viro, hughd, ran.xiaokai, linux-fsdevel, linux-kernel, linux-mm

On Fri, Jun 24, 2022 at 06:21:21PM +0000, cgel.zte@gmail.com wrote:
> From: Ran Xiaokai <ran.xiaokai@zte.com.cn>
> 
> All tmpfs and ramfs pages have PG_dirty bit set
> once they are allocated and added to the pagecache。So pages

minor,
                                                    ^
                                   Chinese full stop here..

Thanks,
Gao Xiang


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-06-25  9:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-24 18:21 [PATCH] drop caches: skip tmpfs and ramfs cgel.zte
2022-06-25  9:19 ` Christoph Hellwig
2022-06-25  9:31 ` Gao Xiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).