Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 10 May 2021 01:14:48 GMT
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 5771601bf45a - stable/13 - Add sleepq_remove_nested()
Message-ID:  <202105100114.14A1EmJa028623@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=5771601bf45a29b5330faa22dfcd15c91360fb07

commit 5771601bf45a29b5330faa22dfcd15c91360fb07
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2021-04-25 00:01:32 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2021-05-10 01:02:23 +0000

    Add sleepq_remove_nested()
    
    (cherry picked from commit 15465a2c25cc2915e8c7c65178805b10e339dde3)
---
 sys/kern/subr_sleepqueue.c | 20 ++++++++++++++++++++
 sys/sys/sleepqueue.h       |  1 +
 2 files changed, 21 insertions(+)

diff --git a/sys/kern/subr_sleepqueue.c b/sys/kern/subr_sleepqueue.c
index 20ca455480b5..0718f01fa48a 100644
--- a/sys/kern/subr_sleepqueue.c
+++ b/sys/kern/subr_sleepqueue.c
@@ -854,6 +854,26 @@ sleepq_remove_thread(struct sleepqueue *sq, struct thread *td)
 	    (void *)td, (long)td->td_proc->p_pid, td->td_name);
 }
 
+void
+sleepq_remove_nested(struct thread *td)
+{
+	struct sleepqueue_chain *sc;
+	struct sleepqueue *sq;
+	const void *wchan;
+
+	MPASS(TD_ON_SLEEPQ(td));
+
+	wchan = td->td_wchan;
+	sc = SC_LOOKUP(wchan);
+	mtx_lock_spin(&sc->sc_lock);
+	sq = sleepq_lookup(wchan);
+	MPASS(sq != NULL);
+	thread_lock(td);
+	sleepq_remove_thread(sq, td);
+	mtx_unlock_spin(&sc->sc_lock);
+	/* Returns with the thread lock owned. */
+}
+
 #ifdef INVARIANTS
 /*
  * UMA zone item deallocator.
diff --git a/sys/sys/sleepqueue.h b/sys/sys/sleepqueue.h
index ba2f85f2c8a1..18c7568777b6 100644
--- a/sys/sys/sleepqueue.h
+++ b/sys/sys/sleepqueue.h
@@ -100,6 +100,7 @@ void	sleepq_release(const void *wchan);
 void	sleepq_remove(struct thread *td, const void *wchan);
 int	sleepq_remove_matching(struct sleepqueue *sq, int queue,
 	    bool (*matches)(struct thread *), int pri);
+void	sleepq_remove_nested(struct thread *td);
 int	sleepq_signal(const void *wchan, int flags, int pri, int queue);
 void	sleepq_set_timeout_sbt(const void *wchan, sbintime_t sbt,
 	    sbintime_t pr, int flags);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202105100114.14A1EmJa028623>