Changeset View
Changeset View
Standalone View
Standalone View
head/sys/kern/kern_resource.c
Show First 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | |||||
static struct rwlock uihashtbl_lock; | static struct rwlock uihashtbl_lock; | ||||
static LIST_HEAD(uihashhead, uidinfo) *uihashtbl; | static LIST_HEAD(uihashhead, uidinfo) *uihashtbl; | ||||
static u_long uihash; /* size of hash table - 1 */ | static u_long uihash; /* size of hash table - 1 */ | ||||
static void calcru1(struct proc *p, struct rusage_ext *ruxp, | static void calcru1(struct proc *p, struct rusage_ext *ruxp, | ||||
struct timeval *up, struct timeval *sp); | struct timeval *up, struct timeval *sp); | ||||
static int donice(struct thread *td, struct proc *chgp, int n); | static int donice(struct thread *td, struct proc *chgp, int n); | ||||
static struct uidinfo *uilookup(uid_t uid); | static struct uidinfo *uilookup(uid_t uid); | ||||
static void ruxagg_locked(struct rusage_ext *rux, struct thread *td); | static void ruxagg_ext_locked(struct rusage_ext *rux, struct thread *td); | ||||
/* | /* | ||||
* Resource controls and accounting. | * Resource controls and accounting. | ||||
*/ | */ | ||||
#ifndef _SYS_SYSPROTO_H_ | #ifndef _SYS_SYSPROTO_H_ | ||||
struct getpriority_args { | struct getpriority_args { | ||||
int which; | int which; | ||||
int who; | int who; | ||||
▲ Show 20 Lines • Show All 763 Lines • ▼ Show 20 Lines | rufetchtd(struct thread *td, struct rusage *ru) | ||||
*/ | */ | ||||
if (td == curthread) { | if (td == curthread) { | ||||
u = cpu_ticks(); | u = cpu_ticks(); | ||||
runtime = u - PCPU_GET(switchtime); | runtime = u - PCPU_GET(switchtime); | ||||
td->td_runtime += runtime; | td->td_runtime += runtime; | ||||
td->td_incruntime += runtime; | td->td_incruntime += runtime; | ||||
PCPU_SET(switchtime, u); | PCPU_SET(switchtime, u); | ||||
} | } | ||||
ruxagg(p, td); | ruxagg_locked(p, td); | ||||
*ru = td->td_ru; | *ru = td->td_ru; | ||||
calcru1(p, &td->td_rux, &ru->ru_utime, &ru->ru_stime); | calcru1(p, &td->td_rux, &ru->ru_utime, &ru->ru_stime); | ||||
} | } | ||||
/* XXX: the MI version is too slow to use: */ | /* XXX: the MI version is too slow to use: */ | ||||
#ifndef __HAVE_INLINE_FLSLL | #ifndef __HAVE_INLINE_FLSLL | ||||
#define flsll(x) (fls((x) >> 32) != 0 ? fls((x) >> 32) + 32 : fls(x)) | #define flsll(x) (fls((x) >> 32) != 0 ? fls((x) >> 32) + 32 : fls(x)) | ||||
#endif | #endif | ||||
▲ Show 20 Lines • Show All 239 Lines • ▼ Show 20 Lines | ruadd(struct rusage *ru, struct rusage_ext *rux, struct rusage *ru2, | ||||
rux->rux_tu += rux2->rux_tu; | rux->rux_tu += rux2->rux_tu; | ||||
rucollect(ru, ru2); | rucollect(ru, ru2); | ||||
} | } | ||||
/* | /* | ||||
* Aggregate tick counts into the proc's rusage_ext. | * Aggregate tick counts into the proc's rusage_ext. | ||||
*/ | */ | ||||
static void | static void | ||||
ruxagg_locked(struct rusage_ext *rux, struct thread *td) | ruxagg_ext_locked(struct rusage_ext *rux, struct thread *td) | ||||
{ | { | ||||
THREAD_LOCK_ASSERT(td, MA_OWNED); | |||||
PROC_STATLOCK_ASSERT(td->td_proc, MA_OWNED); | |||||
rux->rux_runtime += td->td_incruntime; | rux->rux_runtime += td->td_incruntime; | ||||
rux->rux_uticks += td->td_uticks; | rux->rux_uticks += td->td_uticks; | ||||
rux->rux_sticks += td->td_sticks; | rux->rux_sticks += td->td_sticks; | ||||
rux->rux_iticks += td->td_iticks; | rux->rux_iticks += td->td_iticks; | ||||
} | } | ||||
void | void | ||||
ruxagg(struct proc *p, struct thread *td) | ruxagg_locked(struct proc *p, struct thread *td) | ||||
{ | { | ||||
THREAD_LOCK_ASSERT(td, MA_OWNED); | |||||
PROC_STATLOCK_ASSERT(td->td_proc, MA_OWNED); | |||||
thread_lock(td); | ruxagg_ext_locked(&p->p_rux, td); | ||||
ruxagg_locked(&p->p_rux, td); | ruxagg_ext_locked(&td->td_rux, td); | ||||
ruxagg_locked(&td->td_rux, td); | |||||
td->td_incruntime = 0; | td->td_incruntime = 0; | ||||
td->td_uticks = 0; | td->td_uticks = 0; | ||||
td->td_iticks = 0; | td->td_iticks = 0; | ||||
td->td_sticks = 0; | td->td_sticks = 0; | ||||
} | |||||
void | |||||
ruxagg(struct proc *p, struct thread *td) | |||||
{ | |||||
thread_lock(td); | |||||
ruxagg_locked(p, td); | |||||
thread_unlock(td); | thread_unlock(td); | ||||
} | } | ||||
/* | /* | ||||
* Update the rusage_ext structure and fetch a valid aggregate rusage | * Update the rusage_ext structure and fetch a valid aggregate rusage | ||||
* for proc p if storage for one is supplied. | * for proc p if storage for one is supplied. | ||||
*/ | */ | ||||
void | void | ||||
▲ Show 20 Lines • Show All 389 Lines • Show Last 20 Lines |