linux/drivers/base
Dave Hansen c4e1be9ec1 mm, sparsemem: break out of loops early
There are a number of times that we loop over NR_MEM_SECTIONS, looking
for section_present() on each section.  But, when we have very large
physical address spaces (large MAX_PHYSMEM_BITS), NR_MEM_SECTIONS
becomes very large, making the loops quite long.

With MAX_PHYSMEM_BITS=46 and a section size of 128MB, the current loops
are 512k iterations, which we barely notice on modern hardware.  But,
raising MAX_PHYSMEM_BITS higher (like we will see on systems that
support 5-level paging) makes this 64x longer and we start to notice,
especially on slower systems like simulators.  A 10-second delay for
512k iterations is annoying.  But, a 640- second delay is crippling.

This does not help if we have extremely sparse physical address spaces,
but those are quite rare.  We expect that most of the "slow" systems
where this matters will also be quite small and non-sparse.

To fix this, we track the highest section we've ever encountered.  This
lets us know when we will *never* see another section_present(), and
lets us break out of the loops earlier.

Doing the whole for_each_present_section_nr() macro is probably
overkill, but it will ensure that any future loop iterations that we
grow are more likely to be correct.

Kirrill said "It shaved almost 40 seconds from boot time in qemu with
5-level paging enabled for me".

Link: http://lkml.kernel.org/r/20170504174434.C45A4735@viggo.jf.intel.com
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Tested-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-07-06 16:24:31 -07:00
..
power ARM: SoC driver updates 2017-07-04 14:47:47 -07:00
regmap Merge remote-tracking branches 'regmap/topic/1wire', 'regmap/topic/irq' and 'regmap/topic/lzo' into regmap-next 2017-07-03 16:20:28 +01:00
test driver core: test_async: fix up typo found by 0-day 2016-11-29 22:06:42 +01:00
arch_topology.c arm,arm64,drivers: add a prefix to drivers arch_topology interfaces 2017-06-03 19:10:09 +09:00
attribute_container.c attribute_container: Fix typo 2016-08-31 15:13:56 +02:00
base.h Revert "driver core: Add deferred_probe attribute to devices in sysfs" 2017-01-14 14:09:03 +01:00
bus.c driver-core: remove struct bus_type.dev_attrs 2017-06-12 16:18:37 +02:00
cacheinfo.c Merge branch 'x86-cache-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2016-12-22 09:25:45 -08:00
class.c driver core: remove class_attrs from struct class 2017-06-09 10:41:00 +02:00
component.c
container.c
core.c driver core patches for 4.13-rc1 2017-07-03 20:27:48 -07:00
cpu.c CPU / PM: expose pm_qos_resume_latency for CPUs 2017-01-30 11:05:29 +01:00
dd.c of/acpi: Configure dma operations at probe time for platform/amba/pci bus devices 2017-04-20 16:31:06 +02:00
devcoredump.c driver core: devcoredump: convert to use class_groups 2016-11-29 21:12:12 +01:00
devres.c devres: add devm_alloc_percpu() 2016-11-15 22:34:25 -05:00
devtmpfs.c statx: Add a system call to make enhanced file info available 2017-03-02 20:51:15 -05:00
dma-coherent.c drivers: dma-coherent: Move spinlock in dma_alloc_from_coherent() 2016-09-28 17:53:16 +02:00
dma-contiguous.c cma: Store a name in the cma structure 2017-04-18 20:41:12 +02:00
dma-mapping.c drivers: dma-mapping: Do not leave an invalid area->pages pointer in dma_common_contiguous_remap() 2017-06-03 18:51:12 +09:00
driver.c
firmware.c
firmware_class.c firmware: move umh try locks into the umh code 2017-06-03 19:15:50 +09:00
hypervisor.c
init.c
isa.c
Kconfig arm, arm64: factorize common cpu capacity default code 2017-06-03 19:10:09 +09:00
Makefile arm, arm64: factorize common cpu capacity default code 2017-06-03 19:10:09 +09:00
map.c
memory.c mm, sparsemem: break out of loops early 2017-07-06 16:24:31 -07:00
module.c
node.c mm: Adjust system_state check 2017-05-23 10:01:36 +02:00
pinctrl.c driver core: fix automatic pinctrl management 2017-06-13 11:07:32 +02:00
platform-msi.c irqchip/MSI: Use irq_domain_update_bus_token instead of an open coded access 2017-06-22 18:29:17 +02:00
platform.c driver core: platform: fix race condition with driver_override 2017-05-25 15:30:12 +02:00
property.c device property: Read strings using string array reading functions 2017-03-29 22:59:40 +02:00
soc.c base: soc: Allow early registration of a single SoC device 2017-03-29 21:43:26 +02:00
syscore.c
topology.c drivers base/topology: Convert to hotplug state machine 2016-11-09 23:45:29 +01:00
transport_class.c