git: f829268bcc89 - main - Remove TDF_DOING_SA

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Sat, 20 Aug 2022 17:35:03 UTC
The branch main has been updated by kib:

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

commit f829268bcc89bdede5e28044bfb6dc04fb0e9f8a
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2022-08-12 20:25:00 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-08-20 17:34:30 +0000

    Remove TDF_DOING_SA
    
    We cannot see a thread with the flag set in unsuspend, after we stopped
    doing SINGLE_ALLPROC from user processes.
    
    Reviewed by:    markj
    Tested by:      pho
    Sponsored by:   The FreeBSD Foundation
    MFC after:      2 weeks
    Differential revision:  https://reviews.freebsd.org/D36207
---
 sys/kern/kern_thread.c | 16 +++-------------
 sys/sys/proc.h         | 10 +++++-----
 2 files changed, 8 insertions(+), 18 deletions(-)

diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c
index bfd153844464..39bda326dc0d 100644
--- a/sys/kern/kern_thread.c
+++ b/sys/kern/kern_thread.c
@@ -1243,12 +1243,8 @@ 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;
@@ -1335,11 +1331,6 @@ stopme:
 		}
 	}
 	PROC_SUNLOCK(p);
-	if (mode == SINGLE_ALLPROC) {
-		thread_lock(td);
-		td->td_flags &= ~TDF_DOING_SA;
-		thread_unlock(td);
-	}
 	return (0);
 }
 
@@ -1626,11 +1617,10 @@ thread_unsuspend(struct proc *p)
 	if (!P_SHOULDSTOP(p)) {
                 FOREACH_THREAD_IN_PROC(p, td) {
 			thread_lock(td);
-			if (TD_IS_SUSPENDED(td) && (td->td_flags &
-			    TDF_DOING_SA) == 0) {
+			if (TD_IS_SUSPENDED(td))
 				wakeup_swapper |= thread_unsuspend_one(td, p,
 				    true);
-			} else
+			else
 				thread_unlock(td);
 		}
 	} else if (P_SHOULDSTOP(p) == P_STOPPED_SINGLE &&
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index 8c2aa6391d69..fb1553539b1c 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -470,15 +470,15 @@ 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_DOING_SA	0x00800000 /* Doing SINGLE_ALLPROC, do not unsuspend me */
+#define	TDF_UNUSED6	0x00800000 /* Available */
 #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 */
 #define	TDF_SCHED3	0x08000000 /* Reserved for scheduler private use */
-#define	TDF_UNUSED6	0x10000000 /* Available */
-#define	TDF_UNUSED7	0x20000000 /* Available */
-#define	TDF_UNUSED8	0x40000000 /* Available */
-#define	TDF_UNUSED9	0x80000000 /* Available */
+#define	TDF_UNUSED7	0x10000000 /* Available */
+#define	TDF_UNUSED8	0x20000000 /* Available */
+#define	TDF_UNUSED9	0x40000000 /* Available */
+#define	TDF_UNUSED10	0x80000000 /* Available */
 
 enum {
 	TDA_AST = 0,		/* Special: call all non-flagged AST handlers */