linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* kernel hangs in 118th call to vmalloc
@ 2001-08-31 18:40 Timur Tabi
  2001-08-31 20:38 ` Alan Cox
  2001-09-08 18:30 ` Eric W. Biederman
  0 siblings, 2 replies; 4+ messages in thread
From: Timur Tabi @ 2001-08-31 18:40 UTC (permalink / raw)
  To: linux-kernel, linux-mm

I'm writing a driver for the 2.4.2 kernel.  I need to use this kernel 
because this driver needs to be compatible with a stock Red Hat system. 
  Patches to the kernel are not an option.

The purpose of the driver is to locate a device that exists on a 
specific memory chip.  To help find it, I've written this routine:

#define CLEAR_BLOCK_SIZE 1048576UL        // must be a multiple of 1MB
#define CLEAR_BLOCK_COUNT ((PHYSICAL_HOP * 2) / CLEAR_BLOCK_SIZE)

void clear_out_memory(void)
{
     void *p[CLEAR_BLOCK_COUNT];
     unsigned i;
     unsigned long size = 0;

     for (i=0; i<CLEAR_BLOCK_COUNT; i++)
     {
         p[i] = vmalloc(CLEAR_BLOCK_SIZE);
         if (!p[i])
             break;
         size += CLEAR_BLOCK_SIZE;
     }

     while (--i)
         vfree(p[i]);

     printk("Paged %luMB of memory\n", size / 1048576UL);
}

What this routine does is call vmalloc() repeatedly for a number of 1MB 
chunks until it fails or until it's allocated 128MB (CLEAR_BLOCK_COUNT 
is equal to 128 in this case).  Then, it starts freeing them.

The side-effect of this routine is to page-out up to 128MB of RAM. 
Unfortunately, on a 128MB machine, the 118th call to vmalloc() hangs the 
system.  I was expecting it to return NULL instead.

Is this a bug in vmalloc()?  If so, is there a work-around that I can use?

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/

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

end of thread, other threads:[~2001-09-08 19:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-31 18:40 kernel hangs in 118th call to vmalloc Timur Tabi
2001-08-31 20:38 ` Alan Cox
2001-09-08 18:30 ` Eric W. Biederman
2001-09-08 19:39   ` Timur Tabi

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