linux/arch/sparc64/kernel
Wolfgang Wander 1363c3cd86 [PATCH] Avoiding mmap fragmentation
Ingo recently introduced a great speedup for allocating new mmaps using the
free_area_cache pointer which boosts the specweb SSL benchmark by 4-5% and
causes huge performance increases in thread creation.

The downside of this patch is that it does lead to fragmentation in the
mmap-ed areas (visible via /proc/self/maps), such that some applications
that work fine under 2.4 kernels quickly run out of memory on any 2.6
kernel.

The problem is twofold:

  1) the free_area_cache is used to continue a search for memory where
     the last search ended.  Before the change new areas were always
     searched from the base address on.

     So now new small areas are cluttering holes of all sizes
     throughout the whole mmap-able region whereas before small holes
     tended to close holes near the base leaving holes far from the base
     large and available for larger requests.

  2) the free_area_cache also is set to the location of the last
     munmap-ed area so in scenarios where we allocate e.g.  five regions of
     1K each, then free regions 4 2 3 in this order the next request for 1K
     will be placed in the position of the old region 3, whereas before we
     appended it to the still active region 1, placing it at the location
     of the old region 2.  Before we had 1 free region of 2K, now we only
     get two free regions of 1K -> fragmentation.

The patch addresses thes issues by introducing yet another cache descriptor
cached_hole_size that contains the largest known hole size below the
current free_area_cache.  If a new request comes in the size is compared
against the cached_hole_size and if the request can be filled with a hole
below free_area_cache the search is started from the base instead.

The results look promising: Whereas 2.6.12-rc4 fragments quickly and my
(earlier posted) leakme.c test program terminates after 50000+ iterations
with 96 distinct and fragmented maps in /proc/self/maps it performs nicely
(as expected) with thread creation, Ingo's test_str02 with 20000 threads
requires 0.7s system time.

Taking out Ingo's patch (un-patch available per request) by basically
deleting all mentions of free_area_cache from the kernel and starting the
search for new memory always at the respective bases we observe: leakme
terminates successfully with 11 distinctive hardly fragmented areas in
/proc/self/maps but thread creating is gringdingly slow: 30+s(!) system
time for Ingo's test_str02 with 20000 threads.

Now - drumroll ;-) the appended patch works fine with leakme: it ends with
only 7 distinct areas in /proc/self/maps and also thread creation seems
sufficiently fast with 0.71s for 20000 threads.

Signed-off-by: Wolfgang Wander <wwc@rentec.com>
Credit-to: "Richard Purdie" <rpurdie@rpsys.net>
Signed-off-by: Ken Chen <kenneth.w.chen@intel.com>
Acked-by: Ingo Molnar <mingo@elte.hu> (partly)
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-06-21 18:46:16 -07:00
..
Makefile Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
auxio.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
binfmt_aout32.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
binfmt_elf32.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
central.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
chmc.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
cpu.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
devices.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
dtlb_backend.S Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
dtlb_base.S Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
dtlb_prot.S Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
ebus.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
entry.S Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
etrap.S Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
head.S Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
idprom.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
init_task.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
ioctl32.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
iommu_common.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
iommu_common.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
irq.c [SPARC64]: Disable IRQ forwarding. 2005-05-03 22:05:43 -07:00
isa.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
itlb_base.S Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
kprobes.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
module.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
pci.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
pci_common.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
pci_impl.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
pci_iommu.c [SPARC64]: Refine PCI strbuf ctx-based flush. 2005-05-31 19:13:52 -07:00
pci_psycho.c [SPARC64]: Fix streaming buffer flushing on PCI and SBUS. 2005-05-31 16:57:59 -07:00
pci_sabre.c [SPARC64]: Fix streaming buffer flushing on PCI and SBUS. 2005-05-31 16:57:59 -07:00
pci_schizo.c [SPARC64]: Fix streaming buffer flushing on PCI and SBUS. 2005-05-31 16:57:59 -07:00
power.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
process.c [SPARC]: Remove legacy stuff from cpu_idle(). 2005-05-05 14:53:01 -07:00
ptrace.c [PATCH] convert that currently tests _NSIG directly to use valid_signal() 2005-05-01 08:59:14 -07:00
rtrap.S Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
sbus.c [SPARC64]: Fix streaming buffer flushing on PCI and SBUS. 2005-05-31 16:57:59 -07:00
semaphore.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
setup.c [SPARC64]: Add boot option to force UltraSPARC-III P-Cache on. 2005-05-23 15:52:08 -07:00
signal.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
signal32.c [PATCH] sparc64: Fix copy_sigingo_to_user32() 2005-04-17 18:03:12 -07:00
smp.c [SPARC64]: Add boot option to force UltraSPARC-III P-Cache on. 2005-05-23 15:52:08 -07:00
sparc64_ksyms.c [SPARC64]: Kill useless __pte_alloc_one_kernel indirection 2005-05-05 14:27:56 -07:00
starfire.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
sunos_ioctl32.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
sys32.S Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
sys_sparc.c [PATCH] Avoiding mmap fragmentation 2005-06-21 18:46:16 -07:00
sys_sparc32.c [PATCH] sparc64: Fix stat 2005-04-18 15:13:15 -07:00
sys_sunos32.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
systbls.S [PATCH] sparc64: Fix stat 2005-04-18 15:13:15 -07:00
time.c [PATCH] mostek bogus sparse annotations fixed 2005-04-24 12:28:36 -07:00
trampoline.S Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
traps.c [SPARC64]: Add boot option to force UltraSPARC-III P-Cache on. 2005-05-23 15:52:08 -07:00
ttable.S Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
unaligned.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
us2e_cpufreq.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
us3_cpufreq.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
vmlinux.lds.S Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
winfixup.S Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00