Skip to contentSkip to conversation

2.2/2.4/2.6 VMs: do malloc() ever return NULL?

DISCUSSION Ihar 'Philips' Filipau 2 participants 3 messages Nov 26, 2003 2 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 5 lines · Rik van Riel
Quoted 2 lines · Ihar 'Philips' Filipau
Quoted 2 lines
# echo 2 > /proc/sys/vm/overcommit_memory
Quoted 9 lines
Quoted 4 lines
Quoted 1 line

Then try again.

What do you know what is not said in docs?
What '2' means?

Strict non-overcommit mode. You can allocate as much non-file-backed virtual memory as will fit in swap, plus /proc/sys/vm/overcommit_percentage worth of memory.

[ s/overcommit_percentage/overcommit_ratio/ ]

Thanks! On 2.6 it works as expected. Test with two concurrent memory
allocations took some time, but both apps stops exactly when memory was depleted. Great.

Did rmap has something todo with this?
As I see from implementation of do_mmap_pgoff() - it changed from 2.4
to 2.6 - but there are a lot of common things.
If I will do dumb back port of this check to 2.4 - do you think it
will work? 2.4->2.6 memory accounting changed?
I didn't found this check in your rmap patches for 2.4.22. (btw
thanks for keeping them up-to-date).

Signature · 7 lines
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
#3 lore raw
Quoted 3 lines · Rik van Riel
Quoted 3 lines

Strict non-overcommit mode. You can allocate as much non-file-backed virtual memory as will fit in swap, plus /proc/sys/vm/overcommit_percentage worth of memory.

Quoted 11 lines · Ihar 'Philips' Filipau

[ s/overcommit_percentage/overcommit_ratio/ ]
Thanks! On 2.6 it works as expected. Test with two concurrent memory
allocations took some time, but both apps stops exactly when memory was depleted. Great.
Did rmap has something todo with this?
As I see from implementation of do_mmap_pgoff() - it changed from 2.4
to 2.6 - but there are a lot of common things.
If I will do dumb back port of this check to 2.4 - do you think it
will work? 2.4->2.6 memory accounting changed?
I didn't found this check in your rmap patches for 2.4.22. (btw
thanks for keeping them up-to-date).

In principle, non-overcommit shouldn't be dependent on rmap, as it largely consists of keeping track of the sum of MAP_PRIVATE virtual mappings' sizes and refusing them when they exceed RAM + swap.

-- wli

#4 lore raw
Quoted 21 lines · William Lee Irwin III
Quoted 3 lines · Rik van Riel
Quoted 3 lines

Strict non-overcommit mode. You can allocate as much non-file-backed virtual memory as will fit in swap, plus /proc/sys/vm/overcommit_percentage worth of memory.

Quoted 10 lines · Ihar 'Philips' Filipau

[ s/overcommit_percentage/overcommit_ratio/ ]
Thanks! On 2.6 it works as expected. Test with two concurrent memory
allocations took some time, but both apps stops exactly when memory was depleted. Great.
Did rmap has something todo with this?
As I see from implementation of do_mmap_pgoff() - it changed from 2.4
to 2.6 - but there are a lot of common things.
If I will do dumb back port of this check to 2.4 - do you think it
will work? 2.4->2.6 memory accounting changed?
I didn't found this check in your rmap patches for 2.4.22. (btw
thanks for keeping them up-to-date).

Quoted 4 lines

In principle, non-overcommit shouldn't be dependent on rmap, as it largely consists of keeping track of the sum of MAP_PRIVATE virtual mappings' sizes and refusing them when they exceed RAM + swap.

That's the point of my question. I know a few about MM in Linux. As I
understand memory accounting is most complicated: 1st how to account kernel allocatable memory, 2nd how to reliably calculate already allocated memory. (1st looks like not present even in 2.6, 2nd not present in 2.4.)

As I understood, default overcommit_ratio=90% is made especially to
protect kernel from running out of memory. And 2.6 does offset available memory by 3% for all non-root allocation checks.

But I cannot find any similar accounting stuff in 2.4... Hard to draw parallels.

Will appreciate any advice.

Signature · 7 lines
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