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 <tangc...@cn.fujitsu.com>
Reviewed-by: Zhang Yanfei <zhangyan...@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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to