how to purposfully fragment memory?

From: Chris Friesen
Date: Tue Mar 20 2007 - 13:44:29 EST



I'm trying to test code paths dealing with fragmented memory, so I'd like to have a simple way to cause fragmented memory in the kernel. Is there any API in the kernel that would let me allocate two contiguous pages, then free one of them?


I tried the following, but it triggers an oops in free_page():

unsigned long addr =
__get_free_pages(GFP_KERNEL|__GFP_NORETRY|__GFP_NOWARN, 1);
if (!addr)
break;
free_page(addr+4096);


Thanks,

Chris
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/