tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: lwp resource limit



On Wed, May 23, 2012 at 07:37:19PM -0400, Christos Zoulas wrote:
> Hello,
> 
> This is a new resource limit to prevent users from exhausting kernel
> resources that lwps use.
> 
> - The limit is per uid
> - The default is 1024 per user unless the architecture overrides it
> - The kernel is never prohibited from creating threads
> - Exceeding the thread limit does not prevent process creation, but
>   it will prevent processes from creating additional threads. So the
>   effective thread limit is nlwp + nproc
> - The name NTHR was chosen to follow prior art
> - There could be atomicity issues for setuid and lwp exits
> - This diff also adds a sysctl kern.uidinfo.* to show the user the uid
>   limits
> 
> comments?
> 
> christos
> Index: kern/init_main.c
> ===================================================================
> RCS file: /cvsroot/src/sys/kern/init_main.c,v
> retrieving revision 1.442
> diff -u -p -u -r1.442 init_main.c
> --- kern/init_main.c  19 Feb 2012 21:06:47 -0000      1.442
> +++ kern/init_main.c  23 May 2012 23:19:31 -0000
> @@ -256,6 +256,7 @@ int       cold = 1;                       /* still 
> working on star
>  struct timespec boottime;            /* time at system startup - will only 
> follow settime deltas */
>  
>  int  start_init_exec;                /* semaphore for start_init() */
> +int  maxlwp;
>  
>  cprng_strong_t       *kern_cprng;
>  
> @@ -291,6 +292,12 @@ main(void)
>  #endif
>       l->l_pflag |= LP_RUNNING;
>  
> +#ifdef __HAVE_CPU_MAXLWP
> +     maxlwp = cpu_maxlwp();
> +#else
> +     maxlwp = 1024;
> +#endif
> +

Configuring the kernel with the preprocessor is just so ... wordy. :-)
Maybe use the linker instead?  E.g., provide a weak alias to a default
implementation of cpu_maxlwp() and a strong alias to the MD override on
architectures that have one.

Dave

-- 
David Young
dyoung%pobox.com@localhost    Urbana, IL    (217) 721-9981


Home | Main Index | Thread Index | Old Index