[Samba] Restriciting memory usage for samba using Cgroups

Volker Lendecke Volker.Lendecke at SerNet.DE
Mon Aug 11 04:21:09 MDT 2014


On Mon, Aug 11, 2014 at 12:04:40PM +0530, Jonnavithula Sharma wrote:
> Hi
> 
> Currently we are using cgroups to limit samba memory usage on our target
> 
> we have limited the memory to 20MB and we are able to see samba is
> restricted to it.
> 
> With this we are able to restrict the cache memory to ~34MB (never goes
> beyond this)
> 
> BUt issue we arere facing is the Buffers are increasing gradually and it is
> not able to restrict.
> 
> Commands Used to restrict memory on target:
> 
> echo <samba pid >default/tasks
> echo 20971520 > default/memory.limit_in_bytes
> 
> Initial memory status:
> root at ltqcpe:/sys/fs/cgroup/memory# cat /proc/meminfo
> MemTotal:         113760 kB
> MemFree:           41692 kB
> Buffers:            4108 kB
> Cached:            30936 kB
> SwapCached:            0 kB
> 
> After 5 hrs memory Status Looks like this
> root at ltqcpe:/sys/fs/cgroup/memory# cat /proc/meminfo
> cat /proMemTotal:         113760 kB
> MemFree:            9744 kB
> Buffers:           33448 kB
> Cached:            32144 kB
> SwapCached:            0 kB
> 
> Did some one faced this issue?
> Could some one has any inputs to fix this problem?Is there any way to limit
> buffers also

I'd say that this is more a kernel question than a Samba
one. Samba is user space and has no control how the kernel
makes use of the physical memory it has. All Samba can do is
not leak memory :-)

If you limit Samba to something very low, and I would
consider 20MB for all Samba processes together very low,
then eventually you might run into problems. I'm sure that
Samba does not really handle an out-of-memory condition
gracefully at every point. I hope we don't segfault, but we
might exit a server hard when it reaches its limit.

What is your goal? Why do you want a hard limit on the
buffers in-kernel? In my experience, the kernel is pretty
good at balancing the various types of memory allocation.
And unused physical memory is badly used. If free space is
available, why not use it for buffers?

If you have an application that is supposed to NEVER be
swapped out under pressure, you might want to mlock() the
affected ranges and let the kernel balance the rest.

With best regards,

Volker Lendecke

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de


More information about the samba mailing list