Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Mar 2007 17:26:56 +0100 (CET)
From:      Oliver Fromme <olli@lurza.secnetix.de>
To:        freebsd-stable@FreeBSD.ORG, michael.schuh@gmail.com
Subject:   Re: another error with md malloc based fs
Message-ID:  <200703231626.l2NGQukl004840@lurza.secnetix.de>
In-Reply-To: <1dbad3150703221655w62284ed7o8a5c7440aca45891@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Michael Schuh wrote:
 > Chuck Swiger wrote:
 > > Michael Schuh wrote:
 > > > i can't understand how malloc can eat all available
 > > > memory, i have 2Gigs of it ;-)
 > > > so it seems to me i know what i doing, if
 > > > i have 1,6 Gigs free Memory, and i say ok get me 750Megs from
 > > > my 1,6 Gigs of free Memory, what was faulty on that????
 > > 
 > > The two choices involve a swap-based RAMdisk, which can use all of
 > > the available physical RAM it needs to, since this memory is
 > > swappable, or a kernel-memory-based RAMdisk, which uses wired-down
 > > memory from within the kernel.
 > 
 > Ok, so that is it harder to understand for me in the first time,
 > if i understand it now right the swap or file based memory backend
 > is also in the ram, but it get another way managed from kernels vm.
 > the malloc based ramdisk get's not reallly managed by the kvm,
 > but it underlays under the paging and swapping, and also
 > ba the "thread-killer" there shot's thread down it it get's to much
 > work for the system....
 > 
 > i hope i understand this right, it is important for me...

Let me try to explain it with a little different words.
The following is a bit simplified, but it should give
you an idea about the advantages and disadvantages of
each md disk type.

First of all, _both_ "malloc" and "swap"-backed md disks
are RAM disks.  You don't have to worry that a swap-backed
md disk will be created on your swap partiton.  It's not.
It will reside in RAM, just like a "malloc" md disk.

However, the difference is that a malloc md disk uses
memory from the KVM area (kernel virtual memory), which
is hardwired into the RAM.  It cannot be paged, and it
is taken from the kernel's own memory pool, which is
usually much smaller than your total available RAM.
It's taken from the same pool of RAM that's used for
network buffers, driver data and similar things.

On the other hand, "swap-backed" md disks use regular
memory, so to speak, just like a normal user process.
That also means that they are pageable, which means
that they can be paged to swap if necessary (if the
systems runs low on RAM).  That's what "swap-backed"
means.  Because of that, they don't have a size limit
(well, they shouldn't be bigger than your RAM + swap,
of course).  If there is enough RAM, then they will
stay completely in RAM and will _not_ touch your swap
at all.

For typical RAM disks, such as for /tmp, you should use
a swap-backed md disk (it should be the default).  The
"malloc" type should be used only for rather small,
special uses.

I hope it's now a little clearer.

Best regards
   Oliver

-- 
Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606,  Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758,  Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart

FreeBSD-Dienstleistungen, -Produkte und mehr:  http://www.secnetix.de/bsd

"[...]  one observation we can make here is that Python makes
an excellent pseudocoding language, with the wonderful attribute
that it can actually be executed."  --  Bruce Eckel



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200703231626.l2NGQukl004840>