Use callout_reset instead of timeout(9). Most callouts are statically
allocated, 2 have been added to struct proc for setitimer and sleep. Reviewed by: jhb, jlemon
This commit is contained in:
parent
91b7c97713
commit
4f55983606
@ -115,9 +115,9 @@ linux_alarm(struct proc *p, struct linux_alarm_args *args)
|
||||
old_it = p->p_realtimer;
|
||||
getmicrouptime(&tv);
|
||||
if (timevalisset(&old_it.it_value))
|
||||
untimeout(realitexpire, (caddr_t)p, p->p_ithandle);
|
||||
callout_stop(&p->p_itcallout);
|
||||
if (it.it_value.tv_sec != 0) {
|
||||
p->p_ithandle = timeout(realitexpire, (caddr_t)p, tvtohz(&it.it_value));
|
||||
callout_reset(&p->p_itcallout, tvtohz(&it.it_value), realitexpire, p);
|
||||
timevaladd(&it.it_value, &tv);
|
||||
}
|
||||
p->p_realtimer = it;
|
||||
|
@ -312,6 +312,9 @@ proc0_init(void *dummy __unused)
|
||||
|
||||
bcopy("swapper", p->p_comm, sizeof ("swapper"));
|
||||
|
||||
callout_init(&p->p_itcallout, 0);
|
||||
callout_init(&p->p_slpcallout, 0);
|
||||
|
||||
/* Create credentials. */
|
||||
cred0.p_refcnt = 1;
|
||||
cred0.p_uidinfo = uifind(0);
|
||||
|
@ -77,11 +77,9 @@ static comp_t encode_comp_t __P((u_long, u_long));
|
||||
static void acctwatch __P((void *));
|
||||
|
||||
/*
|
||||
* Accounting callout handle used for periodic scheduling of
|
||||
* acctwatch.
|
||||
* Accounting callout used for periodic scheduling of acctwatch.
|
||||
*/
|
||||
static struct callout_handle acctwatch_handle
|
||||
= CALLOUT_HANDLE_INITIALIZER(&acctwatch_handle);
|
||||
static struct callout acctwatch_callout;
|
||||
|
||||
/*
|
||||
* Accounting vnode pointer, and saved vnode pointer.
|
||||
@ -148,7 +146,7 @@ acct(a1, uap)
|
||||
* close the file, and (if no new file was specified, leave).
|
||||
*/
|
||||
if (acctp != NULLVP || savacctp != NULLVP) {
|
||||
untimeout(acctwatch, NULL, acctwatch_handle);
|
||||
callout_stop(&acctwatch_callout);
|
||||
error = vn_close((acctp != NULLVP ? acctp : savacctp), FWRITE,
|
||||
p->p_ucred, p);
|
||||
acctp = savacctp = NULLVP;
|
||||
@ -161,6 +159,7 @@ acct(a1, uap)
|
||||
* free space watcher.
|
||||
*/
|
||||
acctp = nd.ni_vp;
|
||||
callout_init(&acctwatch_callout, 0);
|
||||
acctwatch(NULL);
|
||||
return (error);
|
||||
}
|
||||
@ -329,5 +328,5 @@ acctwatch(a)
|
||||
log(LOG_NOTICE, "Accounting suspended\n");
|
||||
}
|
||||
}
|
||||
acctwatch_handle = timeout(acctwatch, NULL, acctchkfreq * hz);
|
||||
callout_reset(&acctwatch_callout, acctchkfreq * hz, acctwatch, NULL);
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ exit1(p, rv)
|
||||
p->p_flag |= P_WEXIT;
|
||||
SIGEMPTYSET(p->p_siglist);
|
||||
if (timevalisset(&p->p_realtimer.it_value))
|
||||
untimeout(realitexpire, (caddr_t)p, p->p_ithandle);
|
||||
callout_stop(&p->p_itcallout);
|
||||
|
||||
/*
|
||||
* Reset any sigio structures pointing to us as a result of
|
||||
|
@ -483,6 +483,9 @@ again:
|
||||
LIST_INIT(&p2->p_heldmtx);
|
||||
LIST_INIT(&p2->p_contested);
|
||||
|
||||
callout_init(&p2->p_itcallout, 0);
|
||||
callout_init(&p2->p_slpcallout, 0);
|
||||
|
||||
#ifdef KTRACE
|
||||
/*
|
||||
* Copy traceflag and tracefile if enabled.
|
||||
|
@ -70,6 +70,9 @@ int hogticks;
|
||||
int lbolt;
|
||||
int sched_quantum; /* Roundrobin scheduling quantum in ticks. */
|
||||
|
||||
static struct callout schedcpu_callout;
|
||||
static struct callout roundrobin_callout;
|
||||
|
||||
static int curpriority_cmp __P((struct proc *p));
|
||||
static void endtsleep __P((void *));
|
||||
static void maybe_resched __P((struct proc *chk));
|
||||
@ -175,7 +178,7 @@ roundrobin(arg)
|
||||
need_resched();
|
||||
#endif
|
||||
|
||||
timeout(roundrobin, NULL, sched_quantum);
|
||||
callout_reset(&roundrobin_callout, sched_quantum, roundrobin, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -344,7 +347,7 @@ schedcpu(arg)
|
||||
lockmgr(&allproc_lock, LK_RELEASE, NULL, CURPROC);
|
||||
vmmeter();
|
||||
wakeup((caddr_t)&lbolt);
|
||||
timeout(schedcpu, (void *)0, hz);
|
||||
callout_reset(&schedcpu_callout, hz, schedcpu, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -414,7 +417,6 @@ msleep(ident, mtx, priority, wmesg, timo)
|
||||
{
|
||||
struct proc *p = curproc;
|
||||
int s, sig, catch = priority & PCATCH;
|
||||
struct callout_handle thandle;
|
||||
int rval = 0;
|
||||
WITNESS_SAVE_DECL(mtx);
|
||||
|
||||
@ -465,7 +467,7 @@ msleep(ident, mtx, priority, wmesg, timo)
|
||||
p, p->p_pid, p->p_comm, (void *) sched_lock.mtx_lock);
|
||||
TAILQ_INSERT_TAIL(&slpque[LOOKUP(ident)], p, p_slpq);
|
||||
if (timo)
|
||||
thandle = timeout(endtsleep, (void *)p, timo);
|
||||
callout_reset(&p->p_slpcallout, timo, endtsleep, p);
|
||||
/*
|
||||
* We put ourselves on the sleep queue and start our timeout
|
||||
* before calling CURSIG, as we could stop there, and a wakeup
|
||||
@ -517,7 +519,7 @@ resume:
|
||||
goto out;
|
||||
}
|
||||
} else if (timo)
|
||||
untimeout(endtsleep, (void *)p, thandle);
|
||||
callout_stop(&p->p_slpcallout);
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
|
||||
if (catch && (sig != 0 || (sig = CURSIG(p)))) {
|
||||
@ -628,7 +630,6 @@ mawait(struct mtx *mtx, int priority, int timo)
|
||||
s = splhigh();
|
||||
|
||||
if (p->p_wchan != NULL) {
|
||||
struct callout_handle thandle;
|
||||
int sig;
|
||||
int catch;
|
||||
|
||||
@ -646,7 +647,7 @@ mawait(struct mtx *mtx, int priority, int timo)
|
||||
*/
|
||||
|
||||
if (timo)
|
||||
thandle = timeout(endtsleep, (void *)p, timo);
|
||||
callout_reset(&p->p_slpcallout, timo, endtsleep, p);
|
||||
|
||||
sig = 0;
|
||||
catch = priority & PCATCH;
|
||||
@ -687,7 +688,7 @@ resume:
|
||||
goto out;
|
||||
}
|
||||
} else if (timo)
|
||||
untimeout(endtsleep, (void *)p, thandle);
|
||||
callout_stop(&p->p_slpcallout);
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
|
||||
if (catch && (sig != 0 || (sig = CURSIG(p)))) {
|
||||
@ -1036,6 +1037,10 @@ static void
|
||||
sched_setup(dummy)
|
||||
void *dummy;
|
||||
{
|
||||
|
||||
callout_init(&schedcpu_callout, 1);
|
||||
callout_init(&roundrobin_callout, 0);
|
||||
|
||||
/* Kick off timeout driven events by calling first time. */
|
||||
roundrobin(NULL);
|
||||
schedcpu(NULL);
|
||||
|
@ -513,10 +513,10 @@ setitimer(p, uap)
|
||||
s = splclock(); /* XXX: still needed ? */
|
||||
if (uap->which == ITIMER_REAL) {
|
||||
if (timevalisset(&p->p_realtimer.it_value))
|
||||
untimeout(realitexpire, (caddr_t)p, p->p_ithandle);
|
||||
callout_stop(&p->p_itcallout);
|
||||
if (timevalisset(&aitv.it_value))
|
||||
p->p_ithandle = timeout(realitexpire, (caddr_t)p,
|
||||
tvtohz(&aitv.it_value));
|
||||
callout_reset(&p->p_itcallout, tvtohz(&aitv.it_value),
|
||||
realitexpire, p);
|
||||
getmicrouptime(&ctv);
|
||||
timevaladd(&aitv.it_value, &ctv);
|
||||
p->p_realtimer = aitv;
|
||||
@ -560,8 +560,8 @@ realitexpire(arg)
|
||||
if (timevalcmp(&p->p_realtimer.it_value, &ctv, >)) {
|
||||
ntv = p->p_realtimer.it_value;
|
||||
timevalsub(&ntv, &ctv);
|
||||
p->p_ithandle = timeout(realitexpire, (caddr_t)p,
|
||||
tvtohz(&ntv) - 1);
|
||||
callout_reset(&p->p_itcallout, tvtohz(&ntv) - 1,
|
||||
realitexpire, p);
|
||||
splx(s);
|
||||
return;
|
||||
}
|
||||
|
@ -61,6 +61,9 @@
|
||||
static void domaininit __P((void *));
|
||||
SYSINIT(domain, SI_SUB_PROTO_DOMAIN, SI_ORDER_FIRST, domaininit, NULL)
|
||||
|
||||
static struct callout pffast_callout;
|
||||
static struct callout pfslow_callout;
|
||||
|
||||
static void pffasttimo __P((void *));
|
||||
static void pfslowtimo __P((void *));
|
||||
|
||||
@ -137,8 +140,11 @@ domaininit(void *dummy)
|
||||
if (max_linkhdr < 16) /* XXX */
|
||||
max_linkhdr = 16;
|
||||
|
||||
timeout(pffasttimo, (void *)0, 1);
|
||||
timeout(pfslowtimo, (void *)0, 1);
|
||||
callout_init(&pffast_callout, 0);
|
||||
callout_init(&pfslow_callout, 0);
|
||||
|
||||
callout_reset(&pffast_callout, 1, pffasttimo, NULL);
|
||||
callout_reset(&pfslow_callout, 1, pfslowtimo, NULL);
|
||||
}
|
||||
|
||||
|
||||
@ -214,7 +220,7 @@ pfslowtimo(arg)
|
||||
for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
|
||||
if (pr->pr_slowtimo)
|
||||
(*pr->pr_slowtimo)();
|
||||
timeout(pfslowtimo, (void *)0, hz/2);
|
||||
callout_reset(&pfslow_callout, hz/2, pfslowtimo, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -228,5 +234,5 @@ pffasttimo(arg)
|
||||
for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
|
||||
if (pr->pr_fasttimo)
|
||||
(*pr->pr_fasttimo)();
|
||||
timeout(pffasttimo, (void *)0, hz/5);
|
||||
callout_reset(&pffast_callout, hz/5, pffasttimo, NULL);
|
||||
}
|
||||
|
@ -43,7 +43,7 @@
|
||||
#define _SYS_PROC_H_
|
||||
|
||||
#include <machine/proc.h> /* Machine-dependent proc substruct. */
|
||||
#include <sys/callout.h> /* For struct callout_handle. */
|
||||
#include <sys/callout.h> /* For struct callout. */
|
||||
#include <sys/filedesc.h>
|
||||
#include <sys/lock.h> /* For lockmgr. */
|
||||
#include <sys/queue.h>
|
||||
@ -157,10 +157,6 @@ struct proc {
|
||||
LIST_ENTRY(proc) p_sibling; /* List of sibling processes. */
|
||||
LIST_HEAD(, proc) p_children; /* Pointer to list of children. */
|
||||
|
||||
struct callout_handle p_ithandle; /*
|
||||
* Callout handle for scheduling
|
||||
* p_realtimer.
|
||||
*/
|
||||
/* The following fields are all zeroed upon creation in fork. */
|
||||
#define p_startzero p_oppid
|
||||
|
||||
@ -173,11 +169,13 @@ struct proc {
|
||||
u_int p_estcpu; /* Time averaged value of p_cpticks. */
|
||||
int p_cpticks; /* Ticks of cpu time. */
|
||||
fixpt_t p_pctcpu; /* %cpu for this process during p_swtime */
|
||||
struct callout p_slpcallout; /* Callout for sleep. */
|
||||
void *p_wchan; /* Sleep address. */
|
||||
const char *p_wmesg; /* Reason for sleep. */
|
||||
u_int p_swtime; /* Time swapped in or out. */
|
||||
u_int p_slptime; /* Time since last blocked. */
|
||||
|
||||
struct callout p_itcallout; /* Interval timer callout. */
|
||||
struct itimerval p_realtimer; /* Alarm timer. */
|
||||
u_int64_t p_runtime; /* Real time in microsec. */
|
||||
u_int64_t p_uu; /* Previous user time in microsec. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user