diff options
author | Nicolas Pitre <nicolas.pitre@linaro.org> | 2011-08-25 00:24:21 -0400 |
---|---|---|
committer | Nicolas Pitre <nico@fluxnic.net> | 2011-11-18 13:51:22 -0500 |
commit | be9b7335e70696bee731c152429b1737e42fe163 (patch) | |
tree | 46b48be6c58d4ff7b2b1d2a59f0d81cd5646a0ed | |
parent | 55a8173cfe1c6b489f8f5705282c762aed2e265e (diff) |
mm: add vm_area_add_early()
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
different semantics, let's create vm_area_add_early() instead.
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>
Acked-by: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org
-rw-r--r-- | include/linux/vmalloc.h | 1 | ||||
-rw-r--r-- | mm/vmalloc.c | 29 |
2 files changed, 28 insertions, 2 deletions
diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h index 687fb11e2010..4115d6aa80be 100644 --- a/include/linux/vmalloc.h +++ b/include/linux/vmalloc.h | |||
@@ -131,6 +131,7 @@ extern long vwrite(char *buf, char *addr, unsigned long count); | |||
131 | */ | 131 | */ |
132 | extern rwlock_t vmlist_lock; | 132 | extern rwlock_t vmlist_lock; |
133 | extern struct vm_struct *vmlist; | 133 | extern struct vm_struct *vmlist; |
134 | extern __init void vm_area_add_early(struct vm_struct *vm); | ||
134 | extern __init void vm_area_register_early(struct vm_struct *vm, size_t align); | 135 | extern __init void vm_area_register_early(struct vm_struct *vm, size_t align); |
135 | 136 | ||
136 | #ifdef CONFIG_SMP | 137 | #ifdef CONFIG_SMP |
diff --git a/mm/vmalloc.c b/mm/vmalloc.c index b669aa6f6caf..3f2b59221b78 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c | |||
@@ -1118,6 +1118,32 @@ void *vm_map_ram(struct page **pages, unsigned int count, int node, pgprot_t pro | |||
1118 | EXPORT_SYMBOL(vm_map_ram); | 1118 | EXPORT_SYMBOL(vm_map_ram); |
1119 | 1119 | ||
1120 | /** | 1120 | /** |
1121 | * vm_area_add_early - add vmap area early during boot | ||
1122 | * @vm: vm_struct to add | ||
1123 | * | ||
1124 | * This function is used to add fixed kernel vm area to vmlist before | ||
1125 | * vmalloc_init() is called. @vm->addr, @vm->size, and @vm->flags | ||
1126 | * should contain proper values and the other fields should be zero. | ||
1127 | * | ||
1128 | * DO NOT USE THIS FUNCTION UNLESS YOU KNOW WHAT YOU'RE DOING. | ||
1129 | */ | ||
1130 | void __init vm_area_add_early(struct vm_struct *vm) | ||
1131 | { | ||
1132 | struct vm_struct *tmp, **p; | ||
1133 | |||
1134 | BUG_ON(vmap_initialized); | ||
1135 | for (p = &vmlist; (tmp = *p) != NULL; p = &tmp->next) { | ||
1136 | if (tmp->addr >= vm->addr) { | ||
1137 | BUG_ON(tmp->addr < vm->addr + vm->size); | ||
1138 | break; | ||
1139 | } else | ||
1140 | BUG_ON(tmp->addr + tmp->size > vm->addr); | ||
1141 | } | ||
1142 | vm->next = *p; | ||
1143 | *p = vm; | ||
1144 | } | ||
1145 | |||
1146 | /** | ||
1121 | * vm_area_register_early - register vmap area early during boot | 1147 | * vm_area_register_early - register vmap area early during boot |
1122 | * @vm: vm_struct to register | 1148 | * @vm: vm_struct to register |
1123 | * @align: requested alignment | 1149 | * @align: requested alignment |
@@ -1139,8 +1165,7 @@ void __init vm_area_register_early(struct vm_struct *vm, size_t align) | |||
1139 | 1165 | ||
1140 | vm->addr = (void *)addr; | 1166 | vm->addr = (void *)addr; |
1141 | 1167 | ||
1142 | vm->next = vmlist; | 1168 | vm_area_add_early(vm); |
1143 | vmlist = vm; | ||
1144 | } | 1169 | } |
1145 | 1170 | ||
1146 | void __init vmalloc_init(void) | 1171 | void __init vmalloc_init(void) |