}
pgrp.pg_session = &sess;
- if ((proc.p_flag & P_CONTROLT) && sess.s_ttyp != NULL) {
+ if ((proc.p_flags & P_CONTROLT) && sess.s_ttyp != NULL) {
if (KREAD(kd, (u_long)sess.s_ttyp, &tty)) {
_kvm_err(kd, kd->program,
"can't read tty at %p", sess.s_ttyp);
break;
case KERN_PROC_TTY:
- if ((proc.p_flag & P_CONTROLT) == 0 ||
+ if ((proc.p_flags & P_CONTROLT) == 0 ||
dev2udev(proc.p_pgrp->pg_session->s_ttyp->t_dev)
!= (dev_t)arg)
continue;
if (db_more(&nl) < 0)
return;
- db_printf(" pid lwp uid ppid pgrp pflag lflag stat wmesg wchan cmd\n");
+ db_printf(" pid lwp uid ppid pgrp pflags lflags stat wmesg wchan cmd\n");
for (;;) {
while (lp == NULL) {
--np;
db_printf("%5d %8p %4d %5d %5d %06x %06x %d %d",
p->p_pid, (volatile void *)lp,
p->p_ucred ? p->p_ucred->cr_ruid : 0, pp->p_pid,
- p->p_pgrp ? p->p_pgrp->pg_id : 0, p->p_flag,
- lp->lwp_flag, p->p_stat, lp->lwp_stat);
+ p->p_pgrp ? p->p_pgrp->pg_id : 0, p->p_flags,
+ lp->lwp_flags, p->p_stat, lp->lwp_stat);
if (lp->lwp_wchan) {
db_printf(" %6s %8p",
(lp->lwp_wmesg ? lp->lwp_wmesg : "?"),
printf "%5d %08x %4d %5d %5d %06x %d %-10s ", \
$proc.p_pid, $aproc, \
$proc.p_cred->p_ruid, $pptr->p_pid, \
- $proc.p_pgrp->pg_id, $proc.p_flag, $proc.p_stat, \
+ $proc.p_pgrp->pg_id, $proc.p_flags, $proc.p_stat, \
&$proc.p_comm[0]
if ($proc.p_wchan)
if ($proc.p_wmesg)
printf "%5d %08x %4d %5d %5d %06x %d %-10s ", \
$proc.p_pid, $aproc, \
$proc.p_cred->p_ruid, $pptr->p_pid, \
- $proc.p_pgrp->pg_id, $proc.p_flag, $proc.p_stat, \
+ $proc.p_pgrp->pg_id, $proc.p_flags, $proc.p_stat, \
&$proc.p_comm[0]
if ($proc.p_wchan)
if ($proc.p_wmesg)
printf "%x", $proc.p_wchan
end
printf "\n"
- if ($proc->p_flag & 4)
+ if ($proc->p_flags & 4)
btr $proc->p_addr->u_pcb->pcb_ebp
else
echo (not loaded)\n
Show backtraces for all processes in the system.
end
define btpp
- if ($myvectorproc->p_flag & 4)
+ if ($myvectorproc->p_flags & 4)
btr $myvectorproc->p_addr->u_pcb->pcb_ebp
else
echo (not loaded)\n
printf "%5d %08x %4d %5d %5d %06x %d %-10s ", \
$proc.p_pid, $aproc, \
$proc.p_cred->p_ruid, $pptr->p_pid, \
- $proc.p_pgrp->pg_id, $proc.p_flag, $proc.p_stat, \
+ $proc.p_pgrp->pg_id, $proc.p_flags, $proc.p_stat, \
&$proc.p_comm[0]
if ($proc.p_wchan)
if ($proc.p_wmesg)
define fr
set $fno = 0
set $searching = 1
-if ($myvectorproc->p_flag & 4)
+if ($myvectorproc->p_flags & 4)
set $frame = $myvectorproc->p_addr->u_pcb->pcb_ebp
while (($searching == 1) && (*(int *) $frame > 0xc0000000))
set $myebp = *(int *) $frame
{
struct daemonq *request;
- curproc->p_flag |= P_SYSTEM; /* we're a system process */
+ curproc->p_flags |= P_SYSTEM; /* we're a system process */
daemon_save_config(); /* start by saving the configuration */
daemonpid = curproc->p_pid; /* mark our territory */
while (1) {
lp->lwp_sigstk.ss_sp = ss.ss_sp;
lp->lwp_sigstk.ss_size = 0;
lp->lwp_sigstk.ss_flags |= ss.ss_onstack & SS_ONSTACK;
- lp->lwp_flag |= LWP_ALTSTACK;
+ lp->lwp_flags |= LWP_ALTSTACK;
}
return (error);
}
* change the owner to root - otherwise 'ps' and friends
* will break even though they are setgid kmem. *SIGH*
*/
- if (procp->p_flag & P_SUGID)
+ if (procp->p_flags & P_SUGID)
vap->va_uid = 0;
else
vap->va_uid = procp->p_ucred->cr_uid;
}
/* System processes can't be debugged. */
- if ((p->p_flag & P_SYSTEM) != 0) {
+ if ((p->p_flags & P_SYSTEM) != 0) {
error = EINVAL;
goto fail;
}
/* not being traced... */
- if ((p->p_flag & P_TRACED) == 0) {
+ if ((p->p_flags & P_TRACED) == 0) {
error = EPERM;
goto fail;
}
}
/* not currently stopped */
- if ((p->p_flag & (P_TRACED|P_WAITED)) == 0) {
+ if ((p->p_flags & (P_TRACED|P_WAITED)) == 0) {
error = EBUSY;
goto fail;
}
/*
* Allocate space for the signal handler context.
*/
- if ((lp->lwp_flag & LWP_ALTSTACK) && !oonstack &&
+ if ((lp->lwp_flags & LWP_ALTSTACK) && !oonstack &&
SIGISMEMBER(p->p_sigacts->ps_sigonstack, sig)) {
fp = (struct l_rt_sigframe *)(lp->lwp_sigstk.ss_sp +
lp->lwp_sigstk.ss_size - sizeof(struct l_rt_sigframe));
frame.sf_sc.uc_stack.ss_sp = lp->lwp_sigstk.ss_sp;
frame.sf_sc.uc_stack.ss_size = lp->lwp_sigstk.ss_size;
- frame.sf_sc.uc_stack.ss_flags = (lp->lwp_flag & LWP_ALTSTACK)
+ frame.sf_sc.uc_stack.ss_flags = (lp->lwp_flags & LWP_ALTSTACK)
? ((oonstack) ? LINUX_SS_ONSTACK : 0) : LINUX_SS_DISABLE;
bsd_to_linux_sigset(mask, &frame.sf_sc.uc_sigmask);
/*
* Allocate space for the signal handler context.
*/
- if ((lp->lwp_flag & LWP_ALTSTACK) && !oonstack &&
+ if ((lp->lwp_flags & LWP_ALTSTACK) && !oonstack &&
SIGISMEMBER(p->p_sigacts->ps_sigonstack, sig)) {
fp = (struct l_sigframe *)(lp->lwp_sigstk.ss_sp +
lp->lwp_sigstk.ss_size - sizeof(struct l_sigframe));
nlookup_done_at(&nd, fp);
if (error == 0 && !(flags & O_NOCTTY) &&
- SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) {
+ SESS_LEADER(p) && !(p->p_flags & P_CONTROLT)) {
struct file *fp;
fp = holdfp(p->p_fd, *iresult, -1);
#define SYNC_LEVEL_MP (IPI_LEVEL - 1)
#define AT_PASSIVE_LEVEL(td) \
- ((td)->td_proc->p_flag & P_KTHREAD == FALSE)
+ ((td)->td_proc->p_flags & P_KTHREAD == FALSE)
#define AT_DISPATCH_LEVEL(td) \
(lwkt_getpri(td) == TDPRI_INT_HIGH)
p->p_sysent = &aout_sysvec;
- p->p_flag = P_SYSTEM;
+ p->p_flags = P_SYSTEM;
p->p_stat = SACTIVE;
lp->lwp_stat = LSRUN;
p->p_nice = NZERO;
error = fork1(&lwp0, RFFDG | RFPROC, &initproc);
if (error)
panic("cannot fork init: %d", error);
- initproc->p_flag |= P_SYSTEM;
+ initproc->p_flags |= P_SYSTEM;
lp = ONLY_LWP_IN_PROC(initproc);
cpu_set_fork_handler(lp, start_init, NULL);
crit_exit();
acct.ac_gid = p->p_ucred->cr_rgid;
/* (7) The terminal from which the process was started */
- if ((p->p_flag & P_CONTROLT) && p->p_pgrp->pg_session->s_ttyp)
+ if ((p->p_flags & P_CONTROLT) && p->p_pgrp->pg_session->s_ttyp)
acct.ac_tty = dev2udev(p->p_pgrp->pg_session->s_ttyp->t_dev);
else
acct.ac_tty = NOUDEV;
* Being able to checkpoint an suid or sgid program is not a good
* idea.
*/
- if (sugid_coredump == 0 && (p->p_flag & P_SUGID)) {
+ if (sugid_coredump == 0 && (p->p_flags & P_SUGID)) {
chptinuse--;
return (EPERM);
}
if (frame && CLKF_USERMODE(frame) &&
timevalisset(&p->p_timer[ITIMER_VIRTUAL].it_value) &&
itimerdecr(&p->p_timer[ITIMER_VIRTUAL], ustick) == 0) {
- p->p_flag |= P_SIGVTALRM;
+ p->p_flags |= P_SIGVTALRM;
need_user_resched();
}
if (timevalisset(&p->p_timer[ITIMER_PROF].it_value) &&
itimerdecr(&p->p_timer[ITIMER_PROF], ustick) == 0) {
- p->p_flag |= P_SIGPROF;
+ p->p_flags |= P_SIGPROF;
need_user_resched();
}
crit_exit_hard();
* Came from userland, handle user time and deal with
* possible process.
*/
- if (p && (p->p_flag & P_PROFIL))
+ if (p && (p->p_flags & P_PROFIL))
addupc_intr(p, CLKF_PC(frame), 1);
td->td_uticks += bump;
void
startprofclock(struct proc *p)
{
- if ((p->p_flag & P_PROFIL) == 0) {
- p->p_flag |= P_PROFIL;
+ if ((p->p_flags & P_PROFIL) == 0) {
+ p->p_flags |= P_PROFIL;
#if 0 /* XXX */
if (++profprocs == 1 && stathz != 0) {
crit_enter();
void
stopprofclock(struct proc *p)
{
- if (p->p_flag & P_PROFIL) {
- p->p_flag &= ~P_PROFIL;
+ if (p->p_flags & P_PROFIL) {
+ p->p_flags &= ~P_PROFIL;
#if 0 /* XXX */
if (--profprocs == 0 && stathz != 0) {
crit_enter();
error = EBADF;
break;
}
- if ((p->p_leader->p_flag & P_ADVLOCK) == 0) {
+ if ((p->p_leader->p_flags & P_ADVLOCK) == 0) {
lwkt_gettoken(&p->p_leader->p_token);
- p->p_leader->p_flag |= P_ADVLOCK;
+ p->p_leader->p_flags |= P_ADVLOCK;
lwkt_reltoken(&p->p_leader->p_token);
}
error = VOP_ADVLOCK(vp, (caddr_t)p->p_leader, F_SETLK,
error = EBADF;
break;
}
- if ((p->p_leader->p_flag & P_ADVLOCK) == 0) {
+ if ((p->p_leader->p_flags & P_ADVLOCK) == 0) {
lwkt_gettoken(&p->p_leader->p_token);
- p->p_leader->p_flag |= P_ADVLOCK;
+ p->p_leader->p_flags |= P_ADVLOCK;
lwkt_reltoken(&p->p_leader->p_token);
}
error = VOP_ADVLOCK(vp, (caddr_t)p->p_leader, F_SETLK,
("filedesc_to_refcount botch: fdl_refcount=%d",
fdtol->fdl_refcount));
if (fdtol->fdl_refcount == 1 &&
- (p->p_leader->p_flag & P_ADVLOCK) != 0) {
+ (p->p_leader->p_flags & P_ADVLOCK) != 0) {
for (i = 0; i <= fdp->fd_lastfile; ++i) {
fdnode = &fdp->fd_files[i];
if (fdnode->fp == NULL ||
retry:
if (fdtol->fdl_refcount == 1) {
if (fdp->fd_holdleaderscount > 0 &&
- (p->p_leader->p_flag & P_ADVLOCK) != 0) {
+ (p->p_leader->p_flags & P_ADVLOCK) != 0) {
/*
* close() or do_dup() has cleared a reference
* in a shared file descriptor table.
if (p != NULL && fp->f_type == DTYPE_VNODE &&
(((struct vnode *)fp->f_data)->v_flag & VMAYHAVELOCKS)
) {
- if ((p->p_leader->p_flag & P_ADVLOCK) != 0) {
+ if ((p->p_leader->p_flags & P_ADVLOCK) != 0) {
lf.l_whence = SEEK_SET;
lf.l_start = 0;
lf.l_len = 0;
for (fdtol = fdtol->fdl_next;
fdtol != p->p_fdtol;
fdtol = fdtol->fdl_next) {
- if ((fdtol->fdl_leader->p_flag &
+ if ((fdtol->fdl_leader->p_flags &
P_ADVLOCK) == 0)
continue;
fdtol->fdl_holdcount++;
* mark as execed, wakeup the process that vforked (if any) and tell
* it that it now has its own resources back
*/
- p->p_flag |= P_EXEC;
- if (p->p_pptr && (p->p_flag & P_PPWAIT)) {
- p->p_flag &= ~P_PPWAIT;
+ p->p_flags |= P_EXEC;
+ if (p->p_pptr && (p->p_flags & P_PPWAIT)) {
+ p->p_flags &= ~P_PPWAIT;
wakeup((caddr_t)p->p_pptr);
}
if ((((attr.va_mode & VSUID) && p->p_ucred->cr_uid != attr.va_uid) ||
((attr.va_mode & VSGID) && p->p_ucred->cr_gid != attr.va_gid)) &&
(imgp->vp->v_mount->mnt_flag & MNT_NOSUID) == 0 &&
- (p->p_flag & P_TRACED) == 0) {
+ (p->p_flags & P_TRACED) == 0) {
/*
* Turn off syscall tracing for set-id programs, except for
* root. Record any set-id flags first to make sure that
} else {
if (p->p_ucred->cr_uid == p->p_ucred->cr_ruid &&
p->p_ucred->cr_gid == p->p_ucred->cr_rgid)
- p->p_flag &= ~P_SUGID;
+ p->p_flags &= ~P_SUGID;
}
/*
* as we're now a bona fide freshly-execed process.
*/
KNOTE(&p->p_klist, NOTE_EXEC);
- p->p_flag &= ~P_INEXEC;
+ p->p_flags &= ~P_INEXEC;
/*
* If tracing the process, trap to debugger so breakpoints
*/
STOPEVENT(p, S_EXEC, 0);
- if (p->p_flag & P_TRACED)
+ if (p->p_flags & P_TRACED)
ksignal(p, SIGTRAP);
/* clear "fork but no exec" flag, as we _are_ execing */
* clearing it.
*/
if (imgp->vmspace_destroyed & 2)
- p->p_flag &= ~P_INEXEC;
+ p->p_flags &= ~P_INEXEC;
lwkt_reltoken(&p->p_token);
if (imgp->vmspace_destroyed) {
/*
return (error);
}
imgp->vmspace_destroyed |= 2; /* we are responsible for P_INEXEC */
- p->p_flag |= P_INEXEC;
+ p->p_flags |= P_INEXEC;
/*
* Blow away entire process VM, if address space not shared,
* Interlock against P_WEXIT. Only one of the process's thread
* is allowed to do the master exit.
*/
- if (p->p_flag & P_WEXIT)
+ if (p->p_flags & P_WEXIT)
return (EALREADY);
- p->p_flag |= P_WEXIT;
+ p->p_flags |= P_WEXIT;
/*
- * Interlock with LWP_WEXIT and kill any remaining LWPs
+ * Interlock with LWP_MP_WEXIT and kill any remaining LWPs
*/
- lp->lwp_flag |= LWP_WEXIT;
+ atomic_set_int(&lp->lwp_mpflags, LWP_MP_WEXIT);
if (p->p_nthreads > 1)
killlwps(lp);
* have been killed.
*/
if (forexec) {
- lp->lwp_flag &= ~LWP_WEXIT;
- p->p_flag &= ~P_WEXIT;
+ atomic_clear_int(&lp->lwp_mpflags, LWP_MP_WEXIT);
+ p->p_flags &= ~P_WEXIT;
}
return(0);
}
/*
* Kill the remaining LWPs. We must send the signal before setting
- * LWP_WEXIT. The setting of WEXIT is optional but helps reduce
+ * LWP_MP_WEXIT. The setting of WEXIT is optional but helps reduce
* races. tlp must be held across the call as it might block and
* allow the target lwp to rip itself out from under our loop.
*/
FOREACH_LWP_IN_PROC(tlp, p) {
LWPHOLD(tlp);
lwkt_gettoken(&tlp->lwp_token);
- if ((tlp->lwp_flag & LWP_WEXIT) == 0) {
+ if ((tlp->lwp_mpflags & LWP_MP_WEXIT) == 0) {
lwpsignal(p, tlp, SIGKILL);
- tlp->lwp_flag |= LWP_WEXIT;
+ atomic_set_int(&tlp->lwp_mpflags, LWP_MP_WEXIT);
}
lwkt_reltoken(&tlp->lwp_token);
LWPRELE(tlp);
TAILQ_FOREACH(ep, &exit_list, next)
(*ep->function)(td);
- if (p->p_flag & P_PROFIL)
+ if (p->p_flags & P_PROFIL)
stopprofclock(p);
/*
* If parent is waiting for us to exit or exec,
* P_PPWAIT is set; we will wakeup the parent below.
*/
- p->p_flag &= ~(P_TRACED | P_PPWAIT);
+ p->p_flags &= ~(P_TRACED | P_PPWAIT);
SIGEMPTYSET(p->p_siglist);
SIGEMPTYSET(lp->lwp_siglist);
if (timevalisset(&p->p_realtimer.it_value))
* Traced processes are killed
* since their existence means someone is screwing up.
*/
- if (q->p_flag & P_TRACED) {
- q->p_flag &= ~P_TRACED;
+ if (q->p_flags & P_TRACED) {
+ q->p_flags &= ~P_TRACED;
ksignal(q, SIGKILL);
}
q = nq;
int dowake = 0;
/*
- * lwp_exit() may be called without setting LWP_WEXIT, so
+ * lwp_exit() may be called without setting LWP_MP_WEXIT, so
* make sure it is set here.
*/
ASSERT_LWKT_TOKEN_HELD(&p->p_token);
- lp->lwp_flag |= LWP_WEXIT;
+ atomic_set_int(&lp->lwp_mpflags, LWP_MP_WEXIT);
/*
* Clean up any virtualization
error = 0;
goto done;
}
- if (p->p_stat == SSTOP && (p->p_flag & P_WAITED) == 0 &&
- ((p->p_flag & P_TRACED) || (options & WUNTRACED))) {
+ if (p->p_stat == SSTOP && (p->p_flags & P_WAITED) == 0 &&
+ ((p->p_flags & P_TRACED) || (options & WUNTRACED))) {
lwkt_gettoken(&p->p_token);
- p->p_flag |= P_WAITED;
+ p->p_flags |= P_WAITED;
*res = p->p_pid;
p->p_usched->heuristic_exiting(td->td_lwp, p);
lwkt_reltoken(&p->p_token);
goto done;
}
- if ((options & WCONTINUED) && (p->p_flag & P_CONTINUED)) {
+ if ((options & WCONTINUED) && (p->p_flags & P_CONTINUED)) {
lwkt_gettoken(&p->p_token);
*res = p->p_pid;
p->p_usched->heuristic_exiting(td->td_lwp, p);
- p->p_flag &= ~P_CONTINUED;
+ p->p_flags &= ~P_CONTINUED;
if (status)
*status = SIGCONT;
lwp_rb_tree_RB_REMOVE(&p->p_lwp_tree, lp);
--p->p_nthreads;
/* lwp_dispose expects an exited lwp, and a held proc */
- lp->lwp_flag |= LWP_WEXIT;
+ atomic_set_int(&lp->lwp_mpflags, LWP_MP_WEXIT);
lp->lwp_thread->td_flags |= TDF_EXITING;
lwkt_remove_tdallq(lp->lwp_thread);
PHOLD(p);
* other consumers to gain temporary references to p2
* (p2->p_lock can change).
*/
- if (p1->p_flag & P_PROFIL)
+ if (p1->p_flags & P_PROFIL)
startprofclock(p2);
p2->p_ucred = crhold(lp1->lwp_thread->td_ucred);
if (jailed(p2->p_ucred))
- p2->p_flag |= P_JAILED;
+ p2->p_flags |= P_JAILED;
if (p2->p_args)
refcount_acquire(&p2->p_args->ar_ref);
* Preserve some more flags in subprocess. P_PROFIL has already
* been preserved.
*/
- p2->p_flag |= p1->p_flag & P_SUGID;
- if (p1->p_session->s_ttyvp != NULL && p1->p_flag & P_CONTROLT)
- p2->p_flag |= P_CONTROLT;
+ p2->p_flags |= p1->p_flags & P_SUGID;
+ if (p1->p_session->s_ttyvp != NULL && p1->p_flags & P_CONTROLT)
+ p2->p_flags |= P_CONTROLT;
if (flags & RFPPWAIT)
- p2->p_flag |= P_PPWAIT;
+ p2->p_flags |= P_PPWAIT;
/*
* Inherit the virtual kernel structure (allows a virtual kernel
bcopy(&origlp->lwp_startcopy, &lp->lwp_startcopy,
(unsigned) ((caddr_t)&lp->lwp_endcopy -
(caddr_t)&lp->lwp_startcopy));
- lp->lwp_flag |= origlp->lwp_flag & LWP_ALTSTACK;
+ lp->lwp_flags |= origlp->lwp_flags & LWP_ALTSTACK;
/*
* Set cpbase to the last timeout that occured (not the upcoming
* timeout).
* We must hold our p_token to interlock the flag/tsleep
*/
lwkt_gettoken(&p2->p_token);
- while (p2->p_flag & P_PPWAIT)
+ while (p2->p_flags & P_PPWAIT)
tsleep(lp1->lwp_proc, 0, "ppwait", 0);
lwkt_reltoken(&p2->p_token);
}
*/
if (emergency_intr_thread.td_kstack == NULL) {
lwkt_create(ithread_emergency, NULL, NULL, &emergency_intr_thread,
- TDF_STOPREQ | TDF_INTTHREAD, ncpus - 1, "ithread emerg");
+ TDF_NOSTART | TDF_INTTHREAD, ncpus - 1, "ithread emerg");
systimer_init_periodic_nq(&emergency_intr_timer,
emergency_intr_timer_callback, &emergency_intr_thread,
(emergency_intr_enable ? emergency_intr_freq : 1));
if (info->i_state == ISTATE_NOTHREAD) {
info->i_state = ISTATE_NORMAL;
lwkt_create(ithread_handler, (void *)(intptr_t)intr, NULL,
- &info->i_thread, TDF_STOPREQ | TDF_INTTHREAD, cpuid,
+ &info->i_thread, TDF_NOSTART | TDF_INTTHREAD, cpuid,
"ithread %d", intr);
if (intr >= FIRST_SOFTINT)
lwkt_setpri(&info->i_thread, TDPRI_SOFT_NORM);
lwkt_gettoken(&p->p_token);
cratom(&p->p_ucred);
p->p_ucred->cr_prison = pr;
- p->p_flag |= P_JAILED;
+ p->p_flags |= P_JAILED;
lwkt_reltoken(&p->p_token);
return(0);
kp->kp_paddr = (uintptr_t)p;
kp->kp_fd = (uintptr_t)p->p_fd;
- kp->kp_flags = p->p_flag;
+ kp->kp_flags = p->p_flags;
kp->kp_stat = p->p_stat;
kp->kp_lock = p->p_lock;
kp->kp_acflag = p->p_acflag;
if ((p->p_session != NULL) && SESS_LEADER(p))
kp->kp_auxflags |= KI_SLEADER;
}
- if (sess && (p->p_flag & P_CONTROLT) != 0 && sess->s_ttyp != NULL) {
+ if (sess && (p->p_flags & P_CONTROLT) != 0 && sess->s_ttyp != NULL) {
kp->kp_tdev = dev2udev(sess->s_ttyp->t_dev);
if (sess->s_ttyp->t_pgrp != NULL)
kp->kp_tpgid = sess->s_ttyp->t_pgrp->pg_id;
kl->kl_pid = lwp->lwp_proc->p_pid;
kl->kl_tid = lwp->lwp_tid;
- kl->kl_flags = lwp->lwp_flag;
+ kl->kl_flags = lwp->lwp_flags;
kl->kl_stat = lwp->lwp_stat;
kl->kl_lock = lwp->lwp_lock;
kl->kl_tdflags = lwp->lwp_thread->td_flags;
*/
if (kl->kl_stat == LSRUN) {
if ((kl->kl_tdflags & TDF_RUNQ) == 0 &&
- (lwp->lwp_flag & LWP_ONRUNQ) == 0) {
+ (lwp->lwp_mpflags & LWP_MP_ONRUNQ) == 0) {
kl->kl_stat = LSSLEEP;
}
}
{
if (td->td_proc == NULL) {
lwkt_gettoken(&kpsus_token);
- td->td_flags |= TDF_STOPREQ; /* request thread pause */
+ /* request thread pause */
+ atomic_set_int(&td->td_mpflags, TDF_MP_STOPREQ);
wakeup(td);
- while (td->td_flags & TDF_STOPREQ) {
+ while (td->td_mpflags & TDF_MP_STOPREQ) {
int error = tsleep(td, 0, "suspkp", timo);
if (error == EWOULDBLOCK)
break;
}
- td->td_flags &= ~TDF_STOPREQ;
+ atomic_clear_int(&td->td_mpflags, TDF_MP_STOPREQ);
lwkt_reltoken(&kpsus_token);
return(0);
} else {
{
struct thread *td = curthread;
- if (td->td_flags & TDF_STOPREQ) {
+ if (td->td_mpflags & TDF_MP_STOPREQ) {
lwkt_gettoken(&kpsus_token);
- td->td_flags &= ~TDF_STOPREQ;
- while ((td->td_flags & TDF_WAKEREQ) == 0) {
+ atomic_clear_int(&td->td_mpflags, TDF_MP_STOPREQ);
+ while ((td->td_mpflags & TDF_MP_WAKEREQ) == 0) {
wakeup(td);
tsleep(td, 0, "kpsusp", 0);
}
- td->td_flags &= ~TDF_WAKEREQ;
+ atomic_clear_int(&td->td_mpflags, TDF_MP_WAKEREQ);
wakeup(td);
lwkt_reltoken(&kpsus_token);
}
caller->cr_rgid == target->cr_rgid && /* XXX */
target->cr_rgid == target->cr_svgid &&
(targetp->p_traceflag & KTRFAC_ROOT) == 0 &&
- (targetp->p_flag & P_SUGID) == 0) ||
+ (targetp->p_flags & P_SUGID) == 0) ||
caller->cr_uid == 0)
return (1);
KASSERT(p == curproc,
("enterpgrp: mksession and p != curproc"));
lwkt_gettoken(&p->p_token);
- p->p_flag &= ~P_CONTROLT;
+ p->p_flags &= ~P_CONTROLT;
lwkt_reltoken(&p->p_token);
} else {
pgrp->pg_session = p->p_session;
break;
case KERN_PROC_TTY:
- if ((p->p_flag & P_CONTROLT) == 0 ||
+ if ((p->p_flags & P_CONTROLT) == 0 ||
p->p_session == NULL ||
p->p_session->s_ttyp == NULL ||
dev2udev(p->p_session->s_ttyp->t_dev) !=
error = EPERM;
goto done;
}
- if (targp->p_flag & P_EXEC) {
+ if (targp->p_flags & P_EXEC) {
error = EACCES;
goto done;
}
int
sys_issetugid(struct issetugid_args *uap)
{
- uap->sysmsg_result = (curproc->p_flag & P_SUGID) ? 1 : 0;
+ uap->sysmsg_result = (curproc->p_flags & P_SUGID) ? 1 : 0;
return (0);
}
KKASSERT(p != NULL);
lwkt_gettoken(&p->p_token);
- p->p_flag |= P_SUGID;
+ p->p_flags |= P_SUGID;
if (!(p->p_pfsflags & PF_ISUGID))
p->p_stops = 0;
lwkt_reltoken(&p->p_token);
if (n < chgp->p_nice && priv_check_cred(cr, PRIV_SCHED_SETPRIORITY, 0))
return (EACCES);
chgp->p_nice = n;
- FOREACH_LWP_IN_PROC(lp, chgp)
+ FOREACH_LWP_IN_PROC(lp, chgp) {
+ LWPHOLD(lp);
chgp->p_usched->resetpriority(lp);
+ LWPRELE(lp);
+ }
return (0);
}
static int sigprop(int sig);
static void lwp_signotify(struct lwp *lp);
#ifdef SMP
-static void signotify_remote(void *arg);
+static void lwp_signotify_remote(void *arg);
#endif
static int kern_sigtimedwait(sigset_t set, siginfo_t *info,
struct timespec *timeout);
lp->lwp_sigstk.ss_flags = SS_DISABLE;
lp->lwp_sigstk.ss_size = 0;
lp->lwp_sigstk.ss_sp = 0;
- lp->lwp_flag &= ~LWP_ALTSTACK;
+ lp->lwp_flags &= ~LWP_ALTSTACK;
/*
* Reset no zombies if child dies flag as Solaris does.
*/
* to indicate this.
*/
lp->lwp_oldsigmask = lp->lwp_sigmask;
- lp->lwp_flag |= LWP_OLDMASK;
+ lp->lwp_flags |= LWP_OLDMASK;
SIG_CANTMASK(*set);
lp->lwp_sigmask = *set;
struct lwp *lp = td->td_lwp;
struct proc *p = td->td_proc;
- if ((lp->lwp_flag & LWP_ALTSTACK) == 0)
+ if ((lp->lwp_flags & LWP_ALTSTACK) == 0)
lp->lwp_sigstk.ss_flags |= SS_DISABLE;
if (oss)
if (ss->ss_flags & SS_DISABLE) {
if (lp->lwp_sigstk.ss_flags & SS_ONSTACK)
return (EINVAL);
- lp->lwp_flag &= ~LWP_ALTSTACK;
+ lp->lwp_flags &= ~LWP_ALTSTACK;
lp->lwp_sigstk.ss_flags = ss->ss_flags;
} else {
if (ss->ss_size < p->p_sysent->sv_minsigstksz)
return (ENOMEM);
- lp->lwp_flag |= LWP_ALTSTACK;
+ lp->lwp_flags |= LWP_ALTSTACK;
lp->lwp_sigstk = *ss;
}
}
LIST_FOREACH(p, &pgrp->pg_members, p_pglist) {
if (p->p_pid <= 1 ||
p->p_stat == SZOMB ||
- (p->p_flag & P_SYSTEM) ||
+ (p->p_flags & P_SYSTEM) ||
!CANSIGNAL(p, sig)) {
continue;
}
{
struct killpg_info *info = data;
- if (p->p_pid <= 1 || (p->p_flag & P_SYSTEM) ||
+ if (p->p_pid <= 1 || (p->p_flags & P_SYSTEM) ||
p == curproc || !CANSIGNAL(p, info->sig)) {
return (0);
}
* called directly with P_WEXIT set to kill individual LWPs
* during exit, which is allowed.
*/
- if (p->p_flag & P_WEXIT) {
+ if (p->p_flags & P_WEXIT) {
lwkt_reltoken(&p->p_token);
PRELE(p);
lwkt_reltoken(&proc_token);
pgref(pgrp);
lockmgr(&pgrp->pg_lock, LK_EXCLUSIVE);
LIST_FOREACH(p, &pgrp->pg_members, p_pglist) {
- if (checkctty == 0 || p->p_flag & P_CONTROLT)
+ if (checkctty == 0 || p->p_flags & P_CONTROLT)
ksignal(p, sig);
}
lockmgr(&pgrp->pg_lock, LK_RELEASE);
}
- if ((p->p_flag & P_TRACED) == 0 && SIGISMEMBER(p->p_sigcatch, sig) &&
+ if ((p->p_flags & P_TRACED) == 0 && SIGISMEMBER(p->p_sigcatch, sig) &&
!SIGISMEMBER(lp->lwp_sigmask, sig)) {
lp->lwp_ru.ru_nsignals++;
#ifdef KTRACE
}
break;
case LSSLEEP:
- if (lp->lwp_flag & LWP_SINTR) {
+ if (lp->lwp_flags & LWP_SINTR) {
if (sleep) {
lwkt_reltoken(&lp->lwp_token);
LWPRELE(lp);
* if signal event is tracked by procfs, give *that*
* a chance, as well.
*/
- if ((p->p_flag & P_TRACED) || (p->p_stops & S_SIG)) {
+ if ((p->p_flags & P_TRACED) || (p->p_stops & S_SIG)) {
action = SIG_DFL;
} else {
/*
* that we must still deliver the signal if P_WEXIT is set
* in the process flags.
*/
- if (lp && (lp->lwp_flag & LWP_WEXIT)) {
+ if (lp && (lp->lwp_mpflags & LWP_MP_WEXIT)) {
if (lp) {
lwkt_reltoken(&lp->lwp_token);
LWPRELE(lp);
return;
}
SIG_CONTSIGMASK(p->p_siglist);
- p->p_flag &= ~P_CONTINUED;
+ p->p_flags &= ~P_CONTINUED;
}
crit_enter();
* If the process is stopped and is being traced, then no
* further action is necessary.
*/
- if (p->p_flag & P_TRACED)
+ if (p->p_flags & P_TRACED)
goto out;
/*
q = p->p_pptr;
PHOLD(q);
lwkt_gettoken(&q->p_token);
- p->p_flag |= P_CONTINUED;
+ p->p_flags |= P_CONTINUED;
wakeup(q);
if (action == SIG_DFL)
SIGDELSET(p->p_siglist, sig);
/*
* Otherwise the process is stopped and it received some
- * signal, which does not change its stopped state.
- *
- * We have to select one thread to set LWP_BREAKTSLEEP,
- * so that the current signal will break the sleep
- * as soon as a SA_CONT signal will unstop the process.
+ * signal, which does not change its stopped state. When
+ * the process is continued a wakeup(p) will be issued which
+ * will wakeup any threads sleeping in tstop().
*/
if (lp == NULL) {
/* NOTE: returns lp w/ token held */
lp = find_lwp_for_signal(p, sig);
}
- if (lp != NULL &&
- (lp->lwp_stat == LSSLEEP || lp->lwp_stat == LSSTOP))
- lp->lwp_flag |= LWP_BREAKTSLEEP;
goto out;
/* NOTREACHED */
* not be dispatched if masked but we must still deliver it.
*/
if (p->p_nice > NZERO && action == SIG_DFL && (prop & SA_KILL) &&
- (p->p_flag & P_TRACED) == 0) {
+ (p->p_flags & P_TRACED) == 0) {
p->p_nice = NZERO;
}
* could cause deadlock. Take no action at this
* time.
*/
- if (p->p_flag & P_PPWAIT) {
+ if (p->p_flags & P_PPWAIT) {
SIGADDSET(p->p_siglist, sig);
goto out;
}
}
/*
- * p->p_token must be held
+ * Notify the LWP that a signal has arrived. The LWP does not have to be
+ * sleeping on the current cpu.
+ *
+ * p->p_token and lp->lwp_token must be held on call.
*/
static void
lwp_signotify(struct lwp *lp)
ASSERT_LWKT_TOKEN_HELD(&lp->lwp_proc->p_token);
crit_enter();
- if (lp->lwp_stat == LSSLEEP || lp->lwp_stat == LSSTOP) {
+ if (lp == lwkt_preempted_proc()) {
/*
- * Thread is in tsleep.
+ * lwp is on the current cpu AND it is currently running
+ * (we preempted it).
*/
-
+ signotify();
+ } else if (lp->lwp_thread->td_gd == mycpu) {
/*
- * If the thread is sleeping uninterruptibly
- * we can't interrupt the sleep... the signal will
- * be noticed when the lwp returns through
- * trap() or syscall().
- *
- * Otherwise the signal can interrupt the sleep.
- *
- * If the process is traced, the lwp will handle the
- * tracing in issignal() when it returns to userland.
+ * lwp is on the current cpu, we can safely call
+ * setrunnable()
*/
- if (lp->lwp_flag & LWP_SINTR) {
- /*
- * Make runnable and break out of any tsleep as well.
- */
- lp->lwp_flag |= LWP_BREAKTSLEEP;
- setrunnable(lp);
- }
- } else {
+ setrunnable(lp);
+ } else
+#ifdef SMP
+ if (lp->lwp_flags & LWP_SINTR) {
/*
- * Otherwise the thread is running
- *
- * LSRUN does nothing with the signal, other than kicking
- * ourselves if we are running.
- * SZOMB and SIDL mean that it will either never be noticed,
- * or noticed very soon.
- *
- * Note that lwp_thread may be NULL or may not be completely
- * initialized if the process is in the SIDL or SZOMB state.
+ * The lwp is on some other cpu but sitting in a tsleep,
+ * we have to hold it to prevent it from going away and
+ * chase after the cpu it is sitting on.
*
- * For SMP we may have to forward the request to another cpu.
- * YYY the MP lock prevents the target process from moving
- * to another cpu, see kern/kern_switch.c
- *
- * If the target thread is waiting on its message port,
- * wakeup the target thread so it can check (or ignore)
- * the new signal. YYY needs cleanup.
+ * The lwp_token interlocks LWP_SINTR.
*/
- if (lp == lwkt_preempted_proc()) {
- signotify();
- } else if (lp->lwp_stat == LSRUN) {
- struct thread *td = lp->lwp_thread;
- struct proc *p __debugvar = lp->lwp_proc;
-
- KASSERT(td != NULL,
- ("pid %d/%d NULL lwp_thread stat %d flags %08x/%08x",
- p->p_pid, lp->lwp_tid, lp->lwp_stat,
- p->p_flag, lp->lwp_flag));
-
- /*
- * To prevent a MP race with TDF_SINTR we must
- * schedule the thread on the correct cpu.
- */
-#ifdef SMP
- if (td->td_gd != mycpu) {
- LWPHOLD(lp);
- lwkt_send_ipiq(td->td_gd, signotify_remote, lp);
- } else
+ LWPHOLD(lp);
+ lwkt_send_ipiq(lp->lwp_thread->td_gd, lwp_signotify_remote, lp);
+ } else
#endif
- if (td->td_flags & TDF_SINTR)
- lwkt_schedule(td);
- }
+ {
+ /*
+ * Otherwise the lwp is either in some uninterruptable state
+ * or it is on the userland scheduler's runqueue waiting to
+ * be scheduled to a cpu.
+ */
}
crit_exit();
}
#ifdef SMP
/*
- * This function is called via an IPI. We will be in a critical section but
- * the MP lock will NOT be held. The passed lp will be held.
+ * This function is called via an IPI so we cannot call setrunnable() here
+ * (because while we hold the lp we don't own its token, and can't get it
+ * from an IPI).
*
- * We must essentially repeat the code at the end of lwp_signotify(),
- * in particular rechecking all races. If we are still not on the
- * correct cpu we leave the lwp ref intact and continue the chase.
- *
- * XXX this may still not be entirely correct, since we are checking
- * lwp_stat asynchronously.
+ * We are interlocked by virtue of being on the same cpu as the target. If
+ * we still are and LWP_SINTR is set we can schedule the target thread.
*/
static void
-signotify_remote(void *arg)
+lwp_signotify_remote(void *arg)
{
struct lwp *lp = arg;
- thread_t td;
+ thread_t td = lp->lwp_thread;
if (lp == lwkt_preempted_proc()) {
signotify();
- } else if (lp->lwp_stat == LSRUN) {
- /*
- * To prevent a MP race with TDF_SINTR we must
- * schedule the thread on the correct cpu.
- */
- td = lp->lwp_thread;
- if (td->td_gd != mycpu) {
- lwkt_send_ipiq(td->td_gd, signotify_remote, lp);
- return;
- /* NOT REACHED */
- }
+ LWPRELE(lp);
+ } else if (td->td_gd == mycpu) {
+ if (lp->lwp_flags & LWP_SINTR)
+ lwkt_schedule(td);
if (td->td_flags & TDF_SINTR)
lwkt_schedule(td);
+ LWPRELE(lp);
+ } else {
+ lwkt_send_ipiq(td->td_gd, lwp_signotify_remote, lp);
+ /* LWPHOLD() is forwarded to the target cpu */
}
- LWPRELE(lp);
}
#endif
/*
* We're sleeping, but we will stop before
* returning to userspace, so count us
- * as stopped as well. We set LWP_WSTOP
+ * as stopped as well. We set LWP_MP_WSTOP
* to signal the lwp that it should not
* increase p_nstopped when reaching tstop().
+ *
+ * LWP_MP_WSTOP is protected by lp->lwp_token.
*/
- if ((lp->lwp_flag & LWP_WSTOP) == 0) {
- lp->lwp_flag |= LWP_WSTOP;
+ if ((lp->lwp_mpflags & LWP_MP_WSTOP) == 0) {
+ atomic_set_int(&lp->lwp_mpflags, LWP_MP_WSTOP);
++p->p_nstopped;
}
break;
q = p->p_pptr;
PHOLD(q);
lwkt_gettoken(&q->p_token);
- p->p_flag &= ~P_WAITED;
+ p->p_flags &= ~P_WAITED;
wakeup(q);
if ((q->p_sigacts->ps_flag & PS_NOCLDSTOP) == 0)
ksignal(p->p_pptr, SIGCHLD);
* Nevertheless we call setrunnable() so that it
* will wake up in case a signal or timeout arrived
* in the meantime.
+ *
+ * LWP_MP_WSTOP is protected by lp->lwp_token.
*/
- if (lp->lwp_flag & LWP_WSTOP) {
- lp->lwp_flag &= ~LWP_WSTOP;
+ if (lp->lwp_mpflags & LWP_MP_WSTOP) {
+ atomic_clear_int(&lp->lwp_mpflags,
+ LWP_MP_WSTOP);
--p->p_nstopped;
} else {
if (bootverbose)
/* FALLTHROUGH */
case LSSTOP:
- setrunnable(lp);
+ /*
+ * This handles any lwp's waiting in a tsleep with
+ * SIGCATCH.
+ */
+ lwp_signotify(lp);
break;
}
lwkt_reltoken(&lp->lwp_token);
LWPRELE(lp);
}
+
+ /*
+ * This handles any lwp's waiting in tstop(). We have interlocked
+ * the setting of p_stat by acquiring and releasing each lpw's
+ * token.
+ */
+ wakeup(p);
crit_exit();
}
lwkt_gettoken(&p->p_token);
for (;;) {
- int traced = (p->p_flag & P_TRACED) || (p->p_stops & S_SIG);
+ int traced = (p->p_flags & P_TRACED) || (p->p_stops & S_SIG);
/*
* If this process is supposed to stop, stop this thread.
mask = lwp_sigpend(lp);
SIGSETNAND(mask, lp->lwp_sigmask);
- if (p->p_flag & P_PPWAIT)
+ if (p->p_flags & P_PPWAIT)
SIG_STOPSIGMASK(mask);
if (SIGISEMPTY(mask)) { /* no signal to send */
lwkt_reltoken(&p->p_token);
spin_unlock(&lp->lwp_spin);
continue;
}
- if (maytrace && (p->p_flag & P_TRACED) && (p->p_flag & P_PPWAIT) == 0) {
+ if (maytrace &&
+ (p->p_flags & P_TRACED) &&
+ (p->p_flags & P_PPWAIT) == 0) {
/*
* If traced, always stop, and stay stopped until
* released by the parent.
proc_stop(p);
do {
tstop();
- } while (!trace_req(p) && (p->p_flag & P_TRACED));
+ } while (!trace_req(p) && (p->p_flags & P_TRACED));
/*
* If parent wants us to take the signal,
* to the top to rescan signals. This ensures
* that p_sig* and ps_sigact are consistent.
*/
- if ((p->p_flag & P_TRACED) == 0)
+ if ((p->p_flags & P_TRACED) == 0)
continue;
}
* process group, ignore tty stop signals.
*/
if (prop & SA_STOP) {
- if (p->p_flag & P_TRACED ||
+ if (p->p_flags & P_TRACED ||
(p->p_pgrp->pg_jobc == 0 &&
prop & SA_TTYSTOP))
break; /* == ignore */
* than SIGCONT, unless process is traced.
*/
if ((prop & SA_CONT) == 0 &&
- (p->p_flag & P_TRACED) == 0)
+ (p->p_flags & P_TRACED) == 0)
kprintf("issignal\n");
break; /* == ignore */
action = ps->ps_sigact[_SIG_IDX(sig)];
#ifdef KTRACE
if (KTRPOINT(lp->lwp_thread, KTR_PSIG))
- ktrpsig(lp, sig, action, lp->lwp_flag & LWP_OLDMASK ?
+ ktrpsig(lp, sig, action, lp->lwp_flags & LWP_OLDMASK ?
&lp->lwp_oldsigmask : &lp->lwp_sigmask, 0);
#endif
STOPEVENT(p, S_SIG, sig);
* mask from before the sigsuspend is what we want
* restored after the signal processing is completed.
*/
- if (lp->lwp_flag & LWP_OLDMASK) {
+ if (lp->lwp_flags & LWP_OLDMASK) {
returnmask = lp->lwp_oldsigmask;
- lp->lwp_flag &= ~LWP_OLDMASK;
+ lp->lwp_flags &= ~LWP_OLDMASK;
} else {
returnmask = lp->lwp_sigmask;
}
STOPEVENT(p, S_CORE, 0);
- if (((sugid_coredump == 0) && p->p_flag & P_SUGID) || do_coredump == 0)
+ if (((sugid_coredump == 0) && p->p_flags & P_SUGID) || do_coredump == 0)
return (EFAULT);
/*
lockmgr(&pg->pg_lock, LK_EXCLUSIVE);
LIST_FOREACH(p, &pg->pg_members, p_pglist) {
if (CANSIGIO(sigio->sio_ruid, sigio->sio_ucred, p) &&
- (checkctty == 0 || (p->p_flag & P_CONTROLT)))
+ (checkctty == 0 || (p->p_flags & P_CONTROLT)))
ksignal(p, sig);
}
lockmgr(&pg->pg_lock, LK_RELEASE);
static void endtsleep (void *);
static void loadav (void *arg);
static void schedcpu (void *arg);
-#ifdef SMP
-static void tsleep_wakeup_remote(struct thread *td);
-#endif
/*
* Adjust the scheduler quantum. The quantum is specified in microseconds.
killproc(p, "exceeded maximum CPU limit");
break;
case PLIMIT_TESTCPU_XCPU:
- if ((p->p_flag & P_XCPU) == 0) {
- p->p_flag |= P_XCPU;
+ if ((p->p_flags & P_XCPU) == 0) {
+ p->p_flags |= P_XCPU;
ksignal(p, SIGXCPU);
}
break;
/*
* Remove thread from sleepq. Must be called with a critical section held.
+ * The thread must not be migrating.
*/
static __inline void
_tsleep_remove(thread_t td)
int id;
KKASSERT(td->td_gd == gd && IN_CRITICAL_SECT(td));
+ KKASSERT((td->td_flags & TDF_MIGRATING) == 0);
if (td->td_flags & TDF_TSLEEPQ) {
td->td_flags &= ~TDF_TSLEEPQ;
id = LOOKUP(td->td_wchan);
}
/*
- * This function removes a thread from the tsleep queue and schedules
- * it. This function may act asynchronously. The target thread may be
- * sleeping on a different cpu.
- *
- * This function mus be called while in a critical section but if the
- * target thread is sleeping on a different cpu we cannot safely probe
- * td_flags.
- *
- * This function is only called from a different cpu via setrunnable()
- * when the thread is in a known sleep. However, multiple wakeups are
- * possible and we must hold the td to prevent a race against the thread
- * exiting.
- */
-static __inline
-void
-_tsleep_wakeup(struct thread *td)
-{
-#ifdef SMP
- globaldata_t gd = mycpu;
-
- if (td->td_gd != gd) {
- lwkt_hold(td);
- lwkt_send_ipiq(td->td_gd, (ipifunc1_t)tsleep_wakeup_remote, td);
- return;
- }
-#endif
- _tsleep_remove(td);
- if (td->td_flags & TDF_TSLEEP_DESCHEDULED) {
- td->td_flags &= ~TDF_TSLEEP_DESCHEDULED;
- lwkt_schedule(td);
- }
-}
-
-#ifdef SMP
-static
-void
-tsleep_wakeup_remote(struct thread *td)
-{
- _tsleep_wakeup(td);
- lwkt_rele(td);
-}
-#endif
-
-
-/*
* General sleep call. Suspends the current process until a wakeup is
* performed on the specified identifier. The process will then be made
* runnable with the specified priority. Sleeps at most timo/hz seconds
}
/*
- * Setup for the current process (if this is a process).
- *
- * We hold the process token if lp && catch. The resume
- * code will release it.
+ * Setup for the current process (if this is a process). We must
+ * interlock with lwp_token to avoid remote wakeup races via
+ * setrunnable()
*/
if (lp) {
+ lwkt_gettoken(&lp->lwp_token);
if (catch) {
/*
* Early termination if PCATCH was set and a
* Causes ksignal to wake us up if a signal is
* received (interlocked with p->p_token).
*/
- lp->lwp_flag |= LWP_SINTR;
+ lp->lwp_flags |= LWP_SINTR;
}
} else {
KKASSERT(p == NULL);
/*
* Ok, we are sleeping. Place us in the SSLEEP state.
*/
- KKASSERT((lp->lwp_flag & LWP_ONRUNQ) == 0);
+ KKASSERT((lp->lwp_mpflags & LWP_MP_ONRUNQ) == 0);
/*
* tstop() sets LSSTOP, so don't fiddle with that.
*/
lp->lwp_stat = LSSLEEP;
lp->lwp_ru.ru_nvcsw++;
lwkt_switch();
- td->td_flags &= ~TDF_TSLEEP_DESCHEDULED;
/*
* And when we are woken up, put us back in LSRUN. If we
lp->lwp_slptime = 0;
} else {
lwkt_switch();
- td->td_flags &= ~TDF_TSLEEP_DESCHEDULED;
}
/*
/*
* Cleanup the timeout. If the timeout has already occured thandle
- * has already been stopped, otherwise stop thandle.
+ * has already been stopped, otherwise stop thandle. If the timeout
+ * is running (the callout thread must be blocked trying to get
+ * lwp_token) then wait for us to get scheduled.
*/
if (timo) {
+ while (td->td_flags & TDF_TIMEOUT_RUNNING) {
+ lwkt_deschedule_self(td);
+ td->td_wmesg = "tsrace";
+ lwkt_switch();
+ kprintf("td %p %s: timeout race\n", td, td->td_comm);
+ }
if (td->td_flags & TDF_TIMEOUT) {
td->td_flags &= ~TDF_TIMEOUT;
error = EWOULDBLOCK;
callout_stop(&thandle);
}
}
+ td->td_flags &= ~TDF_TSLEEP_DESCHEDULED;
/*
* Make sure we have been removed from the sleepq. In most
* signal we want to return EINTR or ERESTART.
*/
resume:
- if (p) {
+ if (lp) {
if (catch && error == 0) {
if (sig != 0 || (sig = CURSIG(lp))) {
if (SIGISMEMBER(p->p_sigacts->ps_sigintr, sig))
error = ERESTART;
}
}
- lp->lwp_flag &= ~(LWP_BREAKTSLEEP | LWP_SINTR);
+ lp->lwp_flags &= ~LWP_SINTR;
+ lwkt_reltoken(&lp->lwp_token);
}
logtsleep1(tsleep_end);
crit_exit_quick(td);
/*
* Implement the timeout for tsleep.
*
- * We set LWP_BREAKTSLEEP to indicate that an event has occured, but
- * we only call setrunnable if the process is not stopped.
- *
* This type of callout timeout is scheduled on the same cpu the process
* is sleeping on. Also, at the moment, the MP lock is held.
*/
thread_t td = arg;
struct lwp *lp;
- KKASSERT(td->td_gd == mycpu);
- crit_enter();
-
/*
- * Do this before we potentially block acquiring the token. Setting
- * TDF_TIMEOUT tells tsleep that we have already stopped the callout.
+ * We are going to have to get the lwp_token, which means we might
+ * block. This can race a tsleep getting woken up by other means
+ * so set TDF_TIMEOUT_RUNNING to force the tsleep to wait for our
+ * processing to complete (sorry tsleep!).
+ *
+ * We can safely set td_flags because td MUST be on the same cpu
+ * as we are.
*/
- lwkt_hold(td);
- td->td_flags |= TDF_TIMEOUT;
+ KKASSERT(td->td_gd == mycpu);
+ crit_enter();
+ td->td_flags |= TDF_TIMEOUT_RUNNING | TDF_TIMEOUT;
/*
- * This can block
+ * This can block but TDF_TIMEOUT_RUNNING will prevent the thread
+ * from exiting the tsleep on us. The flag is interlocked by virtue
+ * of lp being on the same cpu as we are.
*/
if ((lp = td->td_lwp) != NULL)
lwkt_gettoken(&lp->lwp_token);
- /*
- * Only do nominal wakeup processing if TDF_TIMEOUT and
- * TDF_TSLEEP_DESCHEDULED are both still set. Otherwise
- * we raced a wakeup or we began executing and raced due to
- * blocking in the token above, and should do nothing.
- */
- if ((td->td_flags & (TDF_TIMEOUT | TDF_TSLEEP_DESCHEDULED)) ==
- (TDF_TIMEOUT | TDF_TSLEEP_DESCHEDULED)) {
- if (lp) {
- lp->lwp_flag |= LWP_BREAKTSLEEP;
- if (lp->lwp_proc->p_stat != SSTOP)
- setrunnable(lp);
- } else {
- _tsleep_wakeup(td);
- }
- }
- if (lp)
+ KKASSERT(td->td_flags & TDF_TSLEEP_DESCHEDULED);
+
+ if (lp) {
+ if (lp->lwp_proc->p_stat != SSTOP)
+ setrunnable(lp);
lwkt_reltoken(&lp->lwp_token);
- lwkt_rele(td);
+ } else {
+ _tsleep_remove(td);
+ lwkt_schedule(td);
+ }
+ KKASSERT(td->td_gd == mycpu);
+ td->td_flags &= ~TDF_TIMEOUT_RUNNING;
crit_exit();
}
KKASSERT(td->td_gd == gd);
_tsleep_remove(td);
if (td->td_flags & TDF_TSLEEP_DESCHEDULED) {
- td->td_flags &= ~TDF_TSLEEP_DESCHEDULED;
lwkt_schedule(td);
if (domain & PWAKEUP_ONE)
goto done;
/*
* setrunnable()
*
- * Make a process runnable. lp->lwp_proc->p_token must be held on call.
- * This only has an effect if we are in SSLEEP. We only break out of the
- * tsleep if LWP_BREAKTSLEEP is set, otherwise we just fix-up the state.
+ * Make a process runnable. lp->lwp_token must be held on call and this
+ * function must be called from the cpu owning lp.
*
- * NOTE: With p_token held we can only safely manipulate the process
- * structure and the lp's lwp_stat.
+ * This only has an effect if we are in LSSTOP or LSSLEEP.
*/
void
setrunnable(struct lwp *lp)
{
+ thread_t td = lp->lwp_thread;
+
ASSERT_LWKT_TOKEN_HELD(&lp->lwp_token);
+ KKASSERT(td->td_gd == mycpu);
crit_enter();
if (lp->lwp_stat == LSSTOP)
lp->lwp_stat = LSSLEEP;
- if (lp->lwp_stat == LSSLEEP && (lp->lwp_flag & LWP_BREAKTSLEEP))
- _tsleep_wakeup(lp->lwp_thread);
+ if (lp->lwp_stat == LSSLEEP) {
+ _tsleep_remove(td);
+ lwkt_schedule(td);
+ } else if (td->td_flags & TDF_SINTR) {
+ lwkt_schedule(td);
+ }
crit_exit();
}
* The process is stopped due to some condition, usually because p_stat is
* set to SSTOP, but also possibly due to being traced.
*
+ * Caller must hold p->p_token
+ *
* NOTE! If the caller sets SSTOP, the caller must also clear P_WAITED
* because the parent may check the child's status before the child actually
* gets to this routine.
*
* This routine is called with the current lwp only, typically just
- * before returning to userland.
- *
- * Setting LWP_BREAKTSLEEP before entering the tsleep will cause a passive
- * SIGCONT to break out of the tsleep.
+ * before returning to userland if the process state is detected as
+ * possibly being in a stopped state.
*/
void
tstop(void)
struct proc *p = lp->lwp_proc;
struct proc *q;
+ lwkt_gettoken(&lp->lwp_token);
crit_enter();
+
/*
- * If LWP_WSTOP is set, we were sleeping
+ * If LWP_MP_WSTOP is set, we were sleeping
* while our process was stopped. At this point
* we were already counted as stopped.
*/
- if ((lp->lwp_flag & LWP_WSTOP) == 0) {
+ if ((lp->lwp_mpflags & LWP_MP_WSTOP) == 0) {
/*
* If we're the last thread to stop, signal
* our parent.
*/
p->p_nstopped++;
- lp->lwp_flag |= LWP_WSTOP;
+ atomic_set_int(&lp->lwp_mpflags, LWP_MP_WSTOP);
wakeup(&p->p_nstopped);
if (p->p_nstopped == p->p_nthreads) {
/*
q = p->p_pptr;
PHOLD(q);
lwkt_gettoken(&q->p_token);
- p->p_flag &= ~P_WAITED;
+ p->p_flags &= ~P_WAITED;
wakeup(p->p_pptr);
if ((q->p_sigacts->ps_flag & PS_NOCLDSTOP) == 0)
ksignal(q, SIGCHLD);
}
}
while (p->p_stat == SSTOP) {
- lp->lwp_flag |= LWP_BREAKTSLEEP;
lp->lwp_stat = LSSTOP;
tsleep(p, 0, "stop", 0);
}
p->p_nstopped--;
- lp->lwp_flag &= ~LWP_WSTOP;
+ atomic_clear_int(&lp->lwp_mpflags, LWP_MP_WSTOP);
crit_exit();
+ lwkt_reltoken(&lp->lwp_token);
}
/*
uap->sysmsg_result = 0;
if (p->p_wakeup == 0) {
sleepstart = ticks;
- lp->lwp_flag |= LWP_SINTR;
+ lp->lwp_flags |= LWP_SINTR;
error = tsleep(p, 0, "thrslp", timo);
- lp->lwp_flag &= ~LWP_SINTR;
+ lp->lwp_flags &= ~LWP_SINTR;
if (error == EWOULDBLOCK) {
p->p_wakeup = 0;
uap->sysmsg_result = EAGAIN;
p->p_timer[uap->which] = aitv;
switch(uap->which) {
case ITIMER_VIRTUAL:
- p->p_flag &= ~P_SIGVTALRM;
+ p->p_flags &= ~P_SIGVTALRM;
break;
case ITIMER_PROF:
- p->p_flag &= ~P_SIGPROF;
+ p->p_flags &= ~P_SIGPROF;
break;
}
}
* the cpu they were scheduled on.
*/
lwkt_create(softclock_handler, sc, NULL,
- &sc->thread, TDF_STOPREQ | TDF_INTTHREAD,
+ &sc->thread, TDF_NOSTART | TDF_INTTHREAD,
cpu, "softclock %d", cpu);
}
}
vu->vu_pending = (int)(intptr_t)uap->data;
error = 0;
targlp = vu->vu_lwp;
- targlp->lwp_proc->p_flag |= P_UPCALLPEND; /* XXX lwp flags */
- if (targlp->lwp_proc->p_flag & P_UPCALLWAIT)
+ targlp->lwp_proc->p_flags |= P_UPCALLPEND; /* XXX lwp flags */
+ if (targlp->lwp_proc->p_flags & P_UPCALLWAIT)
wakeup(&targlp->lwp_upcall);
#ifdef SMP
if (targlp->lwp_thread->td_gd != mycpu)
}
}
if (uap->cmd == UPC_CONTROL_WAIT && vu == NULL) {
- lp->lwp_proc->p_flag |= P_UPCALLWAIT; /* XXX lwp flags */
+ lp->lwp_proc->p_flags |= P_UPCALLWAIT; /* XXX lwp flags */
tsleep(&lp->lwp_upcall, PCATCH, "wupcall", 0);
- lp->lwp_proc->p_flag &= ~P_UPCALLWAIT; /* XXX lwp flags */
+ lp->lwp_proc->p_flags &= ~P_UPCALLWAIT; /* XXX lwp flags */
}
break;
default:
td->td_kstack = NULL;
td->td_kstack_size = 0;
td->td_flags = TDF_ALLOCATED_THREAD;
+ td->td_mpflags = 0;
return (1);
}
crit_enter_quick(td);
KASSERT(td != &td->td_gd->gd_idlethread,
("lwkt_schedule_self(): scheduling gd_idlethread is illegal!"));
- KKASSERT(td->td_lwp == NULL || (td->td_lwp->lwp_flag & LWP_ONRUNQ) == 0);
+ KKASSERT(td->td_lwp == NULL ||
+ (td->td_lwp->lwp_mpflags & LWP_MP_ONRUNQ) == 0);
_lwkt_enqueue(td);
crit_exit_quick(td);
}
td->td_kstack = stack;
td->td_kstack_size = stksize;
td->td_flags = flags;
+ td->td_mpflags = 0;
td->td_gd = gd;
td->td_pri = TDPRI_KERN_DAEMON;
td->td_critcount = 1;
("lwkt_schedule(): scheduling gd_idlethread is illegal!"));
KKASSERT((td->td_flags & TDF_MIGRATING) == 0);
crit_enter_gd(mygd);
- KKASSERT(td->td_lwp == NULL || (td->td_lwp->lwp_flag & LWP_ONRUNQ) == 0);
+ KKASSERT(td->td_lwp == NULL ||
+ (td->td_lwp->lwp_mpflags & LWP_MP_ONRUNQ) == 0);
+
if (td == mygd->gd_curthread) {
_lwkt_enqueue(td);
} else {
cpu_mfence();
td->td_flags &= ~TDF_MIGRATING;
KKASSERT(td->td_migrate_gd == NULL);
- KKASSERT(td->td_lwp == NULL || (td->td_lwp->lwp_flag & LWP_ONRUNQ) == 0);
+ KKASSERT(td->td_lwp == NULL ||
+ (td->td_lwp->lwp_mpflags & LWP_MP_ONRUNQ) == 0);
_lwkt_enqueue(td);
}
#endif
/*
* Schedule the thread to run
*/
- if ((td->td_flags & TDF_STOPREQ) == 0)
- lwkt_schedule(td);
+ if (td->td_flags & TDF_NOSTART)
+ td->td_flags &= ~TDF_NOSTART;
else
- td->td_flags &= ~TDF_STOPREQ;
+ lwkt_schedule(td);
return 0;
}
struct putchar_arg pca;
int retval = 0;
- if (p && p->p_flag & P_CONTROLT &&
- p->p_session->s_ttyvp) {
+ if (p && (p->p_flags & P_CONTROLT) && p->p_session->s_ttyvp) {
__va_start(ap, fmt);
pca.tty = p->p_session->s_ttyp;
pca.flags = TOTTY;
tpr_t
tprintf_open(struct proc *p)
{
- if ((p->p_flag & P_CONTROLT) && p->p_session->s_ttyvp) {
+ if ((p->p_flags & P_CONTROLT) && p->p_session->s_ttyvp) {
sess_hold(p->p_session);
return ((tpr_t) p->p_session);
}
u_short v;
/* Testing P_PROFIL may be unnecessary, but is certainly safe. */
- if ((p->p_flag & P_PROFIL) == 0 || ticks == 0)
+ if ((p->p_flags & P_PROFIL) == 0 || ticks == 0)
return;
prof = &p->p_prof;
if (count == 1) {
error = lwkt_create(taskqueue_thread_loop, tqp,
&tq->tq_threads[i], NULL,
- TDF_STOPREQ, cpu,
+ TDF_NOSTART, cpu,
"%s", ktname);
} else {
error = lwkt_create(taskqueue_thread_loop, tqp,
&tq->tq_threads[i], NULL,
- TDF_STOPREQ, cpu,
+ TDF_NOSTART, cpu,
"%s_%d", ktname, i);
}
if (error) {
* us. So make a note to restore it after executing
* the handler.
*/
- lp->lwp_flag |= LWP_OLDMASK;
+ lp->lwp_flags |= LWP_OLDMASK;
} else {
/*
* No handler to run. Restore previous mask immediately.
lwkt_gettoken(&p->p_token);
/* Can't trace a process that's currently exec'ing. */
- if ((p->p_flag & P_INEXEC) != 0) {
+ if ((p->p_flags & P_INEXEC) != 0) {
lwkt_reltoken(&p->p_token);
PRELE(p);
lwkt_reltoken(&proc_token);
}
/* Already traced */
- if (p->p_flag & P_TRACED) {
+ if (p->p_flags & P_TRACED) {
lwkt_reltoken(&p->p_token);
PRELE(p);
lwkt_reltoken(&proc_token);
return EBUSY;
}
- if (curp->p_flag & P_TRACED)
+ if (curp->p_flags & P_TRACED)
for (pp = curp->p_pptr; pp != NULL; pp = pp->p_pptr)
if (pp == p) {
lwkt_reltoken(&p->p_token);
/* not owned by you, has done setuid (unless you're root) */
if ((p->p_ucred->cr_ruid != curp->p_ucred->cr_ruid) ||
- (p->p_flag & P_SUGID)) {
+ (p->p_flags & P_SUGID)) {
if ((error = priv_check_cred(curp->p_ucred, PRIV_ROOT, 0)) != 0) {
lwkt_reltoken(&p->p_token);
PRELE(p);
case PT_SETDBREGS:
#endif
/* not being traced... */
- if ((p->p_flag & P_TRACED) == 0) {
+ if ((p->p_flags & P_TRACED) == 0) {
lwkt_reltoken(&p->p_token);
PRELE(p);
lwkt_reltoken(&proc_token);
/* not currently stopped */
if (p->p_stat != SSTOP ||
- (p->p_flag & P_WAITED) == 0) {
+ (p->p_flags & P_WAITED) == 0) {
lwkt_reltoken(&p->p_token);
PRELE(p);
lwkt_reltoken(&proc_token);
switch (req) {
case PT_TRACE_ME:
/* set my trace flag and "owner" so it can read/write me */
- p->p_flag |= P_TRACED;
+ p->p_flags |= P_TRACED;
p->p_oppid = p->p_pptr->p_pid;
lwkt_reltoken(&p->p_token);
PRELE(p);
case PT_ATTACH:
/* security check done above */
- p->p_flag |= P_TRACED;
+ p->p_flags |= P_TRACED;
p->p_oppid = p->p_pptr->p_pid;
if (p->p_pptr != curp)
proc_reparent(p, curp);
PRELE(pp);
}
- p->p_flag &= ~(P_TRACED | P_WAITED);
+ p->p_flags &= ~(P_TRACED | P_WAITED);
p->p_oppid = 0;
/* should we send SIGCHLD? */
crit_enter();
if (p->p_stat == SSTOP) {
p->p_xstat = data;
- lp->lwp_flag |= LWP_BREAKTSLEEP;
proc_unstop(p);
} else if (data) {
ksignal(p, data);
case TIOCSETP:
case TIOCSLTC:
#endif
- while (isbackground(p, tp) && !(p->p_flag & P_PPWAIT) &&
+ while (isbackground(p, tp) && !(p->p_flags & P_PPWAIT) &&
!SIGISMEMBER(p->p_sigignore, SIGTTOU) &&
!SIGISMEMBER(lp->lwp_sigmask, SIGTTOU)) {
if (p->p_pgrp->pg_jobc == 0) {
tp->t_pgrp = p->p_pgrp;
otp = p->p_session->s_ttyp;
p->p_session->s_ttyp = tp;
- p->p_flag |= P_CONTROLT;
+ p->p_flags |= P_CONTROLT;
if (otp)
ttyunhold(otp);
if (opgrp) {
crit_exit();
if (SIGISMEMBER(pp->p_sigignore, SIGTTIN) ||
SIGISMEMBER(lp->lwp_sigmask, SIGTTIN) ||
- (pp->p_flag & P_PPWAIT) || pp->p_pgrp->pg_jobc == 0) {
+ (pp->p_flags & P_PPWAIT) || pp->p_pgrp->pg_jobc == 0) {
lwkt_reltoken(&proc_token);
lwkt_reltoken(&tty_token);
return (EIO);
*/
lwkt_gettoken(&proc_token);
if ((pp = curproc) && isbackground(pp, tp) &&
- ISSET(tp->t_lflag, TOSTOP) && !(pp->p_flag & P_PPWAIT) &&
+ ISSET(tp->t_lflag, TOSTOP) && !(pp->p_flags & P_PPWAIT) &&
!SIGISMEMBER(pp->p_sigignore, SIGTTOU) &&
!SIGISMEMBER(lp->lwp_sigmask, SIGTTOU)) {
if (pp->p_pgrp->pg_jobc == 0) {
* XXX lwp This is a horrible mixture. We need to rework this
* as soon as lwps have their own runnable status.
*/
- if (pick->p_flag & P_WEXIT)
+ if (pick->p_flags & P_WEXIT)
str = "exiting";
else if (lp->lwp_stat == LSRUN)
str = "running";
* 'pick' becomes invalid the moment we exit the critical
* section.
*/
- if (lp->lwp_thread && (pick->p_flag & P_SWAPPEDOUT) == 0)
+ if (lp->lwp_thread && (pick->p_flags & P_SWAPPEDOUT) == 0)
calcru_proc(pick, &ru);
pctcpu = (lp->lwp_pctcpu * 10000 + FSCALE / 2) >> FSHIFT;
/*
* favor one sleeping in a non-interruptible sleep
*/
- if (lp1->lwp_flag & LWP_SINTR && (lp2->lwp_flag & LWP_SINTR) == 0)
+ if (lp1->lwp_flags & LWP_SINTR && (lp2->lwp_flags & LWP_SINTR) == 0)
return (1);
- if (lp2->lwp_flag & LWP_SINTR && (lp1->lwp_flag & LWP_SINTR) == 0)
+ if (lp2->lwp_flags & LWP_SINTR && (lp1->lwp_flags & LWP_SINTR) == 0)
return (0);
return (p2->p_pid > p1->p_pid); /* tie - return highest pid */
}
while (isbackground(p, tp)) {
if (SIGISMEMBER(p->p_sigignore, SIGTTIN) ||
SIGISMEMBER(lp->lwp_sigmask, SIGTTIN) ||
- p->p_pgrp->pg_jobc == 0 || p->p_flag & P_PPWAIT) {
+ p->p_pgrp->pg_jobc == 0 ||
+ (p->p_flags & P_PPWAIT)) {
lwkt_reltoken(&tty_token);
return (EIO);
}
.d_kqfilter = cttykqfilter
};
-#define cttyvp(p) ((p)->p_flag & P_CONTROLT ? (p)->p_session->s_ttyvp : NULL)
+#define cttyvp(p) (((p)->p_flags & P_CONTROLT) ? \
+ (p)->p_session->s_ttyvp : NULL)
/*
* This opens /dev/tty. Because multiple opens of /dev/tty only
}
if (ap->a_cmd == TIOCNOTTY) {
if (!SESS_LEADER(p)) {
- p->p_flag &= ~P_CONTROLT;
+ p->p_flags &= ~P_CONTROLT;
lwkt_reltoken(&proc_token);
lwkt_reltoken(&p->p_token);
return (0);
{
globaldata_t gd;
bsd4_pcpu_t dd;
+ thread_t td;
#if 0
struct lwp *olp;
#endif
- crit_enter();
+ /*
+ * Make sure we aren't sitting on a tsleep queue.
+ */
+ td = lp->lwp_thread;
+ crit_enter_quick(td);
+ if (td->td_flags & TDF_TSLEEPQ)
+ tsleep_remove(td);
bsd4_recalculate_estcpu(lp);
/*
}
} while (dd->uschedcp != lp);
- crit_exit();
- KKASSERT((lp->lwp_flag & LWP_ONRUNQ) == 0);
+ crit_exit_quick(td);
+ KKASSERT((lp->lwp_mpflags & LWP_MP_ONRUNQ) == 0);
}
/*
if (dd->uschedcp == lp) {
crit_enter();
- KKASSERT((lp->lwp_flag & LWP_ONRUNQ) == 0);
+ KKASSERT((lp->lwp_mpflags & LWP_MP_ONRUNQ) == 0);
dd->uschedcp = NULL; /* don't let lp be selected */
dd->upri = PRIBASE_NULL;
atomic_clear_cpumask(&bsd4_curprocmask, gd->gd_cpumask);
*/
crit_enter();
KASSERT(lp->lwp_stat == LSRUN, ("setrunqueue: lwp not LSRUN"));
- KASSERT((lp->lwp_flag & LWP_ONRUNQ) == 0,
+ KASSERT((lp->lwp_mpflags & LWP_MP_ONRUNQ) == 0,
("lwp %d/%d already on runq! flag %08x/%08x", lp->lwp_proc->p_pid,
- lp->lwp_tid, lp->lwp_proc->p_flag, lp->lwp_flag));
+ lp->lwp_tid, lp->lwp_proc->p_flags, lp->lwp_flags));
KKASSERT((lp->lwp_thread->td_flags & TDF_RUNQ) == 0);
/*
*/
if ((lp->lwp_priority ^ newpriority) & ~PPQMASK) {
lp->lwp_priority = newpriority;
- if (lp->lwp_flag & LWP_ONRUNQ) {
+ if (lp->lwp_mpflags & LWP_MP_ONRUNQ) {
bsd4_remrunqueue_locked(lp);
lp->lwp_rqtype = newrqtype;
lp->lwp_rqindex = (newpriority & PRIMASK) / PPQ;
--bsd4_runqcount;
if (TAILQ_EMPTY(q))
*which &= ~(1 << pri);
- KASSERT((lp->lwp_flag & LWP_ONRUNQ) != 0, ("not on runq6!"));
- lp->lwp_flag &= ~LWP_ONRUNQ;
+ KASSERT((lp->lwp_mpflags & LWP_MP_ONRUNQ) != 0, ("not on runq6!"));
+ atomic_clear_int(&lp->lwp_mpflags, LWP_MP_ONRUNQ);
return lp;
}
u_int32_t *which;
u_int8_t pri;
- KKASSERT(lp->lwp_flag & LWP_ONRUNQ);
- lp->lwp_flag &= ~LWP_ONRUNQ;
+ KKASSERT(lp->lwp_mpflags & LWP_MP_ONRUNQ);
+ atomic_clear_int(&lp->lwp_mpflags, LWP_MP_ONRUNQ);
--bsd4_runqcount;
KKASSERT(bsd4_runqcount >= 0);
u_int32_t *which;
int pri;
- KKASSERT((lp->lwp_flag & LWP_ONRUNQ) == 0);
- lp->lwp_flag |= LWP_ONRUNQ;
+ KKASSERT((lp->lwp_mpflags & LWP_MP_ONRUNQ) == 0);
+ atomic_set_int(&lp->lwp_mpflags, LWP_MP_ONRUNQ);
++bsd4_runqcount;
pri = lp->lwp_rqindex;
kprintf(" %d", i);
lwkt_create(sched_thread, NULL, NULL, &dd->helper_thread,
- TDF_STOPREQ, i, "usched %d", i);
+ TDF_NOSTART, i, "usched %d", i);
/*
* Allow user scheduling on the target cpu. cpu #0 has already
crit_exit();
gd = mycpu;
dd = &dummy_pcpu[gd->gd_cpuid];
- KKASSERT((lp->lwp_flag & LWP_ONRUNQ) == 0);
+ KKASSERT((lp->lwp_mpflags & LWP_MP_ONRUNQ) == 0);
} while (dd->uschedcp != lp);
}
globaldata_t gd = mycpu;
dummy_pcpu_t dd = &dummy_pcpu[gd->gd_cpuid];
- KKASSERT((lp->lwp_flag & LWP_ONRUNQ) == 0);
+ KKASSERT((lp->lwp_mpflags & LWP_MP_ONRUNQ) == 0);
if (dd->uschedcp == lp) {
dummy_select_curproc(gd);
}
} else {
--dummy_runqcount;
TAILQ_REMOVE(&dummy_runq, lp, lwp_procq);
- lp->lwp_flag &= ~LWP_ONRUNQ;
+ atomic_clear_int(&lp->lwp_mpflags, LWP_MP_ONRUNQ);
dd->uschedcp = lp;
atomic_set_cpumask(&dummy_curprocmask, gd->gd_cpumask);
spin_unlock(&dummy_spin);
* the current process on the userland scheduler's run queue prior
* to calling dummy_select_curproc().
*
- * The caller may set LWP_PASSIVE_ACQ in lwp_flag to indicate that we should
+ * The caller may set LWP_PASSIVE_ACQ in lwp_flags to indicate that we should
* attempt to leave the thread on the current cpu.
*
* MPSAFE
/*
* Add to our global runq
*/
- KKASSERT((lp->lwp_flag & LWP_ONRUNQ) == 0);
+ KKASSERT((lp->lwp_mpflags & LWP_MP_ONRUNQ) == 0);
spin_lock(&dummy_spin);
++dummy_runqcount;
TAILQ_INSERT_TAIL(&dummy_runq, lp, lwp_procq);
- lp->lwp_flag |= LWP_ONRUNQ;
+ atomic_set_int(&lp->lwp_mpflags, LWP_MP_ONRUNQ);
#ifdef SMP
lwkt_giveaway(lp->lwp_thread);
#endif
} else if ((lp = TAILQ_FIRST(&dummy_runq)) != NULL) {
--dummy_runqcount;
TAILQ_REMOVE(&dummy_runq, lp, lwp_procq);
- lp->lwp_flag &= ~LWP_ONRUNQ;
+ atomic_clear_int(&lp->lwp_mpflags, LWP_MP_ONRUNQ);
dd->uschedcp = lp;
atomic_set_cpumask(&dummy_curprocmask, cpumask);
spin_unlock(&dummy_spin);
kprintf(" %d", i);
lwkt_create(dummy_sched_thread, NULL, NULL, &dd->helper_thread,
- TDF_STOPREQ, i, "dsched %d", i);
+ TDF_NOSTART, i, "dsched %d", i);
/*
* Allow user scheduling on the target cpu. cpu #0 has already
jo->flags &= ~(MC_JOURNAL_STOP_REQ | MC_JOURNAL_STOP_IMM);
jo->flags |= MC_JOURNAL_WACTIVE;
lwkt_create(journal_wthread, jo, NULL, &jo->wthread,
- TDF_STOPREQ, -1,
+ TDF_NOSTART, -1,
"journal w:%.*s", JIDMAX, jo->id);
lwkt_setpri(&jo->wthread, TDPRI_KERN_DAEMON);
lwkt_schedule(&jo->wthread);
if (jo->flags & MC_JOURNAL_WANT_FULLDUPLEX) {
jo->flags |= MC_JOURNAL_RACTIVE;
lwkt_create(journal_rthread, jo, NULL, &jo->rthread,
- TDF_STOPREQ, -1,
+ TDF_NOSTART, -1,
"journal r:%.*s", JIDMAX, jo->id);
lwkt_setpri(&jo->rthread, TDPRI_KERN_DAEMON);
lwkt_schedule(&jo->rthread);
struct thread *thr = &ifnet_threads[i];
lwkt_create(ifnet_service_loop, NULL, NULL,
- thr, TDF_STOPREQ|TDF_FORCE_SPINPORT,
+ thr, TDF_NOSTART|TDF_FORCE_SPINPORT,
i, "ifnet %d", i);
netmsg_service_port_init(&thr->td_msgport);
lwkt_schedule(thr);
*/
for (i = 0; i < ncpus; ++i) {
lwkt_create(netmsg_service_loop, NULL, NULL,
- &netisr_cpu[i], TDF_STOPREQ|TDF_FORCE_SPINPORT,
+ &netisr_cpu[i], TDF_NOSTART|TDF_FORCE_SPINPORT,
i, "netisr_cpu %d", i);
netmsg_service_port_init(&netisr_cpu[i].td_msgport);
lwkt_schedule(&netisr_cpu[i]);
*newpp = p2;
/* this is a non-swapped system process */
- p2->p_flag |= P_SYSTEM;
+ p2->p_flags |= P_SYSTEM;
p2->p_sigacts->ps_flag |= PS_NOCLDWAIT;
lp2 = ONLY_LWP_IN_PROC(p2);
db_printf("pid %d not found\n", pid);
return;
}
- if ((p->p_flag & P_SWAPPEDOUT)) {
+ if ((p->p_flags & P_SWAPPEDOUT)) {
db_printf("pid %d swapped out\n", pid);
return;
}
sf.sf_uc.uc_mcontext.mc_len = sizeof(sf.sf_uc.uc_mcontext);
/* Allocate and validate space for the signal handler context. */
- if ((lp->lwp_flag & LWP_ALTSTACK) != 0 && !oonstack &&
+ if ((lp->lwp_flags & LWP_ALTSTACK) != 0 && !oonstack &&
SIGISMEMBER(psp->ps_sigonstack, sig)) {
sfp = (struct sigframe *)(lp->lwp_sigstk.ss_sp +
lp->lwp_sigstk.ss_size - sizeof(struct sigframe));
* This may do a copyout and block, so do it first even though it
* means some system time will be charged as user time.
*/
- if (p->p_flag & P_PROFIL) {
+ if (p->p_flags & P_PROFIL) {
addupc_task(p, frame->tf_eip,
(u_int)((int)lp->lwp_thread->td_sticks - sticks));
}
/*
* If the jungle wants us dead, so be it.
*/
- if (lp->lwp_flag & LWP_WEXIT) {
+ if (lp->lwp_mpflags & LWP_MP_WEXIT) {
lwkt_gettoken(&p->p_token);
lwp_exit(0);
lwkt_reltoken(&p->p_token); /* NOT REACHED */
* Block here if we are in a stopped state.
*/
if (p->p_stat == SSTOP || dump_stop_usertds) {
- get_mplock();
+ lwkt_gettoken(&p->p_token);
tstop();
- rel_mplock();
+ lwkt_reltoken(&p->p_token);
goto recheck;
}
* Post any pending upcalls. If running a virtual kernel be sure
* to restore the virtual kernel's vmspace before posting the upcall.
*/
- if (p->p_flag & (P_SIGVTALRM | P_SIGPROF | P_UPCALLPEND)) {
+ if (p->p_flags & (P_SIGVTALRM | P_SIGPROF | P_UPCALLPEND)) {
lwkt_gettoken(&p->p_token);
- if (p->p_flag & P_SIGVTALRM) {
- p->p_flag &= ~P_SIGVTALRM;
+ if (p->p_flags & P_SIGVTALRM) {
+ p->p_flags &= ~P_SIGVTALRM;
ksignal(p, SIGVTALRM);
}
- if (p->p_flag & P_SIGPROF) {
- p->p_flag &= ~P_SIGPROF;
+ if (p->p_flags & P_SIGPROF) {
+ p->p_flags &= ~P_SIGPROF;
ksignal(p, SIGPROF);
}
- if (p->p_flag & P_UPCALLPEND) {
- p->p_flag &= ~P_UPCALLPEND;
+ if (p->p_flags & P_UPCALLPEND) {
+ p->p_flags &= ~P_UPCALLPEND;
postupcall(lp);
}
lwkt_reltoken(&p->p_token);
* (such as SIGKILL). proc0 (the swapin scheduler) is already
* aware of our situation, we do not have to wake it up.
*/
- if (p->p_flag & P_SWAPPEDOUT) {
+ if (p->p_flags & P_SWAPPEDOUT) {
lwkt_gettoken(&p->p_token);
get_mplock();
- p->p_flag |= P_SWAPWAIT;
+ p->p_flags |= P_SWAPWAIT;
swapin_request();
- if (p->p_flag & P_SWAPWAIT)
+ if (p->p_flags & P_SWAPWAIT)
tsleep(p, PCATCH, "SWOUT", 0);
- p->p_flag &= ~P_SWAPWAIT;
+ p->p_flags &= ~P_SWAPWAIT;
rel_mplock();
lwkt_reltoken(&p->p_token);
goto recheck;
* Make sure postsig() handled request to restore old signal mask after
* running signal handler.
*/
- KKASSERT((lp->lwp_flag & LWP_OLDMASK) == 0);
+ KKASSERT((lp->lwp_flags & LWP_OLDMASK) == 0);
}
/*
* after this loop will generate another AST.
*/
while (lp->lwp_proc->p_stat == SSTOP) {
- get_mplock();
+ lwkt_gettoken(&lp->lwp_proc->p_token);
tstop();
- rel_mplock();
+ lwkt_reltoken(&lp->lwp_proc->p_token);
}
/*
if (KTRPOINT(lp->lwp_thread, KTR_SYSRET))
ktrsysret(lp, SYS_fork, 0, 0);
#endif
- lp->lwp_flag |= LWP_PASSIVE_ACQ;
+ lp->lwp_flags |= LWP_PASSIVE_ACQ;
userexit(lp);
- lp->lwp_flag &= ~LWP_PASSIVE_ACQ;
+ lp->lwp_flags &= ~LWP_PASSIVE_ACQ;
}
/*
sf.sf_uc.uc_mcontext.mc_len = sizeof(sf.sf_uc.uc_mcontext);
/* Allocate and validate space for the signal handler context. */
- if ((lp->lwp_flag & LWP_ALTSTACK) != 0 && !oonstack &&
+ if ((lp->lwp_flags & LWP_ALTSTACK) != 0 && !oonstack &&
SIGISMEMBER(psp->ps_sigonstack, sig)) {
sp = (char *)(lp->lwp_sigstk.ss_sp + lp->lwp_sigstk.ss_size -
sizeof(struct sigframe));
if (ocred)
crfree(ocred);
}
+
+ /*
+ * Debugging, remove top two user stack pages to catch kernel faults
+ */
+ if (freeze_on_seg_fault > 1 && curtd->td_lwp) {
+ pmap_remove(vmspace_pmap(curtd->td_lwp->lwp_vmspace),
+ 0x00007FFFFFFFD000LU,
+ 0x0000800000000000LU);
+ }
}
/*
* This may do a copyout and block, so do it first even though it
* means some system time will be charged as user time.
*/
- if (p->p_flag & P_PROFIL) {
+ if (p->p_flags & P_PROFIL) {
addupc_task(p, frame->tf_rip,
(u_int)((int)lp->lwp_thread->td_sticks - sticks));
}
/*
* If the jungle wants us dead, so be it.
*/
- if (lp->lwp_flag & LWP_WEXIT) {
+ if (lp->lwp_mpflags & LWP_MP_WEXIT) {
lwkt_gettoken(&p->p_token);
lwp_exit(0);
lwkt_reltoken(&p->p_token); /* NOT REACHED */
* Block here if we are in a stopped state.
*/
if (p->p_stat == SSTOP || dump_stop_usertds) {
- get_mplock();
+ lwkt_gettoken(&p->p_token);
tstop();
- rel_mplock();
+ lwkt_reltoken(&p->p_token);
goto recheck;
}
* Post any pending upcalls. If running a virtual kernel be sure
* to restore the virtual kernel's vmspace before posting the upcall.
*/
- if (p->p_flag & (P_SIGVTALRM | P_SIGPROF | P_UPCALLPEND)) {
+ if (p->p_flags & (P_SIGVTALRM | P_SIGPROF | P_UPCALLPEND)) {
lwkt_gettoken(&p->p_token);
- if (p->p_flag & P_SIGVTALRM) {
- p->p_flag &= ~P_SIGVTALRM;
+ if (p->p_flags & P_SIGVTALRM) {
+ p->p_flags &= ~P_SIGVTALRM;
ksignal(p, SIGVTALRM);
}
- if (p->p_flag & P_SIGPROF) {
- p->p_flag &= ~P_SIGPROF;
+ if (p->p_flags & P_SIGPROF) {
+ p->p_flags &= ~P_SIGPROF;
ksignal(p, SIGPROF);
}
- if (p->p_flag & P_UPCALLPEND) {
- p->p_flag &= ~P_UPCALLPEND;
+ if (p->p_flags & P_UPCALLPEND) {
+ p->p_flags &= ~P_UPCALLPEND;
postupcall(lp);
}
lwkt_reltoken(&p->p_token);
* (such as SIGKILL). proc0 (the swapin scheduler) is already
* aware of our situation, we do not have to wake it up.
*/
- if (p->p_flag & P_SWAPPEDOUT) {
+ if (p->p_flags & P_SWAPPEDOUT) {
lwkt_gettoken(&p->p_token);
get_mplock();
- p->p_flag |= P_SWAPWAIT;
+ p->p_flags |= P_SWAPWAIT;
swapin_request();
- if (p->p_flag & P_SWAPWAIT)
+ if (p->p_flags & P_SWAPWAIT)
tsleep(p, PCATCH, "SWOUT", 0);
- p->p_flag &= ~P_SWAPWAIT;
+ p->p_flags &= ~P_SWAPWAIT;
rel_mplock();
lwkt_reltoken(&p->p_token);
goto recheck;
* Make sure postsig() handled request to restore old signal mask after
* running signal handler.
*/
- KKASSERT((lp->lwp_flag & LWP_OLDMASK) == 0);
+ KKASSERT((lp->lwp_flags & LWP_OLDMASK) == 0);
}
/*
* after this loop will generate another AST.
*/
while (lp->lwp_proc->p_stat == SSTOP) {
- get_mplock();
+ lwkt_gettoken(&lp->lwp_proc->p_token);
tstop();
- rel_mplock();
+ lwkt_reltoken(&lp->lwp_proc->p_token);
}
/*
goto nogo;
}
+ /*
+ * Debugging, try to catch kernel faults on the user address space when not inside
+ * on onfault (e.g. copyin/copyout) routine.
+ */
+ if (usermode == 0 && (td->td_pcb == NULL || td->td_pcb->pcb_onfault == NULL)) {
+ if (freeze_on_seg_fault) {
+ kprintf("trap_pfault: user address fault from kernel mode "
+ "%016lx\n", (long)frame->tf_addr);
+ while (freeze_on_seg_fault) {
+ tsleep(&freeze_on_seg_fault, 0, "frzseg", hz * 20);
+ }
+ }
+ }
map = &vm->vm_map;
}
if (KTRPOINT(lp->lwp_thread, KTR_SYSRET))
ktrsysret(lp, SYS_fork, 0, 0);
#endif
- lp->lwp_flag |= LWP_PASSIVE_ACQ;
+ lp->lwp_flags |= LWP_PASSIVE_ACQ;
userexit(lp);
- lp->lwp_flag &= ~LWP_PASSIVE_ACQ;
+ lp->lwp_flags &= ~LWP_PASSIVE_ACQ;
}
/*
sf.sf_uc.uc_mcontext.mc_len = sizeof(sf.sf_uc.uc_mcontext);
/* Allocate and validate space for the signal handler context. */
- if ((lp->lwp_flag & LWP_ALTSTACK) != 0 && !oonstack &&
+ if ((lp->lwp_flags & LWP_ALTSTACK) != 0 && !oonstack &&
SIGISMEMBER(psp->ps_sigonstack, sig)) {
sfp = (struct sigframe *)(lp->lwp_sigstk.ss_sp +
lp->lwp_sigstk.ss_size - sizeof(struct sigframe));
* This may do a copyout and block, so do it first even though it
* means some system time will be charged as user time.
*/
- if (p->p_flag & P_PROFIL) {
+ if (p->p_flags & P_PROFIL) {
addupc_task(p, frame->tf_eip,
(u_int)((int)lp->lwp_thread->td_sticks - sticks));
}
/*
* If the jungle wants us dead, so be it.
*/
- if (lp->lwp_flag & LWP_WEXIT) {
+ if (lp->lwp_mpflags & LWP_MP_WEXIT) {
lwkt_gettoken(&p->p_token);
lwp_exit(0);
lwkt_reltoken(&p->p_token); /* NOT REACHED */
* Block here if we are in a stopped state.
*/
if (p->p_stat == SSTOP) {
- get_mplock();
+ lwkt_gettoken(&p->p_token);
tstop();
- rel_mplock();
+ lwkt_reltoken(&p->p_token);
goto recheck;
}
* Post any pending upcalls. If running a virtual kernel be sure
* to restore the virtual kernel's vmspace before posting the upcall.
*/
- if (p->p_flag & (P_SIGVTALRM | P_SIGPROF | P_UPCALLPEND)) {
+ if (p->p_flags & (P_SIGVTALRM | P_SIGPROF | P_UPCALLPEND)) {
lwkt_gettoken(&p->p_token);
- if (p->p_flag & P_SIGVTALRM) {
- p->p_flag &= ~P_SIGVTALRM;
+ if (p->p_flags & P_SIGVTALRM) {
+ p->p_flags &= ~P_SIGVTALRM;
ksignal(p, SIGVTALRM);
}
- if (p->p_flag & P_SIGPROF) {
- p->p_flag &= ~P_SIGPROF;
+ if (p->p_flags & P_SIGPROF) {
+ p->p_flags &= ~P_SIGPROF;
ksignal(p, SIGPROF);
}
- if (p->p_flag & P_UPCALLPEND) {
- p->p_flag &= ~P_UPCALLPEND;
+ if (p->p_flags & P_UPCALLPEND) {
+ p->p_flags &= ~P_UPCALLPEND;
postupcall(lp);
}
lwkt_reltoken(&p->p_token);
* (such as SIGKILL). proc0 (the swapin scheduler) is already
* aware of our situation, we do not have to wake it up.
*/
- if (p->p_flag & P_SWAPPEDOUT) {
+ if (p->p_flags & P_SWAPPEDOUT) {
lwkt_gettoken(&p->p_token);
get_mplock();
- p->p_flag |= P_SWAPWAIT;
+ p->p_flags |= P_SWAPWAIT;
swapin_request();
- if (p->p_flag & P_SWAPWAIT)
+ if (p->p_flags & P_SWAPWAIT)
tsleep(p, PCATCH, "SWOUT", 0);
- p->p_flag &= ~P_SWAPWAIT;
+ p->p_flags &= ~P_SWAPWAIT;
rel_mplock();
lwkt_reltoken(&p->p_token);
goto recheck;
* Make sure postsig() handled request to restore old signal mask after
* running signal handler.
*/
- KKASSERT((lp->lwp_flag & LWP_OLDMASK) == 0);
+ KKASSERT((lp->lwp_flags & LWP_OLDMASK) == 0);
}
/*
* after this loop will generate another AST.
*/
while (lp->lwp_proc->p_stat == SSTOP) {
- get_mplock();
+ lwkt_gettoken(&lp->lwp_proc->p_token);
tstop();
- rel_mplock();
+ lwkt_reltoken(&lp->lwp_proc->p_token);
}
/*
if (KTRPOINT(lp->lwp_thread, KTR_SYSRET))
ktrsysret(lp, SYS_fork, 0, 0);
#endif
- lp->lwp_flag |= LWP_PASSIVE_ACQ;
+ lp->lwp_flags |= LWP_PASSIVE_ACQ;
userexit(lp);
- lp->lwp_flag &= ~LWP_PASSIVE_ACQ;
+ lp->lwp_flags &= ~LWP_PASSIVE_ACQ;
}
/*
sf.sf_uc.uc_mcontext.mc_len = sizeof(sf.sf_uc.uc_mcontext);
/* Allocate and validate space for the signal handler context. */
- if ((lp->lwp_flag & LWP_ALTSTACK) != 0 && !oonstack &&
+ if ((lp->lwp_flags & LWP_ALTSTACK) != 0 && !oonstack &&
SIGISMEMBER(psp->ps_sigonstack, sig)) {
sp = (char *)(lp->lwp_sigstk.ss_sp + lp->lwp_sigstk.ss_size -
sizeof(struct sigframe));
* This may do a copyout and block, so do it first even though it
* means some system time will be charged as user time.
*/
- if (p->p_flag & P_PROFIL) {
+ if (p->p_flags & P_PROFIL) {
addupc_task(p, frame->tf_rip,
(u_int)((int)lp->lwp_thread->td_sticks - sticks));
}
/*
* If the jungle wants us dead, so be it.
*/
- if (lp->lwp_flag & LWP_WEXIT) {
+ if (lp->lwp_mpflags & LWP_MP_WEXIT) {
lwkt_gettoken(&p->p_token);
lwp_exit(0);
lwkt_reltoken(&p->p_token); /* NOT REACHED */
* Block here if we are in a stopped state.
*/
if (p->p_stat == SSTOP) {
- get_mplock();
+ lwkt_gettoken(&p->p_token);
tstop();
- rel_mplock();
+ lwkt_reltoken(&p->p_token);
goto recheck;
}
* Post any pending upcalls. If running a virtual kernel be sure
* to restore the virtual kernel's vmspace before posting the upcall.
*/
- if (p->p_flag & (P_SIGVTALRM | P_SIGPROF | P_UPCALLPEND)) {
+ if (p->p_flags & (P_SIGVTALRM | P_SIGPROF | P_UPCALLPEND)) {
lwkt_gettoken(&p->p_token);
- if (p->p_flag & P_SIGVTALRM) {
- p->p_flag &= ~P_SIGVTALRM;
+ if (p->p_flags & P_SIGVTALRM) {
+ p->p_flags &= ~P_SIGVTALRM;
ksignal(p, SIGVTALRM);
}
- if (p->p_flag & P_SIGPROF) {
- p->p_flag &= ~P_SIGPROF;
+ if (p->p_flags & P_SIGPROF) {
+ p->p_flags &= ~P_SIGPROF;
ksignal(p, SIGPROF);
}
- if (p->p_flag & P_UPCALLPEND) {
- p->p_flag &= ~P_UPCALLPEND;
+ if (p->p_flags & P_UPCALLPEND) {
+ p->p_flags &= ~P_UPCALLPEND;
postupcall(lp);
}
lwkt_reltoken(&p->p_token);
* (such as SIGKILL). proc0 (the swapin scheduler) is already
* aware of our situation, we do not have to wake it up.
*/
- if (p->p_flag & P_SWAPPEDOUT) {
+ if (p->p_flags & P_SWAPPEDOUT) {
lwkt_gettoken(&p->p_token);
get_mplock();
- p->p_flag |= P_SWAPWAIT;
+ p->p_flags |= P_SWAPWAIT;
swapin_request();
- if (p->p_flag & P_SWAPWAIT)
+ if (p->p_flags & P_SWAPWAIT)
tsleep(p, PCATCH, "SWOUT", 0);
- p->p_flag &= ~P_SWAPWAIT;
+ p->p_flags &= ~P_SWAPWAIT;
rel_mplock();
lwkt_reltoken(&p->p_token);
goto recheck;
* Make sure postsig() handled request to restore old signal mask after
* running signal handler.
*/
- KKASSERT((lp->lwp_flag & LWP_OLDMASK) == 0);
+ KKASSERT((lp->lwp_flags & LWP_OLDMASK) == 0);
}
/*
* after this loop will generate another AST.
*/
while (lp->lwp_proc->p_stat == SSTOP) {
- get_mplock();
+ lwkt_gettoken(&lp->lwp_proc->p_token);
tstop();
- rel_mplock();
+ lwkt_reltoken(&lp->lwp_proc->p_token);
}
/*
if (KTRPOINT(lp->lwp_thread, KTR_SYSRET))
ktrsysret(lp, SYS_fork, 0, 0);
#endif
- lp->lwp_flag |= LWP_PASSIVE_ACQ;
+ lp->lwp_flags |= LWP_PASSIVE_ACQ;
userexit(lp);
- lp->lwp_flag &= ~LWP_PASSIVE_ACQ;
+ lp->lwp_flags &= ~LWP_PASSIVE_ACQ;
}
/*
struct vmspace *lwp_vmspace; /* Inherited from p_vmspace */
struct vkernel_lwp *lwp_vkernel;/* VKernel support, lwp part */
- lwpid_t lwp_tid; /* Our thread id . */
+ lwpid_t lwp_tid; /* Our thread id */
- int lwp_flag; /* LWP_* flags. */
- enum lwpstat lwp_stat; /* LS* lwp status. */
+ u_int lwp_flags; /* LWP_* flags */
+ u_int lwp_mpflags; /* LWP_MP_* flags */
+ enum lwpstat lwp_stat; /* LS* lwp status */
int lwp_lock; /* lwp lock (prevent destruct) count */
- int lwp_dupfd; /* Sideways return value from fdopen. XXX */
+ int lwp_dupfd; /* Sideways return value from fdopen */
/*
* The following two fields are marked XXX since (at least) the
#define p_sigcatch p_sigacts->ps_sigcatch
#define p_rlimit p_limit->pl_rlimit
- int p_flag; /* P_* flags. */
+ int p_flags; /* P_* flags. */
enum procstat p_stat; /* S* process status. */
char p_pad1[3];
#define p_pgid p_pgrp->pg_id
/* These flags are kept in p_flags. */
-#define P_ADVLOCK 0x00001 /* Process may hold a POSIX advisory lock. */
-#define P_CONTROLT 0x00002 /* Has a controlling terminal. */
+#define P_ADVLOCK 0x00001 /* Process may hold a POSIX advisory lock */
+#define P_CONTROLT 0x00002 /* Has a controlling terminal */
#define P_SWAPPEDOUT 0x00004 /* Swapped out of memory */
-#define P_UNUSED3 0x00008 /* was: Event pending, break tsleep on sigcont */
-#define P_PPWAIT 0x00010 /* Parent is waiting for child to exec/exit. */
-#define P_PROFIL 0x00020 /* Has started profiling. */
-#define P_UNUSED5 0x00040 /* was: Selecting; wakeup/waiting danger. */
-#define P_UNUSED4 0x00080 /* was: Sleep is interruptible. */
-#define P_SUGID 0x00100 /* Had set id privileges since last exec. */
-#define P_SYSTEM 0x00200 /* System proc: no sigs, stats or swapping. */
+#define P_UNUSED3 0x00008
+#define P_PPWAIT 0x00010 /* Parent is waiting for child to exec/exit */
+#define P_PROFIL 0x00020 /* Has started profiling */
+#define P_UNUSED5 0x00040 /* was: Selecting; wakeup/waiting danger */
+#define P_UNUSED4 0x00080 /* was: Sleep is interruptible */
+#define P_SUGID 0x00100 /* Had set id privileges since last exec */
+#define P_SYSTEM 0x00200 /* System proc: no sigs, stats or swapping */
#define P_UNUSED2 0x00400 /* was: SIGSTOP status */
-#define P_TRACED 0x00800 /* Debugged process being traced. */
+#define P_TRACED 0x00800 /* Debugged process being traced */
#define P_WAITED 0x01000 /* SIGSTOP status was returned by wait3/4 */
#define P_WEXIT 0x02000 /* Working on exiting (master exit) */
-#define P_EXEC 0x04000 /* Process called exec. */
-#define P_CONTINUED 0x08000 /* Proc has continued from a stopped state. */
+#define P_EXEC 0x04000 /* Process called exec */
+#define P_CONTINUED 0x08000 /* Proc has continued from a stopped state */
-/* Should probably be changed into a hold count. */
-/* was P_NOSWAP 0x08000 was: Do not swap upages; p->p_hold */
-#define P_UNUSED7 0x10000
+#define P_UNUSED16 0x00010000
+#define P_UPCALLPEND 0x00020000 /* an upcall is pending */
-#define P_UPCALLPEND 0x20000 /* an upcall is pending */
-
-#define P_SWAPWAIT 0x40000 /* Waiting for a swapin */
-#define P_UNUSED6 0x80000 /* was: Now in a zombied state */
+#define P_SWAPWAIT 0x00040000 /* Waiting for a swapin */
+#define P_UNUSED19 0x00080000 /* was: Now in a zombied state */
/* Marked a kernel thread */
-#define P_UNUSED07 0x100000 /* was: on a user scheduling run queue */
-#define P_KTHREADP 0x200000 /* Process is really a kernel thread */
-#define P_IDLESWAP 0x400000 /* Swapout was due to idleswap, not load */
-
-#define P_JAILED 0x1000000 /* Process is in jail */
-#define P_SIGVTALRM 0x2000000 /* signal SIGVTALRM pending due to itimer */
-#define P_SIGPROF 0x4000000 /* signal SIGPROF pending due to itimer */
-#define P_INEXEC 0x8000000 /* Process is in execve(). */
-#define P_UNUSED1000 0x10000000
+#define P_UNUSED20 0x00100000 /* was: on a user scheduling run queue */
+#define P_KTHREADP 0x00200000 /* Process is really a kernel thread */
+#define P_IDLESWAP 0x00400000 /* Swapout was due to idleswap, not load */
+
+#define P_JAILED 0x01000000 /* Process is in jail */
+#define P_SIGVTALRM 0x02000000 /* signal SIGVTALRM pending due to itimer */
+#define P_SIGPROF 0x04000000 /* signal SIGPROF pending due to itimer */
+#define P_INEXEC 0x08000000 /* Process is in execve(). */
+#define P_UNUSED28 0x10000000
#define P_UPCALLWAIT 0x20000000 /* Wait for upcall or signal */
#define P_XCPU 0x40000000 /* SIGXCPU */
+#define LWP_ALTSTACK 0x0000001 /* have alternate signal stack */
+#define LWP_OLDMASK 0x0000002 /* need to restore mask before pause */
+#define LWP_SINTR 0x0000008 /* Sleep is interruptible. */
+#define LWP_SELECT 0x0000010 /* Selecting; wakeup/waiting danger. */
+#define LWP_UNUSED20 0x0000020
+#define LWP_UNUSED40 0x0000040
+#define LWP_UNUSED80 0x0000080
+#define LWP_PASSIVE_ACQ 0x0000100 /* Passive acquire cpu (see kern_switch) */
+#define LWP_PAGING 0x0000200 /* Currently in vm_fault */
+
/*
- * LWP_WSTOP: When set the thread will stop prior to return to userland
+ * LWP_MP_WSTOP: When set the thread will stop prior to return to userland
* and has been counted in the process stop-threads-count, but
* may still be running in kernel-land.
*
- * LWP_WEXIT: When set the thread has been asked to exit and will not return
+ * LWP_MP_WEXIT: When set the thread has been asked to exit and will not return
* to userland. p_nthreads will not be decremented until the
* thread has actually exited.
*/
-#define LWP_ALTSTACK 0x0000001 /* have alternate signal stack */
-#define LWP_OLDMASK 0x0000002 /* need to restore mask before pause */
-#define LWP_BREAKTSLEEP 0x0000004 /* Event pending, break tsleep on sigcont */
-#define LWP_SINTR 0x0000008 /* Sleep is interruptible. */
-#define LWP_SELECT 0x0000010 /* Selecting; wakeup/waiting danger. */
-#define LWP_ONRUNQ 0x0000020 /* on a user scheduling run queue */
-#define LWP_WEXIT 0x0000040 /* working on exiting */
-#define LWP_WSTOP 0x0000080 /* working on stopping */
-#define LWP_PASSIVE_ACQ 0x0000100 /* Passive acquire cpu (see kern_switch) */
-#define LWP_PAGING 0x0000200 /* Currently in vm_fault */
+#define LWP_MP_ONRUNQ 0x0000001 /* on a user scheduling run queue */
+#define LWP_MP_WEXIT 0x0000002 /* working on exiting */
+#define LWP_MP_WSTOP 0x0000004 /* working on stopping */
#define FIRST_LWP_IN_PROC(p) RB_FIRST(lwp_rb_tree, &(p)->p_lwp_tree)
#define FOREACH_LWP_IN_PROC(lp, p) \
* a) we may block and
* b) somebody is tracing us.
*/
- if (!(mayblock && (p->p_flag & P_TRACED)))
+ if (!(mayblock && (p->p_flags & P_TRACED)))
return (0);
}
const volatile void *td_wchan; /* waiting on channel */
int td_pri; /* 0-31, 31=highest priority (note 1) */
int td_critcount; /* critical section priority */
- int td_flags; /* TDF flags */
+ u_int td_flags; /* TDF flags */
int td_wdomain; /* domain for wchan address (typ 0) */
void (*td_preemptable)(struct thread *td, int critcount);
void (*td_release)(struct thread *td);
int td_refs; /* hold position in gd_tdallq / hold free */
int td_nest_count; /* prevent splz nesting */
int td_contended; /* token contention count */
- int td_unused01[1]; /* for future fields */
+ u_int td_mpflags; /* flags can be set by foreign cpus */
#ifdef SMP
int td_cscount; /* cpu synchronization master */
#else
* does not allow a thread to be scheduled if it already resides on some
* queue.
*/
-#define TDF_RUNNING 0x0001 /* thread still active */
-#define TDF_RUNQ 0x0002 /* on an LWKT run queue */
-#define TDF_PREEMPT_LOCK 0x0004 /* I have been preempted */
-#define TDF_PREEMPT_DONE 0x0008 /* acknowledge preemption complete */
-#define TDF_UNUSED00000010 0x0010
-#define TDF_MIGRATING 0x0020 /* thread is being migrated */
-#define TDF_SINTR 0x0040 /* interruptability hint for 'ps' */
-#define TDF_TSLEEPQ 0x0080 /* on a tsleep wait queue */
-
-#define TDF_SYSTHREAD 0x0100 /* allocations may use reserve */
-#define TDF_ALLOCATED_THREAD 0x0200 /* objcache allocated thread */
-#define TDF_ALLOCATED_STACK 0x0400 /* objcache allocated stack */
-#define TDF_VERBOSE 0x0800 /* verbose on exit */
-#define TDF_DEADLKTREAT 0x1000 /* special lockmgr deadlock treatment */
-#define TDF_STOPREQ 0x2000 /* suspend_kproc */
-#define TDF_WAKEREQ 0x4000 /* resume_kproc */
-#define TDF_TIMEOUT 0x8000 /* tsleep timeout */
+#define TDF_RUNNING 0x00000001 /* thread still active */
+#define TDF_RUNQ 0x00000002 /* on an LWKT run queue */
+#define TDF_PREEMPT_LOCK 0x00000004 /* I have been preempted */
+#define TDF_PREEMPT_DONE 0x00000008 /* ac preemption complete */
+#define TDF_NOSTART 0x00000010 /* do not schedule on create */
+#define TDF_MIGRATING 0x00000020 /* thread is being migrated */
+#define TDF_SINTR 0x00000040 /* interruptability for 'ps' */
+#define TDF_TSLEEPQ 0x00000080 /* on a tsleep wait queue */
+
+#define TDF_SYSTHREAD 0x00000100 /* reserve memory may be used */
+#define TDF_ALLOCATED_THREAD 0x00000200 /* objcache allocated thread */
+#define TDF_ALLOCATED_STACK 0x00000400 /* objcache allocated stack */
+#define TDF_VERBOSE 0x00000800 /* verbose on exit */
+#define TDF_DEADLKTREAT 0x00001000 /* special lockmgr treatment */
+#define TDF_UNUSED2000 0x00002000
+#define TDF_TIMEOUT_RUNNING 0x00004000 /* tsleep timeout race */
+#define TDF_TIMEOUT 0x00008000 /* tsleep timeout */
#define TDF_INTTHREAD 0x00010000 /* interrupt thread */
#define TDF_TSLEEP_DESCHEDULED 0x00020000 /* tsleep core deschedule */
#define TDF_BLOCKED 0x00040000 /* Thread is blocked */
#define TDF_UNUSED02000000 0x02000000
#define TDF_CRYPTO 0x04000000 /* crypto thread */
+#define TDF_MP_STOPREQ 0x00000001 /* suspend_kproc */
+#define TDF_MP_WAKEREQ 0x00000002 /* resume_kproc */
+
/*
* Thread priorities. Typically only one thread from any given
* user process scheduling queue is on the LWKT run queue at a time.
/* Is tp controlling terminal for p? */
#define isctty(p, tp) \
- ((p)->p_session == (tp)->t_session && (p)->p_flag & P_CONTROLT)
+ ((p)->p_session == (tp)->t_session && ((p)->p_flags & P_CONTROLT))
/* Is p in background of tp? */
#define isbackground(p, tp) \
((((p1)->p_ucred->cr_uid == (p2)->p_ucred->cr_ruid) && \
((p1)->p_ucred->cr_ruid == (p2)->p_ucred->cr_ruid) && \
((p1)->p_ucred->cr_svuid == (p2)->p_ucred->cr_ruid) && \
- ((p2)->p_flag & (P_SUGID|P_INEXEC)) == 0) || \
+ ((p2)->p_flags & (P_SUGID|P_INEXEC)) == 0) || \
(priv_check_cred((p1)->p_ucred, PRIV_DEBUG_UNPRIV, 0) == 0))
/*
#define TRACE_WAIT_P(curp, p) \
(((p)->p_stat == SSTOP) && \
(p)->p_pptr == (curp) && \
- ((p)->p_flag & P_TRACED))
+ ((p)->p_flags & P_TRACED))
#define PROCFS_CTL_ATTACH 1
#define PROCFS_CTL_DETACH 2
ASSERT_LWKT_TOKEN_HELD(&proc_token);
/* Can't trace a process that's currently exec'ing. */
- if ((p->p_flag & P_INEXEC) != 0)
+ if ((p->p_flags & P_INEXEC) != 0)
return EAGAIN;
/*
* Authorization check: rely on normal debugging protection, except
*/
if (op == PROCFS_CTL_ATTACH) {
/* check whether already being traced */
- if (p->p_flag & P_TRACED)
+ if (p->p_flags & P_TRACED)
return (EBUSY);
/* can't trace yourself! */
* proc gets to see all the action.
* Stop the target.
*/
- p->p_flag |= P_TRACED;
+ p->p_flags |= P_TRACED;
faultin(p);
p->p_xstat = 0; /* XXX ? */
if (p->p_pptr != curp) {
*/
case PROCFS_CTL_DETACH:
/* if not being traced, then this is a painless no-op */
- if ((p->p_flag & P_TRACED) == 0)
+ if ((p->p_flags & P_TRACED) == 0)
return (0);
/* not being traced any more */
- p->p_flag &= ~P_TRACED;
+ p->p_flags &= ~P_TRACED;
/* remove pending SIGTRAP, else the process will die */
spin_lock(&lp->lwp_spin);
}
p->p_oppid = 0;
- p->p_flag &= ~P_WAITED; /* XXX ? */
- wakeup((caddr_t) curp); /* XXX for CTL_WAIT below ? */
+ p->p_flags &= ~P_WAITED; /* XXX ? */
+ wakeup((caddr_t) curp); /* XXX for CTL_WAIT below ? */
break;
*/
case PROCFS_CTL_WAIT:
error = 0;
- if (p->p_flag & P_TRACED) {
+ if (p->p_flags & P_TRACED) {
while (error == 0 &&
p->p_stat != SSTOP &&
- (p->p_flag & P_TRACED) &&
+ (p->p_flags & P_TRACED) &&
(p->p_pptr == curp)) {
error = tsleep((caddr_t) p,
PCATCH, "procfsx", 0);
/*
* If the process is in a stopped state, make it runnable again.
- * Do not set LWP_BREAKTSLEEP - that is, do not break a tsleep that
- * might be in progress.
+ * Do not set LWP_MP_BREAKTSLEEP - that is, do not break a tsleep
+ * that might be in progress.
*/
if (p->p_stat == SSTOP)
proc_unstop(p);
int kl;
/* Can't trace a process that's currently exec'ing. */
- if ((p->p_flag & P_INEXEC) != 0)
+ if ((p->p_flags & P_INEXEC) != 0)
return EAGAIN;
if (!CHECKIO(curp, p) || p_trespass(curp->p_ucred, p->p_ucred))
return (EPERM);
int
procfs_validdbregs(struct lwp *lp)
{
- return ((lp->lwp_proc->p_flag & P_SYSTEM) == 0);
+ return ((lp->lwp_proc->p_flags & P_SYSTEM) == 0);
}
int kl;
/* Can't trace a process that's currently exec'ing. */
- if ((p->p_flag & P_INEXEC) != 0)
+ if ((p->p_flags & P_INEXEC) != 0)
return EAGAIN;
if (!CHECKIO(curp, p) || p_trespass(curp->p_ucred, p->p_ucred))
return EPERM;
int
procfs_validfpregs(struct lwp *lp)
{
- return ((lp->lwp_proc->p_flag & P_SYSTEM) == 0);
+ return ((lp->lwp_proc->p_flags & P_SYSTEM) == 0);
}
int
procfs_validmap(struct lwp *lp)
{
- return ((lp->lwp_proc->p_flag & P_SYSTEM) == 0);
+ return ((lp->lwp_proc->p_flags & P_SYSTEM) == 0);
}
* page table usage in that process may be messed up.
*/
vm = p->p_vmspace;
- if ((p->p_flag & P_WEXIT) || sysref_isinactive(&vm->vm_sysref)) {
+ if ((p->p_flags & P_WEXIT) || sysref_isinactive(&vm->vm_sysref)) {
return EFAULT;
}
return (0);
lwkt_gettoken(&p->p_token);
- if ((p->p_flag & P_INEXEC) != 0) {
+ if ((p->p_flags & P_INEXEC) != 0) {
/*
* Can't trace a process that's currently exec'ing.
*/
int kl;
/* Can't trace a process that's currently exec'ing. */
- if ((p->p_flag & P_INEXEC) != 0)
+ if ((p->p_flags & P_INEXEC) != 0)
return EAGAIN;
if (!CHECKIO(curp, p) || p_trespass(curp->p_ucred, p->p_ucred))
return EPERM;
int
procfs_validregs(struct lwp *lp)
{
- return ((lp->lwp_proc->p_flag & P_SYSTEM) == 0);
+ return ((lp->lwp_proc->p_flags & P_SYSTEM) == 0);
}
ps += ksnprintf(ps, psbuf + sizeof(psbuf) - ps,
" %d %d %d %d ", pid, ppid, pgid, sid);
DOCHECK();
- if ((p->p_flag&P_CONTROLT) && (tp = sess->s_ttyp))
+ if ((p->p_flags & P_CONTROLT) && (tp = sess->s_ttyp))
ps += ksnprintf(ps, psbuf + sizeof(psbuf) - ps,
"%d,%d ", major(tp->t_dev), minor(tp->t_dev));
else
DOCHECK();
}
- if (p->p_flag & P_SWAPPEDOUT) {
+ if (p->p_flags & P_SWAPPEDOUT) {
ps += ksnprintf(ps, psbuf + sizeof(psbuf) - ps,
" -1,-1 -1,-1 -1,-1");
} else {
if (p->p_args &&
(ps_argsopen || (CHECKIO(curp, p) &&
- (p->p_flag & P_INEXEC) == 0 && !p_trespass(curp->p_ucred, p->p_ucred)))
+ (p->p_flags & P_INEXEC) == 0 &&
+ !p_trespass(curp->p_ucred, p->p_ucred)))
) {
bp = p->p_args->ar_args;
buflen = p->p_args->ar_length;
int
procfs_validtype(struct lwp *lp)
{
- return ((lp->lwp_proc->p_flag & P_SYSTEM) == 0);
+ return ((lp->lwp_proc->p_flags & P_SYSTEM) == 0);
}
p1 = curproc;
KKASSERT(p1);
/* Can't trace a process that's currently exec'ing. */
- if ((p2->p_flag & P_INEXEC) != 0) {
+ if ((p2->p_flags & P_INEXEC) != 0) {
error = EAGAIN;
goto done;
}
}
/* Can't trace a process that's currently exec'ing. */
- if ((procp->p_flag & P_INEXEC) != 0) {
+ if ((procp->p_flags & P_INEXEC) != 0) {
error = EAGAIN;
goto done;
}
case Pfpregs:
case Pdbregs:
case Pmem:
- if (procp->p_flag & P_SUGID)
+ if (procp->p_flags & P_SUGID)
vap->va_mode &= ~((VREAD|VWRITE)|
((VREAD|VWRITE)>>3)|
((VREAD|VWRITE)>>6));
* change the owner to root - otherwise 'ps' and friends
* will break even though they are setgid kmem. *SIGH*
*/
- if (procp->p_flag & P_SUGID)
+ if (procp->p_flags & P_SUGID)
vap->va_uid = 0;
else
vap->va_uid = procp->p_ucred->cr_uid;
static int debug_cluster = 0;
SYSCTL_INT(_vm, OID_AUTO, debug_cluster, CTLFLAG_RW, &debug_cluster, 0, "");
-static int vm_shared_fault = 1;
+static int vm_shared_fault = 0;
SYSCTL_INT(_vm, OID_AUTO, shared_fault, CTLFLAG_RW, &vm_shared_fault, 0,
"Allow shared token on vm_object");
static long vm_shared_hit = 0;
growstack = 1;
if ((lp = curthread->td_lwp) != NULL)
- lp->lwp_flag |= LWP_PAGING;
+ lp->lwp_flags |= LWP_PAGING;
lwkt_gettoken(&map->token);
* short-cut a quick mapping.
*
* WARNING! We cannot call swap_pager_unswapped()
- * with a shared token!
+ * with a shared token! Note that we
+ * have to test fs.first_prot here.
*/
vm_page_activate(fs.m);
if (fs.m->valid == VM_PAGE_BITS_ALL &&
((fs.m->flags & PG_SWAPPED) == 0 ||
- (fs.prot & VM_PROT_WRITE) == 0 ||
+ (fs.first_prot & VM_PROT_WRITE) == 0 ||
(fs.fault_flags & VM_FAULT_DIRTY) == 0)) {
fs.lookup_still_valid = TRUE;
fs.first_m = NULL;
vm_object_drop(fs.first_object);
lwkt_reltoken(&map->token);
if (lp)
- lp->lwp_flag &= ~LWP_PAGING;
+ lp->lwp_flags &= ~LWP_PAGING;
return (result);
}
void
faultin(struct proc *p)
{
- if (p->p_flag & P_SWAPPEDOUT) {
+ if (p->p_flags & P_SWAPPEDOUT) {
/*
* The process is waiting in the kernel to return to user
* mode but cannot until P_SWAPPEDOUT gets cleared.
*/
lwkt_gettoken(&p->p_token);
- p->p_flag &= ~(P_SWAPPEDOUT | P_SWAPWAIT);
+ p->p_flags &= ~(P_SWAPPEDOUT | P_SWAPWAIT);
#ifdef INVARIANTS
if (swap_debug)
kprintf("swapping in %d (%s)\n", p->p_pid, p->p_comm);
segsz_t pgs;
int pri;
- if (p->p_flag & P_SWAPWAIT) {
+ if (p->p_flags & P_SWAPWAIT) {
pri = 0;
FOREACH_LWP_IN_PROC(lp, p) {
/* XXX lwp might need a different metric */
#define swappable(p) \
(((p)->p_lock == 0) && \
- ((p)->p_flag & (P_TRACED|P_SYSTEM|P_SWAPPEDOUT|P_WEXIT)) == 0)
+ ((p)->p_flags & (P_TRACED|P_SYSTEM|P_SWAPPEDOUT|P_WEXIT)) == 0)
/*
* remember the process resident count
*/
p->p_vmspace->vm_swrss = vmspace_resident_count(p->p_vmspace);
- p->p_flag |= P_SWAPPEDOUT;
+ p->p_flags |= P_SWAPPEDOUT;
p->p_swtime = 0;
}
struct vmtotal *totalp = data;
struct lwp *lp;
- if (p->p_flag & P_SYSTEM)
+ if (p->p_flags & P_SYSTEM)
return(0);
FOREACH_LWP_IN_PROC(lp, p) {
switch (lp->lwp_stat) {
case LSSTOP:
case LSSLEEP:
- if ((p->p_flag & P_SWAPPEDOUT) == 0) {
- if ((lp->lwp_flag & LWP_SINTR) == 0)
+ if ((p->p_flags & P_SWAPPEDOUT) == 0) {
+ if ((lp->lwp_flags & LWP_SINTR) == 0)
totalp->t_dw++;
else if (lp->lwp_slptime < maxslp)
totalp->t_sl++;
break;
case LSRUN:
- if (p->p_flag & P_SWAPPEDOUT)
+ if (p->p_flags & P_SWAPPEDOUT)
totalp->t_sw++;
else
totalp->t_rq++;
/*
* Set while in vm_fault()
*/
- if (lp->lwp_flag & LWP_PAGING)
+ if (lp->lwp_flags & LWP_PAGING)
totalp->t_pw++;
}
return(0);
* Never kill system processes or init. If we have configured swap
* then try to avoid killing low-numbered pids.
*/
- if ((p->p_flag & P_SYSTEM) || (p->p_pid == 1) ||
+ if ((p->p_flags & P_SYSTEM) || (p->p_pid == 1) ||
((p->p_pid < 48) && (vm_swap_size != 0))) {
return (0);
}
* if this is a system process or if we have already
* looked at this process, skip it.
*/
- if (p->p_flag & (P_SYSTEM | P_WEXIT))
+ if (p->p_flags & (P_SYSTEM | P_WEXIT))
return (0);
/*
* swapped out. Set the limit to nothing to get as
* many pages out to swap as possible.
*/
- if (p->p_flag & P_SWAPPEDOUT)
+ if (p->p_flags & P_SWAPPEDOUT)
limit = 0;
lwkt_gettoken(&p->p_vmspace->vm_map.token);