public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
[parent not found: <VLAm.2g1.9@gated-at.bofh.it>]
* 2.2/2.4/2.6 VMs: do malloc() ever return NULL?
@ 2003-11-25 13:27 Ihar 'Philips' Filipau
  2003-11-25 14:00 ` Arjan van de Ven
                   ` (2 more replies)
  0 siblings, 3 replies; 22+ messages in thread
From: Ihar 'Philips' Filipau @ 2003-11-25 13:27 UTC (permalink / raw)
  To: Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 2213 bytes --]

Hello!

   I just wondering: do last three stable branches of LK able to return 
malloc()==NULL and/or ENOMEM?

   2.2: I cannot test this stuff right now - but it was hanging hard on 
"for (;;) memset(malloc(N), 0, N);" So we do not have NULL from malloc().
   2.4: same behaviour if OOM disabled. But by default (OOM even has no 
configuration entry - so always on) it just kills offending process. No 
NULL pointer either.
   2.6: the same as 2.4 with oom killer (default conf). I have no test 
system to check 2.6. w/o oom killer.

   Resume: we malloc() never returns NULL. so man-pages are incorrect ;-)
   [ AFAIK only kmalloc(GFP_ATOMIC) can potentially return NULL - but I 
didn't yet tested my modules under memory pressure. TODO. ]

   Most interesting thing is that on 2.4 "for(;;) malloc(N)" able to 
allocate about 1.8GB of memory on system with only 256M of physical RAM. 
Laghtingly fast. Then malloc() returns NULL. Good signs.
   But as soon as I will put "memset()" -  app will be killed or box 
will go bananas. Neither of this two things are appropriate. Especially 
when applications are tuned to handle memmory allocation errors.

   Can anyone comment on this?

   Does any one has patches with replacement VM? I'm very interesting in 
knowing all aspect of VM<->block layer<->rest of the kernel integration.

   Pointers to on-line memory management algorithms will be valuable 
too, if some one knows any.

P.S. I know about linux-mm.org - out-dated, but I do read it right now. 
Any other pointers will be appreciated.
But looks like general Linux crowd is satisfied with current (and past) 
status of MM...

P.P.S. Small memory eating app is attached. lines 16 & 17 (for() loop) 
used to touch every kbyte of memory to make it really allocated.

-- 
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

[-- Attachment #2: malloc.c --]
[-- Type: text/plain, Size: 368 bytes --]


#include <stdlib.h>
#include <stdio.h>

#define CHUNK_SIZE	(1<<16)

int main()
{
	char *b;
	unsigned long sz = 0;
	for (;;) {
		fprintf(stderr, "alloc ");
		if ((b = malloc( CHUNK_SIZE ))) {
			unsigned int i;
			sz += CHUNK_SIZE;
			for (i=0; i<(CHUNK_SIZE>>10); ++i)
				b[i<<10] = '0';
		} else
			exit(1);
		fprintf(stderr, "done. [%lu%s]\n", sz>>10, "k");
	}
}


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2003-11-26 14:40 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <VQJL.62Q.11@gated-at.bofh.it>
     [not found] ` <VR3c.6Ns.21@gated-at.bofh.it>
2003-11-26 10:30   ` 2.2/2.4/2.6 VMs: do malloc() ever return NULL? Ihar 'Philips' Filipau
2003-11-26 10:39     ` William Lee Irwin III
2003-11-26 12:14       ` Ihar 'Philips' Filipau
     [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
2003-11-25 13:27 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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox