mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Yinghai Lu" <yhlu.kernel@gmail.com>
To: "Gabriel C" <nix.or.die@googlemail.com>
Cc: "Andrew Morton" <akpm@linux-foundation.org>,
	"Ingo Molnar" <mingo@elte.hu>, "H. Peter Anvin" <hpa@zytor.com>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Mika Fischer" <mika.fischer@zoopnet.de>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/2] x86: mtrr cleanup for converting continuous to discrete layout v7
Date: Tue, 29 Apr 2008 20:00:56 -0700	[thread overview]
Message-ID: <86802c440804292000j1b559bc2y8281fa1608d8e4af@mail.gmail.com> (raw)
In-Reply-To: <4817C52A.8000000@googlemail.com>

[-- Attachment #1: Type: text/plain, Size: 36277 bytes --]

On Tue, Apr 29, 2008 at 6:02 PM, Gabriel C <nix.or.die@googlemail.com> wrote:
>
> Yinghai Lu wrote:
>  > On Tue, Apr 29, 2008 at 5:06 PM, Gabriel C <nix.or.die@googlemail.com> wrote:
>  >> Gabriel C wrote:
>  >>  > Yinghai Lu wrote:
>  >>  >> On Tue, Apr 29, 2008 at 1:25 PM, Gabriel C <nix.or.die@googlemail.com> wrote:
>  >>  >>> Yinghai Lu wrote:
>  >>  >>>  > On Tue, Apr 29, 2008 at 4:51 AM, Gabriel C <nix.or.die@googlemail.com> wrote:
>  >>  >>>  >> Yinghai Lu wrote:
>  >>  >>>  >>  > On Tue, Apr 29, 2008 at 3:30 AM, Yinghai Lu <yhlu.kernel@gmail.com> wrote:
>  >>  >>>  >>  >> On Tue, Apr 29, 2008 at 2:47 AM, Gabriel C <nix.or.die@googlemail.com> wrote:
>  >>  >>>  >>  >>  > Yinghai Lu wrote:
>  >>  >>>  >>  >>  >  > some BIOS like to use continus MTRR layout, and may X driver can not add
>  >>  >>>  >>  >>  >  > WB entries for graphical cards when 4g or more RAM installed.
>  >>  >>>  >>  >>  >  >
>  >>  >>>  >>  >>  >  > the patch will change MTRR to discrete.
>  >>  >>>  >>  >>  >  >
>  >>  >>>  >>  >>  >  > mtrr_chunk_size= could be used to have smaller continuous block to hold holes.
>  >>  >>>  >>  >>  >  > default is 256m, could be set according to size of graphics card memory.
>  >>  >>>  >>  >>  >  >
>  >>  >>>  >>  >>  >  > v2: fix -1 for UC checking
>  >>  >>>  >>  >>  >  > v3: default to disable, and need use enable_mtrr_cleanup to enable this feature
>  >>  >>>  >>  >>  >  >     skip the var state change warning.
>  >>  >>>  >>  >>  >  >     remove next_basek in range_to_mtrr()
>  >>  >>>  >>  >>  >  > v4: correct warning mask.
>  >>  >>>  >>  >>  >  > v5: CONFIG_MTRR_SANITIZER
>  >>  >>>  >>  >>  >  > v6: fix 1g, 2g, 512 aligment with extra hole
>  >>  >>>  >>  >>  >  > v7: gran_sizek to prevent running out of MTRRs.
>  >>  >>>  >>  >>  >  >
>  >>  >>>  >>  >>  >
>  >>  >>>  >>  >>  >  With this version ( and patch http://lkml.org/lkml/2008/4/29/97 ) applyed on latest linus git tree
>  >>  >>>  >>  >>  >  the box OOPS'es early.
>  >>  >>>  >>  >>  >
>  >>  >>>  >>  >>  >  Sorry I don't have time right now to write down the part of the OOPS I can see on monitor , I can try to find
>  >>  >>>  >>  >>  >  some time later.
>  >>  >>>  >>  >>  >
>  >>  >>>  >>  >>  >  In any way OOPS'es on __free_one_page+0x191/0x21e
>  >>  >>>  >>  >>
>  >>  >>>  >>  >>  thanks. found one problem with hole_basek ...
>  >>  >>>  >>  >>
>  >>  >>>  >>  >>  will send you v8, and hope it will be last version.
>  >>  >>>  >>  >
>  >>  >>>  >>  > please try v8, it should get rid of the 8m entry. it need patch
>  >>  >>>  >>  > http://lkml.org/lkml/2008/4/29/97 too.
>  >>  >>>  >>
>  >>  >>>  >>  Box does boot with v8 but now I get that warning you fixed in v2 again =):
>  >>  >>>  >>
>  >>  >>>  >>  ....
>  >>  >>>  >>  [    0.000000] Linux version 2.6.25-06058-ga01e035-dirty (crazy@thor) (gcc version 4.3.0 (Frugalware Linux) ) #805 SMP PREEMPT Tue Apr 29 13:04:49 CEST 2008
>  >>  >>>  >>  [    0.000000] Command line: root=/dev/sdb1 ro debug vga=0x317
>  >>  >>>  >>  [    0.000000] BIOS-provided physical RAM map:
>  >>  >>>  >>  [    0.000000]  BIOS-e820: 0000000000000000 - 000000000009cc00 (usable)
>  >>  >>>  >>  [    0.000000]  BIOS-e820: 000000000009cc00 - 00000000000a0000 (reserved)
>  >>  >>>  >>  [    0.000000]  BIOS-e820: 00000000000e4000 - 0000000000100000 (reserved)
>  >>  >>>  >>  [    0.000000]  BIOS-e820: 0000000000100000 - 00000000cf550000 (usable)
>  >>  >>>  >>  [    0.000000]  BIOS-e820: 00000000cf550000 - 00000000cf55e000 (ACPI data)
>  >>  >>>  >>  [    0.000000]  BIOS-e820: 00000000cf55e000 - 00000000cf5e0000 (ACPI NVS)
>  >>  >>>  >>  [    0.000000]  BIOS-e820: 00000000cf5e0000 - 00000000cf600000 (reserved)
>  >>  >>>  >>  [    0.000000]  BIOS-e820: 00000000fee00000 - 00000000fee01000 (reserved)
>  >>  >>>  >>  [    0.000000]  BIOS-e820: 00000000ffc00000 - 0000000100000000 (reserved)
>  >>  >>>  >>  [    0.000000]  BIOS-e820: 0000000100000000 - 000000012c000000 (usable)
>  >>  >>>  >>  [    0.000000] Entering add_active_range(0, 0, 156) 0 entries of 256 used
>  >>  >>>  >>  [    0.000000] Entering add_active_range(0, 256, 849232) 1 entries of 256 used
>  >>  >>>  >>  [    0.000000] Entering add_active_range(0, 1048576, 1228800) 2 entries of 256 used
>  >>  >>>  >>  [    0.000000] max_pfn_mapped = 1228800
>  >>  >>>  >>  [    0.000000] x86 PAT enabled: cpu 0, old 0x7040600070406, new 0x7010600070106
>  >>  >>>  >>  [    0.000000] After WB checking
>  >>  >>>  >>  [    0.000000] MTRR MAP PFN: 0000000000000000 - 000000000012c000
>  >>  >>>  >>  [    0.000000] After UC checking
>  >>  >>>  >>  [    0.000000] MTRR MAP PFN: 0000000000000000 - 00000000000cf600
>  >>  >>>  >>  [    0.000000] MTRR MAP PFN: 0000000000100000 - 000000000012c000
>  >>  >>>  >>  [    0.000000] MTRR MAP PFN: 00000000000cf800 - 00000000000d0000
>  >>  >>>  >>  [    0.000000] After sorting
>  >>  >>>  >>  [    0.000000] MTRR MAP PFN: 0000000000000000 - 00000000000cf600
>  >>  >>>  >>  [    0.000000] MTRR MAP PFN: 00000000000cf800 - 00000000000d0000
>  >>  >>>  >>  [    0.000000] MTRR MAP PFN: 0000000000100000 - 000000000012c000
>  >>  >>>  >>  [    0.000000] range0: 0000000000000000 - 00000000c0000000
>  >>  >>>  >>  [    0.000000] Setting variable MTRR 0, base: 0MB, range: 2048MB, type WB
>  >>  >>>  >>  [    0.000000] Setting variable MTRR 1, base: 2048MB, range: 1024MB, type WB
>  >>  >>>  >>  [    0.000000] range: 00000000c0000000 - 00000000d0000000
>  >>  >>>  >>  [    0.000000] Setting variable MTRR 2, base: 3072MB, range: 256MB, type WB
>  >>  >>>  >>  [    0.000000] hole: 00000000cc000000 - 00000000d0000000
>  >>  >>>  >>  [    0.000000] Setting variable MTRR 3, base: 3264MB, range: 64MB, type UC
>  >>  >>>  >>  [    0.000000] rangeX: 00000000d0000000 - 00000000d0000000
>  >>  >>>  >>  [    0.000000] range0: 0000000100000000 - 0000000120000000
>  >>  >>>  >>  [    0.000000] Setting variable MTRR 4, base: 4096MB, range: 512MB, type WB
>  >>  >>>  >>  [    0.000000] range: 0000000120000000 - 0000000130000000
>  >>  >>>  >>  [    0.000000] Setting variable MTRR 5, base: 4608MB, range: 256MB, type WB
>  >>  >>>  >>  [    0.000000] hole: 000000012c000000 - 0000000130000000
>  >>  >>>  >>  [    0.000000] Setting variable MTRR 6, base: 4800MB, range: 64MB, type UC
>  >>  >>>  >>  [    0.000000] DONE variable MTRRs
>  >>  >>>  >>  [    0.000000] x86 PAT enabled: cpu 0, old 0x7010600070106, new 0x7010600070106
>  >>  >>>  >>  [    0.000000] After WB checking
>  >>  >>>  >>  [    0.000000] MTRR MAP PFN: 0000000000000000 - 00000000000d0000
>  >>  >>>  >>  [    0.000000] MTRR MAP PFN: 0000000000100000 - 0000000000130000
>  >>  >>>  >>  [    0.000000] After UC checking
>  >>  >>>  >>  [    0.000000] MTRR MAP PFN: 0000000000000000 - 00000000000cc000
>  >>  >>>  >>  [    0.000000] MTRR MAP PFN: 0000000000100000 - 000000000012c000
>  >>  >>>  >>  [    0.000000] After sorting
>  >>  >>>  >>  [    0.000000] MTRR MAP PFN: 0000000000000000 - 00000000000cc000
>  >>  >>>  >>  [    0.000000] MTRR MAP PFN: 0000000000100000 - 000000000012c000
>  >>  >>>  >>  [    0.000000] WARNING: BIOS bug: CPU MTRRs don't cover all of memory, losing 757MB of RAM.
>  >>  >>>  >
>  >>  >>>  > so
>  >>  >>>  >>  [    0.000000] MTRR MAP PFN: 0000000000000000 - 00000000000cf600
>  >>  >>>  >>  [    0.000000] MTRR MAP PFN: 00000000000cf800 - 00000000000d0000
>  >>  >>>  >>  [    0.000000] MTRR MAP PFN: 0000000000100000 - 000000000012c000
>  >>  >>>  > ===>
>  >>  >>>  >>  [    0.000000] MTRR MAP PFN: 0000000000000000 - 00000000000cc000
>  >>  >>>  >>  [    0.000000] MTRR MAP PFN: 0000000000100000 - 000000000012c000
>  >>  >>>  >
>  >>  >>>  > please try
>  >>  >>>
>  >>  >>>  Now I have 2 warnings
>  >>  >>>
>  >>  >>>
>  >>  >>>  > mtrr_chunk_size=512m mtrr_gran_size=128m
>  >>  >>>
>  >>  >>>  ...
>  >>  >>>
>  >>  >>>  [    0.000000] Command line: root=/dev/sdb1 ro debug vga=0x317 mtrr_chunk_size=512m mtrr_gran_size=128m 3
>  >>  >>>
>  >>  >>>
>  >>  >>> [    0.000000] BIOS-provided physical RAM map:
>  >>  >>>  [    0.000000]  BIOS-e820: 0000000000000000 - 000000000009cc00 (usable)
>  >>  >>>  [    0.000000]  BIOS-e820: 000000000009cc00 - 00000000000a0000 (reserved)
>  >>  >>>  [    0.000000]  BIOS-e820: 00000000000e4000 - 0000000000100000 (reserved)
>  >>  >>>  [    0.000000]  BIOS-e820: 0000000000100000 - 00000000cf550000 (usable)
>  >>  >>>  [    0.000000]  BIOS-e820: 00000000cf550000 - 00000000cf55e000 (ACPI data)
>  >>  >>>  [    0.000000]  BIOS-e820: 00000000cf55e000 - 00000000cf5e0000 (ACPI NVS)
>  >>  >>>  [    0.000000]  BIOS-e820: 00000000cf5e0000 - 00000000cf600000 (reserved)
>  >>  >>>  [    0.000000]  BIOS-e820: 00000000fee00000 - 00000000fee01000 (reserved)
>  >>  >>>  [    0.000000]  BIOS-e820: 00000000ffc00000 - 0000000100000000 (reserved)
>  >>  >>>  [    0.000000]  BIOS-e820: 0000000100000000 - 000000012c000000 (usable)
>  >>  >>>  [    0.000000] Entering add_active_range(0, 0, 156) 0 entries of 256 used
>  >>  >>>  [    0.000000] Entering add_active_range(0, 256, 849232) 1 entries of 256 used
>  >>  >>>  [    0.000000] Entering add_active_range(0, 1048576, 1228800) 2 entries of 256 used
>  >>  >>>  [    0.000000] max_pfn_mapped = 1228800
>  >>  >>>  [    0.000000] x86 PAT enabled: cpu 0, old 0x7040600070406, new 0x7010600070106
>  >>  >>>  [    0.000000] After WB checking
>  >>  >>>  [    0.000000] MTRR MAP PFN: 0000000000000000 - 000000000012c000
>  >>  >>>  [    0.000000] After UC checking
>  >>  >>>  [    0.000000] MTRR MAP PFN: 0000000000000000 - 00000000000cf600
>  >>  >>>  [    0.000000] MTRR MAP PFN: 0000000000100000 - 000000000012c000
>  >>  >>>  [    0.000000] MTRR MAP PFN: 00000000000cf800 - 00000000000d0000
>  >>  >>>  [    0.000000] After sorting
>  >>  >>>  [    0.000000] MTRR MAP PFN: 0000000000000000 - 00000000000cf600
>  >>  >>>  [    0.000000] MTRR MAP PFN: 00000000000cf800 - 00000000000d0000
>  >>  >>>  [    0.000000] MTRR MAP PFN: 0000000000100000 - 000000000012c000
>  >>  >>>  [    0.000000] range0: 0000000000000000 - 00000000c0000000
>  >>  >>>  [    0.000000] Setting variable MTRR 0, base: 0MB, range: 2048MB, type WB
>  >>  >>>  [    0.000000] Setting variable MTRR 1, base: 2048MB, range: 1024MB, type WB
>  >>  >>>  [    0.000000] range: 00000000c0000000 - 00000000c8000000
>  >>  >>>  [    0.000000] Setting variable MTRR 2, base: 3072MB, range: 128MB, type WB
>  >>  >>>
>  >>  >>> [    0.000000] rangeX: 00000000d0000000 - 00000000d0000000
>  >>  >>>  [    0.000000] range0: 0000000100000000 - 0000000120000000
>  >>  >>>  [    0.000000] Setting variable MTRR 3, base: 4096MB, range: 512MB, type WB
>  >>  >>>  [    0.000000] range: 0000000120000000 - 0000000128000000
>  >>  >>>  [    0.000000] Setting variable MTRR 4, base: 4608MB, range: 128MB, type WB
>  >>  >>>
>  >>  >>> [    0.000000] DONE variable MTRRs
>  >>  >>>  [    0.000000] x86 PAT enabled: cpu 0, old 0x7010600070106, new 0x7010600070106
>  >>  >>>  [    0.000000] After WB checking
>  >>  >>>  [    0.000000] MTRR MAP PFN: 0000000000000000 - 00000000000c8000
>  >>  >>>  [    0.000000] MTRR MAP PFN: 0000000000100000 - 0000000000128000
>  >>  >>>
>  >>  >>> [    0.000000] After UC checking
>  >>  >>>  [    0.000000] MTRR MAP PFN: 0000000000000000 - 00000000000c8000
>  >>  >>>  [    0.000000] MTRR MAP PFN: 0000000000100000 - 0000000000128000
>  >>  >>>  [    0.000000] After sorting
>  >>  >>>  [    0.000000] MTRR MAP PFN: 0000000000000000 - 00000000000c8000
>  >>  >>>  [    0.000000] MTRR MAP PFN: 0000000000100000 - 0000000000128000
>  >>  >>>  [    0.000000] WARNING: BIOS bug: CPU MTRRs don't cover all of memory, losing 64MB of RAM.
>  >>  >>>  [    0.000000] ------------[ cut here ]------------
>  >>  >>>  [    0.000000] WARNING: at arch/x86/kernel/cpu/mtrr/main.c:1206 mtrr_trim_uncached_memory+0x25b/0x35a()
>  >>  >>>
>  >>  >>> [    0.000000] Modules linked in:
>  >>  >>>  [    0.000000] Pid: 0, comm: swapper Not tainted 2.6.25-06058-ga01e035-dirty #805
>  >>  >>>  [    0.000000]
>  >>  >>>  [    0.000000] Call Trace:
>  >>  >>>  [    0.000000]  [<ffffffff8022d661>] warn_on_slowpath+0x51/0x78
>  >>  >>>  [    0.000000]  [<ffffffff8067f0dc>] x86_get_mtrr_mem_range+0x241/0x25c
>  >>  >>>  [    0.000000]  [<ffffffff8067d93e>] update_memory_range+0x95/0xb7
>  >>  >>>  [    0.000000]  [<ffffffff8067fa51>] mtrr_trim_uncached_memory+0x25b/0x35a
>  >>  >>>
>  >>  >>> [    0.000000]  [<ffffffff8067ca43>] setup_arch+0x280/0x4a2
>  >>  >>>  [    0.000000]  [<ffffffff80676aa6>] start_kernel+0x6e/0x308
>  >>  >>>  [    0.000000]  [<ffffffff80676432>] x86_64_start_kernel+0x241/0x24a
>  >>  >>>  [    0.000000]
>  >>  >>>  [    0.000000] ---[ end trace ca143223eefdc828 ]---
>  >>  >>>  [    0.000000] update e820 for mtrr -- end_pfn
>  >>  >>>  [    0.000000] modified physical RAM map:
>  >>  >>>  [    0.000000]  modified: 0000000000000000 - 000000000009cc00 (usable)
>  >>  >>>  [    0.000000]  modified: 000000000009cc00 - 00000000000a0000 (reserved)
>  >>  >>>  [    0.000000]  modified: 00000000000e4000 - 0000000000100000 (reserved)
>  >>  >>>  [    0.000000]  modified: 0000000000100000 - 00000000cf550000 (usable)
>  >>  >>>  [    0.000000]  modified: 00000000cf550000 - 00000000cf55e000 (ACPI data)
>  >>  >>>  [    0.000000]  modified: 00000000cf55e000 - 00000000cf5e0000 (ACPI NVS)
>  >>  >>>  [    0.000000]  modified: 00000000cf5e0000 - 00000000cf600000 (reserved)
>  >>  >>>  [    0.000000]  modified: 00000000fee00000 - 00000000fee01000 (reserved)
>  >>  >>>  [    0.000000]  modified: 00000000ffc00000 - 0000000100000000 (reserved)
>  >>  >>>  [    0.000000]  modified: 0000000100000000 - 0000000128000000 (usable)
>  >>  >>>  [    0.000000]  modified: 0000000128000000 - 000000012c000000 (reserved)
>  >>  >>>
>  >>  >>> [    0.000000] WARNING: BIOS bug: CPU MTRRs don't cover all of memory, losing 757MB of RAM.
>  >>  >>>
>  >>  >>> [    0.000000] ------------[ cut here ]------------
>  >>  >>>  [    0.000000] WARNING: at arch/x86/kernel/cpu/mtrr/main.c:1227 mtrr_trim_uncached_memory+0x30c/0x35a()
>  >>  >>>  [    0.000000] Modules linked in:
>  >>  >>>  [    0.000000] Pid: 0, comm: swapper Not tainted 2.6.25-06058-ga01e035-dirty #805
>  >>  >>>  [    0.000000]
>  >>  >>>  [    0.000000] Call Trace:
>  >>  >>>  [    0.000000]  [<ffffffff8022d661>] warn_on_slowpath+0x51/0x78
>  >>  >>>  [    0.000000]  [<ffffffff8067f0dc>] x86_get_mtrr_mem_range+0x241/0x25c
>  >>  >>>  [    0.000000]  [<ffffffff8067d93e>] update_memory_range+0x95/0xb7
>  >>  >>>  [    0.000000]  [<ffffffff8067fb02>] mtrr_trim_uncached_memory+0x30c/0x35a
>  >>  >>>  [    0.000000]  [<ffffffff8067ca43>] setup_arch+0x280/0x4a2
>  >>  >>>  [    0.000000]  [<ffffffff80676aa6>] start_kernel+0x6e/0x308
>  >>  >>>  [    0.000000]  [<ffffffff80676432>] x86_64_start_kernel+0x241/0x24a
>  >>  >>>  [    0.000000]
>  >>  >>>  [    0.000000] ---[ end trace ca143223eefdc828 ]---
>  >>  >>>  [    0.000000] update e820 for mtrr -- holes
>  >>  >>>  [    0.000000] modified physical RAM map:
>  >>  >>>  [    0.000000]  modified: 0000000000000000 - 000000000009cc00 (usable)
>  >>  >>>  [    0.000000]  modified: 000000000009cc00 - 00000000000a0000 (reserved)
>  >>  >>>  [    0.000000]  modified: 00000000000e4000 - 0000000000100000 (reserved)
>  >>  >>>  [    0.000000]  modified: 0000000000100000 - 00000000c8000000 (usable)
>  >>  >>>  [    0.000000]  modified: 00000000c8000000 - 00000000cf550000 (reserved)
>  >>  >>>  [    0.000000]  modified: 00000000cf550000 - 00000000cf55e000 (ACPI data)
>  >>  >>>  [    0.000000]  modified: 00000000cf55e000 - 00000000cf5e0000 (ACPI NVS)
>  >>  >>>  [    0.000000]  modified: 00000000cf5e0000 - 00000000cf600000 (reserved)
>  >>  >>>  [    0.000000]  modified: 00000000fee00000 - 00000000fee01000 (reserved)
>  >>  >>>  [    0.000000]  modified: 00000000ffc00000 - 000000012c000000 (reserved)
>  >>  >>>
>  >>  >>> [    0.000000] Entering add_active_range(0, 0, 156) 3 entries of 256 used
>  >>  >>>  [    0.000000] Entering add_active_range(0, 256, 819200) 3 entries of 256 used
>  >>  >> please try attached trim_holes_fix.patch..., it will fix the trim hole problem.
>  >>  >
>  >>  > Tested but warning is still there. I try to boot with mtrr_chunk_size / mtrr_gran_size and see what I get.
>  >>  >
>  >>  > ...
>  >>  >
>  >>  > [    0.000000] Linux version 2.6.25-06589-gc65a350-dirty (crazy@thor) (gcc version 4.3.0 (Frugalware Linux) ) #808 SMP PREEMPT Wed Apr 30 01:37:38 CEST 2008
>  >>  > [    0.000000] Command line: root=/dev/sdb1 ro debug vga=0x317
>  >>  > [    0.000000] BIOS-provided physical RAM map:
>  >>  > [    0.000000]  BIOS-e820: 0000000000000000 - 000000000009cc00 (usable)
>  >>  > [    0.000000]  BIOS-e820: 000000000009cc00 - 00000000000a0000 (reserved)
>  >>  > [    0.000000]  BIOS-e820: 00000000000e4000 - 0000000000100000 (reserved)
>  >>  > [    0.000000]  BIOS-e820: 0000000000100000 - 00000000cf550000 (usable)
>  >>  > [    0.000000]  BIOS-e820: 00000000cf550000 - 00000000cf55e000 (ACPI data)
>  >>  > [    0.000000]  BIOS-e820: 00000000cf55e000 - 00000000cf5e0000 (ACPI NVS)
>  >>  > [    0.000000]  BIOS-e820: 00000000cf5e0000 - 00000000cf600000 (reserved)
>  >>  > [    0.000000]  BIOS-e820: 00000000fee00000 - 00000000fee01000 (reserved)
>  >>  > [    0.000000]  BIOS-e820: 00000000ffc00000 - 0000000100000000 (reserved)
>  >>  > [    0.000000]  BIOS-e820: 0000000100000000 - 000000012c000000 (usable)
>  >>  > [    0.000000] Entering add_active_range(0, 0, 156) 0 entries of 256 used
>  >>  > [    0.000000] Entering add_active_range(0, 256, 849232) 1 entries of 256 used
>  >>  > [    0.000000] Entering add_active_range(0, 1048576, 1228800) 2 entries of 256 used
>  >>  > [    0.000000] max_pfn_mapped = 1228800
>  >>  > [    0.000000] x86 PAT enabled: cpu 0, old 0x7040600070406, new 0x7010600070106
>  >>  > [    0.000000] After WB checking
>  >>  > [    0.000000] MTRR MAP PFN: 0000000000000000 - 000000000012c000
>  >>  > [    0.000000] After UC checking
>  >>  > [    0.000000] MTRR MAP PFN: 0000000000000000 - 00000000000cf600
>  >>  > [    0.000000] MTRR MAP PFN: 0000000000100000 - 000000000012c000
>  >>  > [    0.000000] MTRR MAP PFN: 00000000000cf800 - 00000000000d0000
>  >>  > [    0.000000] After sorting
>  >>  > [    0.000000] MTRR MAP PFN: 0000000000000000 - 00000000000cf600
>  >>  > [    0.000000] MTRR MAP PFN: 00000000000cf800 - 00000000000d0000
>  >>  > [    0.000000] MTRR MAP PFN: 0000000000100000 - 000000000012c000
>  >>  > [    0.000000] range0: 0000000000000000 - 00000000c0000000
>  >>  > [    0.000000] Setting variable MTRR 0, base: 0MB, range: 2048MB, type WB
>  >>  > [    0.000000] Setting variable MTRR 1, base: 2048MB, range: 1024MB, type WB
>  >>  > [    0.000000] range: 00000000c0000000 - 00000000d0000000
>  >>  > [    0.000000] Setting variable MTRR 2, base: 3072MB, range: 256MB, type WB
>  >>  > [    0.000000] hole: 00000000cc000000 - 00000000d0000000
>  >>  > [    0.000000] Setting variable MTRR 3, base: 3264MB, range: 64MB, type UC
>  >>  > [    0.000000] rangeX: 00000000d0000000 - 00000000d0000000
>  >>  > [    0.000000] range0: 0000000100000000 - 0000000120000000
>  >>  > [    0.000000] Setting variable MTRR 4, base: 4096MB, range: 512MB, type WB
>  >>  > [    0.000000] range: 0000000120000000 - 0000000130000000
>  >>  > [    0.000000] Setting variable MTRR 5, base: 4608MB, range: 256MB, type WB
>  >>  > [    0.000000] hole: 000000012c000000 - 0000000130000000
>  >>  > [    0.000000] Setting variable MTRR 6, base: 4800MB, range: 64MB, type UC
>  >>  > [    0.000000] DONE variable MTRRs
>  >>  > [    0.000000] x86 PAT enabled: cpu 0, old 0x7010600070106, new 0x7010600070106
>  >>  > [    0.000000] After WB checking
>  >>  > [    0.000000] MTRR MAP PFN: 0000000000000000 - 00000000000d0000
>  >>  > [    0.000000] MTRR MAP PFN: 0000000000100000 - 0000000000130000
>  >>  > [    0.000000] After UC checking
>  >>  > [    0.000000] MTRR MAP PFN: 0000000000000000 - 00000000000cc000
>  >>  > [    0.000000] MTRR MAP PFN: 0000000000100000 - 000000000012c000
>  >>  > [    0.000000] After sorting
>  >>  > [    0.000000] MTRR MAP PFN: 0000000000000000 - 00000000000cc000
>  >>  > [    0.000000] MTRR MAP PFN: 0000000000100000 - 000000000012c000
>  >>  > [    0.000000] WARNING: BIOS bug: CPU MTRRs don't cover all of memory, losing 757MB of RAM.
>  >>  > [    0.000000] ------------[ cut here ]------------
>  >>  > [    0.000000] WARNING: at arch/x86/kernel/cpu/mtrr/main.c:1227 mtrr_trim_uncached_memory+0x313/0x361()
>  >>  > [    0.000000] Modules linked in:
>  >>  > [    0.000000] Pid: 0, comm: swapper Not tainted 2.6.25-06589-gc65a350-dirty #808
>  >>  > [    0.000000]
>  >>  > [    0.000000] Call Trace:
>  >>  > [    0.000000]  [<ffffffff8022d699>] warn_on_slowpath+0x51/0x8c
>  >>  > [    0.000000]  [<ffffffff806810b4>] x86_get_mtrr_mem_range+0x241/0x25c
>  >>  > [    0.000000]  [<ffffffff8067f915>] update_memory_range+0x95/0xb7
>  >>  > [    0.000000]  [<ffffffff80681ae1>] mtrr_trim_uncached_memory+0x313/0x361
>  >>  > [    0.000000]  [<ffffffff8067ea16>] setup_arch+0x280/0x4a6
>  >>  > [    0.000000]  [<ffffffff80678a3d>] start_kernel+0x6e/0x30d
>  >>  > [    0.000000]  [<ffffffff80678432>] x86_64_start_kernel+0x241/0x24a
>  >>  > [    0.000000]
>  >>  > [    0.000000] ---[ end trace 4eaa2a86a8e2da22 ]---
>  >>  > [    0.000000] update e820 for mtrr -- holes
>  >>  > [    0.000000] modified physical RAM map:
>  >>  > [    0.000000]  modified: 0000000000000000 - 000000000009cc00 (usable)
>  >>  > [    0.000000]  modified: 000000000009cc00 - 00000000000a0000 (reserved)
>  >>  > [    0.000000]  modified: 00000000000e4000 - 0000000000100000 (reserved)
>  >>  > [    0.000000]  modified: 0000000000100000 - 00000000cc000000 (usable)
>  >>  > [    0.000000]  modified: 00000000cc000000 - 00000000cf550000 (reserved)
>  >>  > [    0.000000]  modified: 00000000cf550000 - 00000000cf55e000 (ACPI data)
>  >>  > [    0.000000]  modified: 00000000cf55e000 - 00000000cf5e0000 (ACPI NVS)
>  >>  > [    0.000000]  modified: 00000000cf5e0000 - 00000000cf600000 (reserved)
>  >>  > [    0.000000]  modified: 00000000fee00000 - 00000000fee01000 (reserved)
>  >>  > [    0.000000]  modified: 00000000ffc00000 - 000000012c000000 (reserved)
>  >>  > [    0.000000] Entering add_active_range(0, 0, 156) 3 entries of 256 used
>  >>  > [    0.000000] Entering add_active_range(0, 256, 835584) 3 entries of 256 used
>  >>  > [    0.000000] max_pfn_mapped = 1228800
>  >>  > [    0.000000] init_memory_mapping
>  >>  >
>  >>  > ...
>  >>  >
>  >>
>  >>  with mtrr_chunk_size=256m mtrr_gran_size=128m I'm getting :
>  >>
>  >>  ...
>  >>
>  >>
>  >>
>  >>  [    0.000000] BIOS-provided physical RAM map:
>  >>  [    0.000000]  BIOS-e820: 0000000000000000 - 000000000009cc00 (usable)
>  >>  [    0.000000]  BIOS-e820: 000000000009cc00 - 00000000000a0000 (reserved)
>  >>  [    0.000000]  BIOS-e820: 00000000000e4000 - 0000000000100000 (reserved)
>  >>  [    0.000000]  BIOS-e820: 0000000000100000 - 00000000cf550000 (usable)
>  >>  [    0.000000]  BIOS-e820: 00000000cf550000 - 00000000cf55e000 (ACPI data)
>  >>  [    0.000000]  BIOS-e820: 00000000cf55e000 - 00000000cf5e0000 (ACPI NVS)
>  >>  [    0.000000]  BIOS-e820: 00000000cf5e0000 - 00000000cf600000 (reserved)
>  >>  [    0.000000]  BIOS-e820: 00000000fee00000 - 00000000fee01000 (reserved)
>  >>  [    0.000000]  BIOS-e820: 00000000ffc00000 - 0000000100000000 (reserved)
>  >>  [    0.000000]  BIOS-e820: 0000000100000000 - 000000012c000000 (usable)
>  >>  [    0.000000] Entering add_active_range(0, 0, 156) 0 entries of 256 used
>  >>  [    0.000000] Entering add_active_range(0, 256, 849232) 1 entries of 256 used
>  >>  [    0.000000] Entering add_active_range(0, 1048576, 1228800) 2 entries of 256 used
>  >>  [    0.000000] max_pfn_mapped = 1228800
>  >>  [    0.000000] x86 PAT enabled: cpu 0, old 0x7040600070406, new 0x7010600070106
>  >>  [    0.000000] After WB checking
>  >>  [    0.000000] MTRR MAP PFN: 0000000000000000 - 000000000012c000
>  >>  [    0.000000] After UC checking
>  >>  [    0.000000] MTRR MAP PFN: 0000000000000000 - 00000000000cf600
>  >>  [    0.000000] MTRR MAP PFN: 0000000000100000 - 000000000012c000
>  >>  [    0.000000] MTRR MAP PFN: 00000000000cf800 - 00000000000d0000
>  >>  [    0.000000] After sorting
>  >>  [    0.000000] MTRR MAP PFN: 0000000000000000 - 00000000000cf600
>  >>  [    0.000000] MTRR MAP PFN: 00000000000cf800 - 00000000000d0000
>  >>  [    0.000000] MTRR MAP PFN: 0000000000100000 - 000000000012c000
>  >>  [    0.000000] range0: 0000000000000000 - 00000000c0000000
>  >>  [    0.000000] Setting variable MTRR 0, base: 0MB, range: 2048MB, type WB
>  >>  [    0.000000] Setting variable MTRR 1, base: 2048MB, range: 1024MB, type WB
>  >>  [    0.000000] range: 00000000c0000000 - 00000000c8000000
>  >>  [    0.000000] Setting variable MTRR 2, base: 3072MB, range: 128MB, type WB
>  >>  [    0.000000] rangeX: 00000000d0000000 - 00000000d0000000
>  >>  [    0.000000] range0: 0000000100000000 - 0000000120000000
>  >>  [    0.000000] Setting variable MTRR 3, base: 4096MB, range: 512MB, type WB
>  >>  [    0.000000] range: 0000000120000000 - 0000000128000000
>  >>  [    0.000000] Setting variable MTRR 4, base: 4608MB, range: 128MB, type WB
>  >>  [    0.000000] DONE variable MTRRs
>  >>  [    0.000000] x86 PAT enabled: cpu 0, old 0x7010600070106, new 0x7010600070106
>  >>  [    0.000000] After WB checking
>  >>  [    0.000000] MTRR MAP PFN: 0000000000000000 - 00000000000c8000
>  >>  [    0.000000] MTRR MAP PFN: 0000000000100000 - 0000000000128000
>  >>  [    0.000000] After UC checking
>  >>  [    0.000000] MTRR MAP PFN: 0000000000000000 - 00000000000c8000
>  >>  [    0.000000] MTRR MAP PFN: 0000000000100000 - 0000000000128000
>  >>  [    0.000000] After sorting
>  >>  [    0.000000] MTRR MAP PFN: 0000000000000000 - 00000000000c8000
>  >>  [    0.000000] MTRR MAP PFN: 0000000000100000 - 0000000000128000
>  >>  [    0.000000] WARNING: BIOS bug: CPU MTRRs don't cover all of memory, losing 64MB of RAM.
>  >>  [    0.000000] ------------[ cut here ]------------
>  >>  [    0.000000] WARNING: at arch/x86/kernel/cpu/mtrr/main.c:1206 mtrr_trim_uncached_memory+0x25b/0x361()
>  >>
>  >> [    0.000000] Modules linked in:
>  >>  [    0.000000] Pid: 0, comm: swapper Not tainted 2.6.25-06589-gc65a350-dirty #808
>  >>  [    0.000000]
>  >>  [    0.000000] Call Trace:
>  >>  [    0.000000]  [<ffffffff8022d699>] warn_on_slowpath+0x51/0x8c
>  >>  [    0.000000]  [<ffffffff806810b4>] x86_get_mtrr_mem_range+0x241/0x25c
>  >>  [    0.000000]  [<ffffffff8067f915>] update_memory_range+0x95/0xb7
>  >>  [    0.000000]  [<ffffffff80681a29>] mtrr_trim_uncached_memory+0x25b/0x361
>  >>
>  >> [    0.000000]  [<ffffffff8067ea16>] setup_arch+0x280/0x4a6
>  >>  [    0.000000]  [<ffffffff80678a3d>] start_kernel+0x6e/0x30d
>  >>  [    0.000000]  [<ffffffff80678432>] x86_64_start_kernel+0x241/0x24a
>  >>  [    0.000000]
>  >>  [    0.000000] ---[ end trace 4eaa2a86a8e2da22 ]---
>  >>
>  >> [    0.000000] update e820 for mtrr -- end_pfn
>  >>  [    0.000000] modified physical RAM map:
>  >>  [    0.000000]  modified: 0000000000000000 - 000000000009cc00 (usable)
>  >>  [    0.000000]  modified: 000000000009cc00 - 00000000000a0000 (reserved)
>  >>  [    0.000000]  modified: 00000000000e4000 - 0000000000100000 (reserved)
>  >>  [    0.000000]  modified: 0000000000100000 - 00000000cf550000 (usable)
>  >>  [    0.000000]  modified: 00000000cf550000 - 00000000cf55e000 (ACPI data)
>  >>  [    0.000000]  modified: 00000000cf55e000 - 00000000cf5e0000 (ACPI NVS)
>  >>  [    0.000000]  modified: 00000000cf5e0000 - 00000000cf600000 (reserved)
>  >>  [    0.000000]  modified: 00000000fee00000 - 00000000fee01000 (reserved)
>  >>  [    0.000000]  modified: 00000000ffc00000 - 0000000100000000 (reserved)
>  >>  [    0.000000]  modified: 0000000100000000 - 0000000128000000 (usable)
>  >>  [    0.000000]  modified: 0000000128000000 - 000000012c000000 (reserved)
>  >>  [    0.000000] WARNING: BIOS bug: CPU MTRRs don't cover all of memory, losing 757MB of RAM.
>  >>  [    0.000000] ------------[ cut here ]------------
>  >>
>  >> [    0.000000] WARNING: at arch/x86/kernel/cpu/mtrr/main.c:1227 mtrr_trim_uncached_memory+0x313/0x361()
>  >>  [    0.000000] Modules linked in:
>  >>  [    0.000000] Pid: 0, comm: swapper Tainted: G        W 2.6.25-06589-gc65a350-dirty #808
>  >>
>  >> [    0.000000]
>  >>  [    0.000000] Call Trace:
>  >>  [    0.000000]  [<ffffffff8022d699>] warn_on_slowpath+0x51/0x8c
>  >>  [    0.000000]  [<ffffffff806810b4>] x86_get_mtrr_mem_range+0x241/0x25c
>  >>  [    0.000000]  [<ffffffff8067f915>] update_memory_range+0x95/0xb7
>  >>  [    0.000000]  [<ffffffff80681ae1>] mtrr_trim_uncached_memory+0x313/0x361
>  >>  [    0.000000]  [<ffffffff8067ea16>] setup_arch+0x280/0x4a6
>  >>  [    0.000000]  [<ffffffff80678a3d>] start_kernel+0x6e/0x30d
>  >>  [    0.000000]  [<ffffffff80678432>] x86_64_start_kernel+0x241/0x24a
>  >>  [    0.000000]
>  >>  [    0.000000] ---[ end trace 4eaa2a86a8e2da22 ]---
>  >>  [    0.000000] update e820 for mtrr -- holes
>  >>  [    0.000000] modified physical RAM map:
>  >>  [    0.000000]  modified: 0000000000000000 - 000000000009cc00 (usable)
>  >>  [    0.000000]  modified: 000000000009cc00 - 00000000000a0000 (reserved)
>  >>  [    0.000000]  modified: 00000000000e4000 - 0000000000100000 (reserved)
>  >>
>  >> [    0.000000]  modified: 0000000000100000 - 00000000c8000000 (usable)
>  >>  [    0.000000]  modified: 00000000c8000000 - 00000000cf550000 (reserved)
>  >>  [    0.000000]  modified: 00000000cf550000 - 00000000cf55e000 (ACPI data)
>  >>  [    0.000000]  modified: 00000000cf55e000 - 00000000cf5e0000 (ACPI NVS)
>  >>  [    0.000000]  modified: 00000000cf5e0000 - 00000000cf600000 (reserved)
>  >>  [    0.000000]  modified: 00000000fee00000 - 00000000fee01000 (reserved)
>  >>  [    0.000000]  modified: 00000000ffc00000 - 000000012c000000 (reserved)
>  >>  [    0.000000] Entering add_active_range(0, 0, 156) 3 entries of 256 used
>  >>  [    0.000000] Entering add_active_range(0, 256, 819200) 3 entries of 256 used
>  >>
>  > please check attached debug patch...
>
>  Here the output :
>
>  ...
>
>  [    0.000000] Linux version 2.6.25-06598-g33ae0cd-dirty (crazy@thor) (gcc version 4.3.0 (Frugalware Linux) ) #814 SMP PREEMPT Wed Apr 30 02:47:52 CEST 2008
>  [    0.000000] Command line: root=/dev/sdb1 ro debug vga=0x317 mtrr_chunk_size=256m mtrr_gran_size=128m
>
>
> [    0.000000] BIOS-provided physical RAM map:
>  [    0.000000]  BIOS-e820: 0000000000000000 - 000000000009cc00 (usable)
>  [    0.000000]  BIOS-e820: 000000000009cc00 - 00000000000a0000 (reserved)
>  [    0.000000]  BIOS-e820: 00000000000e4000 - 0000000000100000 (reserved)
>  [    0.000000]  BIOS-e820: 0000000000100000 - 00000000cf550000 (usable)
>  [    0.000000]  BIOS-e820: 00000000cf550000 - 00000000cf55e000 (ACPI data)
>  [    0.000000]  BIOS-e820: 00000000cf55e000 - 00000000cf5e0000 (ACPI NVS)
>  [    0.000000]  BIOS-e820: 00000000cf5e0000 - 00000000cf600000 (reserved)
>  [    0.000000]  BIOS-e820: 00000000fee00000 - 00000000fee01000 (reserved)
>  [    0.000000]  BIOS-e820: 00000000ffc00000 - 0000000100000000 (reserved)
>  [    0.000000]  BIOS-e820: 0000000100000000 - 000000012c000000 (usable)
>  [    0.000000] Entering add_active_range(0, 0, 156) 0 entries of 256 used
>  [    0.000000] Entering add_active_range(0, 256, 849232) 1 entries of 256 used
>  [    0.000000] Entering add_active_range(0, 1048576, 1228800) 2 entries of 256 used
>  [    0.000000] max_pfn_mapped = 1228800
>  [    0.000000] x86 PAT enabled: cpu 0, old 0x7040600070406, new 0x7010600070106
>  [    0.000000] After WB checking
>  [    0.000000] MTRR MAP PFN: 0000000000000000 - 000000000012c000
>  [    0.000000] After UC checking
>  [    0.000000] MTRR MAP PFN: 0000000000000000 - 00000000000cf600
>  [    0.000000] MTRR MAP PFN: 0000000000100000 - 000000000012c000
>  [    0.000000] MTRR MAP PFN: 00000000000cf800 - 00000000000d0000
>  [    0.000000] After sorting
>  [    0.000000] MTRR MAP PFN: 0000000000000000 - 00000000000cf600
>  [    0.000000] MTRR MAP PFN: 00000000000cf800 - 00000000000d0000
>  [    0.000000] MTRR MAP PFN: 0000000000100000 - 000000000012c000
>  [    0.000000] range0: 0000000000000000 - 00000000c0000000
>  [    0.000000] Setting variable MTRR 0, base: 0MB, range: 2048MB, type WB
>  [    0.000000] Setting variable MTRR 1, base: 2048MB, range: 1024MB, type WB
>  [    0.000000] range: 00000000c0000000 - 00000000c8000000
>  [    0.000000] Setting variable MTRR 2, base: 3072MB, range: 128MB, type WB
>  [    0.000000] rangeX: 00000000d0000000 - 00000000d0000000
>  [    0.000000] range0: 0000000100000000 - 0000000120000000
>  [    0.000000] Setting variable MTRR 3, base: 4096MB, range: 512MB, type WB
>  [    0.000000] range: 0000000120000000 - 0000000128000000
>  [    0.000000] Setting variable MTRR 4, base: 4608MB, range: 128MB, type WB
>  [    0.000000] DONE variable MTRRs
>  [    0.000000] x86 PAT enabled: cpu 0, old 0x7010600070106, new 0x7010600070106
>  [    0.000000] After WB checking
>  [    0.000000] MTRR MAP PFN: 0000000000000000 - 00000000000c8000
>  [    0.000000] MTRR MAP PFN: 0000000000100000 - 0000000000128000
>  [    0.000000] After UC checking
>  [    0.000000] MTRR MAP PFN: 0000000000000000 - 00000000000c8000
>  [    0.000000] MTRR MAP PFN: 0000000000100000 - 0000000000128000
>  [    0.000000] After sorting
>  [    0.000000] MTRR MAP PFN: 0000000000000000 - 00000000000c8000
>  [    0.000000] MTRR MAP PFN: 0000000000100000 - 0000000000128000
>  [    0.000000] trimm e820 for MTRR MAP (UC): 0000000000128000 - 000000000012c000
>
> [    0.000000] WARNING: BIOS bug: CPU MTRRs don't cover all of memory, losing 64MB of RAM.
>
> [    0.000000] update e820 for mtrr -- end_pfn
>  [    0.000000] modified physical RAM map:
>  [    0.000000]  modified: 0000000000000000 - 000000000009cc00 (usable)
>  [    0.000000]  modified: 000000000009cc00 - 00000000000a0000 (reserved)
>  [    0.000000]  modified: 00000000000e4000 - 0000000000100000 (reserved)
>  [    0.000000]  modified: 0000000000100000 - 00000000cf550000 (usable)
>  [    0.000000]  modified: 00000000cf550000 - 00000000cf55e000 (ACPI data)
>  [    0.000000]  modified: 00000000cf55e000 - 00000000cf5e0000 (ACPI NVS)
>  [    0.000000]  modified: 00000000cf5e0000 - 00000000cf600000 (reserved)
>  [    0.000000]  modified: 00000000fee00000 - 00000000fee01000 (reserved)
>  [    0.000000]  modified: 00000000ffc00000 - 0000000100000000 (reserved)
>  [    0.000000]  modified: 0000000100000000 - 0000000128000000 (usable)
>  [    0.000000]  modified: 0000000128000000 - 000000012c000000 (reserved)
>  [    0.000000] trimm e820 for MTRR MAP (UC): 00000000000c8000 - 0000000000100000
>
> [    0.000000] WARNING: BIOS bug: CPU MTRRs don't cover all of memory, losing 757MB of RAM.
>
> [    0.000000] update e820 for mtrr -- holes
>  [    0.000000] modified physical RAM map:
>  [    0.000000]  modified: 0000000000000000 - 000000000009cc00 (usable)
>  [    0.000000]  modified: 000000000009cc00 - 00000000000a0000 (reserved)
>  [    0.000000]  modified: 00000000000e4000 - 0000000000100000 (reserved)
>  [    0.000000]  modified: 0000000000100000 - 00000000c8000000 (usable)
>  [    0.000000]  modified: 00000000c8000000 - 00000000cf550000 (reserved)
>  [    0.000000]  modified: 00000000cf550000 - 00000000cf55e000 (ACPI data)
>  [    0.000000]  modified: 00000000cf55e000 - 00000000cf5e0000 (ACPI NVS)
>  [    0.000000]  modified: 00000000cf5e0000 - 00000000cf600000 (reserved)
>  [    0.000000]  modified: 00000000fee00000 - 00000000fee01000 (reserved)
>  [    0.000000]  modified: 00000000ffc00000 - 000000012c000000 (reserved)
>  [    0.000000] Entering add_active_range(0, 0, 156) 3 entries of 256 used
>  [    0.000000] Entering add_active_range(0, 256, 819200) 3 entries of 256 used
>
> [    0.000000] max_pfn_mapped = 1228800
>  [    0.000000] init_memory_mapping
>
>  ...
>
>  ( this kernel is still not build with your second cleanup patch will do so in next run )
>
>  Also let me know if you want me to boot with any other mtrr_chunk_size / mtrr_gran_size values.
>
i can not find problem with the code, wonder why it trim out
0000000100000000 - 0000000128000000

please try the attached debug patch in addtion to

http://people.redhat.com/mingo/x86.git/README

YH

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: trim_holes_fix.patch --]
[-- Type: text/x-patch; name=trim_holes_fix.patch, Size: 3206 bytes --]

