-/* $OpenBSD: kvm_proc2.c,v 1.32 2020/12/07 16:55:28 mpi Exp $ */
+/* $OpenBSD: kvm_proc2.c,v 1.33 2021/02/08 10:51:01 mpi Exp $ */
/* $NetBSD: kvm_proc.c,v 1.30 1999/03/24 05:50:50 mrg Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
kp.p_pctcpu = 0;
kp.p_stat = (process.ps_flags & PS_ZOMBIE) ? SDEAD :
SIDL;
- for (p = SMR_TAILQ_FIRST_LOCKED(&process.ps_threads);
- p != NULL;
- p = SMR_TAILQ_NEXT_LOCKED(&proc, p_thr_link)) {
+ for (p = TAILQ_FIRST(&process.ps_threads); p != NULL;
+ p = TAILQ_NEXT(&proc, p_thr_link)) {
if (KREAD(kd, (u_long)p, &proc)) {
_kvm_err(kd, kd->program,
"can't read proc at %lx",
if (!dothreads)
continue;
- for (p = SMR_TAILQ_FIRST_LOCKED(&process.ps_threads); p != NULL;
- p = SMR_TAILQ_NEXT_LOCKED(&proc, p_thr_link)) {
+ for (p = TAILQ_FIRST(&process.ps_threads); p != NULL;
+ p = TAILQ_NEXT(&proc, p_thr_link)) {
if (KREAD(kd, (u_long)p, &proc)) {
_kvm_err(kd, kd->program,
"can't read proc at %lx",
-/* $OpenBSD: exec_elf.c,v 1.157 2021/01/17 15:28:21 mvs Exp $ */
+/* $OpenBSD: exec_elf.c,v 1.158 2021/02/08 10:51:01 mpi Exp $ */
/*
* Copyright (c) 1996 Per Fogelstrom
#include <sys/signalvar.h>
#include <sys/stat.h>
#include <sys/pledge.h>
-#include <sys/smr.h>
#include <sys/mman.h>
* threads in the process have been stopped and the list can't
* change.
*/
- SMR_TAILQ_FOREACH_LOCKED(q, &pr->ps_threads, p_thr_link) {
+ TAILQ_FOREACH(q, &pr->ps_threads, p_thr_link) {
if (q == p) /* we've taken care of this thread */
continue;
error = coredump_note_elf(q, iocookie, ¬esize);
-/* $OpenBSD: init_main.c,v 1.305 2021/01/11 18:49:38 mpi Exp $ */
+/* $OpenBSD: init_main.c,v 1.306 2021/02/08 10:51:01 mpi Exp $ */
/* $NetBSD: init_main.c,v 1.84.4.1 1996/06/02 09:08:06 mrg Exp $ */
/*
*/
LIST_FOREACH(pr, &allprocess, ps_list) {
nanouptime(&pr->ps_start);
- SMR_TAILQ_FOREACH_LOCKED(p, &pr->ps_threads, p_thr_link) {
+ TAILQ_FOREACH(p, &pr->ps_threads, p_thr_link) {
nanouptime(&p->p_cpu->ci_schedstate.spc_runtime);
timespecclear(&p->p_rtime);
}
-/* $OpenBSD: kern_exit.c,v 1.194 2021/01/17 15:28:21 mvs Exp $ */
+/* $OpenBSD: kern_exit.c,v 1.195 2021/02/08 10:51:01 mpi Exp $ */
/* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */
/*
#ifdef SYSVSEM
#include <sys/sem.h>
#endif
-#include <sys/smr.h>
#include <sys/witness.h>
#include <sys/mount.h>
}
/* unlink ourselves from the active threads */
- SMR_TAILQ_REMOVE_LOCKED(&pr->ps_threads, p, p_thr_link);
+ TAILQ_REMOVE(&pr->ps_threads, p, p_thr_link);
if ((p->p_flag & P_THREAD) == 0) {
/* main thread gotta wait because it has the pid, et al */
while (pr->ps_refcnt > 1)
if (pr->ps_ptstat != NULL)
free(pr->ps_ptstat, M_SUBPROC, sizeof(*pr->ps_ptstat));
pool_put(&rusage_pool, pr->ps_ru);
- KASSERT(SMR_TAILQ_EMPTY_LOCKED(&pr->ps_threads));
+ KASSERT(TAILQ_EMPTY(&pr->ps_threads));
lim_free(pr->ps_limit);
crfree(pr->ps_ucred);
pool_put(&process_pool, pr);
-/* $OpenBSD: kern_fork.c,v 1.231 2021/01/17 15:28:21 mvs Exp $ */
+/* $OpenBSD: kern_fork.c,v 1.232 2021/02/08 10:51:01 mpi Exp $ */
/* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */
/*
#include <sys/acct.h>
#include <sys/ktrace.h>
#include <sys/sched.h>
-#include <sys/smr.h>
#include <sys/sysctl.h>
#include <sys/pool.h>
#include <sys/mman.h>
{
/* initialize the thread links */
pr->ps_mainproc = p;
- SMR_TAILQ_INIT(&pr->ps_threads);
- SMR_TAILQ_INSERT_TAIL_LOCKED(&pr->ps_threads, p, p_thr_link);
+ TAILQ_INIT(&pr->ps_threads);
+ TAILQ_INSERT_TAIL(&pr->ps_threads, p, p_thr_link);
pr->ps_refcnt = 1;
p->p_p = pr;
LIST_INSERT_HEAD(&allproc, p, p_list);
LIST_INSERT_HEAD(TIDHASH(p->p_tid), p, p_hash);
- SMR_TAILQ_INSERT_TAIL_LOCKED(&pr->ps_threads, p, p_thr_link);
+ TAILQ_INSERT_TAIL(&pr->ps_threads, p, p_thr_link);
/*
* if somebody else wants to take us to single threaded mode,
-/* $OpenBSD: kern_proc.c,v 1.89 2020/12/07 16:55:28 mpi Exp $ */
+/* $OpenBSD: kern_proc.c,v 1.90 2021/02/08 10:51:01 mpi Exp $ */
/* $NetBSD: kern_proc.c,v 1.14 1996/02/09 18:59:41 christos Exp $ */
/*
return;
}
- p = SMR_TAILQ_FIRST_LOCKED(&pr->ps_threads);
+ p = TAILQ_FIRST(&pr->ps_threads);
/* Send uncatchable SIGABRT for coredump */
sigabort(p);
while (pr != NULL) {
ppr = pr->ps_pptr;
- SMR_TAILQ_FOREACH_LOCKED(p, &pr->ps_threads, p_thr_link) {
+ TAILQ_FOREACH(p, &pr->ps_threads, p_thr_link) {
#ifdef MULTIPROCESSOR
if (__mp_lock_held(&kernel_lock, p->p_cpu))
has_kernel_lock = 1;
-/* $OpenBSD: kern_resource.c,v 1.70 2020/12/07 16:55:28 mpi Exp $ */
+/* $OpenBSD: kern_resource.c,v 1.71 2021/02/08 10:51:01 mpi Exp $ */
/* $NetBSD: kern_resource.c,v 1.38 1996/10/23 07:19:38 matthias Exp $ */
/*-
return (EACCES);
chgpr->ps_nice = n;
SCHED_LOCK(s);
- SMR_TAILQ_FOREACH_LOCKED(p, &chgpr->ps_threads, p_thr_link) {
+ TAILQ_FOREACH(p, &chgpr->ps_threads, p_thr_link) {
setpriority(p, p->p_estcpu, n);
}
SCHED_UNLOCK(s);
memset(rup, 0, sizeof(*rup));
/* add on all living threads */
- SMR_TAILQ_FOREACH_LOCKED(q, &pr->ps_threads, p_thr_link) {
+ TAILQ_FOREACH(q, &pr->ps_threads, p_thr_link) {
ruadd(rup, &q->p_ru);
tuagg(pr, q);
}
-/* $OpenBSD: kern_sig.c,v 1.271 2021/02/08 08:18:45 mpi Exp $ */
+/* $OpenBSD: kern_sig.c,v 1.272 2021/02/08 10:51:01 mpi Exp $ */
/* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */
/*
* delayed. Otherwise, mark it pending on the
* main thread.
*/
- SMR_TAILQ_FOREACH_LOCKED(q, &pr->ps_threads, p_thr_link) {
+ TAILQ_FOREACH(q, &pr->ps_threads, p_thr_link) {
/* ignore exiting threads */
if (q->p_flag & P_WEXIT)
continue;
* XXX delay processing of SA_STOP signals unless action == SIG_DFL?
*/
if (prop & (SA_CONT | SA_STOP) && type != SPROPAGATED)
- SMR_TAILQ_FOREACH_LOCKED(q, &pr->ps_threads, p_thr_link)
+ TAILQ_FOREACH(q, &pr->ps_threads, p_thr_link)
if (q != p)
ptsignal(q, signum, SPROPAGATED);
pr->ps_singlecount = 0;
membar_producer();
pr->ps_single = p;
- SMR_TAILQ_FOREACH_LOCKED(q, &pr->ps_threads, p_thr_link) {
+ TAILQ_FOREACH(q, &pr->ps_threads, p_thr_link) {
if (q == p)
continue;
if (q->p_flag & P_WEXIT) {
SCHED_LOCK(s);
pr->ps_single = NULL;
atomic_clearbits_int(&pr->ps_flags, PS_SINGLEUNWIND | PS_SINGLEEXIT);
- SMR_TAILQ_FOREACH_LOCKED(q, &pr->ps_threads, p_thr_link) {
+ TAILQ_FOREACH(q, &pr->ps_threads, p_thr_link) {
if (q == p || (q->p_flag & P_SUSPSINGLE) == 0)
continue;
atomic_clearbits_int(&q->p_flag, P_SUSPSINGLE);
-/* $OpenBSD: kern_synch.c,v 1.175 2021/02/08 08:18:45 mpi Exp $ */
+/* $OpenBSD: kern_synch.c,v 1.176 2021/02/08 10:51:02 mpi Exp $ */
/* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */
/*
#include <sys/pool.h>
#include <sys/refcnt.h>
#include <sys/atomic.h>
-#include <sys/smr.h>
#include <sys/witness.h>
#include <sys/tracepoint.h>
* can make some progress.
*/
newprio = p->p_usrpri;
- SMR_TAILQ_FOREACH_LOCKED(q, &p->p_p->ps_threads, p_thr_link)
+ TAILQ_FOREACH(q, &p->p_p->ps_threads, p_thr_link)
newprio = max(newprio, q->p_runpri);
setrunqueue(p->p_cpu, p, newprio);
p->p_ru.ru_nvcsw++;
-/* $OpenBSD: kern_sysctl.c,v 1.388 2021/01/17 15:28:22 mvs Exp $ */
+/* $OpenBSD: kern_sysctl.c,v 1.389 2021/02/08 10:51:02 mpi Exp $ */
/* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */
/*-
if (!dothreads)
continue;
- SMR_TAILQ_FOREACH_LOCKED(p, &pr->ps_threads, p_thr_link) {
+ TAILQ_FOREACH(p, &pr->ps_threads, p_thr_link) {
if (buflen >= elem_size && elem_count > 0) {
fill_kproc(pr, kproc, p, show_pointers);
error = copyout(kproc, dp, elem_size);
} else {
ki->p_pctcpu = 0;
ki->p_stat = (pr->ps_flags & PS_ZOMBIE) ? SDEAD : SIDL;
- SMR_TAILQ_FOREACH_LOCKED(p, &pr->ps_threads, p_thr_link) {
+ TAILQ_FOREACH(p, &pr->ps_threads, p_thr_link) {
ki->p_pctcpu += p->p_pctcpu;
/* find best state: ONPROC > RUN > STOP > SLEEP > .. */
if (p->p_stat == SONPROC || ki->p_stat == SONPROC)
-/* $OpenBSD: subr_witness.c,v 1.44 2021/01/28 15:13:27 visa Exp $ */
+/* $OpenBSD: subr_witness.c,v 1.45 2021/02/08 10:51:02 mpi Exp $ */
/*-
* Copyright (c) 2008 Isilon Systems, Inc.
{
struct proc *p;
- SMR_TAILQ_FOREACH_LOCKED(p, &pr->ps_threads, p_thr_link) {
+ TAILQ_FOREACH(p, &pr->ps_threads, p_thr_link) {
if (witness_thread_has_locks(p))
return (1);
}
LIST_FOREACH(pr, &allprocess, ps_list) {
if (!witness_process_has_locks(pr))
continue;
- SMR_TAILQ_FOREACH_LOCKED(p, &pr->ps_threads, p_thr_link) {
+ TAILQ_FOREACH(p, &pr->ps_threads, p_thr_link) {
if (!witness_thread_has_locks(p))
continue;
db_printf("Process %d (%s) thread %p (%d)\n",
-/* $OpenBSD: sys_process.c,v 1.85 2020/12/07 16:55:29 mpi Exp $ */
+/* $OpenBSD: sys_process.c,v 1.86 2021/02/08 10:51:02 mpi Exp $ */
/* $NetBSD: sys_process.c,v 1.55 1996/05/15 06:17:47 tls Exp $ */
/*-
error = ESRCH;
goto fail;
}
- t = SMR_TAILQ_FIRST_LOCKED(&tr->ps_threads);
+ t = TAILQ_FIRST(&tr->ps_threads);
break;
/* calls that accept a PID or a thread ID */
return ESRCH;
if (t->p_p != tr)
return EINVAL;
- t = SMR_TAILQ_NEXT_LOCKED(t, p_thr_link);
+ t = TAILQ_NEXT(t, p_thr_link);
} else {
- t = SMR_TAILQ_FIRST_LOCKED(&tr->ps_threads);
+ t = TAILQ_FIRST(&tr->ps_threads);
}
if (t == NULL)
if (tr == NULL)
return NULL;
- *tp = SMR_TAILQ_FIRST_LOCKED(&tr->ps_threads);
+ *tp = TAILQ_FIRST(&tr->ps_threads);
return tr;
}
}
-/* $OpenBSD: tty.c,v 1.166 2020/12/25 12:59:52 visa Exp $ */
+/* $OpenBSD: tty.c,v 1.167 2021/02/08 10:51:02 mpi Exp $ */
/* $NetBSD: tty.c,v 1.68.4.2 1996/06/06 16:04:52 thorpej Exp $ */
/*-
ret = 0;
estcpu = 0;
- SMR_TAILQ_FOREACH_LOCKED(p, &pr->ps_threads, p_thr_link) {
+ TAILQ_FOREACH(p, &pr->ps_threads, p_thr_link) {
if (p->p_stat == SRUN || p->p_stat == SONPROC)
ret = 1;
estcpu += p->p_pctcpu;
* - prefer living
* Otherwise take the newest thread
*/
- pick = p = SMR_TAILQ_FIRST_LOCKED(&pickpr->ps_threads);
+ pick = p = TAILQ_FIRST(&pickpr->ps_threads);
if (p == NULL)
goto empty;
run = p->p_stat == SRUN || p->p_stat == SONPROC;
pctcpu = p->p_pctcpu;
- while ((p = SMR_TAILQ_NEXT_LOCKED(p, p_thr_link)) != NULL) {
+ while ((p = TAILQ_NEXT(p, p_thr_link)) != NULL) {
run2 = p->p_stat == SRUN || p->p_stat == SONPROC;
pctcpu2 = p->p_pctcpu;
if (run) {
-/* $OpenBSD: proc.h,v 1.307 2021/02/08 08:18:45 mpi Exp $ */
+/* $OpenBSD: proc.h,v 1.308 2021/02/08 10:51:02 mpi Exp $ */
/* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */
/*-
#include <sys/resource.h> /* For struct rusage */
#include <sys/rwlock.h> /* For struct rwlock */
#include <sys/sigio.h> /* For struct sigio */
-#include <sys/smr.h>
#ifdef _KERNEL
#include <sys/atomic.h>
* R rlimit_lock
* S scheduler lock
* T itimer_mtx
- *
- * For SMR related structures that allow lock-free reads, the write lock
- * is indicated below.
*/
struct process {
/*
struct ucred *ps_ucred; /* Process owner's identity. */
LIST_ENTRY(process) ps_list; /* List of all processes. */
- SMR_TAILQ_HEAD(,proc) ps_threads; /* [K] Threads in this process. */
+ TAILQ_HEAD(,proc) ps_threads; /* Threads in this process. */
LIST_ENTRY(process) ps_pglist; /* List of processes in pgrp. */
struct process *ps_pptr; /* Pointer to parent process. */
/*
* Locks used to protect struct members in this file:
* I immutable after creation
- * K kernel lock
+ * S scheduler lock
* l read only reference, see lim_read_enter()
* o owned (read/modified only) by this thread
- * S scheduler lock
- *
- * For SMR related structures that allow lock-free reads, the write lock
- * is indicated below.
*/
struct proc {
TAILQ_ENTRY(proc) p_runq; /* [S] current run/sleep queue */
LIST_ENTRY(proc) p_list; /* List of all threads. */
struct process *p_p; /* [I] The process of this thread. */
- SMR_TAILQ_ENTRY(proc) p_thr_link; /* [K] Threads in a process linkage */
+ TAILQ_ENTRY(proc) p_thr_link; /* Threads in a process linkage. */
TAILQ_ENTRY(proc) p_fut_link; /* Threads in a futex linkage. */
struct futex *p_futex; /* Current sleeping futex. */
#define SONPROC 7 /* Thread is currently on a CPU. */
#define P_ZOMBIE(p) ((p)->p_stat == SDEAD)
-#define P_HASSIBLING(p) \
- (SMR_TAILQ_FIRST_LOCKED(&(p)->p_p->ps_threads) != (p) || \
- SMR_TAILQ_NEXT_LOCKED((p), p_thr_link) != NULL)
+#define P_HASSIBLING(p) (TAILQ_FIRST(&(p)->p_p->ps_threads) != (p) || \
+ TAILQ_NEXT((p), p_thr_link) != NULL)
/*
* These flags are per-thread and kept in p_flag
-/* $OpenBSD: uvm_glue.c,v 1.77 2020/12/07 16:55:29 mpi Exp $ */
+/* $OpenBSD: uvm_glue.c,v 1.78 2021/02/08 10:51:02 mpi Exp $ */
/* $NetBSD: uvm_glue.c,v 1.44 2001/02/06 19:54:44 eeh Exp $ */
/*
* the smallest p_slptime
*/
slpp = NULL;
- SMR_TAILQ_FOREACH_LOCKED(p, &pr->ps_threads, p_thr_link) {
+ TAILQ_FOREACH(p, &pr->ps_threads, p_thr_link) {
switch (p->p_stat) {
case SRUN:
case SONPROC: