Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Jun 2016 20:52:38 +0300
From:      Artem Kuchin <artem@artem.ru>
To:        FreeBSD Questions Mailing List <freebsd-questions@freebsd.org>
Subject:   rctl memory usage count and swap
Message-ID:  <60ecb4a9-c3c5-6bfd-e032-21fa5f03c85a@artem.ru>

next in thread | raw e-mail | index | archive | help
Hello

freebsd 10.2

I have apache in jail, each apache in running under its own user, so, i 
have many user in one jail

and many httpd processed started under that users.

I wanted to limit memory usage per user and disable swap for all of them.

So, i use rctl

I try such rules

vmemoryuse:log=1g
swapuse:log=0

Now two problem appeared immediately

1) VMEMORYUSE

I see messages in log file like this

kernel: rctl: rule "user:17032:vmemoryuse:log=1073741824" matched by pid 
40360 (httpd), uid 17032, jail XXX

So, it seems like user overused memory, i check

# rctl -u user:17032
cputime=37
datasize=368640
stacksize=0
coredumpsize=0
memoryuse=329007104
memorylocked=0
maxproc=10
openfiles=320
vmemoryuse=4147863552
pseudoterminals=0
swapuse=6148096
nthr=9
msgqqueued=0
msgqsize=0
nmsgq=0
nsem=0
nsemop=0
nshm=0
shmsize=0
wallclock=28270
pcpu=0

Aha, seems like the user used 4G of virtual memory and 329M of real memory

No lets see its processes

17032  2213     1   0  21  0 446372  27808 select SsJ   - 0:02.47 
/usr/local/sbin/httpd
17032 30173  2213   0  20  0 450468  39644 accept IJ    -  0:00.29 
/usr/local/sbin/httpd
17032 39611  2213   0  20  0 450468  37160 accept IJ    -  0:00.06 
/usr/local/sbin/httpd
17032 39612  2213   0  20  0 450468  36712 accept IJ    -  0:00.05 
/usr/local/sbin/httpd
17032 39613  2213   0  20  0 450468  36608 accept IJ    -  0:00.06 
/usr/local/sbin/httpd
17032 39614  2213   0  20  0 450468  36624 accept IJ    -  0:00.05 
/usr/local/sbin/httpd
17032 39617  2213   0  20  0 450468  37144 accept IJ    -  0:00.03 
/usr/local/sbin/httpd
17032 39618  2213   0  20  0 450468  36268 accept SJ    -  0:00.04 
/usr/local/sbin/httpd
17032 39619  2213   0  20  0 450468  36432 accept IJ    -  0:00.05 
/usr/local/sbin/httpd
17032 39621  2213   0  20  0 450468  36332 accept IJ    -  0:00.04 
/usr/local/sbin/httpd
17032 39623  2213   0  20  0 450468  36988 accept IJ    -  0:00.06 
/usr/local/sbin/httpd
17032 39624  2213   0  20  0 450468  36212 accept IJ    -  0:00.03 
/usr/local/sbin/httpd
17032 39626  2213   0  20  0 450468  36544 accept IJ    -  0:00.04 
/usr/local/sbin/httpd
17032 39627  2213   0  20  0 450468  37360 accept IJ    -  0:00.06 
/usr/local/sbin/httpd
17032 39628  2213   0  20  0 450468  36772 accept IJ    -  0:00.04 
/usr/local/sbin/httpd
17032 39633  2213   0  20  0 450468  34972 accept IJ    -  0:00.04 
/usr/local/sbin/httpd
17032 39634  2213   0  20  0 450468  36104 accept IJ    -  0:00.03 
/usr/local/sbin/httpd
17032 39635  2213   0  20  0 450468  35784 accept IJ    -  0:00.03 
/usr/local/sbin/httpd
17032 39637  2213   0  20  0 450468  36232 accept IJ    -  0:00.04 
/usr/local/sbin/httpd
17032 39638  2213   0  20  0 450468  36620 accept IJ    -  0:00.04 
/usr/local/sbin/httpd
17032 39645  2213   0  20  0 450468  36084 accept IJ    -  0:00.04 
/usr/local/sbin/httpd
17032 39649  2213   0  20  0 450468  36356 accept SJ    -  0:00.04 
/usr/local/sbin/httpd
17032 39652  2213   0  20  0 450468  36156 accept SJ    -  0:00.04 
/usr/local/sbin/httpd
17032 39653  2213   0  20  0 450468  35436 accept SJ    -  0:00.03 
/usr/local/sbin/httpd
17032 39655  2213   0  20  0 450468  37752 accept SJ    -  0:00.04 
/usr/local/sbin/httpd
17032 39657  2213   0  20  0 450468  35664 accept IJ    -  0:00.03 
/usr/local/sbin/httpd
17032 39661  2213   0  20  0 450468  36228 accept SJ    -  0:00.04 
/usr/local/sbin/httpd

As you see the virtual memory is 100% shared and RSS is at most 930M

Where rctl gets its number?

memoryuse=329007104
vmemoryuse=4147863552

2) swapuse:log=0

This rule create strange problems (when used with deny)

Jun  2 20:24:57 omni kernel: rctl: rule "user:17094:swapuse:log=0" 
matched by pid 27553 (httpd), uid 17094, jail XXXX
Jun  2 20:24:57 omni kernel: kern.ipc.maxpipekva exceeded; see tuning(7)

As you see from rctl -u  it shows

swapuse=6148096

but!

# swapinfo
Device          1K-blocks     Used    Avail Capacity
/dev/mirror/swap   4194300        0  4194300     0%

So, not swap is really used

But even if i do swapuse:log=300M i get the same error

And what maxpopekva has to do with it?

Is rctl really usable in 10.2 ?





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?60ecb4a9-c3c5-6bfd-e032-21fa5f03c85a>