Ingo Molnar a écrit : > > no, i just wanted to make a demonstration that one can be pretty nasty > in on-lkml replies while being technically correct :-) I think you went > a bit overboard in your replies to Davide. Lets move this back into > constructive channels, ok? :) In any case, here is one preliminary patch to show what I had in mind. I only had time to compile it (its very late here), not even boot tested, so dont try it ! [PATCH] reduce max latency of get_unused_fd(). Goal is to scan at most 4096 bytes (or 32768 bits) in the open_fds bitmap. Processes that have many file descriptors might have to scan 128 KB of ram to find a zero bit. Thats about 100 us on modern machines. This patch introduces an array of counters. Each counter gives the number of 'one' bits in a 4 KB section of the open_fds bitmap. I chose to statically allocate this array of counters, being very small (64 bytes), so a dynamic allocation would only add complexity. As a result, max latency is 4 us (same latency on x86 when vm gives you a new page) Signed-off-by: Eric Dumazet --- fs/fcntl.c | 18 +++++++++++++++--- fs/file.c | 6 +++--- fs/open.c | 13 +++++++++++++ include/linux/file.h | 11 +++++++++++ include/linux/fs.h | 2 -- include/linux/init_task.h | 1 + kernel/fork.c | 1 + 7 files changed, 44 insertions(+), 8 deletions(-)