Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 Jun 2022 19:37:02 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: ea6a7512d299 - stable/13 - thread_unsuspend(): do not unuspend the suspended leader thread doing SINGLE_ALLPROC
Message-ID:  <202206241937.25OJb2Dm084338@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=ea6a7512d299eb75b411b80a2f649054dd332afd

commit ea6a7512d299eb75b411b80a2f649054dd332afd
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2022-06-08 01:27:30 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-06-24 14:45:46 +0000

    thread_unsuspend(): do not unuspend the suspended leader thread doing SINGLE_ALLPROC
    
    (cherry picked from commit 1b4701fe1e840f9ce5dae557b4dd99bda8a85735)
---
 sys/kern/kern_thread.c | 14 ++++++++++++--
 sys/sys/proc.h         |  2 +-
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c
index f10752cf682c..37aaa0b02bd0 100644
--- a/sys/kern/kern_thread.c
+++ b/sys/kern/kern_thread.c
@@ -1216,8 +1216,12 @@ thread_single(struct proc *p, int mode)
 		else
 			p->p_flag &= ~P_SINGLE_BOUNDARY;
 	}
-	if (mode == SINGLE_ALLPROC)
+	if (mode == SINGLE_ALLPROC) {
 		p->p_flag |= P_TOTAL_STOP;
+		thread_lock(td);
+		td->td_flags |= TDF_DOING_SA;
+		thread_unlock(td);
+	}
 	p->p_flag |= P_STOPPED_SINGLE;
 	PROC_SLOCK(p);
 	p->p_singlethread = td;
@@ -1304,6 +1308,11 @@ stopme:
 		}
 	}
 	PROC_SUNLOCK(p);
+	if (mode == SINGLE_ALLPROC) {
+		thread_lock(td);
+		td->td_flags &= ~TDF_DOING_SA;
+		thread_unlock(td);
+	}
 	return (0);
 }
 
@@ -1590,7 +1599,8 @@ thread_unsuspend(struct proc *p)
 	if (!P_SHOULDSTOP(p)) {
                 FOREACH_THREAD_IN_PROC(p, td) {
 			thread_lock(td);
-			if (TD_IS_SUSPENDED(td)) {
+			if (TD_IS_SUSPENDED(td) && (td->td_flags &
+			    TDF_DOING_SA) == 0) {
 				wakeup_swapper |= thread_unsuspend_one(td, p,
 				    true);
 			} else
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index f9d60a6b9935..26280998f00b 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -460,7 +460,7 @@ do {									\
 #define	TDF_THRWAKEUP	0x00100000 /* Libthr thread must not suspend itself. */
 #define	TDF_SEINTR	0x00200000 /* EINTR on stop attempts. */
 #define	TDF_SWAPINREQ	0x00400000 /* Swapin request due to wakeup. */
-#define	TDF_UNUSED23	0x00800000 /* --available-- */
+#define	TDF_DOING_SA	0x00800000 /* Doing SINGLE_ALLPROC, do not unsuspend me */
 #define	TDF_SCHED0	0x01000000 /* Reserved for scheduler private use */
 #define	TDF_SCHED1	0x02000000 /* Reserved for scheduler private use */
 #define	TDF_SCHED2	0x04000000 /* Reserved for scheduler private use */



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