From owner-svn-src-head@freebsd.org Sun Oct 4 18:29:22 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 69BB442F489; Sun, 4 Oct 2020 18:29:22 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4C4C1Z0Wpvz42y0; Sun, 4 Oct 2020 18:29:21 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-wm1-x342.google.com with SMTP id d4so6363325wmd.5; Sun, 04 Oct 2020 11:29:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=t6C3bLUb6CfOEFtd5Uk7287XXTnqGan5mBo/6Em8/aI=; b=OR+WUWPbNNssFy/OnQNX/mtfvoWQElvvW1cTpApqizTqD7FDx/+l9EwiwBZkF/FGCm EbAxhi5Cih4QzXPbc9lHcs4Sf2IHfMnbKy1JDApmUB7iZwLQEBe39ZHbiJJtMBT8Td9N 79xV9LytMQLXjf19Yaip12i2k9rEdyQBriFeS3zHOlSFQmcFs4oSOTYy7LB2g/BgJLn8 dxaI2Tpwvf/v3SKavOillpV4MMcUcI5FcyytEZaln05haDxSSPCh9PtnsctREw8hrgHF NzBmlLMsSvgOJUrBsAJ+JlRHhiGBuA0fHW5UhGWr5Bei8Cug/muQn2aHTx4bRvKag0qC xebQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=t6C3bLUb6CfOEFtd5Uk7287XXTnqGan5mBo/6Em8/aI=; b=FI1liOLI/3UXUW5mLd/BLNTKvx1GkJs0XVqR4RfaW4Wqdu3twFADJYZogUVcczW++E SO8fp3QpR5btNHl/WEgwhDFGb40kBXRhJv39EiU6jbNhu6k6qEycNRjserzE2KGyHd6M bMBvC8f+nI5NzDWXG7yAGfOYdjI5Rs3sPnyWZoRRuGTDPd1agfJr+P7b04Tx1ztLePs/ //f3K3JenJzyZdudrhHsstnaWII/rKtCYoMS2Rc+vZRaJgRNC5sVD9WF8qJfD60z6WmY ty/Ml55V70uJsq8qD1znGOSnNSNDJnSdNiZ71fgjKeZzzi+jHJkqhu5zobGaPrijcUnr SVQQ== X-Gm-Message-State: AOAM530ZdMk/y8SK2Gi9NxratSFiA1RA2dfRKCUkTy5YTiA+YUhieq5l Vc8+IJvLSjEB5egeUUyBATMRLhLERN6l5ock30jVZ6hQ/04= X-Google-Smtp-Source: ABdhPJxKp3xwDlQZJFUHXGAOeuj3ePO6HA0lwJWzB7CFWR4OHZG4UtlJvXpHzXhE/9IADfD9LFO23p1wUlN6KC+wWdw= X-Received: by 2002:a1c:dfd4:: with SMTP id w203mr12881474wmg.178.1601836159806; Sun, 04 Oct 2020 11:29:19 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a05:6000:187:0:0:0:0 with HTTP; Sun, 4 Oct 2020 11:29:18 -0700 (PDT) In-Reply-To: <202010041633.094GXg4l044462@repo.freebsd.org> References: <202010041633.094GXg4l044462@repo.freebsd.org> From: Mateusz Guzik Date: Sun, 4 Oct 2020 20:29:18 +0200 Message-ID: Subject: Re: svn commit: r366429 - in head/sys: kern sys To: Konstantin Belousov Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4C4C1Z0Wpvz42y0 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Oct 2020 18:29:22 -0000 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 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