From: "Ihar 'Philips' Filipau" <filia@softhome.net>
To: William Lee Irwin III <wli@holomorphy.com>
Cc: root@chaos.analogic.com,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: 2.2/2.4/2.6 VMs: do malloc() ever return NULL?
Date: Wed, 26 Nov 2003 15:33:06 +0100 [thread overview]
Message-ID: <3FC4B9A2.7050204@softhome.net> (raw)
In-Reply-To: <20031126132719.GP8039@holomorphy.com>
William Lee Irwin III wrote:
> On Wed, Nov 26, 2003 at 02:20:58PM +0100, Ihar 'Philips' Filipau wrote:
>
>> So what do you use then in user space to reliably allocate memory?
>> As to me - memory is a resource. Is it virtual or is it physical - it
>>is still resource. And I need to allocate part of this resource.
>> malloc() uses brk() inside. But brk() is "implementation details". I
>>honestly do not care about them - I just want to be sure that what ever
>>resource I have allocated - I can use it afterwards until I shall free
>>it. POSIX even doesn't mention brk() BTW.
>> If you can hint me any other method to allocate memory without
>>surprises - I will really appreciate.
>
>
> Non-overcommit is one such method at the kernel level.
> mlockall(MCL_CURRENT|MCL_FUTURE) is another (requiring support at both
> levels, in addition to administrative grants of privilege).
>
"requiring support at both levels" - what do you mean by this?
In other words, right after I have allocated all memory I need for
functioning properly, I can call mlockall(MCL_CURRENT) - and memory of
my app will be guarantied to be present in memory?
If I have understood from man - it will not be swapped out?
Yeah... Nice. Cool. I have no swap in any way ;-)
I do not need that heavy gun: as I have said looser term of memory
being really allocated before malloc() returns - is enough for me. But
as I have guessed overcommit_memory doesn't guarantie this either.
But it looks like this is more appropriate solution for my situation.
(more apropriate comparing to overcommit_memory)
In critical pathes we use only pool based allocators - so we can lock
them in RAM.
How can I tell the limit of the RAM which can be locked?
My test had shown that single application can lock 112MB of RAM, but
fails to lock 128MB of RAM. (I have 256MB phy RAM - We just cannot find
smaller memory modules on market in any way :-))
Is it limited to less than half of physical RAM?
This would be Ok for me in any way.
...
Little bit more test results (2.4.18, 256MB RAM, Motorola's
PowerQuiccIII 8280):
overcommit_memory==0 (default): three memory eater apps run ok.
fourth app which tryes to mlock() /successfully/ allocated 64MB of
memory hang my box.
overcommit_memory==-1: three memory eater apps run ok. fourth app
fails to allocate its memory. All successful memory allocations do mlock
Okay. As by my incomplete tests.
That sounds like results ;-)
Thanks everyone for help and this results!
--
Ihar 'Philips' Filipau / with best regards from Saarbruecken.
-- _ _ _
Because the kernel depends on it existing. "init" |_|*|_|
literally _is_ special from a kernel standpoint, |_|_|*|
because its' the "reaper of zombies" (and, may I add, |*|*|*|
that would be a great name for a rock band).
-- Linus Torvalds
next prev parent reply other threads:[~2003-11-26 14:33 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-25 13:27 2.2/2.4/2.6 VMs: do malloc() ever return NULL? Ihar 'Philips' Filipau
2003-11-25 14:00 ` Arjan van de Ven
2003-11-25 16:58 ` Rik van Riel
2003-11-25 19:03 ` Ihar 'Philips' Filipau
2003-11-25 19:24 ` Rik van Riel
2003-11-25 19:28 ` Chris Wright
2003-11-25 20:17 ` Richard B. Johnson
2003-11-25 23:17 ` Ihar 'Philips' Filipau
2003-11-25 23:40 ` Oliver
2003-11-26 13:06 ` Richard B. Johnson
2003-11-26 13:20 ` Ihar 'Philips' Filipau
2003-11-26 13:27 ` William Lee Irwin III
2003-11-26 14:33 ` Ihar 'Philips' Filipau [this message]
2003-11-26 14:36 ` William Lee Irwin III
2003-11-26 13:49 ` Richard B. Johnson
2003-11-26 14:39 ` Ihar 'Philips' Filipau
2003-11-26 7:31 ` Tim Connors
2003-11-26 9:58 ` William Lee Irwin III
[not found] <VLAm.2g1.9@gated-at.bofh.it>
[not found] ` <VM3n.3jY.9@gated-at.bofh.it>
2003-11-25 15:23 ` Ihar 'Philips' Filipau
[not found] <VQJL.62Q.11@gated-at.bofh.it>
[not found] ` <VR3c.6Ns.21@gated-at.bofh.it>
2003-11-26 10:30 ` Ihar 'Philips' Filipau
2003-11-26 10:39 ` William Lee Irwin III
2003-11-26 12:14 ` Ihar 'Philips' Filipau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3FC4B9A2.7050204@softhome.net \
--to=filia@softhome.net \
--cc=linux-kernel@vger.kernel.org \
--cc=root@chaos.analogic.com \
--cc=wli@holomorphy.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox