* Max groups one can be a member of linux/sched.h and NGROUPS_SMALL
@ 2004-10-28 18:02 Joseph Pingenot
2004-10-28 18:21 ` Tim Hockin
0 siblings, 1 reply; 2+ messages in thread
From: Joseph Pingenot @ 2004-10-28 18:02 UTC (permalink / raw)
To: linux-kernel
Hello.
In my quest to try and figure out the max number of groups one can be a
member of (and to learn more about the kernel internals), I stumbled
across the following tidbit:
(excerpted from linux/sched.h)
#define NGROUPS_SMALL 32
#define NGROUPS_PER_BLOCK ((int)(PAGE_SIZE / sizeof(gid_t)))
struct group_info {
int ngroups;
atomic_t usage;
gid_t small_block[NGROUPS_SMALL];
int nblocks;
gid_t *blocks[0];
};
This seems to be the place where group information is stored (linked to from
task_struct).
So, it appears to hold 32 gids, but what is this blocks bit? Is 32 the max
number of groups one can be a member of?
Thanks!
-Joseph
--
Joseph===============================================trelane@digitasaru.net
Graduate Student in Physics, Freelance Free Software Developer
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: Max groups one can be a member of linux/sched.h and NGROUPS_SMALL
2004-10-28 18:02 Max groups one can be a member of linux/sched.h and NGROUPS_SMALL Joseph Pingenot
@ 2004-10-28 18:21 ` Tim Hockin
0 siblings, 0 replies; 2+ messages in thread
From: Tim Hockin @ 2004-10-28 18:21 UTC (permalink / raw)
To: linux-kernel
On Thu, Oct 28, 2004 at 01:02:30PM -0500, Joseph Pingenot wrote:
> #define NGROUPS_SMALL 32
> #define NGROUPS_PER_BLOCK ((int)(PAGE_SIZE / sizeof(gid_t)))
> struct group_info {
> int ngroups;
> atomic_t usage;
> gid_t small_block[NGROUPS_SMALL];
> int nblocks;
> gid_t *blocks[0];
> };
> So, it appears to hold 32 gids, but what is this blocks bit? Is 32 the max
> number of groups one can be a member of?
By default, every task has enough room for 32 gids. If you need more than
32, it uses a dynamically allocated 2-d array, stored in blocks. Always
use the GROUP_AT() macro, and you can treat it like a 1-d array. I think
there is a hardlimit of 64k groups, but that is simply a #define that can
be changed. You can have as many groups as you need, dynamically
allocated per-task, with CoW between tasks. Sorted and bsearch()ed.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-10-28 18:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-28 18:02 Max groups one can be a member of linux/sched.h and NGROUPS_SMALL Joseph Pingenot
2004-10-28 18:21 ` Tim Hockin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.