Date: Sun, 4 Oct 2020 20:29:18 +0200 From: Mateusz Guzik <mjguzik@gmail.com> To: Konstantin Belousov <kib@freebsd.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r366429 - in head/sys: kern sys Message-ID: <CAGudoHEhqHgSvich0CfDeg_RkpEVkuB=6zQTwfQLjsM5_wmKWQ@mail.gmail.com> In-Reply-To: <202010041633.094GXg4l044462@repo.freebsd.org> References: <202010041633.094GXg4l044462@repo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Why is the process lock always taken? It looks like both routines just check a thread-local flag, so perhaps this can get away without serializing this process-wide? On 10/4/20, Konstantin Belousov <kib@freebsd.org> wrote: > Author: kib > Date: Sun Oct 4 16:33:42 2020 > New Revision: 366429 > URL: https://svnweb.freebsd.org/changeset/base/366429 > > Log: > Add sig_intr(9). > > It gives the answer would the thread sleep according to current state > of signals and suspensions. Of course the answer is racy and allows > for false-negatives (no sleep when signal is delivered after process > lock is dropped). Also the answer might change due to signal > rescheduling among threads in multi-threaded process. > > Still it is the best approximation I can provide, to answering the > question was the thread interrupted. > > Reviewed by: markj > Tested by: pho, rmacklem > Sponsored by: The FreeBSD Foundation > MFC after: 2 weeks > Differential revision: https://reviews.freebsd.org/D26628 > > Modified: > head/sys/kern/kern_sig.c > head/sys/sys/signalvar.h > > Modified: head/sys/kern/kern_sig.c > ============================================================================== > --- head/sys/kern/kern_sig.c Sun Oct 4 16:30:05 2020 (r366428) > +++ head/sys/kern/kern_sig.c Sun Oct 4 16:33:42 2020 (r366429) > @@ -3204,6 +3204,24 @@ sig_ast_needsigchk(struct thread *td) > return (ret); > } > > +int > +sig_intr(void) > +{ > + struct thread *td; > + struct proc *p; > + int ret; > + > + td = curthread; > + p = td->td_proc; > + > + PROC_LOCK(p); > + ret = sig_ast_checksusp(td); > + if (ret == 0) > + ret = sig_ast_needsigchk(td); > + PROC_UNLOCK(p); > + return (ret); > +} > + > void > proc_wkilled(struct proc *p) > { > > Modified: head/sys/sys/signalvar.h > ============================================================================== > --- head/sys/sys/signalvar.h Sun Oct 4 16:30:05 2020 (r366428) > +++ head/sys/sys/signalvar.h Sun Oct 4 16:33:42 2020 (r366429) > @@ -408,6 +408,7 @@ int sig_ffs(sigset_t *set); > void sigfastblock_clear(struct thread *td); > void sigfastblock_fetch(struct thread *td); > void sigfastblock_setpend(struct thread *td, bool resched); > +int sig_intr(void); > void siginit(struct proc *p); > void signotify(struct thread *td); > void sigqueue_delete(struct sigqueue *queue, int sig); > _______________________________________________ > svn-src-all@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/svn-src-all > To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org" > -- Mateusz Guzik <mjguzik gmail.com>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAGudoHEhqHgSvich0CfDeg_RkpEVkuB=6zQTwfQLjsM5_wmKWQ>