lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20220628034517.24861-1-duguoweisz@gmail.com>
Date:   Tue, 28 Jun 2022 11:45:17 +0800
From:   Guowei Du <duguoweisz@...il.com>
To:     jaegeuk@...nel.org, chao@...nel.org
Cc:     linux-f2fs-devel@...ts.sourceforge.net,
        linux-kernel@...r.kernel.org, duguowei <duguowei@...omi.com>
Subject: [PATCH 4/4] f2fs: add swap space for memory using

From: duguowei <duguowei@...omi.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@...omi.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