linux/fs
Andi Kleen 70674f95c0 [PATCH] Optimize select/poll by putting small data sets on the stack
Optimize select and poll by a using stack space for small fd sets

This brings back an old optimization from Linux 2.0.  Using the stack is
faster than kmalloc.  On a Intel P4 system it speeds up a select of a
single pty fd by about 13% (~4000 cycles -> ~3500)

It also saves memory because a daemon hanging in select or poll will
usually save one or two less pages.  This can add up - e.g.  if you have 10
daemons blocking in poll/select you save 40KB of memory.

I did a patch for this long ago, but it was never applied.  This version is
a reimplementation of the old patch that tries to be less intrusive.  I
only did the minimal changes needed for the stack allocation.

The cut off point before external memory is allocated is currently at
832bytes.  The system calls always allocate this much memory on the stack.

These 832 bytes are divided into 256 bytes frontend data (for the select
bitmaps of the pollfds) and the rest of the space for the wait queues used
by the low level drivers.  There are some extreme cases where this won't
work out for select and it falls back to allocating memory too early -
especially with very sparse large select bitmaps - but the majority of
processes who only have a small number of file descriptors should be ok.
[TBD: 832/256 might not be the best split for select or poll]

I suspect more optimizations might be possible, but they would be more
complicated.  One way would be to cache the select/poll context over
multiple system calls because typically the input values should be similar.
 Problem is when to flush the file descriptors out though.

