diff options
author | Vadim Lobanov <vlobanov@speakeasy.net> | 2006-12-10 05:21:12 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.osdl.org> | 2006-12-10 12:57:22 -0500 |
commit | bbea9f69668a3d0cf9feba15a724cd02896f8675 (patch) | |
tree | bc58506e4daba4a04309181a5501ae4eb5424783 /fs/select.c | |
parent | f3d19c90fb117a5f080310a4592929aa8e1ad8e9 (diff) |
[PATCH] fdtable: Make fdarray and fdsets equal in size
Currently, each fdtable supports three dynamically-sized arrays of data: the
fdarray and two fdsets. The code allows the number of fds supported by the
fdarray (fdtable->max_fds) to differ from the number of fds supported by each
of the fdsets (fdtable->max_fdset).
In practice, it is wasteful for these two sizes to differ: whenever we hit a
limit on the smaller-capacity structure, we will reallocate the entire fdtable
and all the dynamic arrays within it, so any delta in the memory used by the
larger-capacity structure will never be touched at all.
Rather than hogging this excess, we shouldn't even allocate it in the first
place, and keep the capacities of the fdarray and the fdsets equal. This
patch removes fdtable->max_fdset. As an added bonus, most of the supporting
code becomes simpler.
Signed-off-by: Vadim Lobanov <vlobanov@speakeasy.net>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Dipankar Sarma <dipankar@in.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/select.c')
-rw-r--r-- | fs/select.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/fs/select.c b/fs/select.c index dcbc1112b7ec..fe0893afd931 100644 --- a/fs/select.c +++ b/fs/select.c | |||
@@ -311,7 +311,7 @@ static int core_sys_select(int n, fd_set __user *inp, fd_set __user *outp, | |||
311 | { | 311 | { |
312 | fd_set_bits fds; | 312 | fd_set_bits fds; |
313 | void *bits; | 313 | void *bits; |
314 | int ret, max_fdset; | 314 | int ret, max_fds; |
315 | unsigned int size; | 315 | unsigned int size; |
316 | struct fdtable *fdt; | 316 | struct fdtable *fdt; |
317 | /* Allocate small arguments on the stack to save memory and be faster */ | 317 | /* Allocate small arguments on the stack to save memory and be faster */ |
@@ -321,13 +321,13 @@ static int core_sys_select(int n, fd_set __user *inp, fd_set __user *outp, | |||
321 | if (n < 0) | 321 | if (n < 0) |
322 | goto out_nofds; | 322 | goto out_nofds; |
323 | 323 | ||
324 | /* max_fdset can increase, so grab it once to avoid race */ | 324 | /* max_fds can increase, so grab it once to avoid race */ |
325 | rcu_read_lock(); | 325 | rcu_read_lock(); |
326 | fdt = files_fdtable(current->files); | 326 | fdt = files_fdtable(current->files); |
327 | max_fdset = fdt->max_fdset; | 327 | max_fds = fdt->max_fds; |
328 | rcu_read_unlock(); | 328 | rcu_read_unlock(); |
329 | if (n > max_fdset) | 329 | if (n > max_fds) |
330 | n = max_fdset; | 330 | n = max_fds; |
331 | 331 | ||
332 | /* | 332 | /* |
333 | * We need 6 bitmaps (in/out/ex for both incoming and outgoing), | 333 | * We need 6 bitmaps (in/out/ex for both incoming and outgoing), |