svn commit: r366429 - in head/sys: kern sys

Rick Macklem rmacklem at uoguelph.ca
Sun Oct 4 21:06:16 UTC 2020


Mateusz Guzik wrote:
>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?
I did spot this slight difference between the initial version of sig_intr() and
this one.  At least w.r.t. copy_file_range(2), the call happens infrequently
enough that the overhead of acquiring the lock is not significant.

rick

On 10/4/20, Konstantin Belousov <kib at 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 at freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/svn-src-all
> To unsubscribe, send any mail to "svn-src-all-unsubscribe at freebsd.org"
>


--
Mateusz Guzik <mjguzik gmail.com>


More information about the svn-src-all mailing list