From: claudio Date: Wed, 16 Aug 2023 07:55:52 +0000 (+0000) Subject: Move SCHED_LOCK after sleep_signal_check. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=3a16673c2ffffc4349bcd56176c191a0d83d7a57;p=openbsd Move SCHED_LOCK after sleep_signal_check. sleep_signal_check() is there to look for pending signals / single thread requests which were posted before sleep_setup() finished. Once p_stat is set to SSLEEP the wakeup and delivery of signals is taken care of by ptsignal and single_thread_set(). Moving the SCHED_LOCK further down allows to cleanup cursig() and to remove a SCHED_LOCK recursion in single_thread_check(). OK mpi@ --- diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index eaa726642a0..af0e0d7f4eb 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sig.c,v 1.312 2023/08/13 15:53:31 claudio Exp $ */ +/* $OpenBSD: kern_sig.c,v 1.313 2023/08/16 07:55:52 claudio Exp $ */ /* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */ /* @@ -1251,7 +1251,6 @@ cursig(struct proc *p, struct sigctx *sctx) { struct process *pr = p->p_p; int signum, mask, prop; - int dolock = (p->p_flag & P_SINTR) == 0; sigset_t ps_siglist; int s; @@ -1294,11 +1293,9 @@ cursig(struct proc *p, struct sigctx *sctx) single_thread_set(p, SINGLE_SUSPEND, 0); pr->ps_xsig = signum; - if (dolock) - SCHED_LOCK(s); + SCHED_LOCK(s); proc_stop(p, 1); - if (dolock) - SCHED_UNLOCK(s); + SCHED_UNLOCK(s); /* * re-take the signal before releasing @@ -1371,11 +1368,9 @@ cursig(struct proc *p, struct sigctx *sctx) prop & SA_TTYSTOP)) break; /* == ignore */ pr->ps_xsig = signum; - if (dolock) - SCHED_LOCK(s); + SCHED_LOCK(s); proc_stop(p, 1); - if (dolock) - SCHED_UNLOCK(s); + SCHED_UNLOCK(s); break; } else if (prop & SA_IGNORE) { /* diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index 591fa77a736..624bf52b2b5 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_synch.c,v 1.197 2023/08/14 08:33:24 mpi Exp $ */ +/* $OpenBSD: kern_synch.c,v 1.198 2023/08/16 07:55:52 claudio Exp $ */ /* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */ /* @@ -373,7 +373,6 @@ sleep_finish(int timo, int do_sleep) timeout_add(&p->p_sleep_to, timo); } - SCHED_LOCK(s); if (catch != 0) { /* * We put ourselves on the sleep queue and start our @@ -390,6 +389,7 @@ sleep_finish(int timo, int do_sleep) } } + SCHED_LOCK(s); /* * If the wakeup happens while going to sleep, p->p_wchan * will be NULL. In that case unwind immediately but still