diff options
Diffstat (limited to 'mm/vmalloc.c')
-rw-r--r-- | mm/vmalloc.c | 56 |
1 files changed, 50 insertions, 6 deletions
diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 9f909622a25e..a3d66b3dc5cb 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c | |||
@@ -293,13 +293,13 @@ static void __insert_vmap_area(struct vmap_area *va) | |||
293 | struct rb_node *tmp; | 293 | struct rb_node *tmp; |
294 | 294 | ||
295 | while (*p) { | 295 | while (*p) { |
296 | struct vmap_area *tmp; | 296 | struct vmap_area *tmp_va; |
297 | 297 | ||
298 | parent = *p; | 298 | parent = *p; |
299 | tmp = rb_entry(parent, struct vmap_area, rb_node); | 299 | tmp_va = rb_entry(parent, struct vmap_area, rb_node); |
300 | if (va->va_start < tmp->va_end) | 300 | if (va->va_start < tmp_va->va_end) |
301 | p = &(*p)->rb_left; | 301 | p = &(*p)->rb_left; |
302 | else if (va->va_end > tmp->va_start) | 302 | else if (va->va_end > tmp_va->va_start) |
303 | p = &(*p)->rb_right; | 303 | p = &(*p)->rb_right; |
304 | else | 304 | else |
305 | BUG(); | 305 | BUG(); |
@@ -1596,6 +1596,13 @@ void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot) | |||
1596 | } | 1596 | } |
1597 | EXPORT_SYMBOL(__vmalloc); | 1597 | EXPORT_SYMBOL(__vmalloc); |
1598 | 1598 | ||
1599 | static inline void *__vmalloc_node_flags(unsigned long size, | ||
1600 | int node, gfp_t flags) | ||
1601 | { | ||
1602 | return __vmalloc_node(size, 1, flags, PAGE_KERNEL, | ||
1603 | node, __builtin_return_address(0)); | ||
1604 | } | ||
1605 | |||
1599 | /** | 1606 | /** |
1600 | * vmalloc - allocate virtually contiguous memory | 1607 | * vmalloc - allocate virtually contiguous memory |
1601 | * @size: allocation size | 1608 | * @size: allocation size |
@@ -1607,12 +1614,28 @@ EXPORT_SYMBOL(__vmalloc); | |||
1607 | */ | 1614 | */ |
1608 | void *vmalloc(unsigned long size) | 1615 | void *vmalloc(unsigned long size) |
1609 | { | 1616 | { |
1610 | return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL, | 1617 | return __vmalloc_node_flags(size, -1, GFP_KERNEL | __GFP_HIGHMEM); |
1611 | -1, __builtin_return_address(0)); | ||
1612 | } | 1618 | } |
1613 | EXPORT_SYMBOL(vmalloc); | 1619 | EXPORT_SYMBOL(vmalloc); |
1614 | 1620 | ||
1615 | /** | 1621 | /** |
1622 | * vzalloc - allocate virtually contiguous memory with zero fill | ||
1623 | * @size: allocation size | ||
1624 | * Allocate enough pages to cover @size from the page level | ||
1625 | * allocator and map them into contiguous kernel virtual space. | ||
1626 | * The memory allocated is set to zero. | ||
1627 | * | ||
1628 | * For tight control over page level allocator and protection flags | ||
1629 | * use __vmalloc() instead. | ||
1630 | */ | ||
1631 | void *vzalloc(unsigned long size) | ||
1632 | { | ||
1633 | return __vmalloc_node_flags(size, -1, | ||
1634 | GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO); | ||
1635 | } | ||
1636 | EXPORT_SYMBOL(vzalloc); | ||
1637 | |||
1638 | /** | ||
1616 | * vmalloc_user - allocate zeroed virtually contiguous memory for userspace | 1639 | * vmalloc_user - allocate zeroed virtually contiguous memory for userspace |
1617 | * @size: allocation size | 1640 | * @size: allocation size |
1618 | * | 1641 | * |
@@ -1653,6 +1676,25 @@ void *vmalloc_node(unsigned long size, int node) | |||
1653 | } | 1676 | } |
1654 | EXPORT_SYMBOL(vmalloc_node); | 1677 | EXPORT_SYMBOL(vmalloc_node); |
1655 | 1678 | ||
1679 | /** | ||
1680 | * vzalloc_node - allocate memory on a specific node with zero fill | ||
1681 | * @size: allocation size | ||
1682 | * @node: numa node | ||
1683 | * | ||
1684 | * Allocate enough pages to cover @size from the page level | ||
1685 | * allocator and map them into contiguous kernel virtual space. | ||
1686 | * The memory allocated is set to zero. | ||
1687 | * | ||
1688 | * For tight control over page level allocator and protection flags | ||
1689 | * use __vmalloc_node() instead. | ||
1690 | */ | ||
1691 | void *vzalloc_node(unsigned long size, int node) | ||
1692 | { | ||
1693 | return __vmalloc_node_flags(size, node, | ||
1694 | GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO); | ||
1695 | } | ||
1696 | EXPORT_SYMBOL(vzalloc_node); | ||
1697 | |||
1656 | #ifndef PAGE_KERNEL_EXEC | 1698 | #ifndef PAGE_KERNEL_EXEC |
1657 | # define PAGE_KERNEL_EXEC PAGE_KERNEL | 1699 | # define PAGE_KERNEL_EXEC PAGE_KERNEL |
1658 | #endif | 1700 | #endif |
@@ -2350,6 +2392,7 @@ void pcpu_free_vm_areas(struct vm_struct **vms, int nr_vms) | |||
2350 | 2392 | ||
2351 | #ifdef CONFIG_PROC_FS | 2393 | #ifdef CONFIG_PROC_FS |
2352 | static void *s_start(struct seq_file *m, loff_t *pos) | 2394 | static void *s_start(struct seq_file *m, loff_t *pos) |
2395 | __acquires(&vmlist_lock) | ||
2353 | { | 2396 | { |
2354 | loff_t n = *pos; | 2397 | loff_t n = *pos; |
2355 | struct vm_struct *v; | 2398 | struct vm_struct *v; |
@@ -2376,6 +2419,7 @@ static void *s_next(struct seq_file *m, void *p, loff_t *pos) | |||
2376 | } | 2419 | } |
2377 | 2420 | ||
2378 | static void s_stop(struct seq_file *m, void *p) | 2421 | static void s_stop(struct seq_file *m, void *p) |
2422 | __releases(&vmlist_lock) | ||
2379 | { | 2423 | { |
2380 | read_unlock(&vmlist_lock); | 2424 | read_unlock(&vmlist_lock); |
2381 | } | 2425 | } |