Index: linux-2.6/arch/x86/kernel/cpu/mtrr/main.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/cpu/mtrr/main.c
+++ linux-2.6/arch/x86/kernel/cpu/mtrr/main.c
@@ -1103,6 +1103,9 @@ static u64 __init real_trim_memory(unsig
 	trim_size = limit_pfn;
 	trim_size <<= PAGE_SHIFT;
 	trim_size -= trim_start;
+
+	printk(KERN_INFO "trim e820 with MTRR MAP (UC): %016lx - %016lx\n", start_pfn, limit_pfn);
+
 	return update_memory_range(trim_start, trim_size, E820_RAM,
 				E820_RESERVED);
 }
@@ -1124,7 +1127,6 @@ int __init mtrr_trim_uncached_memory(uns
 	struct res_range range[RANGE_NUM];
 	int nr_range;
 	u64 total_real_trim_size;
-	int changed;
 
 	/* extra one for all 0 */
 	int num[MTRR_NUM_TYPES + 1];
@@ -1189,49 +1191,35 @@ int __init mtrr_trim_uncached_memory(uns
 	}
 	nr_range = x86_get_mtrr_mem_range(range, nr_range, 0, 0);
 
-	changed = 0;
-	total_real_trim_size = 0;
-
-	/* check the top at first */
-	i = nr_range - 1;
-	if (range[i].end + 1 < end_pfn) {
-			total_real_trim_size += real_trim_memory(range[i].end + 1, end_pfn);
-	}
-
-	if (total_real_trim_size) {
-		printk(KERN_WARNING "WARNING: BIOS bug: CPU MTRRs don't cover"
-			" all of memory, losing %lluMB of RAM.\n",
-			total_real_trim_size >> 20);
-
-		WARN_ON(1);
-
-		printk(KERN_INFO "update e820 for mtrr -- end_pfn\n");
-		update_e820();
-		changed = 1;
-	}
-
 	total_real_trim_size = 0;
+	/* check the head */
 	if (range[0].start)
 		total_real_trim_size += real_trim_memory(0, range[0].start);
-
-	for (i = 0; i < nr_range - 1; i--) {
+	/* check the holes */
+	for (i = 0; i < nr_range - 1; i++) {
 		if (range[i].end + 1 < range[i+1].start)
 			total_real_trim_size += real_trim_memory(range[i].end + 1, range[i+1].start);
 	}
+	/* check the top */
+	i = nr_range - 1;
+	if (range[i].end + 1 < end_pfn)
+		total_real_trim_size += real_trim_memory(range[i].end + 1, end_pfn);
 
 	if (total_real_trim_size) {
 		printk(KERN_WARNING "WARNING: BIOS bug: CPU MTRRs don't cover"
 			" all of memory, losing %lluMB of RAM.\n",
 			total_real_trim_size >> 20);
 
-		WARN_ON(1);
+		if (enable_mtrr_cleanup < 1)
+			WARN_ON(1);
 
-		printk(KERN_INFO "update e820 for mtrr -- holes\n");
+		printk(KERN_INFO "update e820 for mtrr\n");
 		update_e820();
-		changed = 1;
+
+		return 1;
 	}
 
-	return changed;
+	return 0;
 }
 
 /**
Index: linux-2.6/arch/x86/kernel/e820_64.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/e820_64.c
+++ linux-2.6/arch/x86/kernel/e820_64.c
@@ -846,6 +846,8 @@ u64 __init update_memory_range(u64 start
 		if (ei->addr >= start && ei->size <= size) {
 			ei->type = new_type;
 			real_updated_size += ei->size;
+			printk(KERN_INFO "modified physical RAM map - whole cover with %d:\n", i);
+			e820_print_map("modified");
 			continue;
 		}
 		/* partially covered */
@@ -856,6 +858,8 @@ u64 __init update_memory_range(u64 start
 		add_memory_region(final_start, final_end - final_start,
 					 new_type);
 		real_updated_size += final_end - final_start;
+		printk(KERN_INFO "modified physical RAM map - add one with %d:\n", i);
+		e820_print_map("modified");
 	}
 	return real_updated_size;
 }

  reply	other threads:[~2008-04-30  3:01 UTC|newest]

