remarkable-linux/drivers/acpi
Tang Chen e8d1955258 acpi, memory-hotplug: parse SRAT before memblock is ready
On linux, the pages used by kernel could not be migrated.  As a result,
if a memory range is used by kernel, it cannot be hot-removed.  So if we
want to hot-remove memory, we should prevent kernel from using it.

The way now used to prevent this is specify a memory range by
movablemem_map boot option and set it as ZONE_MOVABLE.

But when the system is booting, memblock will allocate memory, and
reserve the memory for kernel.  And before we parse SRAT, and know the
node memory ranges, memblock is working.  And it may allocate memory in
ranges to be set as ZONE_MOVABLE.  This memory can be used by kernel,
and never be freed.

So, let's parse SRAT before memblock is called first.  And it is early
enough.

The first call of memblock_find_in_range_node() is in:

  setup_arch()
    |-->setup_real_mode()

so, this patch add a function early_parse_srat() to parse SRAT, and call
it before setup_real_mode() is called.

NOTE:

1) early_parse_srat() is called before numa_init(), and has initialized
   numa_meminfo.  So DO NOT clear numa_nodes_parsed in numa_init() and DO
   NOT zero numa_meminfo in numa_init(), otherwise we will lose memory
   numa info.

2) I don't know why using count of memory affinities parsed from SRAT
   as a return value in original acpi_numa_init().  So I add a static
   variable srat_mem_cnt to remember this count and use it as the return
   value of the new acpi_numa_init()

[mhocko@suse.cz: parse SRAT before memblock is ready fix]
Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
Reviewed-by: Wen Congyang <wency@cn.fujitsu.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Jiang Liu <jiang.liu@huawei.com>
Cc: Jianguo Wu <wujianguo@huawei.com>
Cc: Kamezawa Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Wu Jianguo <wujianguo@huawei.com>
Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Len Brown <lenb@kernel.org>
Cc: "Brown, Len" <len.brown@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-02-23 17:50:14 -08:00
..
acpica ACPICA: Update predefined info table for _MLS method 2013-01-25 13:30:48 +01:00
apei Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2013-02-19 17:49:41 -08:00
ac.c ACPI: Remove useless type argument of driver .remove() operation 2013-01-26 00:37:24 +01:00
acpi_i2c.c
acpi_ipmi.c
acpi_memhotplug.c memory-hotplug: remove sysfs file of node 2013-02-23 17:50:13 -08:00
acpi_pad.c ACPI: Remove useless type argument of driver .remove() operation 2013-01-26 00:37:24 +01:00
acpi_platform.c ACPI / platform: Use struct acpi_scan_handler for creating devices 2013-01-30 14:27:40 +01:00
battery.c ACPI: Remove useless type argument of driver .remove() operation 2013-01-26 00:37:24 +01:00
bgrt.c
blacklist.c
bus.c ACPI / PM: Move device power management functions to device_pm.c 2013-01-19 22:09:22 +01:00
button.c ACPI: Remove useless type argument of driver .remove() operation 2013-01-26 00:37:24 +01:00
cm_sbs.c
container.c ACPI / hotplug: Fix concurrency issues and memory leaks 2013-02-13 14:36:47 +01:00
csrt.c ACPI: add support for CSRT table 2013-01-19 22:16:21 +01:00
custom_method.c ACPI: fix obsolete comment in custom_method.c 2013-01-26 00:34:22 +01:00
debugfs.c
device_pm.c Merge branch 'acpi-scan' 2013-02-11 13:20:02 +01:00
dock.c ACPI / hotplug: Fix concurrency issues and memory leaks 2013-02-13 14:36:47 +01:00
ec.c ACPI: Remove useless type argument of driver .remove() operation 2013-01-26 00:37:24 +01:00
ec_sys.c
event.c
fan.c ACPI: Remove useless type argument of driver .remove() operation 2013-01-26 00:37:24 +01:00
glue.c Merge branch 'acpi-assorted' 2013-02-15 13:58:43 +01:00
hed.c ACPI: Remove useless type argument of driver .remove() operation 2013-01-26 00:37:24 +01:00
internal.h ACPI / scan: Make container driver use struct acpi_scan_handler 2013-02-13 13:43:01 +01:00
Kconfig Driver core patches for 3.9-rc1 2013-02-21 12:05:51 -08:00
Makefile ACPI: add support for CSRT table 2013-01-19 22:16:21 +01:00
numa.c acpi, memory-hotplug: parse SRAT before memblock is ready 2013-02-23 17:50:14 -08:00
nvs.c
osl.c Merge branch 'pm-assorted' 2013-02-15 13:58:54 +01:00
pci_irq.c
pci_link.c ACPI / PCI: Make PCI IRQ link driver use struct acpi_scan_handler 2013-01-30 14:27:37 +01:00
pci_root.c ACPI / PCI: Make PCI root driver use struct acpi_scan_handler 2013-01-30 14:27:33 +01:00
pci_slot.c ACPI / PCI: pci_slot: replace printk(KERN_xxx) with pr_xxx() 2013-02-13 13:41:38 +01:00
power.c ACPI / PM: Fix consistency check for power resources during resume 2013-01-25 21:51:57 +01:00
proc.c ACPI / PM: Fix /proc/acpi/wakeup for devices w/o bus or parent 2013-01-27 21:40:11 +01:00
processor_core.c
processor_driver.c cpu-hotplug, memory-hotplug: try offlining the node when hotremoving a cpu 2013-02-23 17:50:13 -08:00
processor_idle.c Merge branch 'misc' into release 2013-02-18 00:25:53 -05:00
processor_perflib.c ACPI: Check MSR valid bit before using P-state frequencies 2013-01-22 13:37:21 +01:00
processor_thermal.c
processor_throttling.c
reboot.c
resource.c
sbs.c ACPI: Remove useless type argument of driver .remove() operation 2013-01-26 00:37:24 +01:00
sbshc.c ACPI: Remove useless type argument of driver .remove() operation 2013-01-26 00:37:24 +01:00
sbshc.h
scan.c Merge branch 'acpi-cleanup' 2013-02-15 13:58:30 +01:00
sleep.c Merge branch 'acpi-assorted' 2013-02-15 13:58:43 +01:00
sleep.h ACPI: Drop power resources driver 2013-01-17 14:11:06 +01:00
sysfs.c ACPI sysfs: remove unnecessary newline from exception 2013-01-26 00:34:21 +01:00
tables.c ACPICA: Cleanup table handler naming conflicts. 2013-01-11 13:10:16 +01:00
thermal.c Merge branch 'acpi-assorted' 2013-02-15 13:58:43 +01:00
utils.c
video.c Merge branch 'acpi-assorted' 2013-02-15 13:58:43 +01:00
video_detect.c
wakeup.c