Skip to contentSkip to conversation

vmalloc: introduce __vmalloc_area() function

PATCH In review Oleg Nesterov 2 participants 2 messages Mar 6, 2005 – Mar 22, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/5 vmalloc: introduce __vmalloc_area() function

There are 3 copy-and-paste implementations of __vmalloc() in arch/{arm,sparc64,x86_64}/kernel/module.c.

I believe the only reason is that __vmalloc() doesn't allow to specify parameters of __get_vm_area().

This patch splits __vmalloc() into 2 functions. The new one, __vmalloc_area(), can be used as follows:

	vm_struct *area = __get_vm_area(...);
	void *addr = __vmalloc_area(area, gfp, prot);
include/linux/vmalloc.h renamed from include/linux/0_vmalloc.h +1 -0
@@ -27,6 +27,7 @@ extern void *vmalloc(unsigned long size)
 extern void *vmalloc_exec(unsigned long size);
 extern void *vmalloc_32(unsigned long size);
 extern void *__vmalloc(unsigned long size, int gfp_mask, pgprot_t prot);
+extern void *__vmalloc_area(struct vm_struct *area, int gfp_mask, pgprot_t prot);
 extern void vfree(void *addr);
 
 extern void *vmap(struct page **pages, unsigned int count,
mm/vmalloc.c renamed from mm/0_vmalloc.c +29 -23

74 lines not on this page · raw message

#1 lore raw
Quoted 2 lines · Oleg Nesterov

There are 3 copy-and-paste implementations of __vmalloc() in arch/{arm,sparc64,x86_64}/kernel/module.c.

There is actually a similar copy in arch/arm/mm/consistent.c, but at the time I cleaned it up to be something saner. With some tweaks (such as adding a struct vm_region_head which contains the spinlock, as well as the start/end and list) we essentially end up with a generic memory region allocator suitable for vmalloc, ioremap, module stuff, and so forth.

If anyone's interested in that, I'll sort out those tweaks.

Signature · 3 lines
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 Serial core