]> git.baikalelectronics.ru Git - kernel.git/commit
kernel/sys.c: get rid of expensive divides in groups_sort()
authorEric Dumazet <dada1@cosmosbay.com>
Wed, 6 Feb 2008 09:37:56 +0000 (01:37 -0800)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Wed, 6 Feb 2008 18:41:09 +0000 (10:41 -0800)
commited89b7d56680343522096962cdc8ab0e3803f676
tree0f478764beb8dc4e0c71c5f3d6a657535579fe3a
parentc80c7e7ea213dbf37897bc0888031ea279887682
kernel/sys.c: get rid of expensive divides in groups_sort()

groups_sort() can be quite long if user loads a large gid table.

This is because GROUP_AT(group_info, some_integer) uses an integer divide.
So having to do XXX thousand divides during one syscall can lead to very
high latencies.  (NGROUPS_MAX=65536)

In the past (25 Mar 2006), an analog problem was found in groups_search()
(commit f767b205541b6d2d3ea37418e691cdcb80501e92 ) and at that time I
changed some variables to unsigned int.

I believe that a more generic fix is to make sure NGROUPS_PER_BLOCK is
unsigned.

Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/sched.h
kernel/sys.c