linux-um archives
 help / color / mirror / Atom feed
* [uml-devel] [patch 1/1] Fix malloc-use-vmalloc
@ 2004-07-04 10:56 blaisorblade_spam
  2004-07-13 17:57 ` [uml-devel] " Jeff Dike
  0 siblings, 1 reply; 4+ messages in thread
From: blaisorblade_spam @ 2004-07-04 10:56 UTC (permalink / raw)
  To: jdike; +Cc: user-mode-linux-devel, blaisorblade_spam


* Avoid allocating more than one page at once: that can require
moving pages around to have two contiguos pages, so we're better
with vmalloc.
* Make sure we free() someway, inside __wrap_free.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade_spam@yahoo.it>
---

 linux-2.4.26-paolo/arch/um/main.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff -puN arch/um/main.c~malloc-use-vmalloc-fix arch/um/main.c
--- linux-2.4.26/arch/um/main.c~malloc-use-vmalloc-fix	2004-07-04 12:52:43.887588064 +0200
+++ linux-2.4.26-paolo/arch/um/main.c	2004-07-04 12:52:43.889587760 +0200
@@ -168,7 +168,7 @@ void *__wrap_malloc(int size)
 
 	if(!CAN_KMALLOC())
 		return(__real_malloc(size));
-	else if(size < 128 * 1024) /* kmalloc is good for only 128K */
+	else if(size <= PAGE_SIZE) /* finding contiguos pages is hard */
 		ret = um_kmalloc(size);
 	else ret = um_vmalloc(size);
 
@@ -213,8 +213,11 @@ void __wrap_free(void *ptr)
 			kfree(ptr);
 		else if((addr >= start_vm) && (addr <= end_vm))
 			vfree(ptr);
+		else
+			__real_free(ptr);
 	}
-	else __real_free(ptr);
+	else
+		__real_free(ptr);
 }
 
 /*
_


-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

end of thread, other threads:[~2004-07-26 17:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-04 10:56 [uml-devel] [patch 1/1] Fix malloc-use-vmalloc blaisorblade_spam
2004-07-13 17:57 ` [uml-devel] " Jeff Dike
2004-07-22 15:55   ` BlaisorBlade
2004-07-26 18:18     ` Jeff Dike

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