aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fcntl.c
diff options
context:
space:
mode:
authorEric Dumazet <dada1@cosmosbay.com>2006-03-23 06:00:12 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-23 10:38:09 -0500
commit0c9e63fd38a2fb2181668a0cdd622a3c23cfd567 (patch)
tree8fdb91603347b1da2e83a095ebcaab44b2c3c237 /fs/fcntl.c
parentd8733c2956968a01394a4d2a9e97a8b431a78776 (diff)
[PATCH] Shrinks sizeof(files_struct) and better layout
1) Reduce the size of (struct fdtable) to exactly 64 bytes on 32bits platforms, lowering kmalloc() allocated space by 50%. 2) Reduce the size of (files_struct), using a special 32 bits (or 64bits) embedded_fd_set, instead of a 1024 bits fd_set for the close_on_exec_init and open_fds_init fields. This save some ram (248 bytes per task) as most tasks dont open more than 32 files. D-Cache footprint for such tasks is also reduced to the minimum. 3) Reduce size of allocated fdset. Currently two full pages are allocated, that is 32768 bits on x86 for example, and way too much. The minimum is now L1_CACHE_BYTES. UP and SMP should benefit from this patch, because most tasks will touch only one cache line when open()/close() stdin/stdout/stderr (0/1/2), (next_fd, close_on_exec_init, open_fds_init, fd_array[0 .. 2] being in the same cache line) Signed-off-by: Eric Dumazet <dada1@cosmosbay.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/fcntl.c')
-rw-r--r--fs/fcntl.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/fs/fcntl.c b/fs/fcntl.c
index dc4a7007f4e7..03c789560fb8 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -73,8 +73,8 @@ repeat:
73 * orig_start..fdt->next_fd 73 * orig_start..fdt->next_fd
74 */ 74 */
75 start = orig_start; 75 start = orig_start;
76 if (start < fdt->next_fd) 76 if (start < files->next_fd)
77 start = fdt->next_fd; 77 start = files->next_fd;
78 78
79 newfd = start; 79 newfd = start;
80 if (start < fdt->max_fdset) { 80 if (start < fdt->max_fdset) {
@@ -102,9 +102,8 @@ repeat:
102 * we reacquire the fdtable pointer and use it while holding 102 * we reacquire the fdtable pointer and use it while holding
103 * the lock, no one can free it during that time. 103 * the lock, no one can free it during that time.
104 */ 104 */
105 fdt = files_fdtable(files); 105 if (start <= files->next_fd)
106 if (start <= fdt->next_fd) 106 files->next_fd = newfd + 1;
107 fdt->next_fd = newfd + 1;
108 107
109 error = newfd; 108 error = newfd;
110 109