80 users

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

80 users

Luke Small
As I recall, there is a build configuration of 80 users for some kernel
components. What happens if the system exceeds that number?
Reply | Threaded
Open this post in threaded view
|

Re: 80 users

Wiremu Demchick
I'm new to the OpenBSD source, so I welcome correction from someone
who knows more.  But, I'll put my neck out and attempt to give a basic
tour of this aspect of the source.

The maxusers entry in the config(8) file is where it all begins.
    http://man.openbsd.org/config.8

The figure of 80 seems to be the default used for GENERIC builds for
i386 and amd64.  However, the figure is different for some platforms,
like Octeon, where it is 32.  You may be interested in the following
source files:
    sys/arch/amd64/conf/GENERIC
    sys/arch/i386/conf/GENERIC
    sys/arch/octeon/conf/GENERIC

The maxusers value gets compiled into the param.o object, see:
    sys/conf/param.c
    sys/arch/amd64/conf/Makefile.amd64 lines 105-110

Note that in param.c the maxusers value is now called MAXUSERS.  In
param.c, MAXUSERS is used to calculated a few values, namely
maxprocess, maxthread, maxfiles, and initialvnodes.

Taking the example of maxprocess and maxthread, we see in
sys/kern/kern.c the following comment:
    287         /*
    288          * Although process entries are dynamically created,
we still keep
    289          * a global limit on the maximum number we will
create. We reserve
    290          * the last 5 processes to root. The variable nprocesses is the
    291          * current number of processes, maxprocess is the
limit.  Similar
    292          * rules for threads (struct proc): we reserve the
last 5 to root;
    293          * the variable nthreads is the current number of
procs, maxthread is
    294          * the limit.
    295          */

So, it would appear that in this case the maxprocess value (which is
calculated from MAXUSERS) is a global max.  However, as far as I can
tell, it would appear that MAXUSERS is not an absolute limit on the
maximum number of users that can have processes running at a given
time, but is rather a variable used to estimate what resources are
required.  (See again the config(8) manpage, which says maxusers is
"Used to size various system tables and maximum operating conditions
in an approximate fashion.".)

Of course, there are the limits imposed upon individual users, but
that is a different mechanism.  (See
http://man.openbsd.org/getrlimit.2, RLIMIT_NPROC.  kern_fork.c also
implements this limit.)

So, to answer your question, what happens when the process table is
full?  Line 301 of kern_fork.c says:
    return EAGAIN;

That agrees with:
    http://man.openbsd.org/fork.2

In the case of maxfiles, it seems like ENFILE is returned, but I have
not confirmed this:
    http://man.openbsd.org/open.2

Mauri ora koutou.

On 4/30/17, Luke Small <[hidden email]> wrote:
> As I recall, there is a build configuration of 80 users for some kernel
> components. What happens if the system exceeds that number?
>

Reply | Threaded
Open this post in threaded view
|

Re: 80 users

Wiremu Demchick
Apologies, just realised I should make a quick correction.  When I
said "The maxusers value gets compiled into the param.o object", I
meant that values which are calculated from maxusers are compiled into
the object file.  MAXUSERS is a macro, and not itself placed into the
object file.

On 4/30/17, Wiremu Demchick <[hidden email]> wrote:

> I'm new to the OpenBSD source, so I welcome correction from someone
> who knows more.  But, I'll put my neck out and attempt to give a basic
> tour of this aspect of the source.
>
> The maxusers entry in the config(8) file is where it all begins.
>     http://man.openbsd.org/config.8
>
> The figure of 80 seems to be the default used for GENERIC builds for
> i386 and amd64.  However, the figure is different for some platforms,
> like Octeon, where it is 32.  You may be interested in the following
> source files:
>     sys/arch/amd64/conf/GENERIC
>     sys/arch/i386/conf/GENERIC
>     sys/arch/octeon/conf/GENERIC
>
> The maxusers value gets compiled into the param.o object, see:
>     sys/conf/param.c
>     sys/arch/amd64/conf/Makefile.amd64 lines 105-110
>
> Note that in param.c the maxusers value is now called MAXUSERS.  In
> param.c, MAXUSERS is used to calculated a few values, namely
> maxprocess, maxthread, maxfiles, and initialvnodes.
>
> Taking the example of maxprocess and maxthread, we see in
> sys/kern/kern.c the following comment:
>     287         /*
>     288          * Although process entries are dynamically created,
> we still keep
>     289          * a global limit on the maximum number we will
> create. We reserve
>     290          * the last 5 processes to root. The variable nprocesses is
> the
>     291          * current number of processes, maxprocess is the
> limit.  Similar
>     292          * rules for threads (struct proc): we reserve the
> last 5 to root;
>     293          * the variable nthreads is the current number of
> procs, maxthread is
>     294          * the limit.
>     295          */
>
> So, it would appear that in this case the maxprocess value (which is
> calculated from MAXUSERS) is a global max.  However, as far as I can
> tell, it would appear that MAXUSERS is not an absolute limit on the
> maximum number of users that can have processes running at a given
> time, but is rather a variable used to estimate what resources are
> required.  (See again the config(8) manpage, which says maxusers is
> "Used to size various system tables and maximum operating conditions
> in an approximate fashion.".)
>
> Of course, there are the limits imposed upon individual users, but
> that is a different mechanism.  (See
> http://man.openbsd.org/getrlimit.2, RLIMIT_NPROC.  kern_fork.c also
> implements this limit.)
>
> So, to answer your question, what happens when the process table is
> full?  Line 301 of kern_fork.c says:
>     return EAGAIN;
>
> That agrees with:
>     http://man.openbsd.org/fork.2
>
> In the case of maxfiles, it seems like ENFILE is returned, but I have
> not confirmed this:
>     http://man.openbsd.org/open.2
>
> Mauri ora koutou.
>
> On 4/30/17, Luke Small <[hidden email]> wrote:
>> As I recall, there is a build configuration of 80 users for some kernel
>> components. What happens if the system exceeds that number?
>>
>


--
Wiremu Demchick
īmēra - [hidden email]
īmēra - [hidden email]
īmēra - [hidden email]
waea - 04 282 0414 (+6442820414)
waea pūkoro -  021 292 3891 (+64212923891)
kei wikimedia - Kiwi128