Thread overview: 89+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-28  6:37 [PATCH] x86: mtrr cleanup for converting continuous to discrete layout Yinghai Lu
2008-04-28  9:06 ` [PATCH] x86: mtrr cleanup for converting continuous to discrete layout v2 Yinghai Lu
2008-04-28 13:08   ` Ingo Molnar
2008-04-28 13:49     ` Arjan van de Ven
2008-04-28 15:28       ` Mika Fischer
2008-04-28  5:50         ` Arjan van de Ven
2008-04-28 16:01         ` Gabriel C
2008-04-28 16:28           ` Mika Fischer
2008-04-28 19:44   ` [PATCH] x86: mtrr cleanup for converting continuous to discrete layout v3 Yinghai Lu
2008-04-28 20:15     ` Ingo Molnar
2008-04-28 20:18       ` Yinghai Lu
2008-04-28 20:29         ` Ingo Molnar
2008-04-28 20:16     ` [PATCH] x86: mtrr cleanup for converting continuous to discrete layout v4 Yinghai Lu
2008-04-28 22:05       ` [PATCH] x86: mtrr cleanup for converting continuous to discrete layout v5 Yinghai Lu
2008-04-28 22:36         ` Randy Dunlap
2008-04-28 22:47           ` Yinghai Lu
2008-04-29  2:42         ` Andrew Morton
2008-04-29  3:01           ` Yinghai Lu
     [not found]         ` <200804290157.30651.yhlu.kernel@gmail.com>
