vmalloc.c (513b046c96cc2fbce730a3474f6f7ff0c4fdd05c) vmalloc.c (52fd24ca1db3a741f144bbc229beefe044202cac)
1/*
2 * linux/mm/vmalloc.c
3 *
4 * Copyright (C) 1993 Linus Torvalds
5 * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
6 * SMP-safe vmalloc/vfree/ioremap, Tigran Aivazian <tigran@veritas.com>, May 2000
7 * Major rework to support vmap/vunmap, Christoph Hellwig, SGI, August 2002
8 * Numa awareness, Christoph Lameter, SGI, June 2005

--- 146 unchanged lines hidden (view full) ---

155 err = vmap_pud_range(pgd, addr, next, prot, pages);
156 if (err)
157 break;
158 } while (pgd++, addr = next, addr != end);
159 flush_cache_vmap((unsigned long) area->addr, end);
160 return err;
161}
162
1/*
2 * linux/mm/vmalloc.c
3 *
4 * Copyright (C) 1993 Linus Torvalds
5 * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
6 * SMP-safe vmalloc/vfree/ioremap, Tigran Aivazian <tigran@veritas.com>, May 2000
7 * Major rework to support vmap/vunmap, Christoph Hellwig, SGI, August 2002
8 * Numa awareness, Christoph Lameter, SGI, June 2005

--- 146 unchanged lines hidden (view full) ---

155 err = vmap_pud_range(pgd, addr, next, prot, pages);
156 if (err)
157 break;
158 } while (pgd++, addr = next, addr != end);
159 flush_cache_vmap((unsigned long) area->addr, end);
160 return err;
161}
162
163struct vm_struct *__get_vm_area_node(unsigned long size, unsigned long flags,
164 unsigned long start, unsigned long end, int node)
163static struct vm_struct *__get_vm_area_node(unsigned long size, unsigned long flags,
164 unsigned long start, unsigned long end,
165 int node, gfp_t gfp_mask)
165{
166 struct vm_struct **p, *tmp, *area;
167 unsigned long align = 1;
168 unsigned long addr;
169
166{
167 struct vm_struct **p, *tmp, *area;
168 unsigned long align = 1;
169 unsigned long addr;
170
171 BUG_ON(in_interrupt());
170 if (flags & VM_IOREMAP) {
171 int bit = fls(size);
172
173 if (bit > IOREMAP_MAX_ORDER)
174 bit = IOREMAP_MAX_ORDER;
175 else if (bit < PAGE_SHIFT)
176 bit = PAGE_SHIFT;
177
178 align = 1ul << bit;
179 }
180 addr = ALIGN(start, align);
181 size = PAGE_ALIGN(size);
182
172 if (flags & VM_IOREMAP) {
173 int bit = fls(size);
174
175 if (bit > IOREMAP_MAX_ORDER)
176 bit = IOREMAP_MAX_ORDER;
177 else if (bit < PAGE_SHIFT)
178 bit = PAGE_SHIFT;
179
180 align = 1ul << bit;
181 }
182 addr = ALIGN(start, align);
183 size = PAGE_ALIGN(size);
184
183 area = kmalloc_node(sizeof(*area), GFP_KERNEL, node);
185 area = kmalloc_node(sizeof(*area), gfp_mask, node);
184 if (unlikely(!area))
185 return NULL;
186
187 if (unlikely(!size)) {
188 kfree (area);
189 return NULL;
190 }
191

--- 39 unchanged lines hidden (view full) ---

231 if (printk_ratelimit())
232 printk(KERN_WARNING "allocation failed: out of vmalloc space - use vmalloc=<size> to increase size.\n");
233 return NULL;
234}
235
236struct vm_struct *__get_vm_area(unsigned long size, unsigned long flags,
237 unsigned long start, unsigned long end)
238{
186 if (unlikely(!area))
187 return NULL;
188
189 if (unlikely(!size)) {
190 kfree (area);
191 return NULL;
192 }
193

--- 39 unchanged lines hidden (view full) ---

233 if (printk_ratelimit())
234 printk(KERN_WARNING "allocation failed: out of vmalloc space - use vmalloc=<size> to increase size.\n");
235 return NULL;
236}
237
238struct vm_struct *__get_vm_area(unsigned long size, unsigned long flags,
239 unsigned long start, unsigned long end)
240{
239 return __get_vm_area_node(size, flags, start, end, -1);
241 return __get_vm_area_node(size, flags, start, end, -1, GFP_KERNEL);
240}
241
242/**
243 * get_vm_area - reserve a contingous kernel virtual area
244 * @size: size of the area
245 * @flags: %VM_IOREMAP for I/O mappings or VM_ALLOC
246 *
247 * Search an area of @size in the kernel virtual mapping area,
248 * and reserved it for out purposes. Returns the area descriptor
249 * on success or %NULL on failure.
250 */
251struct vm_struct *get_vm_area(unsigned long size, unsigned long flags)
252{
253 return __get_vm_area(size, flags, VMALLOC_START, VMALLOC_END);
254}
255
242}
243
244/**
245 * get_vm_area - reserve a contingous kernel virtual area
246 * @size: size of the area
247 * @flags: %VM_IOREMAP for I/O mappings or VM_ALLOC
248 *
249 * Search an area of @size in the kernel virtual mapping area,
250 * and reserved it for out purposes. Returns the area descriptor
251 * on success or %NULL on failure.
252 */
253struct vm_struct *get_vm_area(unsigned long size, unsigned long flags)
254{
255 return __get_vm_area(size, flags, VMALLOC_START, VMALLOC_END);
256}
257
256struct vm_struct *get_vm_area_node(unsigned long size, unsigned long flags, int node)
258struct vm_struct *get_vm_area_node(unsigned long size, unsigned long flags,
259 int node, gfp_t gfp_mask)
257{
260{
258 return __get_vm_area_node(size, flags, VMALLOC_START, VMALLOC_END, node);
261 return __get_vm_area_node(size, flags, VMALLOC_START, VMALLOC_END, node,
262 gfp_mask);
259}
260
261/* Caller must hold vmlist_lock */
262static struct vm_struct *__find_vm_area(void *addr)
263{
264 struct vm_struct *tmp;
265
266 for (tmp = vmlist; tmp != NULL; tmp = tmp->next) {

--- 215 unchanged lines hidden (view full) ---

482 int node)
483{
484 struct vm_struct *area;
485
486 size = PAGE_ALIGN(size);
487 if (!size || (size >> PAGE_SHIFT) > num_physpages)
488 return NULL;
489
263}
264
265/* Caller must hold vmlist_lock */
266static struct vm_struct *__find_vm_area(void *addr)
267{
268 struct vm_struct *tmp;
269
270 for (tmp = vmlist; tmp != NULL; tmp = tmp->next) {

--- 215 unchanged lines hidden (view full) ---

486 int node)
487{
488 struct vm_struct *area;
489
490 size = PAGE_ALIGN(size);
491 if (!size || (size >> PAGE_SHIFT) > num_physpages)
492 return NULL;
493
490 area = get_vm_area_node(size, VM_ALLOC, node);
494 area = get_vm_area_node(size, VM_ALLOC, node, gfp_mask);
491 if (!area)
492 return NULL;
493
494 return __vmalloc_area_node(area, gfp_mask, prot, node);
495}
496
497void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot)
498{

--- 248 unchanged lines hidden ---
495 if (!area)
496 return NULL;
497
498 return __vmalloc_area_node(area, gfp_mask, prot, node);
499}
500
501void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot)
502{

--- 248 unchanged lines hidden ---