[OpenWrt-Devel] procd limits usage

Yousong Zhou yszhou4tech at gmail.com
Wed Jan 7 06:32:31 EST 2015


On 7 January 2015 at 00:19, Karl Palsson <karlp at tweak.net.au> wrote:
> Hi,
>
> I'm trying out using procd to kill/restart processes that use too much
> memory, using the "limits" feature added in
> https://lists.openwrt.org/pipermail/openwrt-devel/2013-December/022793.html
> and I've confirmed that it's available in the BB branch procd that I'm
> testing against.
>
> My init script looks like so...
>
> # cat /etc/init.d/hogger
> #!/bin/sh /etc/rc.common
> START=85
> USE_PROCD=1
> PROCD_DEBUG=1
> APP=hogger
>
>
> start_service() {
>     procd_open_instance
>     procd_set_param command $APP
>     procd_append_param limits data=4000
>     procd_set_param respawn
>     procd_close_instance
> }
>
> Starting this service gives a nice debug output from procd, such as:
>
> # /etc/init.d/hogger start
> { "name": "hogger", "script": "\/etc\/init.d\/hogger", "instances": { "instance1": { "command": [ "hogger" ], "limits": { "data": "4000" }, "respawn": [ ] } } }
>
>
> The "hogger" application just uses malloc/free to raise/lower it's
> memory usage, and /proc/$PID/status shows that the VmData field
> increases, eg...
>
>
>
> VmPeak:     4492 kB
> VmSize:     4488 kB
> VmRSS:      1144 kB
> VmData:     1812 kB
> ....
> VmPeak:     6536 kB
> VmSize:     6536 kB
> VmRSS:      3216 kB
> VmData:     3860 kB
> ....
> VmPeak:    10632 kB
> VmSize:    10632 kB
> VmRSS:      7308 kB
> VmData:     7956 kB
>

Which libc was in use?  Because RLIMIT_DATA only applies to those
allocated by brk() and sbrk(), while malloc() of glibc may fallback to
mmap() if sbrk() fails.  AFAIK, malloc() of uClibc for MIPS in OpenWrt
utilizes only sbrk() with the default config.

> But procd does nothing that I can see, no logging, no restarting.  Is
> this the correct usage? Is there some other way these procd limits are
> meant to be used?  The only reference to a procd init script using this
> feature is
> https://github.com/zqlee/smartproxy/blob/master/files/smartproxy.init

"as=" (RTLIMIT_AS) is another option you can try.

Regards,

                yousong

>
> Sincerely,
> Karl P
>
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
>
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list