[PATCH] base-files: update min_free_kbytes configuration

quic_shoudil at quicinc.com quic_shoudil at quicinc.com
Tue Jan 2 18:32:18 PST 2024


From: Zhuo Fu <quic_zfu at quicinc.com>

set proper min_free_kbytes for small RAM device to avoid
OOM during device boot up.

Signed-off-by: shoudil <quic_shoudil at quicinc.com>
---
 package/base-files/files/etc/init.d/sysctl | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/package/base-files/files/etc/init.d/sysctl b/package/base-files/files/etc/init.d/sysctl
index 4db56444c7..742a978cee 100755
--- a/package/base-files/files/etc/init.d/sysctl
+++ b/package/base-files/files/etc/init.d/sysctl
@@ -7,12 +7,14 @@ apply_defaults() {
 	local mem="$(awk '/^MemTotal:/ {print $2}' /proc/meminfo)"
 	local min_free frag_low_thresh frag_high_thresh
 
-	if [ "$mem" -gt 65536 ]; then # 128M
+	if [ "$mem" -gt 262144 ]; then # 512M
 		min_free=16384
-	elif [ "$mem" -gt 32768 ]; then # 64M
-		min_free=8192
+	elif [ "$mem" -gt 131072 ]; then # 256M
+		min_free=3072
+	elif [ "$mem" -gt 32768 ]; then # 64M or 128M
+		min_free=512
 	else
-		min_free=1024
+		min_free=512
 		frag_low_thresh=393216
 		frag_high_thresh=524288
 	fi
-- 
2.25.1




More information about the openwrt-devel mailing list