linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH 4/4] f2fs: add swap space for memory using
@ 2022-06-28  3:45 Guowei Du
  0 siblings, 0 replies; only message in thread
From: Guowei Du @ 2022-06-28  3:45 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: linux-kernel, duguowei, linux-f2fs-devel

From: duguowei <duguowei@xiaomi.com>

If device enables swap file, enlarging the memory usage for each
monitored item. It can be adjusted by ram_thresh sysfs node.

Signed-off-by: duguowei <duguowei@xiaomi.com>
---
 fs/f2fs/node.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 836c79a20afc..f1cf3d2bc7c2 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -54,9 +54,12 @@ bool f2fs_available_free_memory(struct f2fs_sb_info *sbi, int type)
 		return true;
 
 	si_meminfo(&val);
+	si_swapinfo(&val);
 
 	/* only uses low memory */
 	avail_ram = val.totalram - val.totalhigh;
+	/* if there is swap space, use it too.*/
+	avail_ram += val.totalswap;
 
 	/*
 	 * give 25%, 25%, 50%, 50%, 50% memory for each components respectively
@@ -96,7 +99,7 @@ bool f2fs_available_free_memory(struct f2fs_sb_info *sbi, int type)
 		res = mem_size < (avail_ram * nm_i->ram_thresh / 100);
 	} else if (type == COMPRESS_PAGE) {
 #ifdef CONFIG_F2FS_FS_COMPRESSION
-		unsigned long free_ram = val.freeram;
+		unsigned long free_ram = val.freeram + val.freeswap;
 
 		/*
 		 * free memory is lower than watermark or cached page count
-- 
2.36.1



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-28  3:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-28  3:45 [f2fs-dev] [PATCH 4/4] f2fs: add swap space for memory using Guowei Du

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).