]> code.ossystems Code Review - openembedded-core.git/commitdiff
nfs-utils: decrease RLIMIT_NOFILE to 4k for systemd
authorHongxu Jia <hongxu.jia@windriver.com>
Tue, 20 Aug 2019 05:45:18 +0000 (01:45 -0400)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 22 Aug 2019 16:35:43 +0000 (17:35 +0100)
On systemd, it set RLIMIT_NOFILE to 512k, since do_testimage
for core-image-sato-sdk has memory limitation (256Mib) which
caused rpc.statd failed with out of memory.
[  531.306146] Out of memory: Kill process 193 (rpc.statd) score 200 or sacrifice child

The rpc.statd and rpc.mountd allocates memory according to
RLIMIT_NOFILE, so decrease it to 4k to keep sync with sysvinit

After applying the patch, the memory cost is the same with sysvinit:

root@qemux86-64:~# systemctl status nfs-statd
* nfs-statd.service - NFS status monitor for NFSv2/3 locking.
   Loaded: loaded (/lib/systemd/system/nfs-statd.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2019-08-20 03:16:18 UTC; 3min 26s ago
 Main PID: 343 (rpc.statd)
    Tasks: 1 (limit: 271)
   Memory: 1.0M

root@qemux86-64:~# systemctl status nfs-mountd
* nfs-mountd.service - NFS Mount Daemon
   Loaded: loaded (/etc/systemd/system/nfs-mountd.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2019-08-20 03:19:01 UTC; 1min 21s ago
 Main PID: 451 (rpc.mountd)
    Tasks: 1 (limit: 271)
   Memory: 736.0K

Suggested-by: Chen Qi <qi.chen@windriver.com>
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-connectivity/nfs-utils/nfs-utils/nfs-mountd.service
meta/recipes-connectivity/nfs-utils/nfs-utils/nfs-statd.service
meta/recipes-connectivity/nfs-utils/nfs-utils_2.3.3.bb

index 3c3a8022ce80cc3fc83fefa120c96c6ba3754854..c01415de842f6a020f2cbcdf77e9d42f8638d032 100644 (file)
@@ -11,6 +11,7 @@ ConditionPathExists=@SYSCONFDIR@/exports
 [Service]
 EnvironmentFile=-@SYSCONFDIR@/nfs-utils.conf
 ExecStart=@SBINDIR@/rpc.mountd -F $MOUNTD_OPTS
+LimitNOFILE=@HIGH_RLIMIT_NOFILE@
 
 [Install]
 WantedBy=multi-user.target
index 6e196b8c8c16f9bc878ee2aa12aa79091626feab..4fa64e19980850bbdd17b357e527271817b1f05d 100644 (file)
@@ -8,6 +8,7 @@ After=network.target nss-lookup.target rpcbind.service
 [Service]
 EnvironmentFile=-@SYSCONFDIR@/nfs-utils.conf
 ExecStart=@SBINDIR@/rpc.statd -F $STATD_OPTS
+LimitNOFILE=@HIGH_RLIMIT_NOFILE@
 
 [Install]
 WantedBy=multi-user.target
index ac4437b9252e78f7807de374291b7fff4f350f74..28f98980d4b61b3bde760ac623f15e0e1542d4ff 100644 (file)
@@ -119,6 +119,9 @@ do_compile_prepend() {
        make clean
 }
 
+# Works on systemd only
+HIGH_RLIMIT_NOFILE ??= "4096"
+
 do_install_append () {
        install -d ${D}${sysconfdir}/init.d
        install -m 0755 ${WORKDIR}/nfsserver ${D}${sysconfdir}/init.d/nfsserver
@@ -133,6 +136,7 @@ do_install_append () {
        install -m 0644 ${WORKDIR}/nfs-statd.service ${D}${systemd_unitdir}/system/
        sed -i -e 's,@SBINDIR@,${sbindir},g' \
                -e 's,@SYSCONFDIR@,${sysconfdir},g' \
+               -e 's,@HIGH_RLIMIT_NOFILE@,${HIGH_RLIMIT_NOFILE},g' \
                ${D}${systemd_unitdir}/system/*.service
        if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
            install -m 0644 ${WORKDIR}/proc-fs-nfsd.mount ${D}${systemd_unitdir}/system/