From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754754AbYAVQwO (ORCPT ); Tue, 22 Jan 2008 11:52:14 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751786AbYAVQv6 (ORCPT ); Tue, 22 Jan 2008 11:51:58 -0500 Received: from mx3.mail.elte.hu ([157.181.1.138]:45707 "EHLO mx3.mail.elte.hu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751370AbYAVQvy (ORCPT ); Tue, 22 Jan 2008 11:51:54 -0500 Date: Tue, 22 Jan 2008 17:51:25 +0100 From: Ingo Molnar To: Yinghai Lu Cc: Andi Kleen , "H. Peter Anvin" , LKML , Jesse Barnes , Andrew Morton Subject: Re: [PATCH] x86_32: trim memory by updating e820 v2 Message-ID: <20080122165125.GA17992@elte.hu> References: <200801192045.17291.yinghai.lu@sun.com> <200801202255.02645.yinghai.lu@sun.com> <200801202255.58642.yinghai.lu@sun.com> <200801202256.48365.yinghai.lu@sun.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="k1lZvvs/B4yU6o8G" Content-Disposition: inline In-Reply-To: <200801202256.48365.yinghai.lu@sun.com> User-Agent: Mutt/1.5.17 (2007-11-01) X-ELTE-VirusStatus: clean X-ELTE-SpamScore: -0.7 X-ELTE-SpamLevel: X-ELTE-SpamCheck: no X-ELTE-SpamVersion: ELTE 2.0 X-ELTE-SpamCheck-Details: score=-0.7 required=5.9 tests=BAYES_00,UPPERCASE_50_75 autolearn=no SpamAssassin version=3.2.3 -1.5 BAYES_00 BODY: Bayesian spam probability is 0 to 1% [score: 0.0000] 0.8 UPPERCASE_50_75 message body is 50-75% uppercase Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --k1lZvvs/B4yU6o8G Content-Type: text/plain; charset=us-ascii Content-Disposition: inline * Yinghai Lu wrote: > [PATCH] x86_32: trim memory by updating e820 v2 > > when mtrr is not covering all e820 table, need to trim the ram, need > to update e820 > > reuse some code for x86_64 > > here need to add early_identify_cpu for x86_32, and move mtrr_bp_init > early > > compiled test only, need someone test it i picked up the patch below, and it crashes with: Dentry cache hash table entries: 131072 (order: 7, 524288 bytes) Inode-cache hash table entries: 65536 (order: 6, 262144 bytes) ------------[ cut here ]------------ kernel BUG at arch/x86/mm/pageattr_32.c:327! invalid opcode: 0000 [#1] SMP DEBUG_PAGEALLOC Pid: 0, comm: swapper Not tainted (2.6.24-rc8 #15) EIP: 0060:[] EFLAGS: 00010297 CPU: 0 EIP is at kernel_map_pages+0x52/0xb3 config and bootlog attached as well. Ingo ------------------> Subject: x86_32: trim memory by updating e820 From: Yinghai Lu when mtrr is not covering all e820 table, need to trim the ram, need to update e820 reuse some code for x86_64 here need to add early_identify_cpu for x86_32, and move mtrr_bp_init early compiled test only, need someone test it Signed-off-by: Ingo Molnar --- Documentation/kernel-parameters.txt | 2 +- arch/x86/kernel/cpu/common.c | 12 ++++++++---- arch/x86/kernel/cpu/mtrr/main.c | 2 -- arch/x86/kernel/e820_32.c | 11 +++++++++++ arch/x86/kernel/setup_32.c | 7 +++++++ arch/x86/kernel/setup_64.c | 4 +--- include/asm-x86/e820_32.h | 3 +++ include/asm-x86/processor.h | 1 + 8 files changed, 32 insertions(+), 10 deletions(-) Index: linux-x86.q/Documentation/kernel-parameters.txt =================================================================== --- linux-x86.q.orig/Documentation/kernel-parameters.txt +++ linux-x86.q/Documentation/kernel-parameters.txt @@ -575,7 +575,7 @@ and is between 256 and 4096 characters. See drivers/char/README.epca and Documentation/digiepca.txt. - disable_mtrr_trim [X86-64, Intel only] + disable_mtrr_trim [X86, Intel and AMD only] By default the kernel will trim any uncacheable memory out of your available memory pool based on MTRR settings. This parameter disables that behavior, Index: linux-x86.q/arch/x86/kernel/cpu/common.c =================================================================== --- linux-x86.q.orig/arch/x86/kernel/cpu/common.c +++ linux-x86.q/arch/x86/kernel/cpu/common.c @@ -396,11 +396,9 @@ __setup("serialnumber", x86_serial_nr_se /* * This does the hard work of actually picking apart the CPU stuff... */ -void __cpuinit identify_cpu(struct cpuinfo_x86 *c) +void __cpuinit early_identify_cpu(struct cpuinfo_x86 *c) { - int i; - c->loops_per_jiffy = loops_per_jiffy; c->x86_cache_size = -1; c->x86_vendor = X86_VENDOR_UNKNOWN; c->cpuid_level = -1; /* CPUID not detected */ @@ -424,7 +422,14 @@ void __cpuinit identify_cpu(struct cpuin if (this_cpu->c_identify) this_cpu->c_identify(c); +} +void __cpuinit identify_cpu(struct cpuinfo_x86 *c) +{ + int i; + + c->loops_per_jiffy = loops_per_jiffy; + early_identify_cpu(c); /* * Vendor-specific initialization. In this section we * canonicalize the feature flags, meaning if there are @@ -485,7 +490,6 @@ void __init identify_boot_cpu(void) identify_cpu(&boot_cpu_data); sysenter_setup(); enable_sep_cpu(); - mtrr_bp_init(); } void __cpuinit identify_secondary_cpu(struct cpuinfo_x86 *c) Index: linux-x86.q/arch/x86/kernel/cpu/mtrr/main.c =================================================================== --- linux-x86.q.orig/arch/x86/kernel/cpu/mtrr/main.c +++ linux-x86.q/arch/x86/kernel/cpu/mtrr/main.c @@ -624,7 +624,6 @@ static struct sysdev_driver mtrr_sysdev_ .resume = mtrr_restore, }; -#ifdef CONFIG_X86_64 static int disable_mtrr_trim; static int __init disable_mtrr_trim_setup(char *str) @@ -726,7 +725,6 @@ int __init mtrr_trim_uncached_memory(uns return 0; } -#endif /** * mtrr_bp_init - initialize mtrrs on the boot CPU Index: linux-x86.q/arch/x86/kernel/e820_32.c =================================================================== --- linux-x86.q.orig/arch/x86/kernel/e820_32.c +++ linux-x86.q/arch/x86/kernel/e820_32.c @@ -749,3 +749,14 @@ static int __init parse_memmap(char *arg return 0; } early_param("memmap", parse_memmap); +void __init update_e820(void) +{ + u8 nr_map; + + nr_map = e820.nr_map; + if (sanitize_e820_map(e820.map, &nr_map)) + return; + e820.nr_map = nr_map; + printk(KERN_INFO "modified physical RAM map:\n"); + print_memory_map("modified"); +} Index: linux-x86.q/arch/x86/kernel/setup_32.c =================================================================== --- linux-x86.q.orig/arch/x86/kernel/setup_32.c +++ linux-x86.q/arch/x86/kernel/setup_32.c @@ -49,6 +49,7 @@ #include