diff options
author | Johannes Weiner <hannes@cmpxchg.org> | 2012-05-29 18:06:34 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-29 19:22:22 -0400 |
commit | 421456edd27cf512b8f0025245a0f3572bd69b00 (patch) | |
tree | 5514646e0a4113774f9c612b57b645206f71439e /mm/bootmem.c | |
parent | ab3818432294a19ad793a0965d89867b4ce6255b (diff) |
mm: bootmem: unify allocation policy of (non-)panicking node allocations
While the panicking node-specific allocation function tries to satisfy
node+goal, goal, node, anywhere, the non-panicking function still does
node+goal, goal, anywhere.
Make it simpler: define the panicking version in terms of the
non-panicking one, like the node-agnostic interface, so they always behave
the same way apart from how to deal with allocation failure.
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Tejun Heo <tj@kernel.org>
Acked-by: David S. Miller <davem@davemloft.net>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Gavin Shan <shangw@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/bootmem.c')
-rw-r--r-- | mm/bootmem.c | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/mm/bootmem.c b/mm/bootmem.c index b5babdfb9ef8..d9185c30f3cc 100644 --- a/mm/bootmem.c +++ b/mm/bootmem.c | |||
@@ -698,7 +698,7 @@ void * __init __alloc_bootmem(unsigned long size, unsigned long align, | |||
698 | return ___alloc_bootmem(size, align, goal, limit); | 698 | return ___alloc_bootmem(size, align, goal, limit); |
699 | } | 699 | } |
700 | 700 | ||
701 | static void * __init ___alloc_bootmem_node(bootmem_data_t *bdata, | 701 | static void * __init ___alloc_bootmem_node_nopanic(bootmem_data_t *bdata, |
702 | unsigned long size, unsigned long align, | 702 | unsigned long size, unsigned long align, |
703 | unsigned long goal, unsigned long limit) | 703 | unsigned long goal, unsigned long limit) |
704 | { | 704 | { |
@@ -722,6 +722,29 @@ again: | |||
722 | goto again; | 722 | goto again; |
723 | } | 723 | } |
724 | 724 | ||
725 | return NULL; | ||
726 | } | ||
727 | |||
728 | void * __init __alloc_bootmem_node_nopanic(pg_data_t *pgdat, unsigned long size, | ||
729 | unsigned long align, unsigned long goal) | ||
730 | { | ||
731 | if (WARN_ON_ONCE(slab_is_available())) | ||
732 | return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id); | ||
733 | |||
734 | return ___alloc_bootmem_node_nopanic(pgdat->bdata, size, | ||
735 | align, goal, 0); | ||
736 | } | ||
737 | |||
738 | void * __init ___alloc_bootmem_node(bootmem_data_t *bdata, unsigned long size, | ||
739 | unsigned long align, unsigned long goal, | ||
740 | unsigned long limit) | ||
741 | { | ||
742 | void *ptr; | ||
743 | |||
744 | ptr = ___alloc_bootmem_node_nopanic(bdata, size, align, goal, 0); | ||
745 | if (ptr) | ||
746 | return ptr; | ||
747 | |||
725 | printk(KERN_ALERT "bootmem alloc of %lu bytes failed!\n", size); | 748 | printk(KERN_ALERT "bootmem alloc of %lu bytes failed!\n", size); |
726 | panic("Out of memory"); | 749 | panic("Out of memory"); |
727 | return NULL; | 750 | return NULL; |
@@ -802,25 +825,6 @@ void * __init alloc_bootmem_section(unsigned long size, | |||
802 | } | 825 | } |
803 | #endif | 826 | #endif |
804 | 827 | ||
805 | void * __init __alloc_bootmem_node_nopanic(pg_data_t *pgdat, unsigned long size, | ||
806 | unsigned long align, unsigned long goal) | ||
807 | { | ||
808 | void *ptr; | ||
809 | |||
810 | if (WARN_ON_ONCE(slab_is_available())) | ||
811 | return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id); | ||
812 | |||
813 | ptr = alloc_arch_preferred_bootmem(pgdat->bdata, size, align, goal, 0); | ||
814 | if (ptr) | ||
815 | return ptr; | ||
816 | |||
817 | ptr = alloc_bootmem_bdata(pgdat->bdata, size, align, goal, 0); | ||
818 | if (ptr) | ||
819 | return ptr; | ||
820 | |||
821 | return __alloc_bootmem_nopanic(size, align, goal); | ||
822 | } | ||
823 | |||
824 | #ifndef ARCH_LOW_ADDRESS_LIMIT | 828 | #ifndef ARCH_LOW_ADDRESS_LIMIT |
825 | #define ARCH_LOW_ADDRESS_LIMIT 0xffffffffUL | 829 | #define ARCH_LOW_ADDRESS_LIMIT 0xffffffffUL |
826 | #endif | 830 | #endif |