From nobody Mon Jul 29 01:50:01 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WXLs63cTsz5S7Lm; Mon, 29 Jul 2024 01:50:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WXLs60Jmfz4npD; Mon, 29 Jul 2024 01:50:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722217802; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=KeBrK7VbPFsYG93gyf/0gs/ukRNVElb12datnWnZaGA=; b=RogMjRfAKj4VNLwU+TkTWtrCrcL1B4TSgi4F1SMkLL2Vk70uqkJtzbn+R8/mbfms267VE3 6ouhp/vP2gvrsAk2A1lsfYlk9MwSYEIJC3tYJBHevULuJlUXgCQdT1ao5uH7hiMcsWAkWt lvy4VZW/v7gpZmt79DH86NcSWW4mM2XIJ+Ot2JTykHCenGZKtpfS63tuQqexWUUsRkZjAF ulNm6+0gCPcwooUCUvtE23qe3zu+p5QcOCHbsQxC3kuKE2Vn2Yn2afN7Pt9HwXNTifUQIS ughxr2B0rUsOBQzsOwY0eEN5AiZkHlVwJ/cibBYtZQISj/0R3+MeL61/cWvGrQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1722217802; a=rsa-sha256; cv=none; b=g/oTYXSm/KP9ouO04keeHgaeLHtxtWvG3dRLkPWOqjKkW5eypbgdUHuzz6IeKkJuY0K2aZ 97uRH1SBspRfxvACPVQQdocNyfOVJ2bHNgFAJg2bd/ShgjBt1QY2B5ZIqzKWwMPKxYjLvv BekaCthrpLpnqNoeG3uvWspU7QwxcL/yIXtl/k+6F2RCwLc6/Ub6wac7gi87diq7ZXUBp9 aFfKLx3jFl21pZWOWvHLMH8rMRxpA8LZS81uKk5jN5dEvqxvgboTaf0Gslq05hD/vszgcG 1CveLeMaAEwf4h6FGYI6FbVisTg3jZyfmHTjHg8o3t46umJpmx4z1puaK0rrQQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722217802; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=KeBrK7VbPFsYG93gyf/0gs/ukRNVElb12datnWnZaGA=; b=immsXdxNqDDfFE99L6yWUtkvqW9oxbViBeNFQ9sbE7xhtxmc0mVHhSQELzpZvrGIjLOF+J 3RS/RVshG1HNuJd+OvKwQ3WKKGcwU8AkYBWt139ZB+9+/qxQAPZfSyyx6snxYksw78YD5n Lx9F6BjamUanpagyUvtlaG4Ih+7SDzlcVpHf7iIU4TukVKwcfook9DIvFvmTnbcmNntBl+ TqgTbE9HWNCVeDDiPJogqE/QfcCAY+BP0Ler0Q1kH729kuQAY2OuLvuah+7aazlIUbIgh/ JSzHbJPCFZVh+ZA1kl5FugwZQZKR4lkntMn99oV83t+5kxbfw7z4FS/unHCt3g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4WXLs55qZqzFLY; Mon, 29 Jul 2024 01:50:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 46T1o1DL094030; Mon, 29 Jul 2024 01:50:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46T1o1qH094024; Mon, 29 Jul 2024 01:50:01 GMT (envelope-from git) Date: Mon, 29 Jul 2024 01:50:01 GMT Message-Id: <202407290150.46T1o1qH094024@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: d4c4ca856b26 - main - proc: Remove kernel stack swapping support, part 9 List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d4c4ca856b267669b9da18a8ea676f5e556ee5c8 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=d4c4ca856b267669b9da18a8ea676f5e556ee5c8 commit d4c4ca856b267669b9da18a8ea676f5e556ee5c8 Author: Mark Johnston AuthorDate: 2024-07-29 01:42:01 +0000 Commit: Mark Johnston CommitDate: 2024-07-29 01:43:59 +0000 proc: Remove kernel stack swapping support, part 9 setrunnable() no longer needs to return a value. Make its return type void and fix up callers. Now a number of other interfaces no longer need to return a value, they will be fixed up subsequently. Tested by: pho Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D46127 --- sys/kern/kern_sig.c | 69 ++++++++++++++++------------------------- sys/kern/kern_synch.c | 4 +-- sys/kern/kern_thread.c | 77 ++++++++++++++++------------------------------ sys/kern/subr_sleepqueue.c | 53 +++++++++++-------------------- sys/sys/proc.h | 2 +- 5 files changed, 72 insertions(+), 133 deletions(-) diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 46f7b29837e4..cded24450ca1 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -108,7 +108,7 @@ static int issignal(struct thread *td); static void reschedule_signals(struct proc *p, sigset_t block, int flags); static int sigprop(int sig); static void tdsigwakeup(struct thread *, int, sig_t, int); -static int sig_suspend_threads(struct thread *, struct proc *); +static void sig_suspend_threads(struct thread *, struct proc *); static int filt_sigattach(struct knote *kn); static void filt_sigdetach(struct knote *kn); static int filt_signal(struct knote *kn, long hint); @@ -2260,16 +2260,15 @@ tdksignal(struct thread *td, int sig, ksiginfo_t *ksi) (void) tdsendsignal(td->td_proc, td, sig, ksi); } -static int +static void sig_sleepq_abort(struct thread *td, int intrval) { THREAD_LOCK_ASSERT(td, MA_OWNED); - if (intrval == 0 && (td->td_flags & TDF_SIGWAIT) == 0) { + if (intrval == 0 && (td->td_flags & TDF_SIGWAIT) == 0) thread_unlock(td); - return (0); - } - return (sleepq_abort(td, intrval)); + else + sleepq_abort(td, intrval); } int @@ -2277,11 +2276,8 @@ tdsendsignal(struct proc *p, struct thread *td, int sig, ksiginfo_t *ksi) { sig_t action; sigqueue_t *sigqueue; - int prop; struct sigacts *ps; - int intrval; - int ret = 0; - int wakeup_swapper; + int intrval, prop, ret; MPASS(td == NULL || p == td->td_proc); PROC_LOCK_ASSERT(p, MA_OWNED); @@ -2297,7 +2293,7 @@ tdsendsignal(struct proc *p, struct thread *td, int sig, ksiginfo_t *ksi) if (p->p_state == PRS_ZOMBIE) { if (ksi != NULL && (ksi->ksi_flags & KSI_INS) != 0) ksiginfo_tryfree(ksi); - return (ret); + return (0); } ps = p->p_sigacts; @@ -2327,7 +2323,7 @@ tdsendsignal(struct proc *p, struct thread *td, int sig, ksiginfo_t *ksi) mtx_unlock(&ps->ps_mtx); if (ksi != NULL && (ksi->ksi_flags & KSI_INS) != 0) ksiginfo_tryfree(ksi); - return (ret); + return (0); } else { action = SIG_CATCH; intrval = 0; @@ -2360,7 +2356,7 @@ tdsendsignal(struct proc *p, struct thread *td, int sig, ksiginfo_t *ksi) action == SIG_DFL) { if (ksi != NULL && (ksi->ksi_flags & KSI_INS) != 0) ksiginfo_tryfree(ksi); - return (ret); + return (0); } sigqueue_delete_proc(p, SIGCONT); if (p->p_flag & P_CONTINUED) { @@ -2381,9 +2377,7 @@ tdsendsignal(struct proc *p, struct thread *td, int sig, ksiginfo_t *ksi) */ if (action == SIG_HOLD && !((prop & SIGPROP_CONT) && (p->p_flag & P_STOPPED_SIG))) - return (ret); - - wakeup_swapper = 0; + return (0); /* * Some signals have a process-wide effect and a per-thread @@ -2402,7 +2396,7 @@ tdsendsignal(struct proc *p, struct thread *td, int sig, ksiginfo_t *ksi) * then no further action is necessary. */ if (p->p_flag & P_TRACED) - goto out; + return (0); /* * SIGKILL sets process running. * It will die elsewhere. @@ -2418,7 +2412,7 @@ tdsendsignal(struct proc *p, struct thread *td, int sig, ksiginfo_t *ksi) * then no further action is necessary. */ if (p->p_flag & P_TRACED) - goto out; + return (0); /* * If SIGCONT is default (or ignored), we continue the * process but don't leave the signal in sigqueue as @@ -2468,7 +2462,7 @@ tdsendsignal(struct proc *p, struct thread *td, int sig, ksiginfo_t *ksi) * then no further action is necessary. */ if (p->p_flag & P_TRACED) - goto out; + return (0); /* * Already stopped, don't need to stop again * (If we did the shell could get confused). @@ -2476,7 +2470,7 @@ tdsendsignal(struct proc *p, struct thread *td, int sig, ksiginfo_t *ksi) */ p->p_flag |= P_STOPPED_SIG; sigqueue_delete(sigqueue, sig); - goto out; + return (0); } /* @@ -2490,11 +2484,11 @@ tdsendsignal(struct proc *p, struct thread *td, int sig, ksiginfo_t *ksi) PROC_SLOCK(p); thread_lock(td); if (TD_CAN_ABORT(td)) - wakeup_swapper = sig_sleepq_abort(td, intrval); + sig_sleepq_abort(td, intrval); else thread_unlock(td); PROC_SUNLOCK(p); - goto out; + return (0); /* * Mutexes are short lived. Threads waiting on them will * hit thread_suspend_check() soon. @@ -2502,18 +2496,18 @@ tdsendsignal(struct proc *p, struct thread *td, int sig, ksiginfo_t *ksi) } else if (p->p_state == PRS_NORMAL) { if (p->p_flag & P_TRACED || action == SIG_CATCH) { tdsigwakeup(td, sig, action, intrval); - goto out; + return (0); } MPASS(action == SIG_DFL); if (prop & SIGPROP_STOP) { if (p->p_flag & (P_PPWAIT|P_WEXIT)) - goto out; + return (0); p->p_flag |= P_STOPPED_SIG; p->p_xsig = sig; PROC_SLOCK(p); - wakeup_swapper = sig_suspend_threads(td, p); + sig_suspend_threads(td, p); if (p->p_numthreads == p->p_suspcount) { /* * only thread sending signal to another @@ -2527,12 +2521,12 @@ tdsendsignal(struct proc *p, struct thread *td, int sig, ksiginfo_t *ksi) sigqueue_delete_proc(p, p->p_xsig); } else PROC_SUNLOCK(p); - goto out; + return (0); } } else { /* Not in "NORMAL" state. discard the signal. */ sigqueue_delete(sigqueue, sig); - goto out; + return (0); } /* @@ -2547,13 +2541,8 @@ runfast: out_cont: itimer_proc_continue(p); kqtimer_proc_continue(p); -out: - /* If we jump here, proc slock should not be owned. */ - PROC_SLOCK_ASSERT(p, MA_NOTOWNED); - if (wakeup_swapper) - kick_proc0(); - return (ret); + return (0); } /* @@ -2565,7 +2554,7 @@ static void tdsigwakeup(struct thread *td, int sig, sig_t action, int intrval) { struct proc *p = td->td_proc; - int prop, wakeup_swapper; + int prop; PROC_LOCK_ASSERT(p, MA_OWNED); prop = sigprop(sig); @@ -2621,10 +2610,8 @@ tdsigwakeup(struct thread *td, int sig, sig_t action, int intrval) if (td->td_priority > PUSER && !TD_IS_IDLETHREAD(td)) sched_prio(td, PUSER); - wakeup_swapper = sig_sleepq_abort(td, intrval); + sig_sleepq_abort(td, intrval); PROC_SUNLOCK(p); - if (wakeup_swapper) - kick_proc0(); return; } @@ -2778,16 +2765,14 @@ ptrace_remotereq(struct thread *td, int flag) wakeup(p); } -static int +static void sig_suspend_threads(struct thread *td, struct proc *p) { struct thread *td2; - int wakeup_swapper; PROC_LOCK_ASSERT(p, MA_OWNED); PROC_SLOCK_ASSERT(p, MA_OWNED); - wakeup_swapper = 0; FOREACH_THREAD_IN_PROC(p, td2) { thread_lock(td2); ast_sched_locked(td2, TDA_SUSPEND); @@ -2802,8 +2787,7 @@ sig_suspend_threads(struct thread *td, struct proc *p) KASSERT(!TD_IS_SUSPENDED(td2), ("thread with deferred stops suspended")); if (TD_SBDRY_INTR(td2)) { - wakeup_swapper |= sleepq_abort(td2, - TD_SBDRY_ERRNO(td2)); + sleepq_abort(td2, TD_SBDRY_ERRNO(td2)); continue; } } else if (!TD_IS_SUSPENDED(td2)) @@ -2816,7 +2800,6 @@ sig_suspend_threads(struct thread *td, struct proc *p) } thread_unlock(td2); } - return (wakeup_swapper); } /* diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index 25bca094b400..9bb6079c0c20 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -562,7 +562,7 @@ mi_switch(int flags) * * Requires the thread lock on entry, drops on exit. */ -int +void setrunnable(struct thread *td, int srqflags) { THREAD_LOCK_ASSERT(td, MA_OWNED); @@ -586,8 +586,6 @@ setrunnable(struct thread *td, int srqflags) default: panic("setrunnable: state 0x%x", TD_GET_STATE(td)); } - - return (0); } /* diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c index 179ced38b715..00f99516773c 100644 --- a/sys/kern/kern_thread.c +++ b/sys/kern/kern_thread.c @@ -145,7 +145,7 @@ static void thread_reap(void); static void thread_reap_all(void); static void thread_reap_task_cb(void *, int); static void thread_reap_callout_cb(void *); -static int thread_unsuspend_one(struct thread *td, struct proc *p, +static void thread_unsuspend_one(struct thread *td, struct proc *p, bool boundary); static void thread_free_batched(struct thread *td); @@ -935,7 +935,6 @@ thread_exit(void) struct thread *td; struct thread *td2; struct proc *p; - int wakeup_swapper; td = curthread; p = td->td_proc; @@ -981,10 +980,8 @@ thread_exit(void) if (P_SHOULDSTOP(p) == P_STOPPED_SINGLE) { if (p->p_numthreads == p->p_suspcount) { thread_lock(p->p_singlethread); - wakeup_swapper = thread_unsuspend_one( - p->p_singlethread, p, false); - if (wakeup_swapper) - kick_proc0(); + thread_unsuspend_one(p->p_singlethread, + p, false); } } @@ -1137,17 +1134,13 @@ remain_for_mode(int mode) return (mode == SINGLE_ALLPROC ? 0 : 1); } -static int +static void weed_inhib(int mode, struct thread *td2, struct proc *p) { - int wakeup_swapper; - PROC_LOCK_ASSERT(p, MA_OWNED); PROC_SLOCK_ASSERT(p, MA_OWNED); THREAD_LOCK_ASSERT(td2, MA_OWNED); - wakeup_swapper = 0; - /* * Since the thread lock is dropped by the scheduler we have * to retry to check for races. @@ -1156,26 +1149,26 @@ restart: switch (mode) { case SINGLE_EXIT: if (TD_IS_SUSPENDED(td2)) { - wakeup_swapper |= thread_unsuspend_one(td2, p, true); + thread_unsuspend_one(td2, p, true); thread_lock(td2); goto restart; } if (TD_CAN_ABORT(td2)) { - wakeup_swapper |= sleepq_abort(td2, EINTR); - return (wakeup_swapper); + sleepq_abort(td2, EINTR); + return; } break; case SINGLE_BOUNDARY: case SINGLE_NO_EXIT: if (TD_IS_SUSPENDED(td2) && (td2->td_flags & TDF_BOUNDARY) == 0) { - wakeup_swapper |= thread_unsuspend_one(td2, p, false); + thread_unsuspend_one(td2, p, false); thread_lock(td2); goto restart; } if (TD_CAN_ABORT(td2)) { - wakeup_swapper |= sleepq_abort(td2, ERESTART); - return (wakeup_swapper); + sleepq_abort(td2, ERESTART); + return; } break; case SINGLE_ALLPROC: @@ -1189,21 +1182,20 @@ restart: */ if (TD_IS_SUSPENDED(td2) && (td2->td_flags & TDF_ALLPROCSUSP) == 0) { - wakeup_swapper |= thread_unsuspend_one(td2, p, false); + thread_unsuspend_one(td2, p, false); thread_lock(td2); goto restart; } if (TD_CAN_ABORT(td2)) { td2->td_flags |= TDF_ALLPROCSUSP; - wakeup_swapper |= sleepq_abort(td2, ERESTART); - return (wakeup_swapper); + sleepq_abort(td2, ERESTART); + return; } break; default: break; } thread_unlock(td2); - return (wakeup_swapper); } /* @@ -1224,7 +1216,7 @@ thread_single(struct proc *p, int mode) { struct thread *td; struct thread *td2; - int remaining, wakeup_swapper; + int remaining; td = curthread; KASSERT(mode == SINGLE_EXIT || mode == SINGLE_BOUNDARY || @@ -1279,14 +1271,13 @@ thread_single(struct proc *p, int mode) while (remaining != remain_for_mode(mode)) { if (P_SHOULDSTOP(p) != P_STOPPED_SINGLE) goto stopme; - wakeup_swapper = 0; FOREACH_THREAD_IN_PROC(p, td2) { if (td2 == td) continue; thread_lock(td2); ast_sched_locked(td2, TDA_SUSPEND); if (TD_IS_INHIBITED(td2)) { - wakeup_swapper |= weed_inhib(mode, td2, p); + weed_inhib(mode, td2, p); #ifdef SMP } else if (TD_IS_RUNNING(td2)) { forward_signal(td2); @@ -1295,8 +1286,6 @@ thread_single(struct proc *p, int mode) } else thread_unlock(td2); } - if (wakeup_swapper) - kick_proc0(); remaining = calc_remaining(p, mode); /* @@ -1412,7 +1401,6 @@ thread_suspend_check(int return_instead) { struct thread *td; struct proc *p; - int wakeup_swapper; td = curthread; p = td->td_proc; @@ -1475,10 +1463,8 @@ thread_suspend_check(int return_instead) if (P_SHOULDSTOP(p) == P_STOPPED_SINGLE) { if (p->p_numthreads == p->p_suspcount + 1) { thread_lock(p->p_singlethread); - wakeup_swapper = thread_unsuspend_one( - p->p_singlethread, p, false); - if (wakeup_swapper) - kick_proc0(); + thread_unsuspend_one(p->p_singlethread, p, + false); } } PROC_UNLOCK(p); @@ -1585,7 +1571,7 @@ thread_suspend_one(struct thread *td) sched_sleep(td, 0); } -static int +static void thread_unsuspend_one(struct thread *td, struct proc *p, bool boundary) { @@ -1601,7 +1587,7 @@ thread_unsuspend_one(struct thread *td, struct proc *p, bool boundary) p->p_boundary_count--; } } - return (setrunnable(td, 0)); + setrunnable(td, 0); } void @@ -1625,8 +1611,7 @@ thread_run_flash(struct thread *td) MPASS(p->p_suspcount > 0); p->p_suspcount--; PROC_SUNLOCK(p); - if (setrunnable(td, 0)) - kick_proc0(); + setrunnable(td, 0); } /* @@ -1636,17 +1621,14 @@ void thread_unsuspend(struct proc *p) { struct thread *td; - int wakeup_swapper; PROC_LOCK_ASSERT(p, MA_OWNED); PROC_SLOCK_ASSERT(p, MA_OWNED); - wakeup_swapper = 0; if (!P_SHOULDSTOP(p)) { FOREACH_THREAD_IN_PROC(p, td) { thread_lock(td); if (TD_IS_SUSPENDED(td)) - wakeup_swapper |= thread_unsuspend_one(td, p, - true); + thread_unsuspend_one(td, p, true); else thread_unlock(td); } @@ -1659,12 +1641,9 @@ thread_unsuspend(struct proc *p) */ if (p->p_singlethread->td_proc == p) { thread_lock(p->p_singlethread); - wakeup_swapper = thread_unsuspend_one( - p->p_singlethread, p, false); + thread_unsuspend_one(p->p_singlethread, p, false); } } - if (wakeup_swapper) - kick_proc0(); } /* @@ -1674,7 +1653,6 @@ void thread_single_end(struct proc *p, int mode) { struct thread *td; - int wakeup_swapper; KASSERT(mode == SINGLE_EXIT || mode == SINGLE_BOUNDARY || mode == SINGLE_ALLPROC || mode == SINGLE_NO_EXIT, @@ -1693,7 +1671,7 @@ thread_single_end(struct proc *p, int mode) P_TOTAL_STOP); PROC_SLOCK(p); p->p_singlethread = NULL; - wakeup_swapper = 0; + /* * If there are other threads they may now run, * unless of course there is a blanket 'stop order' @@ -1703,18 +1681,15 @@ thread_single_end(struct proc *p, int mode) if (p->p_numthreads != remain_for_mode(mode) && !P_SHOULDSTOP(p)) { FOREACH_THREAD_IN_PROC(p, td) { thread_lock(td); - if (TD_IS_SUSPENDED(td)) { - wakeup_swapper |= thread_unsuspend_one(td, p, - true); - } else + if (TD_IS_SUSPENDED(td)) + thread_unsuspend_one(td, p, true); + else thread_unlock(td); } } KASSERT(mode != SINGLE_BOUNDARY || p->p_boundary_count == 0, ("inconsistent boundary count %d", p->p_boundary_count)); PROC_SUNLOCK(p); - if (wakeup_swapper) - kick_proc0(); wakeup(&p->p_flag); } diff --git a/sys/kern/subr_sleepqueue.c b/sys/kern/subr_sleepqueue.c index 15dbf396c557..0b792d752e94 100644 --- a/sys/kern/subr_sleepqueue.c +++ b/sys/kern/subr_sleepqueue.c @@ -169,7 +169,7 @@ static inline int sleepq_check_timeout(void); static void sleepq_dtor(void *mem, int size, void *arg); #endif static int sleepq_init(void *mem, int size, int flags); -static int sleepq_resume_thread(struct sleepqueue *sq, struct thread *td, +static void sleepq_resume_thread(struct sleepqueue *sq, struct thread *td, int pri, int srqflags); static void sleepq_remove_thread(struct sleepqueue *sq, struct thread *td); static void sleepq_switch(const void *wchan, int pri); @@ -731,13 +731,12 @@ sleepq_type(const void *wchan) } /* - * Removes a thread from a sleep queue and makes it - * runnable. + * Removes a thread from a sleep queue and makes it runnable. * * Requires the sc chain locked on entry. If SRQ_HOLD is specified it will * be locked on return. Returns without the thread lock held. */ -static int +static void sleepq_resume_thread(struct sleepqueue *sq, struct thread *td, int pri, int srqflags) { @@ -788,12 +787,11 @@ sleepq_resume_thread(struct sleepqueue *sq, struct thread *td, int pri, if (TD_IS_SLEEPING(td)) { MPASS(!drop); TD_CLR_SLEEPING(td); - return (setrunnable(td, srqflags)); + setrunnable(td, srqflags); + } else { + MPASS(drop); + thread_unlock(td); } - MPASS(drop); - thread_unlock(td); - - return (0); } static void @@ -929,7 +927,6 @@ sleepq_signal(const void *wchan, int flags, int pri, int queue) struct sleepqueue *sq; struct threadqueue *head; struct thread *td, *besttd; - int wakeup_swapper; CTR2(KTR_PROC, "sleepq_signal(%p, %d)", wchan, flags); KASSERT(wchan != NULL, ("%s: invalid NULL wait channel", __func__)); @@ -972,9 +969,9 @@ sleepq_signal(const void *wchan, int flags, int pri, int queue) } } MPASS(besttd != NULL); - wakeup_swapper = sleepq_resume_thread(sq, besttd, pri, + sleepq_resume_thread(sq, besttd, pri, (flags & SLEEPQ_DROP) ? 0 : SRQ_HOLD); - return (wakeup_swapper); + return (0); } static bool @@ -1012,7 +1009,6 @@ sleepq_remove_matching(struct sleepqueue *sq, int queue, bool (*matches)(struct thread *), int pri) { struct thread *td, *tdn; - int wakeup_swapper; /* * The last thread will be given ownership of sq and may @@ -1020,14 +1016,12 @@ sleepq_remove_matching(struct sleepqueue *sq, int queue, * so we must cache the "next" queue item at the beginning * of the final iteration. */ - wakeup_swapper = 0; TAILQ_FOREACH_SAFE(td, &sq->sq_blocked[queue], td_slpq, tdn) { if (matches(td)) - wakeup_swapper |= sleepq_resume_thread(sq, td, pri, - SRQ_HOLD); + sleepq_resume_thread(sq, td, pri, SRQ_HOLD); } - return (wakeup_swapper); + return (0); } /* @@ -1041,7 +1035,6 @@ sleepq_timeout(void *arg) struct sleepqueue *sq; struct thread *td; const void *wchan; - int wakeup_swapper; td = arg; CTR3(KTR_PROC, "sleepq_timeout: thread %p (pid %ld, %s)", @@ -1064,9 +1057,7 @@ sleepq_timeout(void *arg) sq = sleepq_lookup(wchan); MPASS(sq != NULL); td->td_flags |= TDF_TIMEOUT; - wakeup_swapper = sleepq_resume_thread(sq, td, 0, 0); - if (wakeup_swapper) - kick_proc0(); + sleepq_resume_thread(sq, td, 0, 0); return; } else if (TD_ON_SLEEPQ(td)) { /* @@ -1089,7 +1080,6 @@ sleepq_remove(struct thread *td, const void *wchan) { struct sleepqueue_chain *sc; struct sleepqueue *sq; - int wakeup_swapper; /* * Look up the sleep queue for this wait channel, then re-check @@ -1114,9 +1104,7 @@ sleepq_remove(struct thread *td, const void *wchan) sq = sleepq_lookup(wchan); MPASS(sq != NULL); MPASS(td->td_wchan == wchan); - wakeup_swapper = sleepq_resume_thread(sq, td, 0, 0); - if (wakeup_swapper) - kick_proc0(); + sleepq_resume_thread(sq, td, 0, 0); } /* @@ -1165,7 +1153,8 @@ sleepq_abort(struct thread *td, int intrval) MPASS(sq != NULL); /* Thread is asleep on sleep queue sq, so wake it up. */ - return (sleepq_resume_thread(sq, td, 0, 0)); + sleepq_resume_thread(sq, td, 0, 0); + return (0); } void @@ -1173,25 +1162,19 @@ sleepq_chains_remove_matching(bool (*matches)(struct thread *)) { struct sleepqueue_chain *sc; struct sleepqueue *sq, *sq1; - int i, wakeup_swapper; + int i; - wakeup_swapper = 0; for (sc = &sleepq_chains[0]; sc < sleepq_chains + SC_TABLESIZE; ++sc) { if (LIST_EMPTY(&sc->sc_queues)) { continue; } mtx_lock_spin(&sc->sc_lock); LIST_FOREACH_SAFE(sq, &sc->sc_queues, sq_hash, sq1) { - for (i = 0; i < NR_SLEEPQS; ++i) { - wakeup_swapper |= sleepq_remove_matching(sq, i, - matches, 0); - } + for (i = 0; i < NR_SLEEPQS; ++i) + sleepq_remove_matching(sq, i, matches, 0); } mtx_unlock_spin(&sc->sc_lock); } - if (wakeup_swapper) { - kick_proc0(); - } } /* diff --git a/sys/sys/proc.h b/sys/sys/proc.h index d7d4b4c7450e..5e3f0e2e117d 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1200,7 +1200,7 @@ int securelevel_ge(struct ucred *cr, int level); int securelevel_gt(struct ucred *cr, int level); void sess_hold(struct session *); void sess_release(struct session *); -int setrunnable(struct thread *, int); +void setrunnable(struct thread *, int); void setsugid(struct proc *p); bool should_yield(void); int sigonstack(size_t sp);