Signed-off-by: Andi Kleen <ak@suse.de>
Cc: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-03-28 09:16:04 -08:00
..
9p [PATCH] 9p: fix name consistency problems 2006-03-25 08:22:54 -08:00
adfs [PATCH] cpuset memory spread: slab cache format 2006-03-24 07:33:23 -08:00
affs [PATCH] cpuset memory spread: slab cache format 2006-03-24 07:33:23 -08:00
afs [PATCH] Make address_space_operations->invalidatepage return void 2006-03-26 08:56:55 -08:00
autofs [PATCH] autofs4: change may_umount* functions to boolean 2006-03-27 08:44:40 -08:00
autofs4 [PATCH] autofs4: proper prototype for autofs4_dentry_release() 2006-03-28 09:16:03 -08:00
befs fix typos "wich" -> "which" 2006-03-24 18:23:14 +01:00
bfs [PATCH] cpuset memory spread: slab cache format 2006-03-24 07:33:23 -08:00
cifs [PATCH] 2tb-files-add-blkcnt_t-fixes 2006-03-26 08:57:00 -08:00
coda BUG_ON() Conversion in fs/coda/ 2006-03-24 18:42:13 +01:00
configfs [PATCH] BUG_ON() Conversion in fs/configfs/ 2006-02-03 14:03:09 -08:00
cramfs [PATCH] sem2mutex: fs/ 2006-03-26 08:56:55 -08:00
debugfs [PATCH] debugfs: Add debugfs_create_blob() helper for exporting binary data 2006-03-20 13:42:59 -08:00
devfs [PATCH] mutex subsystem, semaphore to mutex: VFS, ->i_sem 2006-01-09 15:59:24 -08:00
devpts [PATCH] devpts: use lib/parser.c for parsing mount options 2006-03-23 07:38:17 -08:00
efs [PATCH] cpuset memory spread: slab cache filesystems 2006-03-24 07:33:23 -08:00
exportfs [PATCH] exportfs: add find_acceptable_alias helper 2006-01-18 19:20:28 -08:00
ext2 Merge git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial 2006-03-26 09:41:18 -08:00
ext3 [PATCH] ext3: "nobh" writeback support for filesystems blocksize < pagesize 2006-03-26 08:57:02 -08:00
fat [PATCH] fs/fat/: proper prototypes for two functions 2006-03-28 09:16:03 -08:00
freevxfs [PATCH] cpuset memory spread: slab cache filesystems 2006-03-24 07:33:23 -08:00
fuse [PATCH] fuse: fix bug in negative lookup 2006-02-28 20:53:43 -08:00
hfs Merge git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial 2006-03-26 09:41:18 -08:00
hfsplus [PATCH] remove ->get_blocks() support 2006-03-26 08:57:01 -08:00
hostfs [PATCH] uml: fix hostfs stack corruption 2006-03-27 08:44:39 -08:00
hpfs [PATCH] cpuset memory spread: slab cache format 2006-03-24 07:33:23 -08:00
hppfs [PATCH] mutex subsystem, semaphore to mutex: VFS, ->i_sem 2006-01-09 15:59:24 -08:00
hugetlbfs [PATCH] convert hugetlbfs_counter to atomic 2006-03-22 07:54:04 -08:00
isofs [PATCH] isofs: remove unused debugging macros 2006-03-24 07:33:24 -08:00
jbd [PATCH] Make address_space_operations->invalidatepage return void 2006-03-26 08:56:55 -08:00
jffs [PATCH] cpuset memory spread: slab cache format 2006-03-24 07:33:23 -08:00
jffs2 [PATCH] sem2mutex: fs/ 2006-03-26 08:56:55 -08:00
jfs [PATCH] remove ->get_blocks() support 2006-03-26 08:57:01 -08:00
lockd [PATCH] sem2mutex: fs/ 2006-03-26 08:56:55 -08:00
minix [PATCH] fix messages in fs/minix 2006-03-25 08:22:56 -08:00
msdos [PATCH] fat: remove the unneeded vfat_find() in vfat_rename() 2005-10-30 17:37:32 -08:00
ncpfs [PATCH] cpuset memory spread: slab cache format 2006-03-24 07:33:23 -08:00
nfs [PATCH] mempool: use mempool_create_slab_pool() 2006-03-26 08:57:00 -08:00
nfs_common [PATCH] nfsacl: Solaris VxFS compatibility fix 2005-10-11 09:46:54 -07:00
nfsd [PATCH] fs/nfsd/export.c,net/sunrpc/cache.c: make needlessly global code static 2006-03-27 08:44:43 -08:00
nls [PATCH] fs: Use ARRAY_SIZE macro 2006-03-24 07:33:19 -08:00
ntfs [PATCH] bitops: ntfs: remove generic_ffs() 2006-03-26 08:57:15 -08:00
ocfs2 [PATCH] remove ->get_blocks() support 2006-03-26 08:57:01 -08:00
openpromfs [PATCH] kfree cleanup: fs 2005-11-07 07:54:06 -08:00
partitions [PATCH] dm-md-dependency-tree-in-sysfs-holders-slaves-subdirectory-tidy 2006-03-27 08:44:59 -08:00
proc [PATCH] hrtimers: remove it_real_value calculation from proc/*/stat 2006-03-26 08:57:02 -08:00
qnx4 [PATCH] cpuset memory spread: slab cache format 2006-03-24 07:33:23 -08:00
ramfs [PATCH] fs/*/file.c: drop insane header dependencies 2006-03-23 07:38:17 -08:00
reiserfs [PATCH] remove ->get_blocks() support 2006-03-26 08:57:01 -08:00
romfs [PATCH] cpuset memory spread: slab cache format 2006-03-24 07:33:23 -08:00
smbfs [PATCH] smbfs: Fix debug logging-only compilation error 2006-03-25 08:22:55 -08:00
sysfs [PATCH] sysfs: fix a kobject leak in sysfs_add_link on the error path 2006-03-20 13:42:59 -08:00
sysv [PATCH] cpuset memory spread: slab cache filesystems 2006-03-24 07:33:23 -08:00
udf [PATCH] udf: fix uid/gid options and add uid/gid=ignore and forget options 2006-03-25 08:23:00 -08:00
ufs typo patch for fs/ufs/super.c 2006-03-24 18:21:44 +01:00
vfat [PATCH] fat: remove the unneeded vfat_find() in vfat_rename() 2005-10-30 17:37:32 -08:00
xfs [PATCH] remove ->get_blocks() support 2006-03-26 08:57:01 -08:00
aio.c [PATCH] use kzalloc and kcalloc in core fs code 2006-03-25 08:23:00 -08:00
attr.c [PATCH] capable/capability.h (fs/) 2006-01-11 18:42:13 -08:00
bad_inode.c
binfmt_aout.c [PATCH] dump_thread() cleanup 2006-01-10 08:01:25 -08:00
binfmt_elf_fdpic.c BUG_ON() Conversion in fs/binfmt_elf_fdpic.c 2006-03-24 18:38:48 +01:00
binfmt_elf.c [PATCH] x86_64: Increase the variability of the process stack on 64bit architectures 2006-03-25 09:10:52 -08:00
binfmt_em86.c
binfmt_flat.c [PATCH] flat binary loader doesn't check fd table full 2006-03-25 08:23:01 -08:00
binfmt_misc.c [PATCH] Unlinline a bunch of other functions 2006-01-14 18:27:06 -08:00
binfmt_script.c
binfmt_som.c [PATCH] mm: mm_init set_mm_counters 2005-10-29 21:40:38 -07:00
bio.c [PATCH] mempool: use mempool_create_slab_pool() 2006-03-26 08:57:00 -08:00
block_dev.c [PATCH] dm/md dependency tree in sysfs: convert bd_sem to bd_mutex 2006-03-27 08:45:00 -08:00
buffer.c [PATCH] for_each_online_pgdat: renaming for_each_pgdat 2006-03-27 08:44:48 -08:00
char_dev.c [PATCH] use kzalloc and kcalloc in core fs code 2006-03-25 08:23:00 -08:00
compat_ioctl.c [PATCH] fs: Use ARRAY_SIZE macro 2006-03-24 07:33:19 -08:00
compat.c [PATCH] use kzalloc and kcalloc in core fs code 2006-03-25 08:23:00 -08:00
dcache.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial 2006-03-26 09:41:18 -08:00
dcookies.c [PATCH] Use __read_mostly on some hot fs variables 2006-03-26 08:56:56 -08:00
direct-io.c [PATCH] remove ->get_blocks() support 2006-03-26 08:57:01 -08:00
dnotify.c [PATCH] Use __read_mostly on some hot fs variables 2006-03-26 08:56:56 -08:00
dquot.c [PATCH] cpuset memory spread: slab cache format 2006-03-24 07:33:23 -08:00
drop_caches.c [PATCH] drop-pagecache 2006-01-08 20:12:40 -08:00
eventpoll.c [PATCH] Use __read_mostly on some hot fs variables 2006-03-26 08:56:56 -08:00
exec.c [PATCH] hrtimers: remove data field 2006-03-26 08:57:03 -08:00
fcntl.c [PATCH] Use __read_mostly on some hot fs variables 2006-03-26 08:56:56 -08:00
fifo.c Simplify fifo_open() locking logic 2006-03-07 09:16:35 -08:00
file_table.c [PATCH] get_empty_filp tweaks, inline epoll_init_file() 2006-03-23 07:38:17 -08:00
file.c [PATCH] Shrinks sizeof(files_struct) and better layout 2006-03-23 07:38:09 -08:00
filesystems.c [PATCH] fix missing includes 2005-10-30 17:37:32 -08:00
fs-writeback.c [PATCH] Move cond_resched() after iput() in sync_sb_inodes() 2006-03-25 08:22:56 -08:00
inode.c [PATCH] Use __read_mostly on some hot fs variables 2006-03-26 08:56:56 -08:00
inotify.c [PATCH] Use __read_mostly on some hot fs variables 2006-03-26 08:56:56 -08:00
ioctl.c [PATCH] capable/capability.h (fs/) 2006-01-11 18:42:13 -08:00
ioprio.c [PATCH] capable/capability.h (fs/) 2006-01-11 18:42:13 -08:00
Kconfig Merge branch 'linus' 2006-03-23 23:44:19 -05:00
Kconfig.binfmt [PATCH] frv: suppress configuration of certain features for FRV 2006-01-08 20:13:36 -08:00
libfs.c [PATCH] sem2mutex: fs/libfs.c 2006-03-23 07:38:12 -08:00
locks.c [PATCH] VFS,fs/locks.c,NFSD4: add race_free posix_lock_file_conf() interface 2006-03-26 08:56:56 -08:00
Makefile [PATCH] relay: migrate from relayfs to a generic relay API 2006-03-23 19:56:55 +01:00
mbcache.c [PATCH] cpuset memory spread: slab cache filesystems 2006-03-24 07:33:23 -08:00
mpage.c [PATCH] map multiple blocks for mpage_readpages() 2006-03-26 08:57:01 -08:00
namei.c [PATCH] autofs4: nameidata needs to be up to date for follow_link 2006-03-27 08:44:40 -08:00
namespace.c [PATCH] autofs4: change may_umount* functions to boolean 2006-03-27 08:44:40 -08:00
nfsctl.c [PATCH] fs: Use ARRAY_SIZE macro 2006-03-24 07:33:19 -08:00
open.c Merge branch 'audit.b3' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/audit-current 2006-03-25 09:24:53 -08:00
pipe.c [PATCH] Use __read_mostly on some hot fs variables 2006-03-26 08:56:56 -08:00
pnode.c [PATCH] s/;;/;/g 2006-03-24 07:33:24 -08:00
pnode.h [PATCH] unbindable mounts 2005-11-07 18:18:11 -08:00
posix_acl.c [PATCH] gfp flags annotations - part 1 2005-10-08 15:00:57 -07:00
quota_v1.c
quota_v2.c [PATCH] sem2mutex: quota 2006-03-23 07:38:11 -08:00
quota.c [PATCH] sem2mutex: quota 2006-03-23 07:38:11 -08:00
read_write.c [PATCH] remove needless check in fs/read_write.c 2006-03-25 08:23:01 -08:00
readdir.c [PATCH] mutex subsystem, semaphore to mutex: VFS, ->i_sem 2006-01-09 15:59:24 -08:00
select.c [PATCH] Optimize select/poll by putting small data sets on the stack 2006-03-28 09:16:04 -08:00
seq_file.c [PATCH] sem2mutex: fs/seq_file.c 2006-03-23 07:38:12 -08:00
stat.c [PATCH] fstatat64 support 2006-02-11 21:41:10 -08:00
super.c [PATCH] sem2mutex: fs/ 2006-03-26 08:56:55 -08:00
xattr_acl.c
xattr.c [PATCH] Collect more inode information during syscall processing. 2006-03-20 14:08:53 -05:00