Skip to contentSkip to conversation

calculate NGROUPS_PER_BLOCK from PAGE_SIZE

PATCH In review Greg Edwards 2 participants 2 messages May 11, 2004 – May 12, 2004 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 calculate NGROUPS_PER_BLOCK from PAGE_SIZE

On ia64, EXEC_PAGESIZE (max page size) is 65536, but the default page size is 16k. This results in NGROUPS_PER_BLOCK in include/linux/sched.h being calculated incorrectly when the page size is anything other than 64k. For example, on a 16k page size kernel, a setgroups() call with a gidsetsize of 65536 will end up walking over memory since only 1/4 of the needed pages were allocated for the blocks[] array in the group_info struct.

Patch below calculates NGROUPS_PER_BLOCK from PAGE_SIZE instead.

Greg

===== include/linux/sched.h 1.210 vs edited =====

include/linux/sched.h +1 -1
@@ -352,7 +352,7 @@
 void exit_io_context(void);
 
 #define NGROUPS_SMALL		32
-#define NGROUPS_PER_BLOCK	((int)(EXEC_PAGESIZE / sizeof(gid_t)))
+#define NGROUPS_PER_BLOCK	((int)(PAGE_SIZE / sizeof(gid_t)))
 struct group_info {
 	int ngroups;
 	atomic_t usage;
#1 lore raw
Quoted 10 lines · [email protected] (Greg Edwards) wrote:

On ia64, EXEC_PAGESIZE (max page size) is 65536, but the default page size is 16k. This results in NGROUPS_PER_BLOCK in include/linux/sched.h being calculated incorrectly when the page size is anything other than 64k. For example, on a 16k page size kernel, a setgroups() call with a gidsetsize of 65536 will end up walking over memory since only 1/4 of the needed pages were allocated for the blocks[] array in the group_info struct.

Patch below calculates NGROUPS_PER_BLOCK from PAGE_SIZE instead.

yep, thanks.