[RESEND PATCH v2 4/9] x86: Support allocate memory from bottom upwards in setup_log_buf().

Tang Chen
2013-09-12T10:05:03Z

During early boot, if the bottom up mode is set, just
try allocating bottom up from the end of kernel image,
and if that fails, do normal top down allocation.

So in function setup_log_buf(), we add the above logic.

Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
Reviewed-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
---
kernel/printk/printk.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index b4e8500..2958118 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -759,9 +759,20 @@ void __init setup_log_buf(int early)
if (early) {
unsigned long mem;

+ if (memblock_direction_bottom_up()) {
+ mem = memblock_alloc_bottom_up(
+ MEMBLOCK_ALLOC_ACCESSIBLE,
+ MEMBLOCK_ALLOC_ACCESSIBLE,
+ new_log_buf_len, PAGE_SIZE);
+ if (mem)
+ goto success;
+ }
+
mem = memblock_alloc(new_log_buf_len, PAGE_SIZE);
if (!mem)
return;
+
+success:
new_log_buf = __va(mem);
} else {
new_log_buf = alloc_bootmem_nopanic(new_log_buf_len);
--
1.7.1