2008-04-29  8:59           ` [PATCH 2/2] x86: fix trimming e820 with MTRR holes Yinghai Lu
2008-04-29 11:35             ` Ingo Molnar
2008-04-29 17:18               ` Yinghai Lu
2008-04-29 17:20                 ` Yinghai Lu
2008-04-30  3:25             ` [PATCH] x86: fix trimming e820 with MTRR holes. - fix Yinghai Lu
2008-04-30 12:09               ` Ingo Molnar
2008-04-29  9:00         ` [PATCH 1/2] x86: mtrr cleanup for converting continuous to discrete layout v7 Yinghai Lu
2008-04-29  9:47           ` Gabriel C
2008-04-29 10:30             ` Yinghai Lu
2008-04-29 10:56               ` Yinghai Lu
2008-04-29 11:26                 ` Ingo Molnar
2008-04-29 11:51                 ` Gabriel C
2008-04-29 17:11                   ` Yinghai Lu
2008-04-29 20:25                     ` Gabriel C
2008-04-29 21:49                       ` Yinghai Lu
2008-04-29 23:56                         ` Gabriel C
2008-04-30  0:06                           ` Gabriel C
2008-04-30  0:38                             ` Yinghai Lu
2008-04-30  1:02                               ` Gabriel C
2008-04-30  3:00                                 ` Yinghai Lu [this message]
2008-04-30  3:29                                   ` Yinghai Lu
2008-04-30  4:12                                     ` Gabriel C
2008-04-30  4:25                                       ` Yinghai Lu
2008-04-30 12:04                                         ` Gabriel C
2008-04-30 16:26                                           ` Yinghai Lu
2008-04-30  0:13                           ` Yinghai Lu
2008-04-29 10:52           ` [PATCH 1/2] x86: mtrr cleanup for converting continuous to discrete layout v8 Yinghai Lu
2008-04-29 13:07             ` Ingo Molnar
2008-04-29 17:25               ` Yinghai Lu
2008-04-29 20:46             ` Randy Dunlap
2008-04-29 21:54               ` Yinghai Lu
2008-04-30  3:25             ` [PATCH] x86: mtrr cleanup for converting continuous to discrete layout v8 - fix Yinghai Lu
2008-04-30 12:09               ` Ingo Molnar
2008-05-01  8:00               ` [PATCH] x86: mtrr cleanup for converting continuous to discrete - auto detect Yinghai Lu
2008-05-01 11:45                 ` Gabriel C
2008-05-02  0:06                   ` Yinghai Lu
2008-05-02  0:29                     ` Gabriel C
2008-05-02  0:35                       ` Yinghai Lu
2008-05-02  1:18                         ` Gabriel C
2008-05-02  1:55                           ` Yinghai Lu
2008-05-01 12:09                 ` Mika Fischer
2008-05-01 16:35                   ` Yinghai Lu
2008-05-01 16:59                     ` Mika Fischer
2008-05-01 17:40                       ` Yinghai Lu
2008-05-01 15:09                 ` Randy Dunlap
2008-05-01 16:38                   ` Yinghai Lu
2008-05-01 18:57                 ` [PATCH] x86: mtrr cleanup for converting continuous to discrete - auto detect v2 Yinghai Lu
2008-05-01 19:42                   ` H. Peter Anvin
2008-05-01 21:02                     ` Yinghai Lu
2008-05-01 21:10                       ` H. Peter Anvin
2008-05-01 21:20                         ` Yinghai Lu
2008-05-01 21:26                           ` H. Peter Anvin
2008-05-01 21:31                             ` Yinghai Lu
2008-05-01 21:33                               ` H. Peter Anvin
2008-05-01 21:44                                 ` Yinghai Lu
2008-05-01 21:49                                   ` H. Peter Anvin
2008-05-01 22:52                                     ` Yinghai Lu
2008-05-01 22:57                                       ` H. Peter Anvin
2008-05-01 23:10                                         ` Yinghai Lu
2008-05-02  0:52                   ` [PATCH] x86: mtrr cleanup for converting continuous to discrete - auto detect v3 Yinghai Lu
2008-05-02  9:40                     ` [PATCH] x86: mtrr cleanup for converting continuous to discrete - auto detect v4 Yinghai Lu
2008-04-29 19:00         ` [PATCH] x86: mtrr cleanup for converting continuous to discrete layout v5 Eric W. Biederman
2008-04-29 20:04           ` Yinghai Lu
2008-04-29 20:29             ` Eric W. Biederman
2008-04-29 21:57               ` Yinghai Lu
2008-04-29 22:09                 ` Ingo Molnar
2008-04-29 22:18                   ` Yinghai Lu
2008-04-29 22:14                 ` Eric W. Biederman
2008-04-29 22:54                   ` Thomas Gleixner
2008-04-30  1:16                     ` Eric W. Biederman
2008-04-30  9:57                       ` Alan Cox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86802c440804292000j1b559bc2y8281fa1608d8e4af@mail.gmail.com \
    --to=yhlu.kernel@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mika.fischer@zoopnet.de \
    --cc=mingo@elte.hu \
    --cc=nix.or.die@googlemail.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®