From owner-dev-commits-src-branches@freebsd.org Mon May 10 01:14:50 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6730E62803A; Mon, 10 May 2021 01:14:50 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FdjlG28y7z4ZK3; Mon, 10 May 2021 01:14:50 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 362C41B7E3; Mon, 10 May 2021 01:14:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 14A1Eo7B028645; Mon, 10 May 2021 01:14:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14A1Eoic028644; Mon, 10 May 2021 01:14:50 GMT (envelope-from git) Date: Mon, 10 May 2021 01:14:50 GMT Message-Id: <202105100114.14A1Eoic028644@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 8e1c74210cec - stable/13 - Add thread_run_flash() helper MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 8e1c74210cec0b81318b6f90648cb0e9387244ad Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 01:14:50 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=8e1c74210cec0b81318b6f90648cb0e9387244ad commit 8e1c74210cec0b81318b6f90648cb0e9387244ad Author: Konstantin Belousov AuthorDate: 2021-04-24 11:47:53 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-10 01:02:28 +0000 Add thread_run_flash() helper (cherry picked from commit af928fded0705100e4f3926c99ed488f7ab6dcf1) --- 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 3561895d9fff..c16b6dd3c791 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 3e5a96185e0c..9de7be4628dd 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1179,6 +1179,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);