diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2021-02-08 10:51:03 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2021-02-08 10:51:03 +0000 |
commit | b2724c03b5425168dcc83218f4c41d6713283d87 (patch) | |
tree | b350585686ac6b0b1c558976239d4594e5c2b7db /sys/kern | |
parent | 16d10f648535cbd97acb7e1da8caae9c6734c691 (diff) |
Revert the convertion of per-process thread into a SMR_TAILQ.
We did not reach a consensus about using SMR to unlock single_thread_set()
so there's no point in keeping this change.
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/exec_elf.c | 5 | ||||
-rw-r--r-- | sys/kern/init_main.c | 4 | ||||
-rw-r--r-- | sys/kern/kern_exit.c | 7 | ||||
-rw-r--r-- | sys/kern/kern_fork.c | 9 | ||||
-rw-r--r-- | sys/kern/kern_proc.c | 6 | ||||
-rw-r--r-- | sys/kern/kern_resource.c | 6 | ||||
-rw-r--r-- | sys/kern/kern_sig.c | 10 | ||||
-rw-r--r-- | sys/kern/kern_synch.c | 5 | ||||
-rw-r--r-- | sys/kern/kern_sysctl.c | 6 | ||||
-rw-r--r-- | sys/kern/subr_witness.c | 6 | ||||
-rw-r--r-- | sys/kern/sys_process.c | 10 | ||||
-rw-r--r-- | sys/kern/tty.c | 8 |
12 files changed, 39 insertions, 43 deletions
diff --git a/sys/kern/exec_elf.c b/sys/kern/exec_elf.c index dff4c99c341..4fa5ec22aab 100644 --- a/sys/kern/exec_elf.c +++ b/sys/kern/exec_elf.c @@ -1,4 +1,4 @@ -/* $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 @@ -85,7 +85,6 @@ #include <sys/signalvar.h> #include <sys/stat.h> #include <sys/pledge.h> -#include <sys/smr.h> #include <sys/mman.h> @@ -1361,7 +1360,7 @@ coredump_notes_elf(struct proc *p, void *iocookie, size_t *sizep) * 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); diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index dd78c085828..7902f2ea0b6 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -521,7 +521,7 @@ main(void *framep) */ 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); } diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 89326bd6fbc..94e3981151f 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -63,7 +63,6 @@ #ifdef SYSVSEM #include <sys/sem.h> #endif -#include <sys/smr.h> #include <sys/witness.h> #include <sys/mount.h> @@ -162,7 +161,7 @@ exit1(struct proc *p, int xexit, int xsig, int flags) } /* 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) @@ -728,7 +727,7 @@ process_zap(struct process *pr) 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); diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index a8d275907de..f8b8cc67da5 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -52,7 +52,6 @@ #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> @@ -180,8 +179,8 @@ process_initialize(struct process *pr, struct proc *p) { /* 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; @@ -559,7 +558,7 @@ thread_fork(struct proc *curp, void *stack, void *tcb, pid_t *tidptr, 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, diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index d84ef5974c5..bbe709ea883 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -502,7 +502,7 @@ db_kill_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif) return; } - p = SMR_TAILQ_FIRST_LOCKED(&pr->ps_threads); + p = TAILQ_FIRST(&pr->ps_threads); /* Send uncatchable SIGABRT for coredump */ sigabort(p); @@ -558,7 +558,7 @@ db_show_all_procs(db_expr_t addr, int haddr, db_expr_t count, char *modif) 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; diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c index 543f96ed7e2..3133d2b7edc 100644 --- a/sys/kern/kern_resource.c +++ b/sys/kern/kern_resource.c @@ -1,4 +1,4 @@ -/* $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 $ */ /*- @@ -212,7 +212,7 @@ donice(struct proc *curp, struct process *chgpr, int n) 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); @@ -488,7 +488,7 @@ dogetrusage(struct proc *p, int who, struct rusage *rup) 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); } diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index ed3df27da58..6435794c833 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -925,7 +925,7 @@ ptsignal(struct proc *p, int signum, enum signal_type type) * 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; @@ -1009,7 +1009,7 @@ ptsignal(struct proc *p, int signum, enum signal_type type) * 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); @@ -2038,7 +2038,7 @@ single_thread_set(struct proc *p, enum single_thread_mode mode, int deep) 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) { @@ -2130,7 +2130,7 @@ single_thread_clear(struct proc *p, int flag) 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); diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index c7f30eb92ba..45f97b2e604 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -50,7 +50,6 @@ #include <sys/pool.h> #include <sys/refcnt.h> #include <sys/atomic.h> -#include <sys/smr.h> #include <sys/witness.h> #include <sys/tracepoint.h> @@ -599,7 +598,7 @@ sys_sched_yield(struct proc *p, void *v, register_t *retval) * 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++; diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 986f1a0b377..7125cbb2c04 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $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 $ */ /*- @@ -1590,7 +1590,7 @@ again: 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); @@ -1690,7 +1690,7 @@ fill_kproc(struct process *pr, struct kinfo_proc *ki, struct proc *p, } 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) diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c index 9a4d3c28a84..f160bfff057 100644 --- a/sys/kern/subr_witness.c +++ b/sys/kern/subr_witness.c @@ -1,4 +1,4 @@ -/* $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. @@ -1885,7 +1885,7 @@ witness_process_has_locks(struct process *pr) { 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); } @@ -2105,7 +2105,7 @@ db_witness_list_all(db_expr_t addr, int have_addr, db_expr_t count, char *modif) 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", diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index 3af92ae8084..89ea3539caa 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -1,4 +1,4 @@ -/* $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 $ */ /*- @@ -301,7 +301,7 @@ ptrace_ctrl(struct proc *p, int req, pid_t pid, caddr_t addr, int data) 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 */ @@ -561,9 +561,9 @@ ptrace_kstate(struct proc *p, int req, pid_t pid, void *addr) 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) @@ -754,7 +754,7 @@ process_tprfind(pid_t tpid, struct proc **tp) if (tr == NULL) return NULL; - *tp = SMR_TAILQ_FIRST_LOCKED(&tr->ps_threads); + *tp = TAILQ_FIRST(&tr->ps_threads); return tr; } } diff --git a/sys/kern/tty.c b/sys/kern/tty.c index bbeff325b9e..e8144b76ce0 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -1,4 +1,4 @@ -/* $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 $ */ /*- @@ -2118,7 +2118,7 @@ process_sum(struct process *pr, fixpt_t *estcpup) 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; @@ -2220,12 +2220,12 @@ update_pickpr: * - 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) { |