Date: Mon, 3 May 2021 16:20:40 GMT From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: af928fded070 - main - Add thread_run_flash() helper Message-ID: <202105031620.143GKejI022257@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=af928fded0705100e4f3926c99ed488f7ab6dcf1 commit af928fded0705100e4f3926c99ed488f7ab6dcf1 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2021-04-24 11:47:53 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2021-05-03 16:13:47 +0000 Add thread_run_flash() helper It unsuspends single suspended thread, passed as the argument. It is up to the caller to arrange the target thread to suspend later, since the state of the process is not changed from stopped. In particular, the unsuspended thread must not leave to userspace, since boundary code is not prepared to this situation. Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D29955 --- sys/kern/kern_thread.c | 25 +++++++++++++++++++++++++ sys/sys/proc.h | 1 + 2 files changed, 26 insertions(+) diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c index ea569576e7c9..d5549baa6ad5 100644 --- a/sys/kern/kern_thread.c +++ b/sys/kern/kern_thread.c @@ -1514,6 +1514,31 @@ thread_unsuspend_one(struct thread *td, struct proc *p, bool boundary) return (setrunnable(td, 0)); } +void +thread_run_flash(struct thread *td) +{ + struct proc *p; + + p = td->td_proc; + PROC_LOCK_ASSERT(p, MA_OWNED); + + if (TD_ON_SLEEPQ(td)) + sleepq_remove_nested(td); + else + thread_lock(td); + + THREAD_LOCK_ASSERT(td, MA_OWNED); + KASSERT(TD_IS_SUSPENDED(td), ("Thread not suspended")); + + TD_CLR_SUSPENDED(td); + PROC_SLOCK(p); + MPASS(p->p_suspcount > 0); + p->p_suspcount--; + PROC_SUNLOCK(p); + if (setrunnable(td, 0)) + kick_proc0(); +} + /* * Allow all threads blocked by single threading to continue running. */ diff --git a/sys/sys/proc.h b/sys/sys/proc.h index b82de183aa44..a078b859ddc1 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1191,6 +1191,7 @@ void thread_stopped(struct proc *p); void childproc_stopped(struct proc *child, int reason); void childproc_continued(struct proc *child); void childproc_exited(struct proc *child); +void thread_run_flash(struct thread *td); int thread_suspend_check(int how); bool thread_suspend_check_needed(void); void thread_suspend_switch(struct thread *, struct proc *p);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202105031620.143GKejI022257>