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