linux-IllusionX/fs
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
..
adfs
affs
afs
autofs
autofs4 [PATCH] autofs4: tree race fix 2005-05-01 08:59:17 -07:00
befs
bfs
cifs [CIFS] Fix cifs update of page cache. Write at correct offset when out of memory 2005-06-09 14:44:07 -07:00
coda [PATCH] class: convert the remaining class_simple users in the kernel to usee the new class api 2005-06-20 15:15:11 -07:00
cramfs
debugfs [PATCH] libfs: add simple attribute files 2005-06-20 15:15:30 -07:00
devfs
devpts
efs
exportfs
ext2
ext3 [PATCH] Avoid console spam with ext3 aborted journal. 2005-05-18 09:10:02 -07:00
fat
freevxfs
hfs [PATCH] hfs, hfsplus: don't leak s_fs_info and fix an oops 2005-05-01 08:59:16 -07:00
hfsplus [PATCH] hfs, hfsplus: don't leak s_fs_info and fix an oops 2005-05-01 08:59:16 -07:00
hostfs [PATCH] uml: remove 2_5compat.h 2005-05-28 16:46:11 -07:00
hpfs
hppfs
hugetlbfs [PATCH] Avoiding mmap fragmentation 2005-06-21 18:46:16 -07:00
isofs
jbd [PATCH] ext3: fix list scanning in __cleanup_transaction 2005-06-02 15:12:29 -07:00
jffs
jffs2 [PATCH] make some things static 2005-05-05 16:36:47 -07:00
jfs JFS: Fix compiler warning in jfs_logmgr.c 2005-06-03 14:09:54 -05:00
lockd
minix
msdos
ncpfs
nfs [PATCH] NFS: Ensure that we revalidate the cached file length for llseek(SEEK_END) 2005-06-13 10:33:02 -07:00
nfsd
nls [PATCH] make some things static 2005-05-05 16:36:47 -07:00
ntfs
openpromfs
partitions [PATCH] revert msdos partitioning fix 2005-05-06 22:09:27 -07:00
proc [PATCH] mm: add /proc/zoneinfo 2005-06-21 18:46:14 -07:00
qnx4
ramfs
reiserfs [PATCH] reiserfs: max_key fix 2005-05-21 16:45:24 -07:00
romfs
smbfs
sysfs [PATCH] SYSFS: fix PAGE_SIZE check 2005-06-20 15:15:38 -07:00
sysv
udf [PATCH] UDF filesystem: array '__mon_yday' declared as not static 2005-05-31 14:54:18 -07:00
ufs
umsdos
vfat
xfs [PATCH] smp_processor_id() cleanup 2005-06-21 18:46:13 -07:00
aio.c [PATCH] aio: optimize io_submit_one() 2005-05-01 08:59:16 -07:00
attr.c
bad_inode.c [PATCH] make some things static 2005-05-05 16:36:47 -07:00
binfmt_aout.c [PATCH] Avoiding mmap fragmentation 2005-06-21 18:46:16 -07:00
binfmt_elf.c [PATCH] Avoiding mmap fragmentation 2005-06-21 18:46:16 -07:00
binfmt_elf_fdpic.c
binfmt_em86.c
binfmt_flat.c [PATCH] binfmt_flat mmap flag fix 2005-06-06 14:57:51 -07:00
binfmt_misc.c
binfmt_script.c
binfmt_som.c
bio.c [PATCH] DocBook: fix some descriptions 2005-05-01 08:59:26 -07:00
block_dev.c [PATCH] remove do_sync parameter from __invalidate_device 2005-05-05 16:36:44 -07:00
buffer.c [PATCH] block_read_full_page() get_block() error handling fix 2005-05-17 07:59:20 -07:00
char_dev.c [PATCH] make some things static 2005-05-05 16:36:47 -07:00
compat.c
compat_ioctl.c
dcache.c [PATCH] make some things static 2005-05-05 16:36:47 -07:00
dcookies.c
direct-io.c
dnotify.c
dquot.c
eventpoll.c [PATCH] make some things static 2005-05-05 16:36:47 -07:00
exec.c Clean up subthread exec 2005-06-18 13:06:22 -07:00
fcntl.c
fifo.c
file.c
file_table.c
filesystems.c
fs-writeback.c [PATCH] DocBook: fix some descriptions 2005-05-01 08:59:26 -07:00
inode.c [PATCH] remove do_sync parameter from __invalidate_device 2005-05-05 16:36:44 -07:00
ioctl.c
Kconfig [PATCH] devfs: remove devfs from Kconfig preventing it from being built 2005-06-21 15:41:16 -07:00
Kconfig.binfmt
libfs.c [PATCH] libfs: add simple attribute files 2005-06-20 15:15:30 -07:00
locks.c [PATCH] make some things static 2005-05-05 16:36:47 -07:00
Makefile
mbcache.c [PATCH] make some things static 2005-05-05 16:36:47 -07:00
mpage.c [PATCH] mpage_end_io_write() I/O error handling fix 2005-06-04 17:12:59 -07:00
namei.c [PATCH] namei fixes (19/19) 2005-06-06 14:42:27 -07:00
namespace.c
nfsctl.c
open.c
pipe.c
posix_acl.c
quota.c
quota_v1.c
quota_v2.c
read_write.c
readdir.c
select.c [PATCH] make some things static 2005-05-05 16:36:47 -07:00
seq_file.c [PATCH] DocBook: fix some descriptions 2005-05-01 08:59:26 -07:00
stat.c
super.c
xattr.c
xattr_acl.c