summaryrefslogtreecommitdiff
path: root/package/base-files
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@nbd.name>2016-08-01 14:52:13 +0200
committerFelix Fietkau <nbd@nbd.name>2016-08-01 14:53:27 +0200
commit5c9cc7b7f8920944a413644e1c2ea23bfe655bcb (patch)
treec5da77de97d3c6e1b01d002621b9db916cae8b25 /package/base-files
parentdf3a2ca1a9154361167e0e30745ca7954bf13b6f (diff)
downloadmtk-20170518-5c9cc7b7f8920944a413644e1c2ea23bfe655bcb.zip
mtk-20170518-5c9cc7b7f8920944a413644e1c2ea23bfe655bcb.tar.gz
mtk-20170518-5c9cc7b7f8920944a413644e1c2ea23bfe655bcb.tar.bz2
base-files: increase vm.min_free_kbytes
Network drivers typically allocate memory in atomic context. For that to be reliable, there needs to be enough free memory. Set the value heuristically based on the total amount of system RAM. Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'package/base-files')
-rwxr-xr-xpackage/base-files/files/etc/init.d/sysctl16
1 files changed, 16 insertions, 0 deletions
diff --git a/package/base-files/files/etc/init.d/sysctl b/package/base-files/files/etc/init.d/sysctl
index 2dfbaf7..a0daec0 100755
--- a/package/base-files/files/etc/init.d/sysctl
+++ b/package/base-files/files/etc/init.d/sysctl
@@ -2,7 +2,23 @@
# Copyright (C) 2006 OpenWrt.org
START=11
+
+set_vm_min_free() {
+ mem="$(grep MemTotal /proc/meminfo | awk '{print $2}')"
+ if [ "$mem" -gt 65536 ]; then # 128M
+ val=16384
+ elif [ "$mem" -gt 32768 ]; then # 64M
+ val=8192
+ elif [ "$mem" -gt 16384 ]; then # 32M
+ val=4096
+ else
+ return
+ fi
+ sysctl -qw vm.min_free_kbytes="$val"
+}
+
start() {
+ set_vm_min_free
for CONF in /etc/sysctl.conf /etc/sysctl.d/*.conf; do
[ -f "$CONF" ] && sysctl -p "$CONF" -e >&-
done