This just reverses the first if statement in the function so that
the code can be deindented by on level.
diff -b output:
@@ -2018,7 +2018,9 @@ single_thread_check_locked(struct proc *
SCHED_ASSERT_LOCKED();
- if (pr->ps_single != NULL && pr->ps_single != p) {
+ if (pr->ps_single == NULL || pr->ps_single == p)
+ return (0);
+
do {
/* if we're in deep, we need to unwind to the edge */
if (deep) {
@@ -2042,7 +2044,6 @@ single_thread_check_locked(struct proc *
p->p_stat = SSTOP;
mi_switch();
} while (pr->ps_single != NULL);
- }
return (0);
}
--
:wq Claudio
Index: kern/kern_sig.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_sig.c,v
retrieving revision 1.305
diff -u -p -r1.305 kern_sig.c
--- kern/kern_sig.c 10 Feb 2023 14:34:17 -0000 1.305
+++ kern/kern_sig.c 1 Apr 2023 09:18:18 -0000
@@ -2018,31 +2018,32 @@ single_thread_check_locked(struct proc *
SCHED_ASSERT_LOCKED();
- if (pr->ps_single != NULL && pr->ps_single != p) {
- do {
- /* if we're in deep, we need to unwind to the edge */
- if (deep) {
- if (pr->ps_flags & PS_SINGLEUNWIND)
- return (ERESTART);
- if (pr->ps_flags & PS_SINGLEEXIT)
- return (EINTR);
- }
+ if (pr->ps_single == NULL || pr->ps_single == p)
+ return (0);
- if (atomic_dec_int_nv(&pr->ps_singlecount) == 0)
- wakeup(&pr->ps_singlecount);
+ do {
+ /* if we're in deep, we need to unwind to the edge */
+ if (deep) {
+ if (pr->ps_flags & PS_SINGLEUNWIND)
+ return (ERESTART);
+ if (pr->ps_flags & PS_SINGLEEXIT)
+ return (EINTR);
+ }
- if (pr->ps_flags & PS_SINGLEEXIT) {
- SCHED_UNLOCK(s);
- KERNEL_LOCK();
- exit1(p, 0, 0, EXIT_THREAD_NOCHECK);
- /* NOTREACHED */
- }
+ if (atomic_dec_int_nv(&pr->ps_singlecount) == 0)
+ wakeup(&pr->ps_singlecount);
- /* not exiting and don't need to unwind, so suspend */
- p->p_stat = SSTOP;
- mi_switch();
- } while (pr->ps_single != NULL);
- }
+ if (pr->ps_flags & PS_SINGLEEXIT) {
+ SCHED_UNLOCK(s);
+ KERNEL_LOCK();
+ exit1(p, 0, 0, EXIT_THREAD_NOCHECK);
+ /* NOTREACHED */
+ }
+
+ /* not exiting and don't need to unwind, so suspend */
+ p->p_stat = SSTOP;
+ mi_switch();
+ } while (pr->ps_single != NULL);
return (0);
}