]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
mm: add vm_area_add_early()
authorNicolas Pitre <nicolas.pitre@linaro.org>
Tue, 8 Nov 2011 00:20:15 +0000 (11:20 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 8 Nov 2011 03:16:00 +0000 (14:16 +1100)
The existing vm_area_register_early() allows for early vmalloc space
allocation.  However upcoming cleanups in the ARM architecture require
that some fixed locations in the vmalloc area be reserved also very early.

The name "vm_area_register_early" would have been a good name for the
reservation part without the allocation.  Since it is already in use with

Both vm_area_register_early() and vm_area_add_early() can be used together
meaning that the former is now implemented using the later where it is
ensured that no conflicting areas are added, but no attempt is made to
make the allocation scheme in vm_area_register_early() more sophisticated.
After all, you must know what you're doing when using those functions.

Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/vmalloc.h
mm/vmalloc.c

index 687fb11e20107d9c22467e1923d5e736bde16d3e..4115d6aa80be3f8e76e4f12183f568126b6b1bd4 100644 (file)
@@ -131,6 +131,7 @@ extern long vwrite(char *buf, char *addr, unsigned long count);
  */
 extern rwlock_t vmlist_lock;
 extern struct vm_struct *vmlist;
+extern __init void vm_area_add_early(struct vm_struct *vm);
 extern __init void vm_area_register_early(struct vm_struct *vm, size_t align);
 
 #ifdef CONFIG_SMP
index b669aa6f6caff34f41fac15a527a791576f9026a..3f6a3f1aa8699d5f266ad90623358041502cb958 100644 (file)
@@ -1117,6 +1117,31 @@ void *vm_map_ram(struct page **pages, unsigned int count, int node, pgprot_t pro
 }
 EXPORT_SYMBOL(vm_map_ram);
 
+/**
+ * vm_area_add_early - add vmap area early during boot
+ * @vm: vm_struct to add
+ *
+ * This function is used to add fixed kernel vm area to vmlist before
+ * vmalloc_init() is called.  @vm->addr, @vm->size, and @vm->flags
+ * should contain proper values and the other fields should be zero.
+ *
+ * DO NOT USE THIS FUNCTION UNLESS YOU KNOW WHAT YOU'RE DOING.
+ */
+void __init vm_area_add_early(struct vm_struct *vm)
+{
+       struct vm_struct *tmp, **p;
+
+       for (p = &vmlist; (tmp = *p) != NULL; p = &tmp->next) {
+               if (tmp->addr >= vm->addr) {
+                       BUG_ON(tmp->addr < vm->addr + vm->size);
+                       break;
+               } else
+                       BUG_ON(tmp->addr + tmp->size > vm->addr);
+       }
+       vm->next = *p;
+       *p = vm;
+}
+
 /**
  * vm_area_register_early - register vmap area early during boot
  * @vm: vm_struct to register
@@ -1139,8 +1164,7 @@ void __init vm_area_register_early(struct vm_struct *vm, size_t align)
 
        vm->addr = (void *)addr;
 
-       vm->next = vmlist;
-       vmlist = vm;
+       vm_area_add_early(vm);
 }
 
 void __init vmalloc_init(void)