- Initialize uihashtbl in resource_init();

- Make some variables static, remove the externs from header;
- Wrap few long lines, misc;

No functional changes are intended.
This commit is contained in:
rmind 2008-03-17 00:18:24 +00:00
parent b09761a4bb
commit 05595560a2
3 changed files with 32 additions and 29 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_proc.c,v 1.129 2008/01/02 11:48:51 ad Exp $ */
/* $NetBSD: kern_proc.c,v 1.130 2008/03/17 00:18:24 rmind Exp $ */
/*-
* Copyright (c) 1999, 2006, 2007 The NetBSD Foundation, Inc.
@ -69,7 +69,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.129 2008/01/02 11:48:51 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.130 2008/03/17 00:18:24 rmind Exp $");
#include "opt_kstack.h"
#include "opt_maxuprc.h"
@ -330,9 +330,6 @@ procinit(void)
pid_alloc_lim = pid_tbl_mask - 1;
#undef LINK_EMPTY
uihashtbl =
hashinit(maxproc / 16, HASH_LIST, M_PROC, M_WAITOK, &uihash);
proc_specificdata_domain = specificdata_domain_create();
KASSERT(proc_specificdata_domain != NULL);

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_resource.c,v 1.133 2008/02/24 21:44:51 christos Exp $ */
/* $NetBSD: kern_resource.c,v 1.134 2008/03/17 00:18:24 rmind Exp $ */
/*-
* Copyright (c) 1982, 1986, 1991, 1993
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.133 2008/02/24 21:44:51 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.134 2008/03/17 00:18:24 rmind Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -65,12 +65,14 @@ __KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.133 2008/02/24 21:44:51 christos
rlim_t maxdmap = MAXDSIZ;
rlim_t maxsmap = MAXSSIZ;
struct uihashhead *uihashtbl;
u_long uihash; /* size of hash table - 1 */
kmutex_t uihashtbl_lock;
static kmutex_t uihashtbl_lock;
static LIST_HEAD(uihashhead, uidinfo) *uihashtbl;
static u_long uihash;
static pool_cache_t plimit_cache;
static pool_cache_t pstats_cache;
#define UIHASH(uid) (&uihashtbl[(uid) & uihash])
static pool_cache_t plimit_cache;
static pool_cache_t pstats_cache;
void
resource_init(void)
@ -80,6 +82,8 @@ resource_init(void)
"plimitpl", NULL, IPL_NONE, NULL, NULL, NULL);
pstats_cache = pool_cache_init(sizeof(struct pstats), 0, 0, 0,
"pstatspl", NULL, IPL_NONE, NULL, NULL, NULL);
uihashtbl = hashinit(maxproc / 16, HASH_LIST, M_PROC,
M_WAITOK, &uihash);
}
/*
@ -87,7 +91,8 @@ resource_init(void)
*/
int
sys_getpriority(struct lwp *l, const struct sys_getpriority_args *uap, register_t *retval)
sys_getpriority(struct lwp *l, const struct sys_getpriority_args *uap,
register_t *retval)
{
/* {
syscallarg(int) which;
@ -148,7 +153,8 @@ sys_getpriority(struct lwp *l, const struct sys_getpriority_args *uap, register_
/* ARGSUSED */
int
sys_setpriority(struct lwp *l, const struct sys_setpriority_args *uap, register_t *retval)
sys_setpriority(struct lwp *l, const struct sys_setpriority_args *uap,
register_t *retval)
{
/* {
syscallarg(int) which;
@ -251,7 +257,8 @@ donice(struct lwp *l, struct proc *chgp, int n)
/* ARGSUSED */
int
sys_setrlimit(struct lwp *l, const struct sys_setrlimit_args *uap, register_t *retval)
sys_setrlimit(struct lwp *l, const struct sys_setrlimit_args *uap,
register_t *retval)
{
/* {
syscallarg(int) which;
@ -384,7 +391,8 @@ dosetrlimit(struct lwp *l, struct proc *p, int which, struct rlimit *limp)
/* ARGSUSED */
int
sys_getrlimit(struct lwp *l, const struct sys_getrlimit_args *uap, register_t *retval)
sys_getrlimit(struct lwp *l, const struct sys_getrlimit_args *uap,
register_t *retval)
{
/* {
syscallarg(int) which;
@ -478,7 +486,8 @@ calcru(struct proc *p, struct timeval *up, struct timeval *sp,
/* ARGSUSED */
int
sys_getrusage(struct lwp *l, const struct sys_getrusage_args *uap, register_t *retval)
sys_getrusage(struct lwp *l, const struct sys_getrusage_args *uap,
register_t *retval)
{
/* {
syscallarg(int) who;

View File

@ -1,4 +1,4 @@
/* $NetBSD: resourcevar.h,v 1.41 2007/12/26 16:01:38 ad Exp $ */
/* $NetBSD: resourcevar.h,v 1.42 2008/03/17 00:18:24 rmind Exp $ */
/*
* Copyright (c) 1991, 1993
@ -105,12 +105,9 @@ struct uidinfo {
kmutex_t ui_lock; /* mutex for everything */
};
#define UIHASH(uid) (&uihashtbl[(uid) & uihash])
extern LIST_HEAD(uihashhead, uidinfo) *uihashtbl;
extern u_long uihash; /* size of hash table - 1 */
int chgproccnt(uid_t, int);
int chgsbsize(struct uidinfo *, u_long *, u_long, rlim_t);
int chgproccnt(uid_t, int);
int chgsbsize(struct uidinfo *, u_long *, u_long, rlim_t);
struct uidinfo *uid_find(uid_t);
void uid_init(void);
@ -122,15 +119,15 @@ extern uid_t security_setidcore_owner;
extern gid_t security_setidcore_group;
extern mode_t security_setidcore_mode;
void addupc_intr(struct lwp *, u_long);
void addupc_task(struct lwp *, u_long, u_int);
void calcru(struct proc *, struct timeval *, struct timeval *,
void addupc_intr(struct lwp *, u_long);
void addupc_task(struct lwp *, u_long, u_int);
void calcru(struct proc *, struct timeval *, struct timeval *,
struct timeval *, struct timeval *);
struct plimit *lim_copy(struct plimit *lim);
void lim_addref(struct plimit *lim);
void lim_privatise(struct proc *p, bool set_shared);
void limfree(struct plimit *);
void lim_addref(struct plimit *lim);
void lim_privatise(struct proc *p, bool set_shared);
void limfree(struct plimit *);
void resource_init(void);
void ruadd(struct rusage *, struct rusage *);