From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758012AbcIUQXf (ORCPT ); Wed, 21 Sep 2016 12:23:35 -0400 Received: from terminus.zytor.com ([198.137.202.10]:60254 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757305AbcIUQXc (ORCPT ); Wed, 21 Sep 2016 12:23:32 -0400 Date: Wed, 21 Sep 2016 09:22:41 -0700 From: tip-bot for Denys Vlasenko Message-ID: Cc: tglx@linutronix.de, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, brgerst@gmail.com, yinghai@kernel.org, mingo@kernel.org, peterz@infradead.org, jpoimboe@redhat.com, luto@amacapital.net, bp@alien8.de, hpa@zytor.com, dvlasenk@redhat.com, luto@kernel.org Reply-To: hpa@zytor.com, luto@kernel.org, dvlasenk@redhat.com, jpoimboe@redhat.com, bp@alien8.de, luto@amacapital.net, mingo@kernel.org, peterz@infradead.org, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, yinghai@kernel.org, brgerst@gmail.com In-Reply-To: <20160918182125.21000-1-dvlasenk@redhat.com> References: <20160918182125.21000-1-dvlasenk@redhat.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/boot] x86/e820: Use much less memory for e820/e820_saved, save up to 120k Git-Commit-ID: 1827822902cf659d60d3413fd42c7e6cbd18df4d X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 1827822902cf659d60d3413fd42c7e6cbd18df4d Gitweb: http://git.kernel.org/tip/1827822902cf659d60d3413fd42c7e6cbd18df4d Author: Denys Vlasenko AuthorDate: Sun, 18 Sep 2016 20:21:25 +0200 Committer: Ingo Molnar CommitDate: Wed, 21 Sep 2016 15:02:12 +0200 x86/e820: Use much less memory for e820/e820_saved, save up to 120k The maximum size of e820 map array for EFI systems is defined as E820_X_MAX (E820MAX + 3 * MAX_NUMNODES). In x86_64 defconfig, this ends up with E820_X_MAX = 320, e820 and e820_saved are 6404 bytes each. With larger configs, for example Fedora kernels, E820_X_MAX = 3200, e820 and e820_saved are 64004 bytes each. Most of this space is wasted. Typical machines have some 20-30 e820 areas at most. After previous patch, e820 and e820_saved are pointers to e280 maps. Change them to initially point to maps which are __initdata. At the very end of kernel init, just before __init[data] sections are freed in free_initmem(), allocate smaller blocks, copy maps there, and change pointers. The late switch makes sure that all functions which can be used to change e820 maps are no longer accessible (they are all __init functions). Run-tested. Signed-off-by: Denys Vlasenko Acked-by: Thomas Gleixner Cc: Andy Lutomirski Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: H. Peter Anvin Cc: Josh Poimboeuf Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Yinghai Lu Cc: linux-kernel@vger.kernel.org Link: http://lkml.kernel.org/r/20160918182125.21000-1-dvlasenk@redhat.com Signed-off-by: Ingo Molnar --- arch/x86/kernel/e820.c | 8 ++++---- arch/x86/mm/init.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index 585000c9..bb8c690 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c @@ -40,10 +40,10 @@ * user can e.g. boot the original kernel with mem=1G while still booting the * next kernel with full memory. */ -static struct e820map initial_e820; -static struct e820map initial_e820_saved; -struct e820map *e820 = &initial_e820; -struct e820map *e820_saved = &initial_e820_saved; +static struct e820map initial_e820 __initdata; +static struct e820map initial_e820_saved __initdata; +struct e820map *e820 __refdata = &initial_e820; +struct e820map *e820_saved __refdata = &initial_e820_saved; /* For PCI or other memory-mapped resources */ unsigned long pci_mem_start = 0xaeedbabe; diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c index 167deae..22af912 100644 --- a/arch/x86/mm/init.c +++ b/arch/x86/mm/init.c @@ -699,9 +699,9 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end) } } -void free_initmem(void) +void __ref free_initmem(void) { - /* e820_reallocate_tables(); - disabled for now */ + e820_reallocate_tables(); free_init_pages("unused kernel", (unsigned long)(&__init_begin),