kernel_optimize_test/arch/x86/include/asm
KAMEZAWA Hiroyuki f2dbcfa738 mm: clean up for early_pfn_to_nid()
What's happening is that the assertion in mm/page_alloc.c:move_freepages()
is triggering:

	BUG_ON(page_zone(start_page) != page_zone(end_page));

Once I knew this is what was happening, I added some annotations:

	if (unlikely(page_zone(start_page) != page_zone(end_page))) {
		printk(KERN_ERR "move_freepages: Bogus zones: "
		       "start_page[%p] end_page[%p] zone[%p]\n",
		       start_page, end_page, zone);
		printk(KERN_ERR "move_freepages: "
		       "start_zone[%p] end_zone[%p]\n",
		       page_zone(start_page), page_zone(end_page));
		printk(KERN_ERR "move_freepages: "
		       "start_pfn[0x%lx] end_pfn[0x%lx]\n",
		       page_to_pfn(start_page), page_to_pfn(end_page));
		printk(KERN_ERR "move_freepages: "
		       "start_nid[%d] end_nid[%d]\n",
		       page_to_nid(start_page), page_to_nid(end_page));
 ...

And here's what I got:

	move_freepages: Bogus zones: start_page[2207d0000] end_page[2207dffc0] zone[fffff8103effcb00]
	move_freepages: start_zone[fffff8103effcb00] end_zone[fffff8003fffeb00]
	move_freepages: start_pfn[0x81f600] end_pfn[0x81f7ff]
	move_freepages: start_nid[1] end_nid[0]

My memory layout on this box is:

[    0.000000] Zone PFN ranges:
[    0.000000]   Normal   0x00000000 -> 0x0081ff5d
[    0.000000] Movable zone start PFN for each node
[    0.000000] early_node_map[8] active PFN ranges
[    0.000000]     0: 0x00000000 -> 0x00020000
[    0.000000]     1: 0x00800000 -> 0x0081f7ff
[    0.000000]     1: 0x0081f800 -> 0x0081fe50
[    0.000000]     1: 0x0081fed1 -> 0x0081fed8
[    0.000000]     1: 0x0081feda -> 0x0081fedb
[    0.000000]     1: 0x0081fedd -> 0x0081fee5
[    0.000000]     1: 0x0081fee7 -> 0x0081ff51
[    0.000000]     1: 0x0081ff59 -> 0x0081ff5d

So it's a block move in that 0x81f600-->0x81f7ff region which triggers
the problem.

This patch:

Declaration of early_pfn_to_nid() is scattered over per-arch include
files, and it seems it's complicated to know when the declaration is used.
 I think it makes fix-for-memmap-init not easy.

This patch moves all declaration to include/linux/mm.h

After this,
  if !CONFIG_NODES_POPULATES_NODE_MAP && !CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID
     -> Use static definition in include/linux/mm.h
  else if !CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID
     -> Use generic definition in mm/page_alloc.c
  else
     -> per-arch back end function will be called.

Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Tested-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Reported-by: David Miller <davem@davemlloft.net>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: <stable@kernel.org>		[2.6.25.x, 2.6.26.x, 2.6.27.x, 2.6.28.x]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-02-18 15:37:55 -08:00
..
bigsmp
es7000 Merge branch 'x86-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2009-01-10 06:13:09 -08:00
mach-default x86: fix apic.c build error on latest git 2009-01-12 19:24:23 +01:00
mach-generic
mach-rdc321x
mach-voyager
numaq
summit Merge branch 'x86-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2009-01-10 06:13:09 -08:00
uv
visws
xen x86: don't apply __supported_pte_mask to non-present ptes 2009-02-04 21:33:09 -08:00
a.out-core.h x86: include correct %gs in a.out core dump 2009-02-09 14:56:37 +01:00
a.out.h
acpi.h
agp.h
alternative-asm.h
alternative.h
amd_iommu_types.h
amd_iommu.h
apic.h
apicdef.h
arch_hooks.h
asm.h
atomic_32.h
atomic_64.h
atomic.h
auxvec.h
bios_ebda.h
bitops.h x86, generic: mark complex bitops.h inlines as __always_inline 2009-01-13 18:56:30 +01:00
boot.h
bootparam.h
bug.h
bugs.h
byteorder.h byteorder: make swab.h include asm/swab.h like a regular header 2009-01-14 19:56:50 -08:00
cache.h
cacheflush.h
calgary.h
calling.h
checksum_32.h
checksum_64.h
checksum.h
cmpxchg_32.h
cmpxchg_64.h
cmpxchg.h
compat.h
cpu.h
cpufeature.h x86: add clflush before monitor for Intel 7400 series 2009-02-09 11:15:15 +01:00
cputime.h
current.h
debugreg.h
delay.h
desc_defs.h
desc.h
device.h
div64.h
dma-mapping.h Documentation: move DMA-mapping.txt to Doc/PCI/ 2009-01-29 18:19:29 -08:00
dma.h
dmi.h
ds.h
dwarf2.h
e820.h headers_check fix: x86, e820.h 2009-01-31 00:16:22 +05:30
edac.h
efi.h
elf.h
emergency-restart.h
errno.h
fb.h
fcntl.h
fixmap_32.h
fixmap_64.h
fixmap.h
floppy.h
frame.h
ftrace.h
futex.h
gart.h
genapic_32.h
genapic_64.h
genapic.h
geode.h
gpio.h
hardirq_32.h
hardirq_64.h
hardirq.h
highmem.h
hpet.h
hugetlb.h
hw_irq.h
hypertransport.h
hypervisor.h
i387.h
i8253.h
i8259.h
ia32_unistd.h
ia32.h
idle.h
intel_arch_perfmon.h
io_32.h
io_64.h
io_apic.h
io.h x86: fix assumed to be contiguous leaf page tables for kmap_atomic region (take 2) 2009-01-16 13:47:04 +01:00
ioctl.h
ioctls.h
iomap.h
iommu.h
ipcbuf.h
ipi.h
irq_regs_32.h
irq_regs_64.h
irq_regs.h
irq_remapping.h
irq_vectors.h
irq.h
irqflags.h
ist.h
k8.h
Kbuild byteorder: make swab.h include asm/swab.h like a regular header 2009-01-14 19:56:50 -08:00
kdebug.h
kexec.h
kgdb.h
kmap_types.h
kprobes.h
kvm_host.h
kvm_para.h
kvm_x86_emulate.h
kvm.h KVM: Avoid using CONFIG_ in userspace visible headers 2009-02-15 02:47:35 +02:00
ldt.h
lguest_hcall.h
lguest.h
linkage.h
local.h
math_emu.h x86: fix math_emu register frame access 2009-02-10 00:39:14 +01:00
mc146818rtc.h
mca_dma.h
mca.h
mce.h headers_check fix: x86, mce.h 2009-01-31 00:17:13 +05:30
microcode.h
mman.h
mmconfig.h
mmu_context_32.h
mmu_context_64.h
mmu_context.h
mmu.h
mmx.h
mmzone_32.h mm: clean up for early_pfn_to_nid() 2009-02-18 15:37:55 -08:00
mmzone_64.h mm: clean up for early_pfn_to_nid() 2009-02-18 15:37:55 -08:00
mmzone.h
module.h
mpspec_def.h
mpspec.h x86: find nr_irqs_gsi with mp_ioapic_routing 2009-02-09 12:42:59 +01:00
msgbuf.h
msidef.h
msr-index.h x86: add MSR_IA32_MISC_ENABLE bits to <asm/msr-index.h> 2009-01-21 15:13:53 -08:00
msr.h
mtrr.h headers_check fix: x86, mtrr.h 2009-01-31 00:17:39 +05:30
mutex_32.h
mutex_64.h
mutex.h
nmi.h
nops.h
numa_32.h
numa_64.h
numa.h
numaq.h
olpc.h
page_32.h
page_64.h
page.h x86, pat: fix warn_on_once() while mapping 0-1MB range with /dev/mem 2009-02-12 08:27:27 +01:00
param.h
paravirt.h Merge branch 'x86-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2009-02-17 14:27:39 -08:00
parport.h
pat.h
pci_32.h
pci_64.h
pci_x86.h
pci-direct.h
pci.h
pda.h
percpu.h
pgalloc.h x86, mm: fix pte_free() 2009-01-23 18:42:06 +01:00
pgtable_32.h
pgtable_64.h
pgtable-2level-defs.h
pgtable-2level.h
pgtable-3level-defs.h
pgtable-3level.h
pgtable.h x86: don't apply __supported_pte_mask to non-present ptes 2009-02-04 21:33:09 -08:00
poll.h
posix_types_32.h
posix_types_64.h
posix_types.h
prctl.h
processor-cyrix.h
processor-flags.h
processor.h x86: math_emu info cleanup 2009-02-09 14:56:39 +01:00
proto.h
ptrace-abi.h headers_check fix: x86, ptrace-abi.h 2009-01-31 00:18:03 +05:30
ptrace.h
pvclock-abi.h
pvclock.h
reboot_fixups.h
reboot.h
required-features.h
resource.h
resume-trace.h
rio.h
rtc.h
rwlock.h
rwsem.h
scatterlist.h
seccomp_32.h
seccomp_64.h
seccomp.h
sections.h
segment.h
sembuf.h
serial.h
setup.h
shmbuf.h
shmparam.h
sigcontext32.h headers_check fix: x86, sigcontext32.h 2009-01-31 00:18:58 +05:30
sigcontext.h headers_check fix: x86, sigcontext.h 2009-01-31 00:18:30 +05:30
sigframe.h
siginfo.h
signal.h
smp.h
socket.h
sockios.h
sparsemem.h
spinlock_types.h
spinlock.h x86: spinlocks: define dummy __raw_spin_is_contended 2009-02-09 08:15:39 -08:00
srat.h
stacktrace.h
stat.h
statfs.h
string_32.h
string_64.h
string.h
suspend_32.h
suspend_64.h
suspend.h
svm.h
swab.h headers_check fix: x86, swab.h 2009-01-31 00:19:32 +05:30
swiotlb.h
sync_bitops.h
sys_ia32.h
syscall.h
syscalls.h Revert "x86: signal: change type of paramter for sys_rt_sigreturn()" 2009-01-21 09:43:18 +01:00
system_64.h
system.h
tce.h
termbits.h
termios.h
therm_throt.h
thread_info.h
time.h
timer.h
timex.h x86: use standard PIT frequency 2009-01-25 16:57:47 +01:00
tlb.h
tlbflush.h
topology.h
trampoline.h
traps.h x86: fix math_emu register frame access 2009-02-10 00:39:14 +01:00
tsc.h
types.h
uaccess_32.h
uaccess_64.h
uaccess.h
ucontext.h
unaligned.h
unistd_32.h
unistd_64.h
unistd.h
user32.h
user_32.h
user_64.h
user.h
vdso.h
vga.h
vgtod.h
vic.h
virtext.h
vm86.h
vmi_time.h
vmi.h
vmware.h
vmx.h
voyager.h
vsyscall.h
xcr.h
xor_32.h
xor_64.h
xor.h
xsave.h