From owner-svn-src-head@freebsd.org Sun Jun 26 00:53:32 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A1D00A79C02; Sun, 26 Jun 2016 00:53:32 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 677CD1EE8; Sun, 26 Jun 2016 00:53:32 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5Q0rVtB006579; Sun, 26 Jun 2016 00:53:31 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5Q0rVnx006577; Sun, 26 Jun 2016 00:53:31 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201606260053.u5Q0rVnx006577@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Sun, 26 Jun 2016 00:53:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302206 - in head: usr.bin/lastcomm/tests usr.sbin/sa/tests X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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, 26 Jun 2016 00:53:32 -0000 Author: asomers Date: Sun Jun 26 00:53:31 2016 New Revision: 302206 URL: https://svnweb.freebsd.org/changeset/base/302206 Log: Skip lastcomm and sa tests on unsupported architectures usr.bin/lastcom/tests/Makefile usr.sbin/sa/tests/Makefile Set allow_architectures appropriately. These tests depend on golden files that must be generated for each architecture, and haven't yet been generated for all of them. PR: 210566 PR: 204154 Reviewed by: ngie Approved by: re (gjb) MFC after: 4 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D6960 Modified: head/usr.bin/lastcomm/tests/Makefile head/usr.sbin/sa/tests/Makefile Modified: head/usr.bin/lastcomm/tests/Makefile ============================================================================== --- head/usr.bin/lastcomm/tests/Makefile Sat Jun 25 22:44:36 2016 (r302205) +++ head/usr.bin/lastcomm/tests/Makefile Sun Jun 26 00:53:31 2016 (r302206) @@ -3,6 +3,7 @@ PACKAGE= tests TAP_TESTS_SH= legacy_test +TEST_METADATA.legacy_test+= allowed_architectures="amd64 i386 sparc64" ${PACKAGE}FILES+= v1-amd64-acct.in ${PACKAGE}FILES+= v1-amd64.out Modified: head/usr.sbin/sa/tests/Makefile ============================================================================== --- head/usr.sbin/sa/tests/Makefile Sat Jun 25 22:44:36 2016 (r302205) +++ head/usr.sbin/sa/tests/Makefile Sun Jun 26 00:53:31 2016 (r302206) @@ -3,6 +3,7 @@ PACKAGE= tests TAP_TESTS_SH= legacy_test +TEST_METADATA.legacy_test+= allowed_architectures="amd64 i386 sparc64" ${PACKAGE}FILES+= v1-amd64-sav.in ${PACKAGE}FILES+= v1-amd64-sav.out From owner-svn-src-head@freebsd.org Sun Jun 26 04:18:45 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8AF55A79F41; Sun, 26 Jun 2016 04:18:45 +0000 (UTC) (envelope-from cy.schubert@komquats.com) Received: from smtp-out-no.shaw.ca (smtp-out-no.shaw.ca [64.59.134.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 405E71FAF; Sun, 26 Jun 2016 04:18:44 +0000 (UTC) (envelope-from cy.schubert@komquats.com) Received: from spqr.komquats.com ([96.50.22.10]) by shaw.ca with SMTP id H1WqbR9OyEWlrH1WrbLZUs; Sat, 25 Jun 2016 22:18:43 -0600 X-Authority-Analysis: v=2.2 cv=P7p4vWIu c=1 sm=1 tr=0 a=jvE2nwUzI0ECrNeyr98KWA==:117 a=jvE2nwUzI0ECrNeyr98KWA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=pD_ry4oyNxEA:10 a=NEAV23lmAAAA:8 a=KqpIfyakAAAA:8 a=YxBL1-UpAAAA:8 a=6I5d2MoRAAAA:8 a=lFXPonph261V7IbAemoA:9 a=Bn2pgwyD2vrAyMmN8A2t:22 a=gdFSoX5FBteAPHjtcXXc:22 a=Ia-lj3WSrqcvXOmTRaiG:22 a=IjZwj45LgO3ly-622nXo:22 Received: from slippy.cwsent.com (slippy [10.1.1.91]) by spqr.komquats.com (Postfix) with ESMTPS id 3ECE113753; Sat, 25 Jun 2016 21:18:40 -0700 (PDT) Received: from slippy (localhost [127.0.0.1]) by slippy.cwsent.com (8.15.2/8.15.2) with ESMTP id u5Q4Ico4060230; Sat, 25 Jun 2016 21:18:39 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Message-Id: <201606260418.u5Q4Ico4060230@slippy.cwsent.com> X-Mailer: exmh version 2.8.0 04/21/2012 with nmh-1.6 Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.cschubert.com/ To: Jilles Tjoelker cc: Konstantin Belousov , Daniel Eischen , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r302194 - head/lib/libthr/thread In-Reply-To: Message from Jilles Tjoelker of "Sun, 26 Jun 2016 00:33:38 +0200." <20160625223338.GA22802@stack.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sat, 25 Jun 2016 21:18:38 -0700 X-CMAE-Envelope: MS4wfGEg4iAgLr0LR+uL00awXkjT+GtycOUFPfTEpIE6aMAhzhIzp4SNmhQT+NgM36di8QrpT/dXaKYLjbJVpFD0Y/DVqhrzKlpK+2bt78rmW4ieaboqIcXN YZ+dOy3G0CPi5RJRjxH8TEcqPcbGmEh4QFanu+xocVK27vcGl5oTlI3PHyRLj1qD71giVLhB3kpyYL49N+kEk2VmtVU37ZV/3WmzXZOKfI5TE35p8bL1qzHZ SPuBhz60mkzXaVUo6SYGTKSli/I7baiohPZXx6jGX+DRPjD3PXeatUfOviV/QBGVMr6ITjWYA5KX8zHmVvTFo0gLYa8V4SJWMj9Xkxv8cJIMEoSCgoGdXCij 5MbKvBqM X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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, 26 Jun 2016 04:18:45 -0000 In message <20160625223338.GA22802@stack.nl>, Jilles Tjoelker writes: > On Sat, Jun 25, 2016 at 08:29:56PM +0300, Konstantin Belousov wrote: > > I already asked re for approval of the reversal and got it. But I am still > > hesitating doing the revert vs. returning EDEADLK for error-checking > > mutexes. > > > My initial mistake was reading the statement about PTHREAD_MUTEX_ERRORCHECK > > returning EDEADLK as the requirement for both functions. It was induced > > by reading the following code in samba: > > https://github.com/samba-team/samba/blob/master/lib/tdb/common/mutex.c#L928 > > I did extracted this into stand-alone test and checked that glibc does > > return EDEADLK in this case. BTW, if somebody has Solaris machine availabl > e > > to test this, I would be grateful. Code is available at > > https://www.kib.kiev.ua/kib/pshared/pthread_samba.c > > > I.e., plain revert would disable the only known to me consumer of the > > robust mutexes. The patch which I mailed last time, returns EDEADLK for > > trylock on ERRORCHECKed mutexes only. And I am tending toward glibc > > compatibility there, over the literal POSIX compliance, but I want to > > see the confirmation from the Klimenko' test first. > > To be bug-compatible with glibc, you'd need to return the wrong > [EDEADLK] error for robust errorcheck mutexes only. Robust > non-errorcheck and non-robust errorcheck mutexes return the correct > [EBUSY]. I have not checked PI and PP mutexes which probably use a > different code path. > > I'm not sure whether we should copy glibc's bug, but if we do it must be > documented in the man page. I'm not happy with it because the bug may > break applications written to the standard; at least, Samba developers > should be contacted first. I think there are advantages both in POSIX and glibc compatibility however I think it more important to be POSIX compatible. Having said that, there may be a compromise. Either setting an environment variable and/or setting a global variable (or call a function) to invoke a glibc-bug emulation mode. Thus linux-only applications could be ported with minimally invasive alterations. Either we break POSIX compatibility (and some existing applications) or we can implement the above which may satisfy both camps. -- Cheers, Cy Schubert FreeBSD UNIX: Web: http://www.FreeBSD.org The need of the many outweighs the greed of the few. From owner-svn-src-head@freebsd.org Sun Jun 26 08:20:34 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 536C0B74A73 for ; Sun, 26 Jun 2016 08:20:34 +0000 (UTC) (envelope-from junchoon@dec.sakura.ne.jp) Received: from dec.sakura.ne.jp (dec.sakura.ne.jp [210.188.226.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1E92E1F05 for ; Sun, 26 Jun 2016 08:20:33 +0000 (UTC) (envelope-from junchoon@dec.sakura.ne.jp) Received: from fortune.joker.local (123-48-23-227.dz.commufa.jp [123.48.23.227]) (authenticated bits=0) by dec.sakura.ne.jp (8.15.2/8.15.2/[SAKURA-WEB]/20080708) with ESMTPA id u5Q7l0bu034352 for ; Sun, 26 Jun 2016 16:47:01 +0900 (JST) (envelope-from junchoon@dec.sakura.ne.jp) Date: Sun, 26 Jun 2016 16:47:00 +0900 From: Tomoaki AOKI To: svn-src-head@freebsd.org Subject: Re: svn commit: r302194 - head/lib/libthr/thread Message-Id: <20160626164700.89b1f6cb6bd9f6a563f27ef3@dec.sakura.ne.jp> Organization: Junchoon corps X-Mailer: Sylpheed 3.5.0 (GTK+ 2.24.29; amd64-portbld-freebsd10.3) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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, 26 Jun 2016 08:20:34 -0000 > In message <20160625223338.GA22802 at stack.nl>, Jilles Tjoelker writes: >> On Sat, Jun 25, 2016 at 08:29:56PM +0300, Konstantin Belousov wrote: >> > I already asked re for approval of the reversal and got it. But I am still >> > hesitating doing the revert vs. returning EDEADLK for error-checking >> > mutexes. >> >> > My initial mistake was reading the statement about PTHREAD_MUTEX_ERRORCHECK >> > returning EDEADLK as the requirement for both functions. It was induced >> > by reading the following code in samba: >> > https://github.com/samba-team/samba/blob/master/lib/tdb/common/mutex.c#L928 >> > I did extracted this into stand-alone test and checked that glibc does >> > return EDEADLK in this case. BTW, if somebody has Solaris machine availabl >> e >> > to test this, I would be grateful. Code is available at >> > https://www.kib.kiev.ua/kib/pshared/pthread_samba.c >> >> > I.e., plain revert would disable the only known to me consumer of the >> > robust mutexes. The patch which I mailed last time, returns EDEADLK for >> > trylock on ERRORCHECKed mutexes only. And I am tending toward glibc >> > compatibility there, over the literal POSIX compliance, but I want to >> > see the confirmation from the Klimenko' test first. >> >> To be bug-compatible with glibc, you'd need to return the wrong >> [EDEADLK] error for robust errorcheck mutexes only. Robust >> non-errorcheck and non-robust errorcheck mutexes return the correct >> [EBUSY]. I have not checked PI and PP mutexes which probably use a >> different code path. >> >> I'm not sure whether we should copy glibc's bug, but if we do it must be >> documented in the man page. I'm not happy with it because the bug may >> break applications written to the standard; at least, Samba developers >> should be contacted first. > > I think there are advantages both in POSIX and glibc compatibility > however I think it more important to be POSIX compatible. Having said > that, there may be a compromise. Either setting an environment variable > and/or setting a global variable (or call a function) to invoke a > glibc-bug emulation mode. Thus linux-only applications could be ported > with minimally invasive alterations. > > Either we break POSIX compatibility (and some existing applications) or > we can implement the above which may satisfy both camps. It would be better fixing in ports and stay POSIX-compliant side. For linux binaries, they would use glibc introduced by one of linux_base-* port, so native libthr wouldn't be used. (Right?) The problematic cases would be ported softwares primarily for Linux. (Native binary) Of course, the best way is to be cared inside each upstream. (Check for glibc on configure stage, and do special care only if needed.) This case, we need no special care for this glibc quirks. For FreeBSD community, there would be... 1) Make new USES on ports framework for this regression. 2) Patch (via files/* or REINPLACE_CMD) on each port needed. (No special care is needed for libthr itself.) Unfortunately, 1) would be almost impossible without switching like you mentioned, as methods for checking return value / error codes should have tooo many patterns. :-( System-wide setting wouldn't help, as there's possibilities that, for example, console-kit (needs normal POSIX behaviour) and samba4 (needs glibc quirks) can coexist. IMHO, for per-binary settings, using ELF branding or alike to switch would be better than using environment variables. If we prefer environment variable, we'd need wrapper script especially for pkg users, causing possible performance penalty (would be significant for use-cases like filters). But using ELF branding, it's stored inside the binary itself. > > > -- > Cheers, > Cy Schubert > FreeBSD UNIX: Web: http://www.FreeBSD.org > > The need of the many outweighs the greed of the few. -- Tomoaki AOKI junchoon@dec.sakura.ne.jp From owner-svn-src-head@freebsd.org Sun Jun 26 12:41:04 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2AB9DB81ED6; Sun, 26 Jun 2016 12:41:04 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EDB7921F3; Sun, 26 Jun 2016 12:41:03 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5QCf34E064968; Sun, 26 Jun 2016 12:41:03 GMT (envelope-from tuexen@FreeBSD.org) Received: (from tuexen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5QCf3N9064967; Sun, 26 Jun 2016 12:41:03 GMT (envelope-from tuexen@FreeBSD.org) Message-Id: <201606261241.u5QCf3N9064967@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tuexen set sender to tuexen@FreeBSD.org using -f From: Michael Tuexen Date: Sun, 26 Jun 2016 12:41:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302207 - head/sys/netinet X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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, 26 Jun 2016 12:41:04 -0000 Author: tuexen Date: Sun Jun 26 12:41:02 2016 New Revision: 302207 URL: https://svnweb.freebsd.org/changeset/base/302207 Log: This patch fixes a locking bug when a send() call blocks on an SCTP socket and the association is aborted by the peer. Approved by: re (kib) MFC after: 1 week Modified: head/sys/netinet/sctp_output.c Modified: head/sys/netinet/sctp_output.c ============================================================================== --- head/sys/netinet/sctp_output.c Sun Jun 26 00:53:31 2016 (r302206) +++ head/sys/netinet/sctp_output.c Sun Jun 26 12:41:02 2016 (r302207) @@ -13136,6 +13136,7 @@ sctp_lower_sosend(struct socket *so, asoc, stcb->asoc.total_output_queue_size); } if (stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) { + SOCKBUF_UNLOCK(&so->so_snd); goto out_unlocked; } inqueue_bytes = stcb->asoc.total_output_queue_size - (stcb->asoc.chunks_on_out_queue * sizeof(struct sctp_data_chunk)); From owner-svn-src-head@freebsd.org Sun Jun 26 14:18:30 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 26384B812FC; Sun, 26 Jun 2016 14:18:30 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D1A502BAF; Sun, 26 Jun 2016 14:18:29 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5QEIT9B002963; Sun, 26 Jun 2016 14:18:29 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5QEITxu002962; Sun, 26 Jun 2016 14:18:29 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201606261418.u5QEITxu002962@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 26 Jun 2016 14:18:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302210 - head/sys/fs/nfsclient X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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, 26 Jun 2016 14:18:30 -0000 Author: kib Date: Sun Jun 26 14:18:28 2016 New Revision: 302210 URL: https://svnweb.freebsd.org/changeset/base/302210 Log: Clean other flags in ncl_inactive, only. Add comment explaining why other flags should be unset. Suggested and reviewed by: rmacklem Sponsored by: The FreeBSD Foundation MFC after: 12 days Approved by: re (gjb) Modified: head/sys/fs/nfsclient/nfs_clnode.c Modified: head/sys/fs/nfsclient/nfs_clnode.c ============================================================================== --- head/sys/fs/nfsclient/nfs_clnode.c Sun Jun 26 13:18:03 2016 (r302209) +++ head/sys/fs/nfsclient/nfs_clnode.c Sun Jun 26 14:18:28 2016 (r302210) @@ -206,7 +206,7 @@ ncl_releasesillyrename(struct vnode *vp, ASSERT_VOP_ELOCKED(vp, "releasesillyrename"); np = VTONFS(vp); - mtx_lock(&np->n_mtx); + mtx_assert(&np->n_mtx, MA_OWNED); if (vp->v_type != VDIR) { sp = np->n_sillyrename; np->n_sillyrename = NULL; @@ -224,14 +224,13 @@ ncl_releasesillyrename(struct vnode *vp, taskqueue_enqueue(taskqueue_thread, &sp->s_task); mtx_lock(&np->n_mtx); } - np->n_flag &= NMODIFIED; - mtx_unlock(&np->n_mtx); } int ncl_inactive(struct vop_inactive_args *ap) { struct vnode *vp = ap->a_vp; + struct nfsnode *np; boolean_t retv; if (NFS_ISV4(vp) && vp->v_type == VREG) { @@ -254,7 +253,17 @@ ncl_inactive(struct vop_inactive_args *a } } + np = VTONFS(vp); + mtx_lock(&np->n_mtx); ncl_releasesillyrename(vp, ap->a_td); + + /* + * NMODIFIED means that there might be dirty/stale buffers + * associated with the NFS vnode. None of the other flags are + * meaningful after the vnode is unused. + */ + np->n_flag &= NMODIFIED; + mtx_unlock(&np->n_mtx); return (0); } @@ -275,7 +284,9 @@ ncl_reclaim(struct vop_reclaim_args *ap) if (nfs_reclaim_p != NULL) nfs_reclaim_p(ap); + mtx_lock(&np->n_mtx); ncl_releasesillyrename(vp, ap->a_td); + mtx_unlock(&np->n_mtx); /* * Destroy the vm object and flush associated pages. From owner-svn-src-head@freebsd.org Sun Jun 26 14:44:03 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 52A69B81BDE; Sun, 26 Jun 2016 14:44:03 +0000 (UTC) (envelope-from novel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 13C1C2A33; Sun, 26 Jun 2016 14:44:03 +0000 (UTC) (envelope-from novel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5QEi2Rb013831; Sun, 26 Jun 2016 14:44:02 GMT (envelope-from novel@FreeBSD.org) Received: (from novel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5QEi11O013827; Sun, 26 Jun 2016 14:44:01 GMT (envelope-from novel@FreeBSD.org) Message-Id: <201606261444.u5QEi11O013827@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: novel set sender to novel@FreeBSD.org using -f From: Roman Bogorodskiy Date: Sun, 26 Jun 2016 14:44:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302211 - in head/usr.sbin: bhyve bhyveload X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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, 26 Jun 2016 14:44:03 -0000 Author: novel (ports committer) Date: Sun Jun 26 14:44:01 2016 New Revision: 302211 URL: https://svnweb.freebsd.org/changeset/base/302211 Log: bhyve: improve memory size documentation A couple of minor memory size option related nits: - use common name 'memsize' (instead of 'max-size' or just 'size') - bhyve: update usage with memsize unit suffix, drop legacy "MB" unit - bhyveload: update usage with memsize unit suffix - bhyve(8): document default size - bhyveload(8): use memsize formatting like it's done in bhyve(8) Reviewed by: wblock, grehan Approved by: re (kib), wblock, grehan Differential Revision: https://reviews.freebsd.org/D6952 Modified: head/usr.sbin/bhyve/bhyve.8 head/usr.sbin/bhyve/bhyverun.c head/usr.sbin/bhyveload/bhyveload.8 head/usr.sbin/bhyveload/bhyveload.c Modified: head/usr.sbin/bhyve/bhyve.8 ============================================================================== --- head/usr.sbin/bhyve/bhyve.8 Sun Jun 26 14:18:28 2016 (r302210) +++ head/usr.sbin/bhyve/bhyve.8 Sun Jun 26 14:44:01 2016 (r302211) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 18, 2016 +.Dd June 24, 2016 .Dt BHYVE 8 .Os .Sh NAME @@ -36,7 +36,7 @@ .Op Fl c Ar numcpus .Op Fl g Ar gdbport .Op Fl l Ar lpcdev Ns Op , Ns Ar conf -.Op Fl m Ar size Ns Op Ar K|k|M|m|G|g|T|t +.Op Fl m Ar memsize Ns Op Ar K|k|M|m|G|g|T|t .Op Fl p Ar vcpu:hostcpu .Op Fl s Ar slot,emulation Ns Op , Ns Ar conf .Op Fl U Ar uuid @@ -105,7 +105,7 @@ and .Ar com2 and the boot ROM device .Ar bootrom . -.It Fl m Ar size Ns Op Ar K|k|M|m|G|g|T|t +.It Fl m Ar memsize Ns Op Ar K|k|M|m|G|g|T|t Guest physical memory size in bytes. This must be the same size that was given to .Xr bhyveload 8 . @@ -114,6 +114,9 @@ The size argument may be suffixed with o or lower case) to indicate a multiple of kilobytes, megabytes, gigabytes, or terabytes. If no suffix is given, the value is assumed to be in megabytes. +.Pp +.Ar memsize +defaults to 256M. .It Fl p Ar vcpu:hostcpu Pin guest's virtual CPU .Em vcpu Modified: head/usr.sbin/bhyve/bhyverun.c ============================================================================== --- head/usr.sbin/bhyve/bhyverun.c Sun Jun 26 14:18:28 2016 (r302210) +++ head/usr.sbin/bhyve/bhyverun.c Sun Jun 26 14:44:01 2016 (r302211) @@ -125,7 +125,7 @@ usage(int code) fprintf(stderr, "Usage: %s [-abehuwxACHPSWY] [-c vcpus] [-g ] [-l ]\n" - " %*s [-m mem] [-p vcpu:hostcpu] [-s ] [-U uuid] \n" + " %*s [-m memsize[K|k|M|m|G|g|T|t]] [-p vcpu:hostcpu] [-s ] [-U uuid] \n" " -a: local apic is in xAPIC mode (deprecated)\n" " -A: create ACPI tables\n" " -c: # cpus (default 1)\n" @@ -135,7 +135,7 @@ usage(int code) " -h: help\n" " -H: vmexit from the guest on hlt\n" " -l: LPC device configuration\n" - " -m: memory size in MB\n" + " -m: memory size\n" " -p: pin 'vcpu' to 'hostcpu'\n" " -P: vmexit from the guest on pause\n" " -s: PCI slot config\n" Modified: head/usr.sbin/bhyveload/bhyveload.8 ============================================================================== --- head/usr.sbin/bhyveload/bhyveload.8 Sun Jun 26 14:18:28 2016 (r302210) +++ head/usr.sbin/bhyveload/bhyveload.8 Sun Jun 26 14:44:01 2016 (r302211) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 26, 2016 +.Dd June 24, 2016 .Dt BHYVELOAD 8 .Os .Sh NAME @@ -42,7 +42,7 @@ guest inside a bhyve virtual machine .Op Fl e Ar name=value .Op Fl h Ar host-path .Op Fl l Ar os-loader -.Op Fl m Ar mem-size +.Op Fl m Ar memsize Ns Op Ar K|k|M|m|G|g|T|t .Ar vmname .Sh DESCRIPTION .Nm @@ -103,16 +103,12 @@ will use which presents a standard .Fx loader. -.It Fl m Ar mem-size Xo -.Sm off -.Op Cm K | k | M | m | G | g | T | t -.Xc -.Sm on -.Ar mem-size +.It Fl m Ar memsize Ns Op Ar K|k|M|m|G|g|T|t +.Ar memsize is the amount of memory allocated to the guest. .Pp The -.Ar mem-size +.Ar memsize argument may be suffixed with one of .Cm K , .Cm M , @@ -123,9 +119,8 @@ or Kilobytes, Megabytes, Gigabytes or Terabytes respectively. .Pp -The default value of -.Ar mem-size -is 256M. +.Ar memsize +defaults to 256M. .It Fl C Include guest memory in the core file when .Nm Modified: head/usr.sbin/bhyveload/bhyveload.c ============================================================================== --- head/usr.sbin/bhyveload/bhyveload.c Sun Jun 26 14:18:28 2016 (r302210) +++ head/usr.sbin/bhyveload/bhyveload.c Sun Jun 26 14:44:01 2016 (r302211) @@ -648,7 +648,7 @@ usage(void) fprintf(stderr, "usage: %s [-S][-c ] [-d ] [-e ]\n" - " %*s [-h ] [-m mem-size] \n", + " %*s [-h ] [-m memsize[K|k|M|m|G|g|T|t]] \n", progname, (int)strlen(progname), ""); exit(1); From owner-svn-src-head@freebsd.org Sun Jun 26 15:54:46 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 03A8CB81B5F; Sun, 26 Jun 2016 15:54:46 +0000 (UTC) (envelope-from bjkfbsd@gmail.com) Received: from mail-oi0-x231.google.com (mail-oi0-x231.google.com [IPv6:2607:f8b0:4003:c06::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BD61E2D2E; Sun, 26 Jun 2016 15:54:45 +0000 (UTC) (envelope-from bjkfbsd@gmail.com) Received: by mail-oi0-x231.google.com with SMTP id r2so173003083oih.2; Sun, 26 Jun 2016 08:54:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=NJRI5u5l8RfW7vkOuNqOA7D3bLJ/iORq9gJ/gcb2n5g=; b=JeIolOZWsEjSBrdnli7lXgnw+BLYvVWeJG2zaprGpvElz3SAHZZlr4HvttBdf/uQCW UMyJJtXRUDeD2Jd5+TGo77OGoQkpWtwxosZkJBDizZTDkm1zrKHYf9A2ban7hRFR8UlJ mEDVvx2yfklaGGm3IwhevAvywXBeyQiJuz2M3+dH02K/qmyciubmiIPOSRXvptEp1ARi Zleb/THbndnuvAFn9diU6JIqfyAclmFVq9ukqWYjL7/g8Zkxblfhk9xdOwfYMqwUep5Z cMDgIiQe06QwR8hTUa+Tr4OK978cTv9+/GvGyd+XuYBCypqWGuPldJ2BAhHysLXoxrQy RqAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=NJRI5u5l8RfW7vkOuNqOA7D3bLJ/iORq9gJ/gcb2n5g=; b=JmV43JH0uZ9rH15GPampgJV2qgFFcK664WoMFJMjdy45U95kHt23omknjLXhFP1rPm cST00Cvo16n1lY+Dhc+GStzXV6qDYZ4ATE/EgnhJ3RlrOrTAShFGIIpjBSBB/UbTzTMU Mc1z8I0wcF/Fzpzs2Dd3FQdb9MEnCP8jonWVvEqmi3xSjC2Ux3IxZh/qyBiVJuRcPyD5 HEKisz+bSRT2kdO+STWmfzhot2L4cPRLteIiWdxYwhrxL03qLEUcFUzzCuIfYDKLHsDK 5Hp9fg+2pZHtABo3eLcmpv+U6Gor2h/EXci1Dk6VrRpcrhFZ8a4ZSlvnp2erF4bJdDv1 UFzA== X-Gm-Message-State: ALyK8tJdggwJwnPYsnMoNHd0PV9FcKxlR6JUHPUF6D7mPP5vD+Kpk0FT35T03w1EcvbU34wFsIzQtjnuWVtwmw== X-Received: by 10.157.22.179 with SMTP id c48mr9080352ote.35.1466956484941; Sun, 26 Jun 2016 08:54:44 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.12.37 with HTTP; Sun, 26 Jun 2016 08:54:44 -0700 (PDT) In-Reply-To: <201606261418.u5QEITxu002962@repo.freebsd.org> References: <201606261418.u5QEITxu002962@repo.freebsd.org> From: Benjamin Kaduk Date: Sun, 26 Jun 2016 10:54:44 -0500 Message-ID: Subject: Re: svn commit: r302210 - head/sys/fs/nfsclient 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-Content-Filtered-By: Mailman/MimeDel 2.1.22 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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, 26 Jun 2016 15:54:46 -0000 On Sun, Jun 26, 2016 at 9:18 AM, Konstantin Belousov wrote: > Author: kib > Date: Sun Jun 26 14:18:28 2016 > New Revision: 302210 > URL: https://svnweb.freebsd.org/changeset/base/302210 > > Log: > Clean other flags in ncl_inactive, only. Add comment explaining why > other > flags should be unset. > [...] > + > + /* > + * NMODIFIED means that there might be dirty/stale buffers > + * associated with the NFS vnode. None of the other flags are > + * meaningful after the vnode is unused. > + */ > + np->n_flag &= NMODIFIED; > Maybe I am confused, but the commit message reads like this should be '=', not '&='. -Ben > + mtx_unlock(&np->n_mtx); > return (0); > } > > From owner-svn-src-head@freebsd.org Sun Jun 26 16:09:12 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 18F0EB81E2B; Sun, 26 Jun 2016 16:09:12 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7F48323ED; Sun, 26 Jun 2016 16:09:11 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u5QG96pF036420 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Sun, 26 Jun 2016 19:09:06 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u5QG96pF036420 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id u5QG96Oi036419; Sun, 26 Jun 2016 19:09:06 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 26 Jun 2016 19:09:06 +0300 From: Konstantin Belousov To: Benjamin Kaduk Cc: "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Subject: Re: svn commit: r302210 - head/sys/fs/nfsclient Message-ID: <20160626160906.GC38613@kib.kiev.ua> References: <201606261418.u5QEITxu002962@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.1 (2016-04-27) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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, 26 Jun 2016 16:09:12 -0000 On Sun, Jun 26, 2016 at 10:54:44AM -0500, Benjamin Kaduk wrote: > On Sun, Jun 26, 2016 at 9:18 AM, Konstantin Belousov > wrote: > > > Author: kib > > Date: Sun Jun 26 14:18:28 2016 > > New Revision: 302210 > > URL: https://svnweb.freebsd.org/changeset/base/302210 > > > > Log: > > Clean other flags in ncl_inactive, only. Add comment explaining why > > other > > flags should be unset. > > > [...] > > > + > > + /* > > + * NMODIFIED means that there might be dirty/stale buffers > > + * associated with the NFS vnode. None of the other flags are > > + * meaningful after the vnode is unused. > > + */ > > + np->n_flag &= NMODIFIED; > > > > Maybe I am confused, but the commit message reads like this should be '=', > not '&='. The line clears all flags except NMODIFIED, and lefts the NMODIFIED flag intact (it could have been not set there, after all). From owner-svn-src-head@freebsd.org Sun Jun 26 16:28:16 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 662ADB82F25; Sun, 26 Jun 2016 16:28:16 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CC3CD2B8F; Sun, 26 Jun 2016 16:28:15 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u5QGSBBk041132 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Sun, 26 Jun 2016 19:28:11 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u5QGSBBk041132 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id u5QGSBt1041131; Sun, 26 Jun 2016 19:28:11 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 26 Jun 2016 19:28:11 +0300 From: Konstantin Belousov To: Jilles Tjoelker Cc: Daniel Eischen , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r302194 - head/lib/libthr/thread Message-ID: <20160626162811.GD38613@kib.kiev.ua> References: <201606251130.u5PBUeGC001988@repo.freebsd.org> <20160625171440.GA19698@stack.nl> <20160625172956.GE38613@kib.kiev.ua> <20160625223338.GA22802@stack.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160625223338.GA22802@stack.nl> User-Agent: Mutt/1.6.1 (2016-04-27) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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, 26 Jun 2016 16:28:16 -0000 On Sun, Jun 26, 2016 at 12:33:38AM +0200, Jilles Tjoelker wrote: > To be bug-compatible with glibc, you'd need to return the wrong > [EDEADLK] error for robust errorcheck mutexes only. Robust > non-errorcheck and non-robust errorcheck mutexes return the correct > [EBUSY]. I have not checked PI and PP mutexes which probably use a > different code path. Yes, you are right, I read the glibc code wrong way. > I'm not sure whether we should copy glibc's bug, but if we do it must be > documented in the man page. I'm not happy with it because the bug may > break applications written to the standard; at least, Samba developers > should be contacted first. I tried to send the mail to samba tech list yesterday, but it did not pass. Seems that today I managed it. Still, it is pity that the only real-world consumer of the robust interface cannot exercise our implementation due to this minor issue. From owner-svn-src-head@freebsd.org Sun Jun 26 16:38:44 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 38AFEB81101; Sun, 26 Jun 2016 16:38:44 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EED812001; Sun, 26 Jun 2016 16:38:43 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5QGchts056128; Sun, 26 Jun 2016 16:38:43 GMT (envelope-from tuexen@FreeBSD.org) Received: (from tuexen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5QGchex056127; Sun, 26 Jun 2016 16:38:43 GMT (envelope-from tuexen@FreeBSD.org) Message-Id: <201606261638.u5QGchex056127@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tuexen set sender to tuexen@FreeBSD.org using -f From: Michael Tuexen Date: Sun, 26 Jun 2016 16:38:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302212 - head/sys/netinet X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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, 26 Jun 2016 16:38:44 -0000 Author: tuexen Date: Sun Jun 26 16:38:42 2016 New Revision: 302212 URL: https://svnweb.freebsd.org/changeset/base/302212 Log: This patch fixes two bugs related to the SCTP message recovery for messages which have been put on the send queue: * Do not report any DATA or I-DATA chunk padding. * Correctly deal with the I-DATA chunk header instead of the DATA chunk header when the I-DATA extension is used. Approved by: re (kib) MFC after: 1 week Modified: head/sys/netinet/sctputil.c Modified: head/sys/netinet/sctputil.c ============================================================================== --- head/sys/netinet/sctputil.c Sun Jun 26 14:44:01 2016 (r302211) +++ head/sys/netinet/sctputil.c Sun Jun 26 16:38:42 2016 (r302212) @@ -2933,7 +2933,8 @@ sctp_notify_send_failed(struct sctp_tcb struct sctp_send_failed *ssf; struct sctp_send_failed_event *ssfe; struct sctp_queued_to_read *control; - int length; + struct sctp_chunkhdr *chkhdr; + int notifhdr_len, chk_len, chkhdr_len, padding_len, payload_len; if ((stcb == NULL) || (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVSENDFAILEVNT) && @@ -2942,27 +2943,49 @@ sctp_notify_send_failed(struct sctp_tcb return; } if (sctp_stcb_is_feature_on(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVNSENDFAILEVNT)) { - length = sizeof(struct sctp_send_failed_event); + notifhdr_len = sizeof(struct sctp_send_failed_event); } else { - length = sizeof(struct sctp_send_failed); + notifhdr_len = sizeof(struct sctp_send_failed); } - m_notify = sctp_get_mbuf_for_msg(length, 0, M_NOWAIT, 1, MT_DATA); + m_notify = sctp_get_mbuf_for_msg(notifhdr_len, 0, M_NOWAIT, 1, MT_DATA); if (m_notify == NULL) /* no space left */ return; - SCTP_BUF_LEN(m_notify) = 0; + SCTP_BUF_LEN(m_notify) = notifhdr_len; + if (stcb->asoc.idata_supported) { + chkhdr_len = sizeof(struct sctp_idata_chunk); + } else { + chkhdr_len = sizeof(struct sctp_data_chunk); + } + /* Use some defaults in case we can't access the chunk header */ + if (chk->send_size >= chkhdr_len) { + payload_len = chk->send_size - chkhdr_len; + } else { + payload_len = 0; + } + padding_len = 0; + if (chk->data != NULL) { + chkhdr = mtod(chk->data, struct sctp_chunkhdr *); + if (chkhdr != NULL) { + chk_len = ntohs(chkhdr->chunk_length); + if ((chk_len >= chkhdr_len) && + (chk->send_size >= chk_len) && + (chk->send_size - chk_len < 4)) { + padding_len = chk->send_size - chk_len; + payload_len = chk->send_size - chkhdr_len - padding_len; + } + } + } if (sctp_stcb_is_feature_on(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVNSENDFAILEVNT)) { ssfe = mtod(m_notify, struct sctp_send_failed_event *); - memset(ssfe, 0, length); + memset(ssfe, 0, notifhdr_len); ssfe->ssfe_type = SCTP_SEND_FAILED_EVENT; if (sent) { ssfe->ssfe_flags = SCTP_DATA_SENT; } else { ssfe->ssfe_flags = SCTP_DATA_UNSENT; } - length += chk->send_size; - length -= sizeof(struct sctp_data_chunk); - ssfe->ssfe_length = length; + ssfe->ssfe_length = (uint32_t) (notifhdr_len + payload_len); ssfe->ssfe_error = error; /* not exactly what the user sent in, but should be close :) */ ssfe->ssfe_info.snd_sid = chk->rec.data.stream_number; @@ -2971,39 +2994,33 @@ sctp_notify_send_failed(struct sctp_tcb ssfe->ssfe_info.snd_context = chk->rec.data.context; ssfe->ssfe_info.snd_assoc_id = sctp_get_associd(stcb); ssfe->ssfe_assoc_id = sctp_get_associd(stcb); - SCTP_BUF_LEN(m_notify) = sizeof(struct sctp_send_failed_event); } else { ssf = mtod(m_notify, struct sctp_send_failed *); - memset(ssf, 0, length); + memset(ssf, 0, notifhdr_len); ssf->ssf_type = SCTP_SEND_FAILED; if (sent) { ssf->ssf_flags = SCTP_DATA_SENT; } else { ssf->ssf_flags = SCTP_DATA_UNSENT; } - length += chk->send_size; - length -= sizeof(struct sctp_data_chunk); - ssf->ssf_length = length; + ssf->ssf_length = (uint32_t) (notifhdr_len + payload_len); ssf->ssf_error = error; /* not exactly what the user sent in, but should be close :) */ - bzero(&ssf->ssf_info, sizeof(ssf->ssf_info)); ssf->ssf_info.sinfo_stream = chk->rec.data.stream_number; - ssf->ssf_info.sinfo_ssn = chk->rec.data.stream_seq; + ssf->ssf_info.sinfo_ssn = (uint16_t) chk->rec.data.stream_seq; ssf->ssf_info.sinfo_flags = chk->rec.data.rcv_flags; ssf->ssf_info.sinfo_ppid = chk->rec.data.payloadtype; ssf->ssf_info.sinfo_context = chk->rec.data.context; ssf->ssf_info.sinfo_assoc_id = sctp_get_associd(stcb); ssf->ssf_assoc_id = sctp_get_associd(stcb); - SCTP_BUF_LEN(m_notify) = sizeof(struct sctp_send_failed); } - if (chk->data) { - /* - * trim off the sctp chunk header(it should be there) - */ - if (chk->send_size >= sizeof(struct sctp_data_chunk)) { - m_adj(chk->data, sizeof(struct sctp_data_chunk)); + if (chk->data != NULL) { + /* Trim off the sctp chunk header (it should be there) */ + if (chk->send_size == chkhdr_len + payload_len + padding_len) { + m_adj(chk->data, chkhdr_len); + m_adj(chk->data, -padding_len); sctp_mbuf_crush(chk->data); - chk->send_size -= sizeof(struct sctp_data_chunk); + chk->send_size -= (chkhdr_len + padding_len); } } SCTP_BUF_NEXT(m_notify) = chk->data; @@ -3048,7 +3065,7 @@ sctp_notify_send_failed2(struct sctp_tcb struct sctp_send_failed *ssf; struct sctp_send_failed_event *ssfe; struct sctp_queued_to_read *control; - int length; + int notifhdr_len; if ((stcb == NULL) || (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVSENDFAILEVNT) && @@ -3057,23 +3074,22 @@ sctp_notify_send_failed2(struct sctp_tcb return; } if (sctp_stcb_is_feature_on(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVNSENDFAILEVNT)) { - length = sizeof(struct sctp_send_failed_event); + notifhdr_len = sizeof(struct sctp_send_failed_event); } else { - length = sizeof(struct sctp_send_failed); + notifhdr_len = sizeof(struct sctp_send_failed); } - m_notify = sctp_get_mbuf_for_msg(length, 0, M_NOWAIT, 1, MT_DATA); + m_notify = sctp_get_mbuf_for_msg(notifhdr_len, 0, M_NOWAIT, 1, MT_DATA); if (m_notify == NULL) { /* no space left */ return; } - SCTP_BUF_LEN(m_notify) = 0; + SCTP_BUF_LEN(m_notify) = notifhdr_len; if (sctp_stcb_is_feature_on(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVNSENDFAILEVNT)) { ssfe = mtod(m_notify, struct sctp_send_failed_event *); - memset(ssfe, 0, length); + memset(ssfe, 0, notifhdr_len); ssfe->ssfe_type = SCTP_SEND_FAILED_EVENT; ssfe->ssfe_flags = SCTP_DATA_UNSENT; - length += sp->length; - ssfe->ssfe_length = length; + ssfe->ssfe_length = (uint32_t) (notifhdr_len + sp->length); ssfe->ssfe_error = error; /* not exactly what the user sent in, but should be close :) */ ssfe->ssfe_info.snd_sid = sp->stream; @@ -3086,14 +3102,12 @@ sctp_notify_send_failed2(struct sctp_tcb ssfe->ssfe_info.snd_context = sp->context; ssfe->ssfe_info.snd_assoc_id = sctp_get_associd(stcb); ssfe->ssfe_assoc_id = sctp_get_associd(stcb); - SCTP_BUF_LEN(m_notify) = sizeof(struct sctp_send_failed_event); } else { ssf = mtod(m_notify, struct sctp_send_failed *); - memset(ssf, 0, length); + memset(ssf, 0, notifhdr_len); ssf->ssf_type = SCTP_SEND_FAILED; ssf->ssf_flags = SCTP_DATA_UNSENT; - length += sp->length; - ssf->ssf_length = length; + ssf->ssf_length = (uint32_t) (notifhdr_len + sp->length); ssf->ssf_error = error; /* not exactly what the user sent in, but should be close :) */ ssf->ssf_info.sinfo_stream = sp->stream; @@ -3107,7 +3121,6 @@ sctp_notify_send_failed2(struct sctp_tcb ssf->ssf_info.sinfo_context = sp->context; ssf->ssf_info.sinfo_assoc_id = sctp_get_associd(stcb); ssf->ssf_assoc_id = sctp_get_associd(stcb); - SCTP_BUF_LEN(m_notify) = sizeof(struct sctp_send_failed); } SCTP_BUF_NEXT(m_notify) = sp->data; From owner-svn-src-head@freebsd.org Sun Jun 26 17:00:00 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E7678B81641; Sun, 26 Jun 2016 17:00:00 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AB24B2903; Sun, 26 Jun 2016 17:00:00 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5QGxxxV063618; Sun, 26 Jun 2016 16:59:59 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5QGxx6K063617; Sun, 26 Jun 2016 16:59:59 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201606261659.u5QGxx6K063617@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sun, 26 Jun 2016 16:59:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302213 - head/sys/compat/linux X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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, 26 Jun 2016 17:00:01 -0000 Author: dchagin Date: Sun Jun 26 16:59:59 2016 New Revision: 302213 URL: https://svnweb.freebsd.org/changeset/base/302213 Log: Fix a bug introduced in r283433. [1] Remove unneeded sockaddr conversion before kern_recvit() call as the from argument is used to record result (the source address of the received message) only. [2] In Linux the type of msg_namelen member of struct msghdr is signed but native msg_namelen has a unsigned type (socklen_t). So use the proper storage to fetch fromlen from userspace and than check the user supplied value and return EINVAL if it is less than 0 as a Linux do. Reported by: Thomas Mueller [1] Reviewed by: kib@ Approved by: re (gjb, kib) MFC after: 3 days Modified: head/sys/compat/linux/linux_socket.c Modified: head/sys/compat/linux/linux_socket.c ============================================================================== --- head/sys/compat/linux/linux_socket.c Sun Jun 26 16:38:42 2016 (r302212) +++ head/sys/compat/linux/linux_socket.c Sun Jun 26 16:59:59 2016 (r302213) @@ -1054,18 +1054,16 @@ linux_recvfrom(struct thread *td, struct { struct msghdr msg; struct iovec aiov; - int error; + int error, fromlen; if (PTRIN(args->fromlen) != NULL) { - error = copyin(PTRIN(args->fromlen), &msg.msg_namelen, - sizeof(msg.msg_namelen)); - if (error != 0) - return (error); - - error = linux_to_bsd_sockaddr((struct sockaddr *)PTRIN(args->from), - msg.msg_namelen); + error = copyin(PTRIN(args->fromlen), &fromlen, + sizeof(fromlen)); if (error != 0) return (error); + if (fromlen < 0) + return (EINVAL); + msg.msg_namelen = fromlen; } else msg.msg_namelen = 0; From owner-svn-src-head@freebsd.org Sun Jun 26 18:43:44 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 43E00B8185F; Sun, 26 Jun 2016 18:43:44 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F1349227D; Sun, 26 Jun 2016 18:43:43 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5QIhheE012291; Sun, 26 Jun 2016 18:43:43 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5QIhhnx012289; Sun, 26 Jun 2016 18:43:43 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201606261843.u5QIhhnx012289@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Sun, 26 Jun 2016 18:43:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302214 - head/sys/powerpc/aim X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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, 26 Jun 2016 18:43:44 -0000 Author: nwhitehorn Date: Sun Jun 26 18:43:42 2016 New Revision: 302214 URL: https://svnweb.freebsd.org/changeset/base/302214 Log: Enter 64-bit mode as early as possible in the 64-bit PowerPC boot sequence. Most of the effect of setting MSR[SF] is that the CPU will stop ignoring the high 32 bits of registers containing addresses in load/store instructions. As such, the kernel was setting it only when it began to need access to high memory. MSR[SF] also affects the operation of some conditional instructions, however, and so setting it at late times could subtly break code at very early times. This fixes use of the FDT mode in loader, and FDT boot more generally, on 64-bit PowerPC systems. Hardware provided by: IBM LTC Approved by: re (kib) Modified: head/sys/powerpc/aim/aim_machdep.c head/sys/powerpc/aim/locore64.S Modified: head/sys/powerpc/aim/aim_machdep.c ============================================================================== --- head/sys/powerpc/aim/aim_machdep.c Sun Jun 26 16:59:59 2016 (r302213) +++ head/sys/powerpc/aim/aim_machdep.c Sun Jun 26 18:43:42 2016 (r302214) @@ -179,17 +179,6 @@ aim_cpu_init(vm_offset_t toc) trap_offset = 0; cacheline_warn = 0; - #ifdef __powerpc64__ - /* - * Switch to 64-bit mode, if the bootloader didn't, before we start - * using memory beyond what the bootloader might have set up. - * Guaranteed not to cause an implicit branch since we either (a) - * started with a 32-bit bootloader below 4 GB or (b) were already in - * 64-bit mode, making this a no-op. - */ - mtmsrd(mfmsr() | PSL_SF); - #endif - /* Various very early CPU fix ups */ switch (mfpvr() >> 16) { /* Modified: head/sys/powerpc/aim/locore64.S ============================================================================== --- head/sys/powerpc/aim/locore64.S Sun Jun 26 16:59:59 2016 (r302213) +++ head/sys/powerpc/aim/locore64.S Sun Jun 26 18:43:42 2016 (r302214) @@ -76,6 +76,14 @@ btext: */ .text ASENTRY_NOPROF(__start) + /* Set 64-bit mode if not yet set before branching to C */ + mfmsr %r20 + li %r21,1 + insrdi %r20,%r21,1,0 + mtmsrd %r20 + isync + nop /* Make this block a multiple of 8 bytes */ + /* Set up the TOC pointer */ b 0f .align 3 From owner-svn-src-head@freebsd.org Sun Jun 26 18:52:19 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D66FCB81A69; Sun, 26 Jun 2016 18:52:19 +0000 (UTC) (envelope-from bjkfbsd@gmail.com) Received: from mail-oi0-x232.google.com (mail-oi0-x232.google.com [IPv6:2607:f8b0:4003:c06::232]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9B7962819; Sun, 26 Jun 2016 18:52:19 +0000 (UTC) (envelope-from bjkfbsd@gmail.com) Received: by mail-oi0-x232.google.com with SMTP id f189so175915298oig.3; Sun, 26 Jun 2016 11:52:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=GjYdoo1ReWzbKmF6F5sJf4dgYIGagw/fkXSPA441vfc=; b=uAP/zN0LV+g1JhWctymmfTRFT7YhZcwC7wMnzYdHufDVNRz6C95r9BzGd1MF3sskP8 cf5BBPcDHjTOn9/SLHfI9IUrttYgN6IGLZErDMZWuJD3SwoxlY8HAKBDrP91YFAeU58m bFgBfJQi6zQ4JCsQrO5UnPfrYOqKWiEL11UxYAqN7JYaaWi+2sDNqBKUTVoc4Ai6XRuB 18RFRvQvDsJH2UjXDXmeXUxkx3xTT7AGwcB+RDMnJkndkKxsKRU0Dxk5wU5W87WmLg6F DnzZ62HZBepHDnsIe5/OeRlkE2WOtPyECtVq9BTKSW+Bb3OxXS/IE3Xb/7hRBB0EWD5E +TBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=GjYdoo1ReWzbKmF6F5sJf4dgYIGagw/fkXSPA441vfc=; b=ByeBuarHVI0ssZXEX+HPdZnEPPF9Ojs9UKCxlFbBHiBtnMTwQGqSGXfSuuaJQbAh+p 0xGOKsLgvdDAqz+NV+BSGCME01QreOQd+vrXvurgjOntkjkks9cKxnjhJGi3225SfKos w+9qaVv9EAtm5e2zsYa/Rxdnfa773LeEbYj13o8IQnPYi9FdTTwuv5HDYvqqimOZSRp2 063PJRoQL2Adt/XzKBHz+v9b2ctbHaudfXzm3sF8iSNgO2eedfTeXR70Rl+8s6nKsydB d2eW3Io/UUwm5W7O8QNamu+6hoatAjFKA5iIeH+oOS+aMMyNqMZYcl52OOFob9wyGIBt OWDw== X-Gm-Message-State: ALyK8tLmbTw8PQbZUg//q5kdCQxeaS7Xnm67B6JjUxpKQkcL5OaIcPhx9wOyIb1zhBTvMxvIY0F0yYo8l9Yemw== X-Received: by 10.157.44.145 with SMTP id p17mr8501746otb.184.1466967138906; Sun, 26 Jun 2016 11:52:18 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.12.37 with HTTP; Sun, 26 Jun 2016 11:52:18 -0700 (PDT) In-Reply-To: References: <201604241053.u3OAr0bn072180@repo.freebsd.org> From: Benjamin Kaduk Date: Sun, 26 Jun 2016 13:52:18 -0500 Message-ID: Subject: Re: svn commit: r298537 - head/etc/rc.d To: Jens Schweikhardt Cc: "svn-src-head@freebsd.org" , Jan Beich , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.22 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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, 26 Jun 2016 18:52:19 -0000 On Sun, Apr 24, 2016 at 12:01 PM, Jan Beich wrote: > Jens Schweikhardt writes: > > > - parenthesize the "case" string for symmetry and improved > > search for matching paren (e.g. with vi's %) > [...] > > case "${state}" in > > - [oO][nN]) > > + ([oO][nN]) > > swapon /dev/zvol/${name} > > ;; > > For style consistency is more important. Why this case is special unlike > the rest of rc.d/* or rc.subr ? > Coming in quite late, I agree. I think this part should be reverted. -Ben From owner-svn-src-head@freebsd.org Sun Jun 26 20:07:26 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 108C5B8185B; Sun, 26 Jun 2016 20:07:26 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DF8CC2AA3; Sun, 26 Jun 2016 20:07:25 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5QK7PTu042641; Sun, 26 Jun 2016 20:07:25 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5QK7OG0042634; Sun, 26 Jun 2016 20:07:24 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201606262007.u5QK7OG0042634@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 26 Jun 2016 20:07:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302215 - in head/sys: fs/fifofs kern sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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, 26 Jun 2016 20:07:26 -0000 Author: kib Date: Sun Jun 26 20:07:24 2016 New Revision: 302215 URL: https://svnweb.freebsd.org/changeset/base/302215 Log: Rewrite sigdeferstop(9) and sigallowstop(9) into more flexible framework allowing to set the suspension policy for the dynamic block. Extend the currently possible policies of stopping on interruptible sleeps and ignoring such sleeps by two more: do not suspend at interruptible sleeps, but interrupt them with either EINTR or ERESTART. Reviewed by: jilles Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Approved by: re (gjb) Modified: head/sys/fs/fifofs/fifo_vnops.c head/sys/kern/kern_sig.c head/sys/kern/kern_thread.c head/sys/kern/subr_trap.c head/sys/sys/mount.h head/sys/sys/proc.h head/sys/sys/signalvar.h Modified: head/sys/fs/fifofs/fifo_vnops.c ============================================================================== --- head/sys/fs/fifofs/fifo_vnops.c Sun Jun 26 18:43:42 2016 (r302214) +++ head/sys/fs/fifofs/fifo_vnops.c Sun Jun 26 20:07:24 2016 (r302215) @@ -194,11 +194,10 @@ fifo_open(ap) if ((ap->a_mode & FREAD) && fip->fi_writers == 0) { gen = fip->fi_wgen; VOP_UNLOCK(vp, 0); - stops_deferred = sigallowstop(); + stops_deferred = sigdeferstop(SIGDEFERSTOP_OFF); error = msleep(&fip->fi_readers, PIPE_MTX(fpipe), PDROP | PCATCH | PSOCK, "fifoor", 0); - if (stops_deferred) - sigdeferstop(); + sigallowstop(stops_deferred); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); if (error != 0 && gen == fip->fi_wgen) { fip->fi_readers--; @@ -222,11 +221,10 @@ fifo_open(ap) if ((ap->a_mode & FWRITE) && fip->fi_readers == 0) { gen = fip->fi_rgen; VOP_UNLOCK(vp, 0); - stops_deferred = sigallowstop(); + stops_deferred = sigdeferstop(SIGDEFERSTOP_OFF); error = msleep(&fip->fi_writers, PIPE_MTX(fpipe), PDROP | PCATCH | PSOCK, "fifoow", 0); - if (stops_deferred) - sigdeferstop(); + sigallowstop(stops_deferred); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); if (error != 0 && gen == fip->fi_rgen) { fip->fi_writers--; Modified: head/sys/kern/kern_sig.c ============================================================================== --- head/sys/kern/kern_sig.c Sun Jun 26 18:43:42 2016 (r302214) +++ head/sys/kern/kern_sig.c Sun Jun 26 20:07:24 2016 (r302215) @@ -2596,41 +2596,81 @@ tdsigcleanup(struct thread *td) } +static int +sigdeferstop_curr_flags(int cflags) +{ + + MPASS((cflags & (TDF_SEINTR | TDF_SERESTART)) == 0 || + (cflags & TDF_SBDRY) != 0); + return (cflags & (TDF_SBDRY | TDF_SEINTR | TDF_SERESTART)); +} + /* - * Defer the delivery of SIGSTOP for the current thread. Returns true - * if stops were deferred and false if they were already deferred. + * Defer the delivery of SIGSTOP for the current thread, according to + * the requested mode. Returns previous flags, which must be restored + * by sigallowstop(). + * + * TDF_SBDRY, TDF_SEINTR, and TDF_SERESTART flags are only set and + * cleared by the current thread, which allow the lock-less read-only + * accesses below. */ int -sigdeferstop(void) +sigdeferstop(int mode) { struct thread *td; + int cflags, nflags; td = curthread; - if (td->td_flags & TDF_SBDRY) - return (0); - thread_lock(td); - td->td_flags |= TDF_SBDRY; - thread_unlock(td); - return (1); + cflags = sigdeferstop_curr_flags(td->td_flags); + switch (mode) { + case SIGDEFERSTOP_NOP: + nflags = cflags; + break; + case SIGDEFERSTOP_OFF: + nflags = 0; + break; + case SIGDEFERSTOP_SILENT: + nflags = (cflags | TDF_SBDRY) & ~(TDF_SEINTR | TDF_SERESTART); + break; + case SIGDEFERSTOP_EINTR: + nflags = (cflags | TDF_SBDRY | TDF_SEINTR) & ~TDF_SERESTART; + break; + case SIGDEFERSTOP_ERESTART: + nflags = (cflags | TDF_SBDRY | TDF_SERESTART) & ~TDF_SEINTR; + break; + default: + panic("sigdeferstop: invalid mode %x", mode); + break; + } + if (cflags != nflags) { + thread_lock(td); + td->td_flags = (td->td_flags & ~cflags) | nflags; + thread_unlock(td); + } + return (cflags); } /* - * Permit the delivery of SIGSTOP for the current thread. This does - * not immediately suspend if a stop was posted. Instead, the thread - * will suspend either via ast() or a subsequent interruptible sleep. + * Restores the STOP handling mode, typically permitting the delivery + * of SIGSTOP for the current thread. This does not immediately + * suspend if a stop was posted. Instead, the thread will suspend + * either via ast() or a subsequent interruptible sleep. */ -int -sigallowstop(void) +void +sigallowstop(int prev) { struct thread *td; - int prev; + int cflags; + KASSERT((prev & ~(TDF_SBDRY | TDF_SEINTR | TDF_SERESTART)) == 0, + ("sigallowstop: incorrect previous mode %x", prev)); td = curthread; - thread_lock(td); - prev = (td->td_flags & TDF_SBDRY) != 0; - td->td_flags &= ~TDF_SBDRY; - thread_unlock(td); - return (prev); + cflags = sigdeferstop_curr_flags(td->td_flags); + if (cflags != prev) { + thread_lock(td); + td->td_flags = (td->td_flags & ~cflags) | prev; + thread_unlock(td); + } } /* Modified: head/sys/kern/kern_thread.c ============================================================================== --- head/sys/kern/kern_thread.c Sun Jun 26 18:43:42 2016 (r302214) +++ head/sys/kern/kern_thread.c Sun Jun 26 20:07:24 2016 (r302215) @@ -894,7 +894,7 @@ thread_suspend_check(int return_instead) { struct thread *td; struct proc *p; - int wakeup_swapper; + int wakeup_swapper, r; td = curthread; p = td->td_proc; @@ -927,7 +927,21 @@ thread_suspend_check(int return_instead) if ((td->td_flags & TDF_SBDRY) != 0) { KASSERT(return_instead, ("TDF_SBDRY set for unsafe thread_suspend_check")); - return (0); + switch (td->td_flags & (TDF_SEINTR | TDF_SERESTART)) { + case 0: + r = 0; + break; + case TDF_SEINTR: + r = EINTR; + break; + case TDF_SERESTART: + r = ERESTART; + break; + default: + panic("both TDF_SEINTR and TDF_SERESTART"); + break; + } + return (r); } /* Modified: head/sys/kern/subr_trap.c ============================================================================== --- head/sys/kern/subr_trap.c Sun Jun 26 18:43:42 2016 (r302214) +++ head/sys/kern/subr_trap.c Sun Jun 26 20:07:24 2016 (r302215) @@ -160,7 +160,7 @@ userret(struct thread *td, struct trapfr ("userret: Returning with with pinned thread")); KASSERT(td->td_vp_reserv == 0, ("userret: Returning while holding vnode reservation")); - KASSERT((td->td_flags & TDF_SBDRY) == 0, + KASSERT((td->td_flags & (TDF_SBDRY | TDF_SEINTR | TDF_SERESTART)) == 0, ("userret: Returning with stop signals deferred")); KASSERT(td->td_su == NULL, ("userret: Returning with SU cleanup request not handled")); Modified: head/sys/sys/mount.h ============================================================================== --- head/sys/sys/mount.h Sun Jun 26 18:43:42 2016 (r302214) +++ head/sys/sys/mount.h Sun Jun 26 20:07:24 2016 (r302215) @@ -653,15 +653,15 @@ vfs_statfs_t __vfs_statfs; #define VFS_PROLOGUE(MP) do { \ struct mount *mp__; \ - int _enable_stops; \ + int _prev_stops; \ \ mp__ = (MP); \ - _enable_stops = (mp__ != NULL && \ - (mp__->mnt_vfc->vfc_flags & VFCF_SBDRY) && sigdeferstop()) + _prev_stops = sigdeferstop((mp__ != NULL && \ + (mp__->mnt_vfc->vfc_flags & VFCF_SBDRY) != 0) ? \ + SIGDEFERSTOP_SILENT : SIGDEFERSTOP_NOP); #define VFS_EPILOGUE(MP) \ - if (_enable_stops) \ - sigallowstop(); \ + sigallowstop(_prev_stops); \ } while (0) #define VFS_MOUNT(MP) ({ \ Modified: head/sys/sys/proc.h ============================================================================== --- head/sys/sys/proc.h Sun Jun 26 18:43:42 2016 (r302214) +++ head/sys/sys/proc.h Sun Jun 26 20:07:24 2016 (r302215) @@ -395,9 +395,9 @@ do { \ #define TDF_NEEDRESCHED 0x00010000 /* Thread needs to yield. */ #define TDF_NEEDSIGCHK 0x00020000 /* Thread may need signal delivery. */ #define TDF_NOLOAD 0x00040000 /* Ignore during load avg calculations. */ -#define TDF_UNUSED19 0x00080000 /* --available-- */ +#define TDF_SERESTART 0x00080000 /* ERESTART on stop attempts. */ #define TDF_THRWAKEUP 0x00100000 /* Libthr thread must not suspend itself. */ -#define TDF_UNUSED21 0x00200000 /* --available-- */ +#define TDF_SEINTR 0x00200000 /* EINTR on stop attempts. */ #define TDF_SWAPINREQ 0x00400000 /* Swapin request due to wakeup. */ #define TDF_UNUSED23 0x00800000 /* --available-- */ #define TDF_SCHED0 0x01000000 /* Reserved for scheduler private use */ Modified: head/sys/sys/signalvar.h ============================================================================== --- head/sys/sys/signalvar.h Sun Jun 26 18:43:42 2016 (r302214) +++ head/sys/sys/signalvar.h Sun Jun 26 20:07:24 2016 (r302215) @@ -325,9 +325,21 @@ extern struct mtx sigio_lock; #define SIGPROCMASK_PROC_LOCKED 0x0002 #define SIGPROCMASK_PS_LOCKED 0x0004 +/* + * Modes for sigdeferstop(). Manages behaviour of + * thread_suspend_check() in the region delimited by + * sigdeferstop()/sigallowstop(). Must be restored to + * SIGDEFERSTOP_OFF before returning to userspace. + */ +#define SIGDEFERSTOP_NOP 0 /* continue doing whatever is done now */ +#define SIGDEFERSTOP_OFF 1 /* stop ignoring STOPs */ +#define SIGDEFERSTOP_SILENT 2 /* silently ignore STOPs */ +#define SIGDEFERSTOP_EINTR 3 /* ignore STOPs, return EINTR */ +#define SIGDEFERSTOP_ERESTART 4 /* ignore STOPs, return ERESTART */ + int cursig(struct thread *td); -int sigdeferstop(void); -int sigallowstop(void); +int sigdeferstop(int mode); +void sigallowstop(int prev); void execsigs(struct proc *p); void gsignal(int pgid, int sig, ksiginfo_t *ksi); void killproc(struct proc *p, char *why); From owner-svn-src-head@freebsd.org Sun Jun 26 20:08:43 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 840A1B818DB; Sun, 26 Jun 2016 20:08:43 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 45D462C24; Sun, 26 Jun 2016 20:08:43 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5QK8gXQ042732; Sun, 26 Jun 2016 20:08:42 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5QK8gTx042729; Sun, 26 Jun 2016 20:08:42 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201606262008.u5QK8gTx042729@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 26 Jun 2016 20:08:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302216 - in head/sys: kern nlm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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, 26 Jun 2016 20:08:43 -0000 Author: kib Date: Sun Jun 26 20:08:42 2016 New Revision: 302216 URL: https://svnweb.freebsd.org/changeset/base/302216 Log: When sleeping waiting for either local or remote advisory lock, interrupt sleeps with the ERESTART on the suspension attempts. Otherwise, single-threading requests are deferred until the locks are granted for NFS files, which causes hangs. When retrying local registration of the remotely-granted adv lock, allow full suspension and check for suspension, for usual reasons. Reported by: markj, pho Reviewed by: jilles Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Approved by: re (gjb) Modified: head/sys/kern/kern_lockf.c head/sys/nlm/nlm_advlock.c head/sys/nlm/nlm_prot_impl.c Modified: head/sys/kern/kern_lockf.c ============================================================================== --- head/sys/kern/kern_lockf.c Sun Jun 26 20:07:24 2016 (r302215) +++ head/sys/kern/kern_lockf.c Sun Jun 26 20:08:42 2016 (r302216) @@ -1378,7 +1378,7 @@ lf_setlock(struct lockf *state, struct l void **cookiep) { static char lockstr[] = "lockf"; - int priority, error; + int error, priority, stops_deferred; #ifdef LOCKF_DEBUG if (lockf_debug & 1) @@ -1466,7 +1466,9 @@ lf_setlock(struct lockf *state, struct l } lock->lf_refs++; + stops_deferred = sigdeferstop(SIGDEFERSTOP_ERESTART); error = sx_sleep(lock, &state->ls_lock, priority, lockstr, 0); + sigallowstop(stops_deferred); if (lf_free_lock(lock)) { error = EDOOFUS; goto out; Modified: head/sys/nlm/nlm_advlock.c ============================================================================== --- head/sys/nlm/nlm_advlock.c Sun Jun 26 20:07:24 2016 (r302215) +++ head/sys/nlm/nlm_advlock.c Sun Jun 26 20:08:42 2016 (r302216) @@ -697,7 +697,8 @@ nlm_record_lock(struct vnode *vp, int op { struct vop_advlockasync_args a; struct flock newfl; - int error; + struct proc *p; + int error, stops_deferred; a.a_vp = vp; a.a_id = NULL; @@ -730,7 +731,12 @@ nlm_record_lock(struct vnode *vp, int op * return EDEADLK. */ pause("nlmdlk", 1); - /* XXXKIB allow suspend */ + p = curproc; + stops_deferred = sigdeferstop(SIGDEFERSTOP_OFF); + PROC_LOCK(p); + thread_suspend_check(0); + PROC_UNLOCK(p); + sigallowstop(stops_deferred); } else if (error == EINTR) { /* * lf_purgelocks() might wake up the lock Modified: head/sys/nlm/nlm_prot_impl.c ============================================================================== --- head/sys/nlm/nlm_prot_impl.c Sun Jun 26 20:07:24 2016 (r302215) +++ head/sys/nlm/nlm_prot_impl.c Sun Jun 26 20:08:42 2016 (r302216) @@ -1356,7 +1356,7 @@ int nlm_wait_lock(void *handle, int timo) { struct nlm_waiting_lock *nw = handle; - int error; + int error, stops_deferred; /* * If the granted message arrived before we got here, @@ -1364,8 +1364,11 @@ nlm_wait_lock(void *handle, int timo) */ mtx_lock(&nlm_global_lock); error = 0; - if (nw->nw_waiting) + if (nw->nw_waiting) { + stops_deferred = sigdeferstop(SIGDEFERSTOP_ERESTART); error = msleep(nw, &nlm_global_lock, PCATCH, "nlmlock", timo); + sigallowstop(stops_deferred); + } TAILQ_REMOVE(&nlm_waiting_locks, nw, nw_link); if (error) { /* From owner-svn-src-head@freebsd.org Mon Jun 27 01:29:20 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 82603A79B56; Mon, 27 Jun 2016 01:29:20 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 205682124; Mon, 27 Jun 2016 01:29:20 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5R1TJ0Q062139; Mon, 27 Jun 2016 01:29:19 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5R1TIHg062125; Mon, 27 Jun 2016 01:29:18 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201606270129.u5R1TIHg062125@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Mon, 27 Jun 2016 01:29:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302221 - in head: contrib/file contrib/file/doc contrib/file/magic contrib/file/magic/Magdir contrib/file/src lib/libmagic X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Mon, 27 Jun 2016 01:29:20 -0000 Author: delphij Date: Mon Jun 27 01:29:17 2016 New Revision: 302221 URL: https://svnweb.freebsd.org/changeset/base/302221 Log: MFV r302218: file 5.28. Relnotes: yes MFC after: 2 weeks Approved by: re (gjb) Added: head/contrib/file/magic/Magdir/ber - copied unchanged from r302218, vendor/file/dist/magic/Magdir/ber head/contrib/file/magic/Magdir/coverage - copied unchanged from r302218, vendor/file/dist/magic/Magdir/coverage head/contrib/file/magic/Magdir/pc88 - copied unchanged from r302218, vendor/file/dist/magic/Magdir/pc88 head/contrib/file/magic/Magdir/pc98 - copied unchanged from r302218, vendor/file/dist/magic/Magdir/pc98 head/contrib/file/magic/Magdir/x68000 - copied unchanged from r302218, vendor/file/dist/magic/Magdir/x68000 Deleted: head/contrib/file/src/magic.h Modified: head/contrib/file/ChangeLog head/contrib/file/config.h.in head/contrib/file/configure head/contrib/file/configure.ac head/contrib/file/doc/file.man head/contrib/file/magic/Magdir/c-lang head/contrib/file/magic/Magdir/console head/contrib/file/magic/Magdir/database head/contrib/file/magic/Magdir/elf head/contrib/file/magic/Magdir/msdos head/contrib/file/magic/Magdir/msx head/contrib/file/magic/Magdir/perl head/contrib/file/magic/Makefile.am head/contrib/file/magic/Makefile.in head/contrib/file/src/Makefile.am head/contrib/file/src/Makefile.in head/contrib/file/src/apprentice.c head/contrib/file/src/cdf.c head/contrib/file/src/compress.c head/contrib/file/src/der.c head/contrib/file/src/file.c head/contrib/file/src/softmagic.c head/lib/libmagic/Makefile head/lib/libmagic/config.h Directory Properties: head/contrib/file/ (props changed) Modified: head/contrib/file/ChangeLog ============================================================================== --- head/contrib/file/ChangeLog Mon Jun 27 01:17:00 2016 (r302220) +++ head/contrib/file/ChangeLog Mon Jun 27 01:29:17 2016 (r302221) @@ -1,3 +1,15 @@ +2016-06-13 19:40 Christos Zoulas + + * release 5.28 + * fix leak on allocation failure + +2016-06-01 1:20 Christos Zoulas + + * PR/555: Avoid overflow for offset > nbytes + * PR/550: Segv on DER parsing: + - use the correct variable for length + - set offset to 0 on failure. + 2016-05-13 12:00 Christos Zoulas * release 5.27 Modified: head/contrib/file/config.h.in ============================================================================== --- head/contrib/file/config.h.in Mon Jun 27 01:17:00 2016 (r302220) +++ head/contrib/file/config.h.in Mon Jun 27 01:29:17 2016 (r302221) @@ -328,6 +328,9 @@ # endif #endif +/* Enable zlib compression support */ +#undef ZLIBSUPPORT + /* Enable large inode numbers on Mac OS X 10.5. */ #ifndef _DARWIN_USE_64_BIT_INODE # define _DARWIN_USE_64_BIT_INODE 1 Modified: head/contrib/file/configure ============================================================================== --- head/contrib/file/configure Mon Jun 27 01:17:00 2016 (r302220) +++ head/contrib/file/configure Mon Jun 27 01:29:17 2016 (r302221) @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for file 5.27. +# Generated by GNU Autoconf 2.69 for file 5.28. # # Report bugs to . # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='file' PACKAGE_TARNAME='file' -PACKAGE_VERSION='5.27' -PACKAGE_STRING='file 5.27' +PACKAGE_VERSION='5.28' +PACKAGE_STRING='file 5.28' PACKAGE_BUGREPORT='christos@astron.com' PACKAGE_URL='' @@ -766,6 +766,7 @@ enable_option_checking enable_silent_rules enable_elf enable_elf_core +enable_zlib enable_fsect_man5 enable_dependency_tracking enable_static @@ -1327,7 +1328,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures file 5.27 to adapt to many kinds of systems. +\`configure' configures file 5.28 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1397,7 +1398,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of file 5.27:";; + short | recursive ) echo "Configuration of file 5.28:";; esac cat <<\_ACEOF @@ -1409,6 +1410,7 @@ Optional Features: --disable-silent-rules verbose build output (undo: "make V=0") --disable-elf disable builtin ELF support --disable-elf-core disable ELF core file support + --disable-zlib disable zlib compression support [default=auto] --enable-fsect-man5 enable file formats in man section 5 --enable-dependency-tracking do not reject slow dependency extractors @@ -1507,7 +1509,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -file configure 5.27 +file configure 5.28 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2163,7 +2165,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by file $as_me 5.27, which was +It was created by file $as_me 5.28, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3029,7 +3031,7 @@ fi # Define the identity of the package. PACKAGE='file' - VERSION='5.27' + VERSION='5.28' cat >>confdefs.h <<_ACEOF @@ -3218,6 +3220,16 @@ $as_echo "#define ELFCORE 1" >>confdefs. fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for zlib support" >&5 +$as_echo_n "checking for zlib support... " >&6; } +# Check whether --enable-zlib was given. +if test "${enable_zlib+set}" = set; then : + enableval=$enable_zlib; +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_zlib" >&5 +$as_echo "$enable_zlib" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file formats in man section 5" >&5 $as_echo_n "checking for file formats in man section 5... " >&6; } # Check whether --enable-fsect-man5 was given. @@ -12812,7 +12824,8 @@ fi done -for ac_header in zlib.h +if test "$enable_zlib" != "no"; then + for ac_header in zlib.h do : ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default" if test "x$ac_cv_header_zlib_h" = xyes; then : @@ -12824,6 +12837,7 @@ fi done +fi ac_fn_c_check_type "$LINENO" "sig_t" "ac_cv_type_sig_t" " #ifdef HAVE_SIGNAL_H #include @@ -14400,7 +14414,8 @@ fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gzopen in -lz" >&5 +if test "$enable_zlib" != "no"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gzopen in -lz" >&5 $as_echo_n "checking for gzopen in -lz... " >&6; } if ${ac_cv_lib_z_gzopen+:} false; then : $as_echo_n "(cached) " >&6 @@ -14445,6 +14460,7 @@ _ACEOF fi +fi if test "$MINGW" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for regexec in -lgnurx" >&5 $as_echo_n "checking for regexec in -lgnurx... " >&6; } @@ -14504,6 +14520,16 @@ else fi +if test "$enable_zlib" = "yes"; then + if test "$ac_cv_header_zlib_h$ac_cv_lib_z_gzopen" != "yesyes"; then + as_fn_error $? "zlib support requested but not found" "$LINENO" 5 + fi +elif test "$ac_cv_header_zlib_h$ac_cv_lib_z_gzopen" = "yesyes"; then + +$as_echo "#define ZLIBSUPPORT 1" >>confdefs.h + +fi + ac_config_files="$ac_config_files Makefile src/Makefile magic/Makefile tests/Makefile doc/Makefile python/Makefile" cat >confcache <<\_ACEOF @@ -15049,7 +15075,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_wri # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by file $as_me 5.27, which was +This file was extended by file $as_me 5.28, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -15115,7 +15141,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -file config.status 5.27 +file config.status 5.28 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Modified: head/contrib/file/configure.ac ============================================================================== --- head/contrib/file/configure.ac Mon Jun 27 01:17:00 2016 (r302220) +++ head/contrib/file/configure.ac Mon Jun 27 01:29:17 2016 (r302221) @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_INIT([file],[5.27],[christos@astron.com]) +AC_INIT([file],[5.28],[christos@astron.com]) AM_INIT_AUTOMAKE([subdir-objects foreign]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) @@ -34,6 +34,11 @@ fi], [ AC_DEFINE([ELFCORE], 1, [Define for ELF core file support]) ]) +AC_MSG_CHECKING(for zlib support) +AC_ARG_ENABLE(zlib, +[AS_HELP_STRING([--disable-zlib], [disable zlib compression support @<:@default=auto@:>@])]) +AC_MSG_RESULT($enable_zlib) + AC_MSG_CHECKING(for file formats in man section 5) AC_ARG_ENABLE(fsect-man5, [ --enable-fsect-man5 enable file formats in man section 5], @@ -84,7 +89,9 @@ AC_CHECK_HEADERS(stdint.h fcntl.h locale AC_CHECK_HEADERS(stddef.h utime.h wchar.h wctype.h limits.h) AC_CHECK_HEADERS(getopt.h err.h xlocale.h signal.h) AC_CHECK_HEADERS(sys/mman.h sys/stat.h sys/types.h sys/utime.h sys/time.h) -AC_CHECK_HEADERS(zlib.h) +if test "$enable_zlib" != "no"; then + AC_CHECK_HEADERS(zlib.h) +fi AC_CHECK_TYPE([sig_t],[AC_DEFINE([HAVE_SIG_T],1,[Have sig_t type])],,[ #ifdef HAVE_SIGNAL_H #include @@ -148,7 +155,9 @@ dnl Provide implementation of some requi AC_REPLACE_FUNCS(getopt_long asprintf vasprintf strlcpy strlcat getline ctime_r asctime_r localtime_r gmtime_r pread strcasestr fmtcheck dprintf) dnl Checks for libraries -AC_CHECK_LIB(z,gzopen) +if test "$enable_zlib" != "no"; then + AC_CHECK_LIB(z, gzopen) +fi if test "$MINGW" = 1; then AC_CHECK_LIB(gnurx,regexec,,AC_MSG_ERROR([libgnurx is required to build file(1) with MinGW])) fi @@ -156,5 +165,14 @@ fi dnl See if we are cross-compiling AM_CONDITIONAL(IS_CROSS_COMPILE, test "$cross_compiling" = yes) +dnl Final sanity checks +if test "$enable_zlib" = "yes"; then + if test "$ac_cv_header_zlib_h$ac_cv_lib_z_gzopen" != "yesyes"; then + AC_MSG_ERROR([zlib support requested but not found]) + fi +elif test "$ac_cv_header_zlib_h$ac_cv_lib_z_gzopen" = "yesyes"; then + AC_DEFINE([ZLIBSUPPORT], 1, [Enable zlib compression support]) +fi + AC_CONFIG_FILES([Makefile src/Makefile magic/Makefile tests/Makefile doc/Makefile python/Makefile]) AC_OUTPUT Modified: head/contrib/file/doc/file.man ============================================================================== --- head/contrib/file/doc/file.man Mon Jun 27 01:17:00 2016 (r302220) +++ head/contrib/file/doc/file.man Mon Jun 27 01:29:17 2016 (r302221) @@ -1,4 +1,4 @@ -.\" $File: file.man,v 1.120 2016/03/31 17:51:12 christos Exp $ +.\" $File: file.man,v 1.121 2016/06/07 22:09:20 rrt Exp $ .Dd March 13, 2016 .Dt FILE __CSECTION__ .Os @@ -213,6 +213,9 @@ Prints ELF file details. Consults magic files. .It tar Examines tar files. +.It text +A synonym for +.Sq ascii . .El .It Fl Fl extension Print a slash-separated list of valid extensions for the file type found. Copied: head/contrib/file/magic/Magdir/ber (from r302218, vendor/file/dist/magic/Magdir/ber) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/contrib/file/magic/Magdir/ber Mon Jun 27 01:29:17 2016 (r302221, copy of r302218, vendor/file/dist/magic/Magdir/ber) @@ -0,0 +1,65 @@ + +#------------------------------------------------------------------------------ +# $File: ber,v 1.1 2016/06/05 00:21:30 christos Exp $ +# ber: file(1) magic for several BER formats used in the mobile +# telecommunications industry (Georg Sauthoff) + +# The file formats are standardized by the GSMA (GSM association). +# They are specified via ASN.1 schemas and some prose. Basic encoding +# rules (BER) is the used encoding. The formats are used for exchanging +# call data records (CDRs) between mobile operators and associated +# parties for roaming clearing purposes and fraud detection. + +# The magic file covers: + +# - TAP files (TD.57) - CDR batches and notifications +# - RAP files (TD.32) - return batches and acknowledgements +# - NRT files (TD.35) - CDR batches for 'near real time' processing + +# +# TAP 3 Files +# TAP -> Transferred Account Procedure +# cf. http://www.gsma.com/newsroom/wp-content/uploads/TD.57-v32.31.pdf +# TransferBatch short tag +0 byte 0x61 +# BatchControlInfo short tag +>&1 search/b5 \x64 +# Sender long tag #TAP 3.x (BER encoded) +>>&1 search/b8 \x5f\x81\x44 +# 3 block +>>>&64 search/b64 \x5f\x81\x49\x01\x03\x5f\x81\x3d\x01 +>>>>&0 byte x TAP 3.%d Batch (TD.57, Transferred Account) + +# Notification short tag +0 byte 0x62 +# Sender long tag +>2 search/b8 \x5f\x81\x44 +# 3 block +>>&64 search/b64 \x5f\x81\x49\x01\x03\x5f\x81\x3d\x01 +>>>&0 byte x TAP 3.%d Notification (TD.57, Transferred Account) + + +# NRT Files +# NRT a.k.a. NRTRDE +0 byte 0x61 +# 2 block +>&1 search/b8 \x5f\x29\x01\x02\x5f\x25\x01 +>>&0 byte x NRT 2.%d (TD.35, Near Real Time Roaming Data Exchange) + +# RAP Files +# cf. http://www.gsma.com/newsroom/wp-content/uploads/TD.32-v6.11.pdf +# Long ReturnBatch tag +0 string \x7f\x84\x16 +# Long RapBatchControlInfo tag +>&1 search/b8 \x7f\x84\x19 +# 3 block +>>&64 search/b64 \x5f\x81\x49\x01\x03\x5f\x81\x3d\x01 +# 1 block +>>>&1 string/b \x5f\x84\x20\x01\x01\x5f\x84\x1f\x01 +>>>>&0 byte x RAP 1.%d Batch (TD.32, Returned Account Procedure), +>>>&0 byte x TAP 3.%d + +# Long Acknowledgement tag +0 string \x7f\x84\x17 +# Long Sender tag +>&1 search/b5 \x5f\x81\x44 RAP Acknowledgement (TD.32, Returned Account Procedure) Modified: head/contrib/file/magic/Magdir/c-lang ============================================================================== --- head/contrib/file/magic/Magdir/c-lang Mon Jun 27 01:17:00 2016 (r302220) +++ head/contrib/file/magic/Magdir/c-lang Mon Jun 27 01:29:17 2016 (r302221) @@ -1,5 +1,5 @@ #------------------------------------------------------------------------------ -# $File: c-lang,v 1.22 2015/10/29 18:49:11 christos Exp $ +# $File: c-lang,v 1.23 2016/05/21 14:28:27 christos Exp $ # c-lang: file(1) magic for C and related languages programs # # The strength is to beat standard HTML @@ -38,7 +38,8 @@ !:strength + 30 !:mime text/x-c++ 0 regex \^class[\ \t\n]+ C++ source text -!:strength + 30 +# But class is reduced to avoid beating php (Jens Schleusener) +!:strength + 13 !:mime text/x-c++ 0 regex \^public: C++ source text !:strength + 30 Modified: head/contrib/file/magic/Magdir/console ============================================================================== --- head/contrib/file/magic/Magdir/console Mon Jun 27 01:17:00 2016 (r302220) +++ head/contrib/file/magic/Magdir/console Mon Jun 27 01:29:17 2016 (r302221) @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: console,v 1.25 2016/04/18 20:22:10 christos Exp $ +# $File: console,v 1.26 2016/06/12 15:20:37 christos Exp $ # Console game magic # Toby Deshane @@ -56,6 +56,32 @@ >4 lelong <16 UNIF v%d format NES ROM image #------------------------------------------------------------------------------ +# fds: file(1) magic for Famciom Disk System disk images +# Reference: http://wiki.nesdev.com/w/index.php/Family_Computer_Disk_System#.FDS_format +# From: David Korth +# TODO: Check "Disk info block" and get info from that in addition to the optional header. + +# Disk info block. (block 1) +0 name nintendo-fds-disk-info-block +>1 string *NINTENDO-HVC* Famicom Disk System disk image: +>23 byte !1 FMC- +>23 byte 1 FSC- +>16 string x \b%.3s +>15 byte x \b, mfr 0x%02X +>20 byte x (Rev.%02u) + +# Headered version. +0 string FDS\x1A +>0x11 string *NINTENDO-HVC* +>>0x10 use nintendo-fds-disk-info-block +>4 byte 1 (%u side) +>4 byte !1 (%u sides) + +# Unheadered version. +1 string *NINTENDO-HVC* +>0 use nintendo-fds-disk-info-block + +#------------------------------------------------------------------------------ # gameboy: file(1) magic for the Nintendo (Color) Gameboy raw ROM format # Reference: http://gbdev.gg8.se/wiki/articles/The_Cartridge_Header # @@ -569,6 +595,15 @@ 0x1C belong 0xC2339F3D Nintendo GameCube disc image: >0 use nintendo-gcn-disc-common +# Type: Nintendo GameCube embedded disc image +# Commonly found on demo discs. +# From: David Korth +# Reference: http://hitmen.c02.at/files/yagcd/yagcd/index.html#idx14.8 +0 belong 0xAE0F38A2 +>0x0C belong 0x00100000 +>>(8.L+0x1C) belong 0xC2339F3D Nintendo GameCube embedded disc image: +>>>(8.L) use nintendo-gcn-disc-common + # Type: Nintendo Wii disc image # From: David Korth # Reference: http://wiibrew.org/wiki/Wii_Disc @@ -586,22 +621,15 @@ # Nintendo 3DS file formats. # -# Type: Nintendo 3DS "NCCH" header. -# Contained within either a CXI executable or an NCSD image. -# From: David Korth -# Reference: https://www.3dbrew.org/wiki/NCCH -0 name nintendo-3ds-NCCH ->0x100 string NCCH ->>0x150 string >\0 \b: "%.16s" ->>0x112 leshort x (v%u) ->>0x18C byte 2 (New3DS only) - # Type: Nintendo 3DS "NCSD" image. (game cards and eMMC) # From: David Korth # Reference: https://www.3dbrew.org/wiki/NCSD 0x100 string NCSD >0x118 lequad 0 Nintendo 3DS Game Card image ->>0x1000 use nintendo-3ds-NCCH +# NCCH header for partition 0. (game data) +>>0x1150 string >\0 \b: "%.16s" +>>0x312 byte x (Rev.%02u) +>>0x118C byte 2 (New3DS only) >>0x18D byte 0 (inner device) >>0x18D byte 1 (Card1) >>0x18D byte 2 (Card2) @@ -609,12 +637,74 @@ >0x118 bequad 0x0102020202000000 Nintendo 3DS eMMC dump (Old3DS) >0x118 bequad 0x0102020203000000 Nintendo 3DS eMMC dump (New3DS) +# Nintendo 3DS version code. +# Reference: https://www.3dbrew.org/wiki/Titles +# Format: leshort containing three fields: +# - 6-bit: Major +# - 6-bit: Minor +# - 4-bit: Revision +# NOTE: Only supporting major/minor versions from 0-15 right now. +# NOTE: Should be prefixed with "v". +0 name nintendo-3ds-version-code +# Raw version. +>0 leshort x \b%u, +# Major version. +>0 leshort&0xFC00 0x0000 0 +>0 leshort&0xFC00 0x0400 1 +>0 leshort&0xFC00 0x0800 2 +>0 leshort&0xFC00 0x0C00 3 +>0 leshort&0xFC00 0x1000 4 +>0 leshort&0xFC00 0x1400 5 +>0 leshort&0xFC00 0x1800 6 +>0 leshort&0xFC00 0x1C00 7 +>0 leshort&0xFC00 0x2000 8 +>0 leshort&0xFC00 0x2400 9 +>0 leshort&0xFC00 0x2800 10 +>0 leshort&0xFC00 0x2C00 11 +>0 leshort&0xFC00 0x3000 12 +>0 leshort&0xFC00 0x3400 13 +>0 leshort&0xFC00 0x3800 14 +>0 leshort&0xFC00 0x3C00 15 +# Minor version. +>0 leshort&0x03F0 0x0000 \b.0 +>0 leshort&0x03F0 0x0010 \b.1 +>0 leshort&0x03F0 0x0020 \b.2 +>0 leshort&0x03F0 0x0030 \b.3 +>0 leshort&0x03F0 0x0040 \b.4 +>0 leshort&0x03F0 0x0050 \b.5 +>0 leshort&0x03F0 0x0060 \b.6 +>0 leshort&0x03F0 0x0070 \b.7 +>0 leshort&0x03F0 0x0080 \b.8 +>0 leshort&0x03F0 0x0090 \b.9 +>0 leshort&0x03F0 0x00A0 \b.10 +>0 leshort&0x03F0 0x00B0 \b.11 +>0 leshort&0x03F0 0x00C0 \b.12 +>0 leshort&0x03F0 0x00D0 \b.13 +>0 leshort&0x03F0 0x00E0 \b.14 +>0 leshort&0x03F0 0x00F0 \b.15 +# Revision. +>0 leshort&0x000F x \b.%u + # Type: Nintendo 3DS "NCCH" container. # https://www.3dbrew.org/wiki/NCCH -0x100 string NCCH Nintendo 3DS ->0x18D byte&2 0 File Archive (CFA) ->0x18D byte&2 2 Executable Image (CXI) ->0 use nintendo-3ds-NCCH +0x100 string NCCH Nintendo 3DS +>0x18D byte&2 0 File Archive (CFA) +>0x18D byte&2 2 Executable Image (CXI) +>0x150 string >\0 \b: "%.16s" +>0x18D byte 0x05 +>>0x10E leshort x (Old3DS System Update v +>>0x10E use nintendo-3ds-version-code +>>0x10E leshort x \b) +>0x18D byte 0x15 +>>0x10E leshort x (New3DS System Update v +>>0x10E use nintendo-3ds-version-code +>>0x10E leshort x \b) +>0x18D byte !0x05 +>>0x18D byte !0x15 +>>>0x112 byte x (v +>>>0x112 use nintendo-3ds-version-code +>>>0x112 byte x \b) +>0x18C byte 2 (New3DS only) # Type: Nintendo 3DS "SMDH" file. (application description) # From: David Korth Copied: head/contrib/file/magic/Magdir/coverage (from r302218, vendor/file/dist/magic/Magdir/coverage) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/contrib/file/magic/Magdir/coverage Mon Jun 27 01:29:17 2016 (r302221, copy of r302218, vendor/file/dist/magic/Magdir/coverage) @@ -0,0 +1,91 @@ + +#------------------------------------------------------------------------------ +# $File: coverage,v 1.1 2016/06/05 00:26:32 christos Exp $ +# xoverage: file(1) magic for test coverage data + +# File formats used to store test coverage data +# 2016-05-21, Georg Sauthoff + + +# - GCC gcno - written by GCC at compile time when compiling with +# gcc -ftest-coverage +# - GCC gcda - written by a program that was compiled with +# gcc -fprofile-arcs +# - LLVM raw profiles - generated by a program compiled with +# clang -fprofile-instr-generate -fcoverage-mapping ... +# - LLVM indexed profiles - generated by +# llvm-profdata +# - GCOV reports, i.e. the annotated source code +# - LCOV trace files, i.e. aggregated GCC profiles +# +# GCC coverage tracefiles +# .gcno file are created during compile time, +# while data collected during runtime is stored in .gcda files +# cf. gcov-io.h +# https://gcc.gnu.org/onlinedocs/gcc-5.3.0/gcc/Gcov-Data-Files.html +# Examples: +# Fedora 23/x86-64/gcc-5.3.1: 6f 6e 63 67 52 33 30 35 +# Debian 8 PPC64/gcc-4.9.2 : 67 63 6e 6f 34 30 39 2a +0 lelong 0x67636e6f GCC gcno coverage (-ftest-coverage), +>&3 byte x version %c. +>&1 byte x \b%c + +# big endian +0 belong 0x67636e6f GCC gcno coverage (-ftest-coverage), +>&0 byte x version %c. +>&2 byte x \b%c (big-endian) + +# Examples: +# Fedora 23/x86-64/gcc-5.3.1: 61 64 63 67 52 33 30 35 +# Debian 8 PPC64/gcc-4.9.2 : 67 63 64 61 34 30 39 2a +0 lelong 0x67636461 GCC gcda coverage (-fprofile-arcs), +>&3 byte x version %c. +>&1 byte x \b%c + +# big endian +0 belong 0x67636461 GCC gcda coverage (-fprofile-arcs), +>&0 byte x version %c. +>&2 byte x \b%c (big-endian) + + +# LCOV tracefiles +# cf. http://ltp.sourceforge.net/coverage/lcov/geninfo.1.php +0 string TN: +>&0 search/64 \nSF:/ LCOV coverage tracefile + + +# Coverage reports generated by gcov +# i.e. source code annoted with coverage information +0 string \x20\x20\x20\x20\x20\x20\x20\x20-:\x20\x20\x20\ 0:Source: +>&0 search/128 \x20\x20\x20\x20\x20\x20\x20\x20-:\x20\x20\x20\ 0:Graph: +>>&0 search/128 \x20\x20\x20\x20\x20\x20\x20\x20-:\x20\x20\x20\ 0:Data: GCOV coverage report + + +# LLVM coverage files + +# raw data after running a program compiled with: +# `clang -fprofile-instr-generate -fcoverage-mapping ...` +# default name: default.profraw +# magic is: \xFF lprofr \x81 +# cf. http://llvm.org/docs/doxygen/html/InstrProfData_8inc_source.html +0 lequad 0xff6c70726f667281 LLVM raw profile data, +>&0 byte x version %d + +# big endian +0 bequad 0xff6c70726f667281 LLVM raw profile data, +>&7 byte x version %d (big-endian) + + +# LLVM indexed instruction profile (as generated by llvm-profdata) +# magic is: reverse(\xFF lprofi \x81) +# cf. http://llvm.org/docs/CoverageMappingFormat.html +# http://llvm.org/docs/doxygen/html/namespacellvm_1_1IndexedInstrProf.html +# http://llvm.org/docs/CommandGuide/llvm-cov.html +# http://llvm.org/docs/CommandGuide/llvm-profdata.html +0 lequad 0x8169666f72706cff LLVM indexed profile data, +>&0 byte x version %d + +# big endian +0 bequad 0x8169666f72706cff LLVM indexed profile data, +>&7 byte x version %d (big-endian) + Modified: head/contrib/file/magic/Magdir/database ============================================================================== --- head/contrib/file/magic/Magdir/database Mon Jun 27 01:17:00 2016 (r302220) +++ head/contrib/file/magic/Magdir/database Mon Jun 27 01:29:17 2016 (r302221) @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: database,v 1.48 2016/04/14 20:34:28 christos Exp $ +# $File: database,v 1.49 2016/06/11 17:01:51 christos Exp $ # database: file(1) magic for various databases # # extracted from header/code files by Graeme Wilford (eep2gw@ee.surrey.ac.uk) @@ -611,3 +611,14 @@ !:ext pan # database name >>>5 pstring x \b, "%s" + +# +# +# askSam Database by Stefan A. Haubenthal +0 string askw40\0 askSam DB + +# +# +# MUIbase Database Tool by Stefan A. Haubenthal +0 string MBSTV\040 MUIbase DB +>6 string x version %s Modified: head/contrib/file/magic/Magdir/elf ============================================================================== --- head/contrib/file/magic/Magdir/elf Mon Jun 27 01:17:00 2016 (r302220) +++ head/contrib/file/magic/Magdir/elf Mon Jun 27 01:29:17 2016 (r302221) @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: elf,v 1.69 2015/06/16 17:23:08 christos Exp $ +# $File: elf,v 1.70 2016/06/02 12:36:30 christos Exp $ # elf: file(1) magic for ELF executables # # We have to check the byte order flag to see what byte order all the @@ -301,25 +301,23 @@ >>0 use elf-le >5 byte 2 MSB >>0 use \^elf-le -# Up to now only 0, 1 and 2 are defined; I've seen a file with 0x83, it seemed -# like proper ELF, but extracting the string had bad results. ->4 byte <0x80 ->>8 string >\0 (%s) ->8 string \0 ->>7 byte 0 (SYSV) ->>7 byte 1 (HP-UX) ->>7 byte 2 (NetBSD) ->>7 byte 3 (GNU/Linux) ->>7 byte 4 (GNU/Hurd) ->>7 byte 5 (86Open) ->>7 byte 6 (Solaris) ->>7 byte 7 (Monterey) ->>7 byte 8 (IRIX) ->>7 byte 9 (FreeBSD) ->>7 byte 10 (Tru64) ->>7 byte 11 (Novell Modesto) ->>7 byte 12 (OpenBSD) ->8 string \2 ->>7 byte 13 (OpenVMS) ->>7 byte 97 (ARM) ->>7 byte 255 (embedded) +>7 byte 0 (SYSV) +>7 byte 1 (HP-UX) +>7 byte 2 (NetBSD) +>7 byte 3 (GNU/Linux) +>7 byte 4 (GNU/Hurd) +>7 byte 5 (86Open) +>7 byte 6 (Solaris) +>7 byte 7 (Monterey) +>7 byte 8 (IRIX) +>7 byte 9 (FreeBSD) +>7 byte 10 (Tru64) +>7 byte 11 (Novell Modesto) +>7 byte 12 (OpenBSD) +>7 byte 13 (OpenVMS) +>7 byte 14 (HP NonStop Kernel) +>7 byte 15 (AROS Research Operating System) +>7 byte 16 (FenixOS) +>7 byte 17 (Nuxi CloudABI) +>7 byte 97 (ARM) +>7 byte 255 (embedded) Modified: head/contrib/file/magic/Magdir/msdos ============================================================================== --- head/contrib/file/magic/Magdir/msdos Mon Jun 27 01:17:00 2016 (r302220) +++ head/contrib/file/magic/Magdir/msdos Mon Jun 27 01:29:17 2016 (r302221) @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: msdos,v 1.105 2016/03/03 18:58:14 christos Exp $ +# $File: msdos,v 1.106 2016/06/11 00:52:14 christos Exp $ # msdos: file(1) magic for MS-DOS files # @@ -633,47 +633,86 @@ 0 string/b \102\101\050\000\000\000\056\000\000\000\000\000\000\000 Icon for MS Windows # Windows icons -0 name ico-dir -# not entirely accurate, the number of icons is part of the header ->0 byte 1 - 1 icon ->0 ubyte >1 - %d icons ->2 byte 0 \b, 256x ->2 byte !0 \b, %dx ->3 byte 0 \b256 ->3 byte !0 \b%d ->4 ubyte !0 \b, %d colors - +# Update: Joerg Jenderek +# URL: https://en.wikipedia.org/wiki/CUR_(file_format) +# Note: similiar to Windows CURsor. container for BMP (only DIB part) or PNG 0 belong 0x00000100 >9 byte 0 ->>0 byte x MS Windows icon resource -!:mime image/x-icon ->>4 use ico-dir +>>0 byte x +>>0 use cur-ico-dir >9 ubyte 0xff ->>0 byte x MS Windows icon resource -!:mime image/x-icon ->>4 use ico-dir +>>0 byte x +>>0 use cur-ico-dir +# displays number of icons and information for icon or cursor +0 name cur-ico-dir +# skip some Lotus 1-2-3 worksheets, CYCLE.PIC and keep Windows cursors with +# 1st data offset = dir header size + n * dir entry size = 6 + n * 10h = ?6h +>18 ulelong &0x00000006 +# skip remaining worksheets, because valid only for DIB image (40) or PNG image (\x89PNG) +>>(18.l) ulelong x MS Windows +>>>0 ubelong 0x00000100 icon resource +#!:mime image/vnd.microsoft.icon +!:mime image/x-icon +!:ext ico +>>>>4 uleshort x - %d icon +# plural s +>>>>4 uleshort >1 \bs +# 1st icon +>>>>0x06 use ico-entry +# 2nd icon +>>>>4 uleshort >1 +>>>>>0x16 use ico-entry +>>>0 ubelong 0x00000200 cursor resource +#!:mime image/x-cur +!:mime image/x-win-bitmap +!:ext cur +>>>>4 uleshort x - %d icon +>>>>4 uleshort >1 \bs +# 1st cursor +>>>>0x06 use cur-entry +#>>>>0x16 use cur-entry +# display information of one cursor entry +0 name cur-entry +>0 use cur-ico-entry +>4 uleshort x \b, hotspot @%dx +>6 uleshort x \b%d +# display information of one icon entry +0 name ico-entry +>0 use cur-ico-entry +# normally 0 1 but also found 14 +>4 uleshort >1 \b, %d planes +# normally 0 1 but also found some 3, 4, some 6, 8, 24, many 32, two 256 +>6 uleshort >1 \b, %d bits/pixel +# display shared information of cursor or icon entry +0 name cur-ico-entry +>0 byte =0 \b, 256x +>0 byte !0 \b, %dx +>1 byte =0 \b256 +>1 byte !0 \b%d +# number of colors in palette +>2 ubyte !0 \b, %d colors +# reserved 0 FFh +#>3 ubyte x \b, reserved %x +#>8 ulelong x \b, image size %d +# offset of PNG or DIB image +#>12 ulelong x \b, offset 0x%x +# PNG header (\x89PNG) +>(12.l) ubelong =0x89504e47 +>>&-4 indirect x \b with +# DIB image +>(12.l) ubelong !0x89504e47 +#>>&-4 use dib-image # Windows non-animated cursors -0 name cur-dir -# not entirely accurate, the number of icons is part of the header ->0 byte 1 - 1 icon ->0 ubyte >1 - %d icons ->2 byte 0 \b, 256x ->2 byte !0 \b, %dx ->3 byte 0 \b256 ->3 byte !0 \b%d ->6 uleshort x \b, hotspot @%dx ->8 uleshort x \b%d - +# Update: Joerg Jenderek +# URL: https://en.wikipedia.org/wiki/CUR_(file_format) +# Note: similiar to Windows ICOn. container for BMP ( only DIB part) +# GRR: line below is too general as it catches also Lotus 1-2-3 files 0 belong 0x00000200 >9 byte 0 ->>0 byte x MS Windows cursor resource -!:mime image/x-cur ->>4 use cur-dir +>>0 use cur-ico-dir >9 ubyte 0xff ->>0 byte x MS Windows cursor resource -!:mime image/x-cur ->>4 use cur-dir +>>0 use cur-ico-dir # .chr files 0 string/b PK\010\010BGI Borland font Modified: head/contrib/file/magic/Magdir/msx ============================================================================== --- head/contrib/file/magic/Magdir/msx Mon Jun 27 01:17:00 2016 (r302220) +++ head/contrib/file/magic/Magdir/msx Mon Jun 27 01:29:17 2016 (r302221) @@ -1,7 +1,7 @@ #------------------------------------------------------------------------------ # msx: file(1) magic for the MSX Home Computer -# v1.1 +# v1.3 # Fabio R. Schmidlin ############## MSX Music file formats ############## @@ -99,34 +99,6 @@ >>5 uleshort 0 >>>3 uleshort >0x013D MSX Graph Saurus compressed image -# Maki-chan Graphic format -0 string/b MAKI02\ \ Maki-chan image, ->8 byte x system ID: %c ->9 byte x \b%c ->10 byte x \b%c ->11 byte x \b%c, ->13 search/0x200 \x1A -# >>&3 ubyte 0 , video mode: PC-98 400 lines, 16 analog colors -# >>&3 ubyte 1 , video mode: MSX SC7, 16 analog colors -# >>&3 ubyte 2 , video mode: VM-98 400 lines, 8 analog colors -# >>&3 ubyte 3 , video mode: PC-88 analog, 200 lines, 8 analog colors -# >>&3 ubyte 4 , video mode: 400 lines, 16 digital colors -# >>&3 ubyte 5 , video mode: 200 lines, 16 digital colors -# >>&3 ubyte 6 , video mode: old PC-98 digital 400 lines, 8 colors -# >>&3 ubyte 7 , video mode: PC-88 400 lines, 8 digital colors ->>&8 uleshort+1 x %dx ->>&10 uleshort+1 x \b%d, ->>&3 ubyte&0x82 0x80 256 colors ->>&3 ubyte&0x82 0x00 16 colors ->>&3 ubyte&0x82 0x01 8 colors ->>&3 ubyte&0x04 4 digital ->>&3 ubyte&0x04 0 analog ->>&3 ubyte&0x01 1 \b, 2:1 dot aspect ratio - -# Japanese PIC file -0 string/b PIC\x1A ->4 lelong 0 Japanese PIC image file - # MSX G9B image file 0 string/b G9B >1 uleshort 11 @@ -146,70 +118,152 @@ ############## Other MSX file formats ############## -# MSX ROMs +# MSX internal ROMs +0 ubeshort 0xF3C3 +>2 uleshort <0x4000 +>>8 ubyte 0xC3 +>>>9 uleshort <0x4000 +>>>>0x0B ubeshort 0x00C3 +>>>>>0x0D uleshort <0x4000 +>>>>>>0x0F ubeshort 0x00C3 +>>>>>>>0x11 uleshort <0x4000 +>>>>>>>>0x13 ubeshort 0x00C3 +>>>>>>>>>0x15 uleshort <0x4000 +>>>>>>>>>>0x50 ubyte 0xC3 +>>>>>>>>>>>0x51 uleshort <0x4000 +>>>>>>>>>>>>(9.s) ubyte 0xC3 +>>>>>>>>>>>>>&0 uleshort >0x4000 +>>>>>>>>>>>>>>&0 ubyte 0xC3 MSX BIOS+BASIC +>>>>>>>>>>>>>>>0x002D ubyte+1 <3 \b. version=MSX%d +>>>>>>>>>>>>>>>0x002D ubyte 2 \b, version=MSX2+ +>>>>>>>>>>>>>>>0x002D ubyte 3 \b, version=MSX Turbo-R +>>>>>>>>>>>>>>>0x002D ubyte >3 \b, version=Unknown MSX %d version +>>>>>>>>>>>>>>>0x0006 ubyte x \b, VDP.DR=0x%2x +>>>>>>>>>>>>>>>0x0007 ubyte x \b, VDP.DW=0x%2x +>>>>>>>>>>>>>>>0x002B ubyte&0xF 0 \b, charset=Japanese +>>>>>>>>>>>>>>>0x002B ubyte&0xF 1 \b, charset=International +>>>>>>>>>>>>>>>0x002B ubyte&0xF 2 \b, charset=Korean +>>>>>>>>>>>>>>>0x002B ubyte&0xF >2 \b, charset=Unknown id:%d +>>>>>>>>>>>>>>>0x002B ubyte&0x70 0x00 \b, date format=Y-M-D +>>>>>>>>>>>>>>>0x002B ubyte&0x70 0x10 \b, date format=M-D-Y +>>>>>>>>>>>>>>>0x002B ubyte&0x70 0x20 \b, date format=D-M-Y +>>>>>>>>>>>>>>>0x002B ubyte&0x80 0x00 \b, vfreq=60Hz +>>>>>>>>>>>>>>>0x002B ubyte&0x80 0x80 \b, vfreq=50Hz +>>>>>>>>>>>>>>>0x002C ubyte&0x0F 0 \b, keyboard=Japanese +>>>>>>>>>>>>>>>0x002C ubyte&0x0F 1 \b, keyboard=International +>>>>>>>>>>>>>>>0x002C ubyte&0x0F 2 \b, keyboard=French +>>>>>>>>>>>>>>>0x002C ubyte&0x0F 3 \b, keyboard=UK +>>>>>>>>>>>>>>>0x002C ubyte&0x0F 4 \b, keyboard=German +>>>>>>>>>>>>>>>0x002C ubyte&0x0F 5 \b, keyboard=Unknown id:%d +>>>>>>>>>>>>>>>0x002C ubyte&0x0F 6 \b, keyboard=Spanish +>>>>>>>>>>>>>>>0x002C ubyte&0x0F >6 \b, keyboard=Unknown id:%d +>>>>>>>>>>>>>>>0x002C ubyte&0xF0 0x00 \b, basic=Japanese +>>>>>>>>>>>>>>>0x002C ubyte&0xF0 0x10 \b, basic=International +>>>>>>>>>>>>>>>0x002C ubyte&0xF0 >0x10 \b, basic=Unknown id:%d +>>>>>>>>>>>>>>>0x002E ubyte&1 1 \b, built-in MIDI + + +0 string/b CD +>2 uleshort >0x10 +>>2 uleshort <0x4000 +>>>4 uleshort <0x4000 +>>>>6 uleshort <0x4000 +>>>>>8 ubyte 0xC3 +>>>>>>9 uleshort <0x4000 +>>>>>>>0x10 ubyte 0xC3 +>>>>>>>>0x11 uleshort <0x4000 +>>>>>>>>>0x14 ubyte 0xC3 +>>>>>>>>>>0x15 uleshort <0x4000 MSX2/2+/TR SubROM + +0 string \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 +>0x5F0 ubequad 0x8282828244380000 +>>0x150 ubyte 0x38 +>>>0x170 string \20\20\20 +>>>>0x1E32 string ()) +>>>>>0x2130 ubequad 0xA5A5594924231807 +>>>>>0x2138 ubequad 0x4A4A3424488830C0 MSX Kanji Font + + + +# MSX extension ROMs 0 string/b AB >2 uleshort 0x0010 MSX ROM >>2 uleshort x \b, init=0x%4x ->>4 uleshort >0 \b, stat=0x%4x ->>6 uleshort >0 \b, dev=0x%4x +>>4 uleshort >0 \b, stahdl=0x%4x +>>6 uleshort >0 \b, devhdl=0x%4x >>8 uleshort >0 \b, bas=0x%4x >2 uleshort 0x4010 MSX ROM >>2 uleshort x \b, init=0x%04x ->>4 uleshort >0 \b, stat=0x%04x ->>6 uleshort >0 \b, dev=0x%04x +>>4 uleshort >0 \b, stahdl=0x%04x +>>6 uleshort >0 \b, devhdl=0x%04x >>8 uleshort >0 \b, bas=0x%04x >2 uleshort 0x8010 MSX ROM >>2 uleshort x \b, init=0x%04x ->>4 uleshort >0 \b, stat=0x%04x ->>6 uleshort >0 \b, dev=0x%04x +>>4 uleshort >0 \b, stahdl=0x%04x +>>6 uleshort >0 \b, devhdl=0x%04x >>8 uleshort >0 \b, bas=0x%04x +0 string/b AB\0\0 +>6 uleshort 0 +>>4 uleshort >0x400F MSX-BASIC extension ROM +>>>4 uleshort >0 \b, stahdl=0x%04x +>>>6 uleshort >0 \b, devhdl=0x%04x +>>>0x1C string OPLL \b, MSX-Music +>>>>0x18 string PAC2 \b (external) +>>>>0x18 string APRL \b (internal) + +0 string/b AB\0\0\0\0 +>6 uleshort >0x400F MSX device BIOS +>>6 uleshort >0 \b, devhdl=0x%04x + 0 string/b AB #>2 string 5JSuperLAYDOCK MSX Super Laydock ROM #>3 string @HYDLIDE3MSX MSX Hydlide-3 ROM #>3 string @3\x80IA862 Golvellius MSX1 ROM ->2 uleshort >10 ->>10 string \0\0\0\0\0\0 MSX ROM ->>>0x10 string YZ\0\0\0\0 Konami Game Master 2 MSX ROM ->>>0x10 string CD \b, Konami RC- ->>>>0x12 ubyte x \b%d ->>>>0x13 ubyte/16 x \b%d ->>>>0x13 ubyte&0xF x \b%d ->>>0x10 string EF \b, Konami RC- *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@freebsd.org Mon Jun 27 06:41:12 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 66E58B84FB3; Mon, 27 Jun 2016 06:41:12 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 378BE24CB; Mon, 27 Jun 2016 06:41:12 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5R6fB4b080777; Mon, 27 Jun 2016 06:41:11 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5R6fBT5080776; Mon, 27 Jun 2016 06:41:11 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201606270641.u5R6fBT5080776@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Mon, 27 Jun 2016 06:41:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302222 - head/lib/libmagic X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Mon, 27 Jun 2016 06:41:12 -0000 Author: delphij Date: Mon Jun 27 06:41:11 2016 New Revision: 302222 URL: https://svnweb.freebsd.org/changeset/base/302222 Log: Fix build: explicitly reference the generated magic.h as dependency of mkmagic and point its location. Reported by: jenkins Pointy hat to: delphij MFC after: 2 weeks X-MFC-With: 302221 Approved by: re (kib) Modified: head/lib/libmagic/Makefile Modified: head/lib/libmagic/Makefile ============================================================================== --- head/lib/libmagic/Makefile Mon Jun 27 01:29:17 2016 (r302221) +++ head/lib/libmagic/Makefile Mon Jun 27 06:41:11 2016 (r302222) @@ -19,7 +19,7 @@ INCS= magic.h MAGICPATH?= /usr/share/misc CFLAGS+= -DMAGIC='"${MAGICPATH}/magic"' -DHAVE_CONFIG_H -CFLAGS+= -I${.CURDIR} -I${CONTRDIR}/src +CFLAGS+= -I${.CURDIR} -I${.OBJDIR} -I${CONTRDIR}/src WARNS?= 3 @@ -40,8 +40,8 @@ magic.mgc: mkmagic magic CLEANFILES+= mkmagic build-tools: mkmagic -mkmagic: apprentice.c cdf_time.c encoding.c funcs.c magic.c print.c ${BUILD_TOOLS_META} - ${CC} ${CFLAGS} -DCOMPILE_ONLY ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} \ +mkmagic: apprentice.c cdf_time.c encoding.c funcs.c magic.c print.c ${INCS} ${BUILD_TOOLS_META} + ${CC} ${CFLAGS} -DCOMPILE_ONLY ${LDFLAGS} -o ${.TARGET} ${.ALLSRC:N*.h} \ ${LDADD} FILEVER!= awk '$$1 == "\#define" && $$2 == "VERSION" { print $$3; exit }' \ From owner-svn-src-head@freebsd.org Mon Jun 27 20:18:50 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 71602B84BB1; Mon, 27 Jun 2016 20:18:50 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: from mail-qt0-x236.google.com (mail-qt0-x236.google.com [IPv6:2607:f8b0:400d:c0d::236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 292432532; Mon, 27 Jun 2016 20:18:50 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: by mail-qt0-x236.google.com with SMTP id c34so27889232qte.0; Mon, 27 Jun 2016 13:18:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=iQQhMCaXchsH9crFQCj1roY5472mQjnW88KSQBtZqxc=; b=ocWDSDqYKKWJM28i65a3XJg1iVgM4ttt3nc03O/Xl3NTnmvV4Xa9Z26B1kUZCuTBI1 j3YRMzJ8xMgWvRKeoHzlBR30wLQbW8jNwmkRYxzZRwa0lOwlqqJb7LZeT+HJUWOYFGkM u9YmNsQWn7XQ+imryE519qx0ZHzQ+/cB1QMtkjWq4B57uj7mmtxn1lQBx+CshFEE3Fe6 aE9CfI0MMd5I7pz54Fl32IAikdcoq5yTlY3aKgwTqL4+ZoU+MZtVNR8Nn29y/ldd0m39 Vn1W2gJe+oTtj9RX6nTic+ZVlQJv9KUO77Cm6fQ2D8eCoFudfWmrulwnGJNsG3Fn2vrf HRxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=iQQhMCaXchsH9crFQCj1roY5472mQjnW88KSQBtZqxc=; b=VqL9xC3hU/iZp62rOQqvWwuOlxBzAiHF5MBNQuTpBgW0PYEhSdbuaJ0dbN8YCJFOQk K00N6NPoUv98sGD+eVSTXhsj8asbxAW7hG7NYTUXuBKeOid9R5Hyu7LbK3uF3cW5z3g6 fQ3GtU1kKk40+PgJ44d2x+DqLurLSwCuJpHpsP82rV6XQ8kZvl+MIto7Whhj0UHZ5uvg TKDIQiXpVoyBvrzaGHf9mLI0+1kESClhKotIimpvWTE3cpBI1EM3iLmxsWf2npK52lFx cs8e5MzdLnHHlpyYoMETIlwRSUQ7jmft65XZ6gxGI/8C2Xd3/HJ+0TkPdy9x1REvIPD7 UZMg== X-Gm-Message-State: ALyK8tIKC4SyD+bxM03Hb/3iqKQYIqffpE+BJciiXaMvA4w/R/VMD4IQMhA31jzvlhEygu2ruNXTMY0aQqEvaw== X-Received: by 10.237.39.167 with SMTP id a36mr26576151qtd.103.1467058729215; Mon, 27 Jun 2016 13:18:49 -0700 (PDT) MIME-Version: 1.0 Received: by 10.55.148.131 with HTTP; Mon, 27 Jun 2016 13:18:48 -0700 (PDT) In-Reply-To: <201606262008.u5QK8gTx042729@repo.freebsd.org> References: <201606262008.u5QK8gTx042729@repo.freebsd.org> From: Ngie Cooper Date: Mon, 27 Jun 2016 13:18:48 -0700 Message-ID: Subject: Re: svn commit: r302216 - in head/sys: kern nlm 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-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Mon, 27 Jun 2016 20:18:50 -0000 On Sun, Jun 26, 2016 at 1:08 PM, Konstantin Belousov wrote: > Author: kib > Date: Sun Jun 26 20:08:42 2016 > New Revision: 302216 > URL: https://svnweb.freebsd.org/changeset/base/302216 > > Log: > When sleeping waiting for either local or remote advisory lock, > interrupt sleeps with the ERESTART on the suspension attempts. > Otherwise, single-threading requests are deferred until the locks are > granted for NFS files, which causes hangs. > > When retrying local registration of the remotely-granted adv lock, > allow full suspension and check for suspension, for usual reasons. > > Reported by: markj, pho > Reviewed by: jilles > Tested by: pho > Sponsored by: The FreeBSD Foundation > MFC after: 2 weeks > Approved by: re (gjb) One of the NetBSD tests seems to be failing now: https://jenkins.freebsd.org/job/FreeBSD_HEAD/334/testReport/junit/sys.kern/lockf_test/randlock/ . Thanks, -Ngie From owner-svn-src-head@freebsd.org Mon Jun 27 21:52:19 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 39166B84DB3; Mon, 27 Jun 2016 21:52:19 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 04AA12418; Mon, 27 Jun 2016 21:52:18 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5RLqIOa031067; Mon, 27 Jun 2016 21:52:18 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5RLqHRV031059; Mon, 27 Jun 2016 21:52:17 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201606272152.u5RLqHRV031059@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 27 Jun 2016 21:52:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302235 - in head/sys: kern sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Mon, 27 Jun 2016 21:52:19 -0000 Author: kib Date: Mon Jun 27 21:52:17 2016 New Revision: 302235 URL: https://svnweb.freebsd.org/changeset/base/302235 Log: When filt_proc() removes event from the knlist due to the process exiting (NOTE_EXIT->knlist_remove_inevent()), two things happen: - knote kn_knlist pointer is reset - INFLUX knote is removed from the process knlist. And, there are two consequences: - KN_LIST_UNLOCK() on such knote is nop - there is nothing which would block exit1() from processing past the knlist_destroy() (and knlist_destroy() resets knlist lock pointers). Both consequences result either in leaked process lock, or dereferencing NULL function pointers for locking. Handle this by stopping embedding the process knlist into struct proc. Instead, the knlist is allocated together with struct proc, but marked as autodestroy on the zombie reap, by knlist_detach() function. The knlist is freed when last kevent is removed from the list, in particular, at the zombie reap time if the list is empty. As result, the knlist_remove_inevent() is no longer needed and removed. Other changes: In filt_procattach(), clear NOTE_EXEC and NOTE_FORK desired events from kn_sfflags for knote registered by kernel to only get NOTE_CHILD notifications. The flags leak resulted in excessive NOTE_EXEC/NOTE_FORK reports. Fix immediate note activation in filt_procattach(). Condition should be either the immediate CHILD_NOTE activation, or immediate NOTE_EXIT report for the exiting process. In knote_fork(), do not perform racy check for KN_INFLUX before kq lock is taken. Besides being racy, it did not accounted for notes just added by scan (KN_SCAN). Some minor and incomplete style fixes. Analyzed and tested by: Eric Badger Reviewed by: jhb Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Approved by: re (gjb) Differential revision: https://reviews.freebsd.org/D6859 Modified: head/sys/kern/init_main.c head/sys/kern/kern_event.c head/sys/kern/kern_exec.c head/sys/kern/kern_exit.c head/sys/kern/kern_fork.c head/sys/kern/kern_sig.c head/sys/sys/event.h head/sys/sys/proc.h Modified: head/sys/kern/init_main.c ============================================================================== --- head/sys/kern/init_main.c Mon Jun 27 21:50:30 2016 (r302234) +++ head/sys/kern/init_main.c Mon Jun 27 21:52:17 2016 (r302235) @@ -482,7 +482,7 @@ proc0_init(void *dummy __unused) p->p_flag = P_SYSTEM | P_INMEM | P_KPROC; p->p_flag2 = 0; p->p_state = PRS_NORMAL; - knlist_init_mtx(&p->p_klist, &p->p_mtx); + p->p_klist = knlist_alloc(&p->p_mtx); STAILQ_INIT(&p->p_ktr); p->p_nice = NZERO; /* pid_max cannot be greater than PID_MAX */ Modified: head/sys/kern/kern_event.c ============================================================================== --- head/sys/kern/kern_event.c Mon Jun 27 21:50:30 2016 (r302234) +++ head/sys/kern/kern_event.c Mon Jun 27 21:52:17 2016 (r302235) @@ -227,14 +227,33 @@ SYSCTL_UINT(_kern, OID_AUTO, kq_calloutm #define KQ_NOTOWNED(kq) do { \ mtx_assert(&(kq)->kq_lock, MA_NOTOWNED); \ } while (0) -#define KN_LIST_LOCK(kn) do { \ - if (kn->kn_knlist != NULL) \ - kn->kn_knlist->kl_lock(kn->kn_knlist->kl_lockarg); \ -} while (0) -#define KN_LIST_UNLOCK(kn) do { \ - if (kn->kn_knlist != NULL) \ - kn->kn_knlist->kl_unlock(kn->kn_knlist->kl_lockarg); \ -} while (0) + +static struct knlist * +kn_list_lock(struct knote *kn) +{ + struct knlist *knl; + + knl = kn->kn_knlist; + if (knl != NULL) + knl->kl_lock(knl->kl_lockarg); + return (knl); +} + +static void +kn_list_unlock(struct knlist *knl) +{ + bool do_free; + + if (knl == NULL) + return; + do_free = knl->kl_autodestroy && knlist_empty(knl); + knl->kl_unlock(knl->kl_lockarg); + if (do_free) { + knlist_destroy(knl); + free(knl, M_KQUEUE); + } +} + #define KNL_ASSERT_LOCK(knl, islocked) do { \ if (islocked) \ KNL_ASSERT_LOCKED(knl); \ @@ -350,16 +369,16 @@ static int filt_procattach(struct knote *kn) { struct proc *p; - int immediate; int error; + bool exiting, immediate; - immediate = 0; + exiting = immediate = false; p = pfind(kn->kn_id); if (p == NULL && (kn->kn_sfflags & NOTE_EXIT)) { p = zpfind(kn->kn_id); - immediate = 1; + exiting = true; } else if (p != NULL && (p->p_flag & P_WEXIT)) { - immediate = 1; + exiting = true; } if (p == NULL) @@ -380,8 +399,8 @@ filt_procattach(struct knote *kn) kn->kn_flags &= ~EV_FLAG2; kn->kn_data = kn->kn_sdata; /* ppid */ kn->kn_fflags = NOTE_CHILD; - kn->kn_sfflags &= ~NOTE_EXIT; - immediate = 1; /* Force immediate activation of child note. */ + kn->kn_sfflags &= ~(NOTE_EXIT | NOTE_EXEC | NOTE_FORK); + immediate = true; /* Force immediate activation of child note. */ } /* * Internal flag indicating registration done by kernel (for other than @@ -391,8 +410,7 @@ filt_procattach(struct knote *kn) kn->kn_flags &= ~EV_FLAG1; } - if (immediate == 0) - knlist_add(&p->p_klist, kn, 1); + knlist_add(p->p_klist, kn, 1); /* * Immediately activate any child notes or, in the case of a zombie @@ -400,7 +418,7 @@ filt_procattach(struct knote *kn) * case where the target process, e.g. a child, dies before the kevent * is registered. */ - if (immediate && filt_proc(kn, NOTE_EXIT)) + if (immediate || (exiting && filt_proc(kn, NOTE_EXIT))) KNOTE_ACTIVATE(kn, 0); PROC_UNLOCK(p); @@ -420,10 +438,8 @@ filt_procattach(struct knote *kn) static void filt_procdetach(struct knote *kn) { - struct proc *p; - p = kn->kn_ptr.p_proc; - knlist_remove(&p->p_klist, kn, 0); + knlist_remove(kn->kn_knlist, kn, 0); kn->kn_ptr.p_proc = NULL; } @@ -444,8 +460,6 @@ filt_proc(struct knote *kn, long hint) /* Process is gone, so flag the event as finished. */ if (event == NOTE_EXIT) { - if (!(kn->kn_status & KN_DETACHED)) - knlist_remove_inevent(&p->p_klist, kn); kn->kn_flags |= EV_EOF | EV_ONESHOT; kn->kn_ptr.p_proc = NULL; if (kn->kn_fflags & NOTE_EXIT) @@ -479,12 +493,6 @@ knote_fork(struct knlist *list, int pid) list->kl_lock(list->kl_lockarg); SLIST_FOREACH(kn, &list->kl_list, kn_selnext) { - /* - * XXX - Why do we skip the kn if it is _INFLUX? Does this - * mean we will not properly wake up some notes? - */ - if ((kn->kn_status & KN_INFLUX) == KN_INFLUX) - continue; kq = kn->kn_kq; KQ_LOCK(kq); if ((kn->kn_status & (KN_INFLUX | KN_SCAN)) == KN_INFLUX) { @@ -525,7 +533,8 @@ knote_fork(struct knlist *list, int pid) */ kev.ident = pid; kev.filter = kn->kn_filter; - kev.flags = kn->kn_flags | EV_ADD | EV_ENABLE | EV_ONESHOT | EV_FLAG2; + kev.flags = kn->kn_flags | EV_ADD | EV_ENABLE | EV_ONESHOT | + EV_FLAG2; kev.fflags = kn->kn_sfflags; kev.data = kn->kn_id; /* parent */ kev.udata = kn->kn_kevent.udata;/* preserve udata */ @@ -1137,6 +1146,7 @@ kqueue_register(struct kqueue *kq, struc struct filterops *fops; struct file *fp; struct knote *kn, *tkn; + struct knlist *knl; cap_rights_t rights; int error, filt, event; int haskqglobal, filedesc_unlock; @@ -1146,6 +1156,7 @@ kqueue_register(struct kqueue *kq, struc fp = NULL; kn = NULL; + knl = NULL; error = 0; haskqglobal = 0; filedesc_unlock = 0; @@ -1300,7 +1311,7 @@ findkn: knote_drop(kn, td); goto done; } - KN_LIST_LOCK(kn); + knl = kn_list_lock(kn); goto done_ev_add; } else { /* No matching knote and the EV_ADD flag is not set. */ @@ -1331,7 +1342,7 @@ findkn: */ kn->kn_status |= KN_INFLUX | KN_SCAN; KQ_UNLOCK(kq); - KN_LIST_LOCK(kn); + knl = kn_list_lock(kn); kn->kn_kevent.udata = kev->udata; if (!fops->f_isfd && fops->f_touch != NULL) { fops->f_touch(kn, kev, EVENT_REGISTER); @@ -1365,7 +1376,7 @@ done_ev_add: KN_ACTIVE) knote_enqueue(kn); kn->kn_status &= ~(KN_INFLUX | KN_SCAN); - KN_LIST_UNLOCK(kn); + kn_list_unlock(knl); KQ_UNLOCK_FLUX(kq); done: @@ -1535,6 +1546,7 @@ kqueue_scan(struct kqueue *kq, int maxev { struct kevent *kevp; struct knote *kn, *marker; + struct knlist *knl; sbintime_t asbt, rsbt; int count, error, haskqglobal, influx, nkev, touch; @@ -1660,7 +1672,7 @@ retry: KQ_UNLOCK(kq); if ((kn->kn_status & KN_KQUEUE) == KN_KQUEUE) KQ_GLOBAL_LOCK(&kq_global, haskqglobal); - KN_LIST_LOCK(kn); + knl = kn_list_lock(kn); if (kn->kn_fop->f_event(kn, 0) == 0) { KQ_LOCK(kq); KQ_GLOBAL_UNLOCK(&kq_global, haskqglobal); @@ -1668,7 +1680,7 @@ retry: ~(KN_QUEUED | KN_ACTIVE | KN_INFLUX | KN_SCAN); kq->kq_count--; - KN_LIST_UNLOCK(kn); + kn_list_unlock(knl); influx = 1; continue; } @@ -1697,7 +1709,7 @@ retry: TAILQ_INSERT_TAIL(&kq->kq_head, kn, kn_tqe); kn->kn_status &= ~(KN_INFLUX | KN_SCAN); - KN_LIST_UNLOCK(kn); + kn_list_unlock(knl); influx = 1; } @@ -2062,7 +2074,8 @@ knlist_add(struct knlist *knl, struct kn } static void -knlist_remove_kq(struct knlist *knl, struct knote *kn, int knlislocked, int kqislocked) +knlist_remove_kq(struct knlist *knl, struct knote *kn, int knlislocked, + int kqislocked) { KASSERT(!(!!kqislocked && !knlislocked), ("kq locked w/o knl locked")); KNL_ASSERT_LOCK(knl, knlislocked); @@ -2075,7 +2088,7 @@ knlist_remove_kq(struct knlist *knl, str SLIST_REMOVE(&knl->kl_list, kn, knote, kn_selnext); kn->kn_knlist = NULL; if (!knlislocked) - knl->kl_unlock(knl->kl_lockarg); + kn_list_unlock(knl); if (!kqislocked) KQ_LOCK(kn->kn_kq); kn->kn_status |= KN_DETACHED; @@ -2093,17 +2106,6 @@ knlist_remove(struct knlist *knl, struct knlist_remove_kq(knl, kn, islocked, 0); } -/* - * remove knote from the specified knlist while in f_event handler. - */ -void -knlist_remove_inevent(struct knlist *knl, struct knote *kn) -{ - - knlist_remove_kq(knl, kn, 1, - (kn->kn_status & KN_HASKQLOCK) == KN_HASKQLOCK); -} - int knlist_empty(struct knlist *knl) { @@ -2202,6 +2204,7 @@ knlist_init(struct knlist *knl, void *lo else knl->kl_assert_unlocked = kl_assert_unlocked; + knl->kl_autodestroy = false; SLIST_INIT(&knl->kl_list); } @@ -2212,6 +2215,16 @@ knlist_init_mtx(struct knlist *knl, stru knlist_init(knl, lock, NULL, NULL, NULL, NULL); } +struct knlist * +knlist_alloc(struct mtx *lock) +{ + struct knlist *knl; + + knl = malloc(sizeof(struct knlist), M_KQUEUE, M_WAITOK); + knlist_init_mtx(knl, lock); + return (knl); +} + void knlist_init_rw_reader(struct knlist *knl, struct rwlock *lock) { @@ -2237,6 +2250,18 @@ knlist_destroy(struct knlist *knl) SLIST_INIT(&knl->kl_list); } +void +knlist_detach(struct knlist *knl) +{ + + KNL_ASSERT_LOCKED(knl); + knl->kl_autodestroy = true; + if (knlist_empty(knl)) { + knlist_destroy(knl); + free(knl, M_KQUEUE); + } +} + /* * Even if we are locked, we may need to drop the lock to allow any influx * knotes time to "settle". @@ -2247,6 +2272,7 @@ knlist_cleardel(struct knlist *knl, stru struct knote *kn, *kn2; struct kqueue *kq; + KASSERT(!knl->kl_autodestroy, ("cleardel for autodestroy %p", knl)); if (islocked) KNL_ASSERT_LOCKED(knl); else { Modified: head/sys/kern/kern_exec.c ============================================================================== --- head/sys/kern/kern_exec.c Mon Jun 27 21:50:30 2016 (r302234) +++ head/sys/kern/kern_exec.c Mon Jun 27 21:52:17 2016 (r302235) @@ -832,7 +832,7 @@ interpret: * Notify others that we exec'd, and clear the P_INEXEC flag * as we're now a bona fide freshly-execed process. */ - KNOTE_LOCKED(&p->p_klist, NOTE_EXEC); + KNOTE_LOCKED(p->p_klist, NOTE_EXEC); p->p_flag &= ~P_INEXEC; /* clear "fork but no exec" flag, as we _are_ execing */ Modified: head/sys/kern/kern_exit.c ============================================================================== --- head/sys/kern/kern_exit.c Mon Jun 27 21:50:30 2016 (r302234) +++ head/sys/kern/kern_exit.c Mon Jun 27 21:52:17 2016 (r302235) @@ -512,7 +512,7 @@ exit1(struct thread *td, int rval, int s /* * Notify interested parties of our demise. */ - KNOTE_LOCKED(&p->p_klist, NOTE_EXIT); + KNOTE_LOCKED(p->p_klist, NOTE_EXIT); #ifdef KDTRACE_HOOKS int reason = CLD_EXITED; @@ -524,13 +524,6 @@ exit1(struct thread *td, int rval, int s #endif /* - * Just delete all entries in the p_klist. At this point we won't - * report any more events, and there are nasty race conditions that - * can beat us if we don't. - */ - knlist_clear(&p->p_klist, 1); - - /* * If this is a process with a descriptor, we may not need to deliver * a signal to the parent. proctree_lock is held over * procdesc_exit() to serialize concurrent calls to close() and @@ -603,12 +596,6 @@ exit1(struct thread *td, int rval, int s PROC_UNLOCK(p->p_pptr); /* - * Hopefully no one will try to deliver a signal to the process this - * late in the game. - */ - knlist_destroy(&p->p_klist); - - /* * Save our children's rusage information in our exit rusage. */ PROC_STATLOCK(p); @@ -853,6 +840,11 @@ proc_reap(struct thread *td, struct proc procdesc_reap(p); sx_xunlock(&proctree_lock); + PROC_LOCK(p); + knlist_detach(p->p_klist); + p->p_klist = NULL; + PROC_UNLOCK(p); + /* * Removal from allproc list and process group list paired with * PROC_LOCK which was executed during that time should guarantee Modified: head/sys/kern/kern_fork.c ============================================================================== --- head/sys/kern/kern_fork.c Mon Jun 27 21:50:30 2016 (r302234) +++ head/sys/kern/kern_fork.c Mon Jun 27 21:52:17 2016 (r302235) @@ -748,7 +748,7 @@ do_fork(struct thread *td, struct fork_r /* * Tell any interested parties about the new process. */ - knote_fork(&p1->p_klist, p2->p_pid); + knote_fork(p1->p_klist, p2->p_pid); SDT_PROBE3(proc, , , create, p2, p1, fr->fr_flags); if (fr->fr_flags & RFPROCDESC) { @@ -950,7 +950,7 @@ fork1(struct thread *td, struct fork_req #ifdef MAC mac_proc_init(newproc); #endif - knlist_init_mtx(&newproc->p_klist, &newproc->p_mtx); + newproc->p_klist = knlist_alloc(&newproc->p_mtx); STAILQ_INIT(&newproc->p_ktr); /* We have to lock the process tree while we look for a pid. */ Modified: head/sys/kern/kern_sig.c ============================================================================== --- head/sys/kern/kern_sig.c Mon Jun 27 21:50:30 2016 (r302234) +++ head/sys/kern/kern_sig.c Mon Jun 27 21:52:17 2016 (r302235) @@ -2112,7 +2112,7 @@ tdsendsignal(struct proc *p, struct thre } ps = p->p_sigacts; - KNOTE_LOCKED(&p->p_klist, NOTE_SIGNAL | sig); + KNOTE_LOCKED(p->p_klist, NOTE_SIGNAL | sig); prop = sigprop(sig); if (td == NULL) { @@ -3542,7 +3542,7 @@ filt_sigattach(struct knote *kn) kn->kn_ptr.p_proc = p; kn->kn_flags |= EV_CLEAR; /* automatically set */ - knlist_add(&p->p_klist, kn, 0); + knlist_add(p->p_klist, kn, 0); return (0); } @@ -3552,7 +3552,7 @@ filt_sigdetach(struct knote *kn) { struct proc *p = kn->kn_ptr.p_proc; - knlist_remove(&p->p_klist, kn, 0); + knlist_remove(p->p_klist, kn, 0); } /* Modified: head/sys/sys/event.h ============================================================================== --- head/sys/sys/event.h Mon Jun 27 21:50:30 2016 (r302234) +++ head/sys/sys/event.h Mon Jun 27 21:52:17 2016 (r302235) @@ -158,7 +158,8 @@ struct knlist { void (*kl_unlock)(void *); void (*kl_assert_locked)(void *); void (*kl_assert_unlocked)(void *); - void *kl_lockarg; /* argument passed to kl_lockf() */ + void *kl_lockarg; /* argument passed to lock functions */ + bool kl_autodestroy; }; @@ -258,9 +259,10 @@ struct rwlock; extern void knote(struct knlist *list, long hint, int lockflags); extern void knote_fork(struct knlist *list, int pid); +extern struct knlist *knlist_alloc(struct mtx *lock); +extern void knlist_detach(struct knlist *knl); extern void knlist_add(struct knlist *knl, struct knote *kn, int islocked); extern void knlist_remove(struct knlist *knl, struct knote *kn, int islocked); -extern void knlist_remove_inevent(struct knlist *knl, struct knote *kn); extern int knlist_empty(struct knlist *knl); extern void knlist_init(struct knlist *knl, void *lock, void (*kl_lock)(void *), void (*kl_unlock)(void *), Modified: head/sys/sys/proc.h ============================================================================== --- head/sys/sys/proc.h Mon Jun 27 21:50:30 2016 (r302234) +++ head/sys/sys/proc.h Mon Jun 27 21:52:17 2016 (r302235) @@ -611,7 +611,7 @@ struct proc { /* End area that is copied on creation. */ #define p_endcopy p_xsig struct pgrp *p_pgrp; /* (c + e) Pointer to process group. */ - struct knlist p_klist; /* (c) Knotes attached to this proc. */ + struct knlist *p_klist; /* (c) Knotes attached to this proc. */ int p_numthreads; /* (c) Number of threads. */ struct mdproc p_md; /* Any machine-dependent fields. */ struct callout p_itcallout; /* (h + c) Interval timer callout. */ From owner-svn-src-head@freebsd.org Mon Jun 27 21:54:21 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 28C0DB84E5C; Mon, 27 Jun 2016 21:54:21 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D2BD425EE; Mon, 27 Jun 2016 21:54:20 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5RLsKCS031835; Mon, 27 Jun 2016 21:54:20 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5RLsKNI031834; Mon, 27 Jun 2016 21:54:20 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201606272154.u5RLsKNI031834@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 27 Jun 2016 21:54:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302236 - head/sys/vm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Mon, 27 Jun 2016 21:54:21 -0000 Author: kib Date: Mon Jun 27 21:54:19 2016 New Revision: 302236 URL: https://svnweb.freebsd.org/changeset/base/302236 Log: If the vm_fault() handler raced with the vm_object_collapse() sleepable scan, iteration over the shadow chain looking for a page could find an OBJ_DEAD object. Such state of the mapping is only transient, the dead object will be terminated and removed from the chain shortly. We must not return KERN_PROTECTION_FAILURE unless the object type is changed to OBJT_DEAD in the chain, indicating that paging on this address is really impossible. Returning KERN_PROTECTION_FAILURE prematurely causes spurious SIGSEGV delivered to processes, or kernel accesses to UVA spuriously failing with EFAULT. If the object with OBJ_DEAD flag is found, only return KERN_PROTECTION_FAILURE when object type is already OBJT_DEAD. Otherwise, sleep a tick and retry the fault handling. Ideally, we would wait until the OBJ_DEAD flag is resolved, e.g. by waiting until the paging on this object is finished. But to do so, we need to reference the dead object, while vm_object_collapse() insists on owning the final reference on the collapsed object. This could be fixed by e.g. changing the assert to shared reference release between vm_fault() and vm_object_collapse(), but it seems to be too much complications for rare boundary condition. PR: 204426 Tested by: pho Reviewed by: alc Sponsored by: The FreeBSD Foundation X-Differential revision: https://reviews.freebsd.org/D6085 MFC after: 2 weeks Approved by: re (gjb) Modified: head/sys/vm/vm_fault.c Modified: head/sys/vm/vm_fault.c ============================================================================== --- head/sys/vm/vm_fault.c Mon Jun 27 21:52:17 2016 (r302235) +++ head/sys/vm/vm_fault.c Mon Jun 27 21:54:19 2016 (r302236) @@ -292,7 +292,7 @@ vm_fault_hold(vm_map_t map, vm_offset_t struct faultstate fs; struct vnode *vp; vm_page_t m; - int ahead, behind, cluster_offset, error, locked; + int ahead, behind, cluster_offset, dead, error, locked; hardfault = 0; growstack = TRUE; @@ -421,11 +421,18 @@ fast_failed: fs.pindex = fs.first_pindex; while (TRUE) { /* - * If the object is dead, we stop here + * If the object is marked for imminent termination, + * we retry here, since the collapse pass has raced + * with us. Otherwise, if we see terminally dead + * object, return fail. */ - if (fs.object->flags & OBJ_DEAD) { + if ((fs.object->flags & OBJ_DEAD) != 0) { + dead = fs.object->type == OBJT_DEAD; unlock_and_deallocate(&fs); - return (KERN_PROTECTION_FAILURE); + if (dead) + return (KERN_PROTECTION_FAILURE); + pause("vmf_de", 1); + goto RetryFault; } /* From owner-svn-src-head@freebsd.org Mon Jun 27 23:34:54 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A184EB81609; Mon, 27 Jun 2016 23:34:54 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 731B62BBF; Mon, 27 Jun 2016 23:34:54 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5RNYrpP069390; Mon, 27 Jun 2016 23:34:53 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5RNYrAG069388; Mon, 27 Jun 2016 23:34:53 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201606272334.u5RNYrAG069388@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 27 Jun 2016 23:34:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302242 - in head/sys: kern sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Mon, 27 Jun 2016 23:34:54 -0000 Author: kib Date: Mon Jun 27 23:34:53 2016 New Revision: 302242 URL: https://svnweb.freebsd.org/changeset/base/302242 Log: Fix userspace build after r302235: do not expose bool field of the structure, change it to int. The real fix is to sanitize user-visible definitions in sys/event.h, e.g. the affected struct knlist is of no use for userspace programs. Reported and tested by: jkim Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Approved by: re (gjb) Modified: head/sys/kern/kern_event.c head/sys/sys/event.h Modified: head/sys/kern/kern_event.c ============================================================================== --- head/sys/kern/kern_event.c Mon Jun 27 22:21:29 2016 (r302241) +++ head/sys/kern/kern_event.c Mon Jun 27 23:34:53 2016 (r302242) @@ -2204,7 +2204,7 @@ knlist_init(struct knlist *knl, void *lo else knl->kl_assert_unlocked = kl_assert_unlocked; - knl->kl_autodestroy = false; + knl->kl_autodestroy = 0; SLIST_INIT(&knl->kl_list); } @@ -2255,7 +2255,7 @@ knlist_detach(struct knlist *knl) { KNL_ASSERT_LOCKED(knl); - knl->kl_autodestroy = true; + knl->kl_autodestroy = 1; if (knlist_empty(knl)) { knlist_destroy(knl); free(knl, M_KQUEUE); Modified: head/sys/sys/event.h ============================================================================== --- head/sys/sys/event.h Mon Jun 27 22:21:29 2016 (r302241) +++ head/sys/sys/event.h Mon Jun 27 23:34:53 2016 (r302242) @@ -159,7 +159,7 @@ struct knlist { void (*kl_assert_locked)(void *); void (*kl_assert_unlocked)(void *); void *kl_lockarg; /* argument passed to lock functions */ - bool kl_autodestroy; + int kl_autodestroy; }; From owner-svn-src-head@freebsd.org Mon Jun 27 23:46:36 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 10A38B81817; Mon, 27 Jun 2016 23:46:36 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AF8C8202F; Mon, 27 Jun 2016 23:46:35 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u5RNkO5A032930 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Tue, 28 Jun 2016 02:46:24 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u5RNkO5A032930 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id u5RNkO8j032929; Tue, 28 Jun 2016 02:46:24 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 28 Jun 2016 02:46:24 +0300 From: Konstantin Belousov To: Ngie Cooper Cc: jilles@freebsd.org, "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Subject: Re: svn commit: r302216 - in head/sys: kern nlm Message-ID: <20160627234624.GV38613@kib.kiev.ua> References: <201606262008.u5QK8gTx042729@repo.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="Wfe1KbQWcwuymTys" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.1 (2016-04-27) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-Content-Filtered-By: Mailman/MimeDel 2.1.22 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Mon, 27 Jun 2016 23:46:36 -0000 --Wfe1KbQWcwuymTys Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Jun 27, 2016 at 01:18:48PM -0700, Ngie Cooper wrote: > On Sun, Jun 26, 2016 at 1:08 PM, Konstantin Belousov wrote: > > Author: kib > > Date: Sun Jun 26 20:08:42 2016 > > New Revision: 302216 > > URL: https://svnweb.freebsd.org/changeset/base/302216 > > > > Log: > > When sleeping waiting for either local or remote advisory lock, > > interrupt sleeps with the ERESTART on the suspension attempts. > > Otherwise, single-threading requests are deferred until the locks are > > granted for NFS files, which causes hangs. > > > > When retrying local registration of the remotely-granted adv lock, > > allow full suspension and check for suspension, for usual reasons. > > > > Reported by: markj, pho > > Reviewed by: jilles > > Tested by: pho > > Sponsored by: The FreeBSD Foundation > > MFC after: 2 weeks > > Approved by: re (gjb) > > One of the NetBSD tests seems to be failing now: > https://jenkins.freebsd.org/job/FreeBSD_HEAD/334/testReport/junit/sys.kern/lockf_test/randlock/ > . Indeed. The reason is that TDF_SBDRY + TDF_SERESTART (or TDF_SEINTR) combination should be treated almost as if TDF_SBDRY is not set, at least for the purposes of filtering out stops. It must not allow the real stop to occur at a protected sleep point, though. The committed revision lacks updates to kern_sig.c to kick the sleeping thread in TDF_SERESTART condition to make it runnable to reach boundary. I attached the distilled case from the NetBSD test below. Another good test case to illustrate that is to do in one terminal echo 123 >/tmp/1 lockf /tmp/1 sleep 100000 and in another lockf /tmp/1 date ^Z This should have failed in similar way on NFS only, before the changes. The patch attached fixed both cases for me. --Wfe1KbQWcwuymTys Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="1.patch" diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 424f316..059103dc 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -107,7 +107,7 @@ static int killpg1(struct thread *td, int sig, int pgid, int all, static int issignal(struct thread *td); static int sigprop(int sig); static void tdsigwakeup(struct thread *, int, sig_t, int); -static void sig_suspend_threads(struct thread *, struct proc *, int); +static int sig_suspend_threads(struct thread *, struct proc *, int); static int filt_sigattach(struct knote *kn); static void filt_sigdetach(struct knote *kn); static int filt_signal(struct knote *kn, long hint); @@ -2327,7 +2327,7 @@ tdsendsignal(struct proc *p, struct thread *td, int sig, ksiginfo_t *ksi) p->p_flag |= P_STOPPED_SIG; p->p_xsig = sig; PROC_SLOCK(p); - sig_suspend_threads(td, p, 1); + wakeup_swapper = sig_suspend_threads(td, p, 1); if (p->p_numthreads == p->p_suspcount) { /* * only thread sending signal to another @@ -2341,6 +2341,8 @@ tdsendsignal(struct proc *p, struct thread *td, int sig, ksiginfo_t *ksi) sigqueue_delete_proc(p, p->p_xsig); } else PROC_SUNLOCK(p); + if (wakeup_swapper) + kick_proc0(); goto out; } } else { @@ -2421,7 +2423,8 @@ tdsigwakeup(struct thread *td, int sig, sig_t action, int intrval) * Don't awaken a sleeping thread for SIGSTOP if the * STOP signal is deferred. */ - if ((prop & SA_STOP) && (td->td_flags & TDF_SBDRY)) + if ((prop & SA_STOP) != 0 && (td->td_flags & (TDF_SBDRY | + TDF_SERESTART | TDF_SEINTR)) == TDF_SBDRY) goto out; /* @@ -2449,14 +2452,16 @@ out: kick_proc0(); } -static void +static int sig_suspend_threads(struct thread *td, struct proc *p, int sending) { struct thread *td2; + int wakeup_swapper; PROC_LOCK_ASSERT(p, MA_OWNED); PROC_SLOCK_ASSERT(p, MA_OWNED); + wakeup_swapper = 0; FOREACH_THREAD_IN_PROC(p, td2) { thread_lock(td2); td2->td_flags |= TDF_ASTPENDING | TDF_NEEDSUSPCHK; @@ -2465,11 +2470,18 @@ sig_suspend_threads(struct thread *td, struct proc *p, int sending) if (td2->td_flags & TDF_SBDRY) { /* * Once a thread is asleep with - * TDF_SBDRY set, it should never + * TDF_SBDRY and without TDF_SERESTART + * or TDF_SEINTR set, it should never * become suspended due to this check. */ KASSERT(!TD_IS_SUSPENDED(td2), ("thread with deferred stops suspended")); + if ((td2->td_flags & (TDF_SERESTART | + TDF_SEINTR)) != 0 && sending) { + wakeup_swapper |= sleepq_abort(td, + (td2->td_flags & TDF_SERESTART) + != 0 ? ERESTART : EINTR); + } } else if (!TD_IS_SUSPENDED(td2)) { thread_suspend_one(td2); } @@ -2483,6 +2495,7 @@ sig_suspend_threads(struct thread *td, struct proc *p, int sending) } thread_unlock(td2); } + return (wakeup_swapper); } int @@ -2705,7 +2718,8 @@ issignal(struct thread *td) SIGSETOR(sigpending, p->p_sigqueue.sq_signals); SIGSETNAND(sigpending, td->td_sigmask); - if (p->p_flag & P_PPWAIT || td->td_flags & TDF_SBDRY) + if ((p->p_flag & P_PPWAIT) != 0 || (td->td_flags & + (TDF_SBDRY | TDF_SERESTART | TDF_SEINTR)) == TDF_SBDRY) SIG_STOPSIGMASK(sigpending); if (SIGISEMPTY(sigpending)) /* no signal to send */ return (0); --Wfe1KbQWcwuymTys-- From owner-svn-src-head@freebsd.org Tue Jun 28 07:47:43 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 89DD7B85CB1; Tue, 28 Jun 2016 07:47:43 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 56DDD2FDA; Tue, 28 Jun 2016 07:47:43 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5S7lgvD051545; Tue, 28 Jun 2016 07:47:42 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5S7lgMq051544; Tue, 28 Jun 2016 07:47:42 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201606280747.u5S7lgMq051544@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Tue, 28 Jun 2016 07:47:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302246 - head/lib/libc/tests/ssp X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Tue, 28 Jun 2016 07:47:43 -0000 Author: cy Date: Tue Jun 28 07:47:42 2016 New Revision: 302246 URL: https://svnweb.freebsd.org/changeset/base/302246 Log: This commit addresses regression introduceded in r302177 (WITH_SYSTEM_COMPILER: Enable by default) and it's prerequisite: r300354, caused i386 builds to fail when cross-built on an amd64 host. Reviewed by: bdrewery, delphij, gjb Approved by: re (gjb) Modified: head/lib/libc/tests/ssp/Makefile Modified: head/lib/libc/tests/ssp/Makefile ============================================================================== --- head/lib/libc/tests/ssp/Makefile Tue Jun 28 07:11:27 2016 (r302245) +++ head/lib/libc/tests/ssp/Makefile Tue Jun 28 07:47:42 2016 (r302246) @@ -1,5 +1,9 @@ # $FreeBSD$ +# XXX This is a workaround to allow i386 to cross-compile on an amd64 host. +.include +# XXX --- + .include NO_WERROR= @@ -34,7 +38,17 @@ PROGS+= h_memset .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" .if ${COMPILER_TYPE} == "clang" && ${MK_TOOLCHAIN} == "yes" .if ${COMPILER_VERSION} < 30500 || 30700 <= ${COMPILER_VERSION} + +# XXX This is a workaround to allow i386 to cross-compile on an amd64 host. +.if ${MACHINE_CPUARCH} == ${_HOST_ARCH} +# XXX --- + PROGS+= h_raw + +# XXX This is a workaround to allow i386 to cross-compile on an amd64 host. +.endif +# XXX --- + .endif .endif .endif From owner-svn-src-head@freebsd.org Tue Jun 28 13:37:03 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 819DCB85A2C; Tue, 28 Jun 2016 13:37:03 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4FF132217; Tue, 28 Jun 2016 13:37:03 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5SDb28I082558; Tue, 28 Jun 2016 13:37:02 GMT (envelope-from jtl@FreeBSD.org) Received: (from jtl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5SDb2rh082554; Tue, 28 Jun 2016 13:37:02 GMT (envelope-from jtl@FreeBSD.org) Message-Id: <201606281337.u5SDb2rh082554@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jtl set sender to jtl@FreeBSD.org using -f From: "Jonathan T. Looney" Date: Tue, 28 Jun 2016 13:37:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302247 - in head: share/man/man4 share/man/man9 tools/build/options X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Tue, 28 Jun 2016 13:37:03 -0000 Author: jtl Date: Tue Jun 28 13:37:01 2016 New Revision: 302247 URL: https://svnweb.freebsd.org/changeset/base/302247 Log: Document support for alternate TCP stacks. Differential Revision: https://reviews.freebsd.org/D6940 Reviewed by: hiren Approved by: re (gjb) Sponsored by: Juniper Networks Added: head/share/man/man9/tcp_functions.9 (contents, props changed) head/tools/build/options/WITH_EXTRA_TCP_STACKS (contents, props changed) Modified: head/share/man/man4/tcp.4 head/share/man/man9/Makefile Modified: head/share/man/man4/tcp.4 ============================================================================== --- head/share/man/man4/tcp.4 Tue Jun 28 07:47:42 2016 (r302246) +++ head/share/man/man4/tcp.4 Tue Jun 28 13:37:01 2016 (r302247) @@ -34,7 +34,7 @@ .\" From: @(#)tcp.4 8.1 (Berkeley) 6/5/93 .\" $FreeBSD$ .\" -.Dd May 19, 2016 +.Dd June 28, 2016 .Dt TCP 4 .Os .Sh NAME @@ -119,7 +119,7 @@ supports a number of socket options whic .Xr setsockopt 2 and tested with .Xr getsockopt 2 : -.Bl -tag -width ".Dv TCP_CONGESTION" +.Bl -tag -width ".Dv TCP_FUNCTION_BLK" .It Dv TCP_INFO Information about a socket's underlying TCP session may be retrieved by passing the read-only option @@ -148,6 +148,20 @@ connection. See .Xr mod_cc 4 for details. +.It Dv TCP_FUNCTION_BLK +Select or query the set of functions that TCP will use for this connection. +This allows a user to select an alternate TCP stack. +The alternate TCP stack must already be loaded in the kernel. +To list the available TCP stacks, see +.Va functions_available +in the +.Sx MIB Variables +section further down. +To list the default TCP stack, see +.Va functions_default +in the +.Sx MIB Variables +section. .It Dv TCP_KEEPINIT This .Xr setsockopt 2 @@ -568,6 +582,10 @@ Number of times default MSS was used in .It Va pmtud_blackhole_failed Number of connections for which retransmits continued even after MSS downshift. +.It Va functions_available +List of available TCP function blocks (TCP stacks). +.It Va functions_default +The default TCP function block (TCP stack). .El .Sh ERRORS A socket operation may fail with one of the following errors returned: @@ -599,6 +617,10 @@ exists; .It Bq Er EAFNOSUPPORT when an attempt is made to bind or connect a socket to a multicast address. +.It Bq Er EINVAL +when trying to change TCP function blocks at an invalid point in the session; +.It Bq Er ENOENT +when trying to use a TCP function block that is not available; .El .Sh SEE ALSO .Xr getsockopt 2 , Modified: head/share/man/man9/Makefile ============================================================================== --- head/share/man/man9/Makefile Tue Jun 28 07:47:42 2016 (r302246) +++ head/share/man/man9/Makefile Tue Jun 28 13:37:01 2016 (r302247) @@ -284,6 +284,7 @@ MAN= accept_filter.9 \ sysctl_ctx_init.9 \ SYSINIT.9 \ taskqueue.9 \ + tcp_functions.9 \ thread_exit.9 \ time.9 \ timeout.9 \ @@ -1734,6 +1735,8 @@ MLINKS+=taskqueue.9 TASK_INIT.9 \ taskqueue.9 taskqueue_start_threads_pinned.9 \ taskqueue.9 taskqueue_unblock.9 \ taskqueue.9 TIMEOUT_TASK_INIT.9 +MLINKS+=tcp_functions.9 register_tcp_functions.9 \ + tcp_functions.9 deregister_tcp_functions.9 MLINKS+=time.9 boottime.9 \ time.9 time_second.9 \ time.9 time_uptime.9 Added: head/share/man/man9/tcp_functions.9 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/share/man/man9/tcp_functions.9 Tue Jun 28 13:37:01 2016 (r302247) @@ -0,0 +1,285 @@ +.\" +.\" Copyright (c) 2016 Jonathan Looney +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR +.\" ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd June 28, 2016 +.Dt TCP_FUNCTIONS 9 +.Os +.Sh NAME +.Nm tcp_functions +.Nd Alternate TCP Stack Framework +.Sh SYNOPSIS +.In netinet/tcp.h +.In netinet/tcp_var.h +.Ft int +.Fn register_tcp_functions "struct tcp_function_block *blk" "int wait" +.Ft int +.Fn deregister_tcp_functions "struct tcp_function_block *blk" +.Sh DESCRIPTION +The +.Nm +framework allows a kernel developer to implement alternate TCP stacks. +The alternate stacks can be compiled in the kernel or can be implemented in +loadable kernel modules. +This functionality is intended to encourage experimentation with the TCP stack +and to allow alternate behaviors to be deployed for different TCP connections +on a single system. +.Pp +A system administrator can set a system default stack. +By default, all TCP connections will use the system default stack. +Additionally, users can specify a particular stack to use on a per-connection +basis. +(See +.Xr tcp 4 +for details on setting the system default stack, or selecting a specific stack +for a given connection.) +.Pp +This man page treats "TCP stacks" as synonymous with "function blocks". +This is intentional. +A "TCP stack" is a collection of functions that implement a set of behavior. +Therefore, an alternate "function block" defines an alternate "TCP stack". +.Pp +.Nm +modules must call the +.Fn register_tcp_functions +function during initialization and successfully call the +.Fn deregister_tcp_functions +function prior to allowing the module to be unloaded. +.Pp +The +.Fn register_tcp_functions +function requests that the system add a specified function block to the system. +.Pp +The +.Fn deregister_tcp_functions +function requests that the system remove a specified function block from the +system. +If the call fails because sockets are still using the specified function block, +the system will mark the function block as being in the process of being +removed. +This will prevent additional sockets from using the specified function block. +However, it will not impact sockets that are already using the function block. +.Pp +The +.Fa blk +argument is a pointer to a +.Vt "struct tcp_function_block" , +which is explained below (see +.Sx Function Block Structure ) . +The +.Fa wait +argument is used as the +.Fa flags +argument to +.Xr malloc 9 , +and must be set to one of the valid values defined in that man page. +.Ss Function Block Structure +The +.Fa blk argument is a pointer to a +.Vt "struct tcp_function_block" , +which has the following members: +.Bd -literal -offset indent +struct tcp_function_block { + char tfb_tcp_block_name[TCP_FUNCTION_NAME_LEN_MAX]; + int (*tfb_tcp_output)(struct tcpcb *); + void (*tfb_tcp_do_segment)(struct mbuf *, struct tcphdr *, + struct socket *, struct tcpcb *, + int, int, uint8_t, + int); + int (*tfb_tcp_ctloutput)(struct socket *so, + struct sockopt *sopt, + struct inpcb *inp, struct tcpcb *tp); + /* Optional memory allocation/free routine */ + void (*tfb_tcp_fb_init)(struct tcpcb *); + void (*tfb_tcp_fb_fini)(struct tcpcb *); + /* Optional timers, must define all if you define one */ + int (*tfb_tcp_timer_stop_all)(struct tcpcb *); + void (*tfb_tcp_timer_activate)(struct tcpcb *, + uint32_t, u_int); + int (*tfb_tcp_timer_active)(struct tcpcb *, uint32_t); + void (*tfb_tcp_timer_stop)(struct tcpcb *, uint32_t); + void (*tfb_tcp_rexmit_tmr)(struct tcpcb *); + volatile uint32_t tfb_refcnt; + uint32_t tfb_flags; +}; +.Ed +.Pp +The +.Va tfb_tcp_block_name +field identifies the unique name of the TCP stack, and should be no longer than +TCP_FUNCTION_NAME_LEN_MAX-1 characters in length. +.Pp +The +.Va tfb_tcp_output , +.Va tfb_tcp_do_segment , +and +.Va tfb_tcp_ctloutput +fields are pointers to functions that perform the equivalent actions +as the default +.Fn tcp_output , +.Fn tcp_do_segment , +and +.Fn tcp_default_ctloutput +functions, respectively. +Each of these function pointers must be non-NULL. +.Pp +If a TCP stack needs to initialize data when a socket first selects the TCP +stack (or, when the socket is first opened), it should set a non-NULL +pointer in the +.Va tfb_tcp_fb_init +field. +Likewise, if a TCP stack needs to cleanup data when a socket stops using the +TCP stack (or, when the socket is closed), it should set a non-NULL pointer +in the +.Va tfb_tcp_fb_fini +field. +.Pp +If the TCP stack implements additional timers, the TCP stack should set a +non-NULL pointer in the +.Va tfb_tcp_timer_stop_all , +.Va tfb_tcp_timer_activate , +.Va tfb_tcp_timer_active , +and +.Va tfb_tcp_timer_stop +fields. +These fields should all be +.Dv NULL +or should all contain pointers to functions. +The +.Va tfb_tcp_timer_activate , +.Va tfb_tcp_timer_active , +and +.Va tfb_tcp_timer_stop +functions will be called when the +.Fn tcp_timer_activate , +.Fn tcp_timer_active , +and +.Fn tcp_timer_stop +functions, respectively, are called with a timer type other than the standard +types. +The functions defined by the TCP stack have the same semantics (both for +arguments and return values) as the normal timer functions they supplement. +.Pp +Additionally, a stack may define its own actions to take when the retransmit +timer fires by setting a non-NULL function pointer in the +.Va tfb_tcp_rexmit_tmr +field. +This function is called very early in the process of handling a retransmit +timer. +However, care must be taken to ensure the retransmit timer leaves the +TCP control block in a valid state for the remainder of the retransmit +timer logic. +.Pp +The +.Va tfb_refcnt +and +.Va tfb_flags +fields are used by the kernel's TCP code and will be initialized when the +TCP stack is registered. +.Ss Requirements for Alternate TCP Stacks +If the TCP stack needs to store data beyond what is stored in the default +TCP control block, the TCP stack can initialize its own per-connection storage. +The +.Va t_fb_ptr +field in the +.Vt "struct tcpcb" +control block structure has been reserved to hold a pointer to this +per-connection storage. +If the TCP stack uses this alternate storage, it should understand that the +value of the +.Va t_fb_ptr +pointer may not be initialized to +.Dv NULL . +Therefore, it should use a +.Va tfb_tcp_fb_init +function to initialize this field. +Additionally, it should use a +.Va tfb_tcp_fb_fini +function to deallocate storage when the socket is closed. +.Pp +It is understood that alternate TCP stacks may keep different sets of data. +However, in order to ensure that data is available to both the user and the +rest of the system in a standardized format, alternate TCP stacks must +update all fields in the TCP control block to the greatest extent practical. +.Sh RETURN VALUES +The +.Fn register_tcp_functions +and +.Fn deregister_tcp_functions +functions return zero on success and non-zero on failure. +In particular, the +.Fn deregister_tcp_functions +will return +.Er EBUSY +until no more connections are using the specified TCP stack. +A module calling +.Fn deregister_tcp_functions +must be prepared to wait until all connections have stopped using the +specified TCP stack. +.Sh ERRORS +The +.Fn register_tcp_functions +function will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +Any of the members of the +.Fa blk +argument are set incorrectly. +.It Bq Er ENOMEM +The function could not allocate memory for its internal data. +.It Bq Er EALREADY +A function block is already registered with the same name. +.El +The +.Fn deregister_tcp_functions +function will fail if: +.Bl -tag -width Er +.It Bq Er EPERM +The +.Fa blk +argument references the kernel's compiled-in default function block. +.It Bq Er EBUSY +The function block is still in use by one or more sockets, or is defined as +the current default function block. +.It Bq Er ENOENT +The +.Fa blk +argument references a function block that is not currently registered. +.Sh SEE ALSO +.Xr malloc 9 , +.Xr tcp 4 +.Sh HISTORY +This framework first appeared in +.Fx 11.0 . +.Sh AUTHORS +.An -nosplit +The +.Nm +framework was written by +.An Randall Stewart Aq Mt rrs@FreeBSD.org . +.Pp +This manual page was written by +.An Jonathan Looney Aq Mt jtl@FreeBSD.org . Added: head/tools/build/options/WITH_EXTRA_TCP_STACKS ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/build/options/WITH_EXTRA_TCP_STACKS Tue Jun 28 13:37:01 2016 (r302247) @@ -0,0 +1,2 @@ +.\" $FreeBSD$ +Set to build extra TCP stack modules. From owner-svn-src-head@freebsd.org Tue Jun 28 13:42:51 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BB4CCB85BDA; Tue, 28 Jun 2016 13:42:51 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 880BC2793; Tue, 28 Jun 2016 13:42:51 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5SDgorn086244; Tue, 28 Jun 2016 13:42:50 GMT (envelope-from jtl@FreeBSD.org) Received: (from jtl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5SDgoMD086243; Tue, 28 Jun 2016 13:42:50 GMT (envelope-from jtl@FreeBSD.org) Message-Id: <201606281342.u5SDgoMD086243@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jtl set sender to jtl@FreeBSD.org using -f From: "Jonathan T. Looney" Date: Tue, 28 Jun 2016 13:42:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302248 - head/share/man/man5 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Tue, 28 Jun 2016 13:42:51 -0000 Author: jtl Date: Tue Jun 28 13:42:50 2016 New Revision: 302248 URL: https://svnweb.freebsd.org/changeset/base/302248 Log: Regenerate for WITH_EXTRA_TCP_STACKS updates. Approved by: re (gjb) Sponsored by: Juniper Networks Modified: head/share/man/man5/src.conf.5 Modified: head/share/man/man5/src.conf.5 ============================================================================== --- head/share/man/man5/src.conf.5 Tue Jun 28 13:37:01 2016 (r302247) +++ head/share/man/man5/src.conf.5 Tue Jun 28 13:42:50 2016 (r302248) @@ -1,7 +1,7 @@ .\" DO NOT EDIT-- this file is automatically generated. .\" from FreeBSD: head/tools/build/options/makeman 292283 2015-12-15 18:42:30Z bdrewery .\" $FreeBSD$ -.Dd June 24, 2016 +.Dd June 28, 2016 .Dt SRC.CONF 5 .Os .Sh NAME @@ -633,6 +633,9 @@ An alternate bootstrap tool chain must b .\" from FreeBSD: head/tools/build/options/WITHOUT_EXAMPLES 156938 2006-03-21 09:06:24Z ru Set to avoid installing examples to .Pa /usr/share/examples/ . +.It Va WITH_EXTRA_TCP_STACKS +.\" from FreeBSD: head/tools/build/options/WITH_EXTRA_TCP_STACKS 302247 2016-06-28 13:37:01Z jtl +Set to build extra TCP stack modules. .It Va WITHOUT_FDT .\" from FreeBSD: head/tools/build/options/WITHOUT_FDT 221539 2011-05-06 19:10:27Z ru Set to not build Flattened Device Tree support as part of the base system. From owner-svn-src-head@freebsd.org Tue Jun 28 16:41:51 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C0330B859D6; Tue, 28 Jun 2016 16:41:51 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 983192969; Tue, 28 Jun 2016 16:41:51 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5SGfocH061451; Tue, 28 Jun 2016 16:41:50 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5SGfoTq061450; Tue, 28 Jun 2016 16:41:50 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201606281641.u5SGfoTq061450@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 28 Jun 2016 16:41:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302250 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Tue, 28 Jun 2016 16:41:51 -0000 Author: kib Date: Tue Jun 28 16:41:50 2016 New Revision: 302250 URL: https://svnweb.freebsd.org/changeset/base/302250 Log: Complete r302215. TDF_SBDRY | TDF_SERESTART and TDF_SBDRY | TDF_SEINTR flags values, unlike TDF_SBDRY, must be treated almost as if TDF_SBDRY is not set for STOP signal delivery. The only difference is that sig_suspend_threads() should abort the sleep instead of doing immediate suspension. Reported by: ngie Sponsored by: The FreeBSD Foundation MFC after: 12 days Approved by: re (gjb) Modified: head/sys/kern/kern_sig.c Modified: head/sys/kern/kern_sig.c ============================================================================== --- head/sys/kern/kern_sig.c Tue Jun 28 16:41:02 2016 (r302249) +++ head/sys/kern/kern_sig.c Tue Jun 28 16:41:50 2016 (r302250) @@ -107,7 +107,7 @@ static int killpg1(struct thread *td, in static int issignal(struct thread *td); static int sigprop(int sig); static void tdsigwakeup(struct thread *, int, sig_t, int); -static void sig_suspend_threads(struct thread *, struct proc *, int); +static int sig_suspend_threads(struct thread *, struct proc *, int); static int filt_sigattach(struct knote *kn); static void filt_sigdetach(struct knote *kn); static int filt_signal(struct knote *kn, long hint); @@ -2327,7 +2327,7 @@ tdsendsignal(struct proc *p, struct thre p->p_flag |= P_STOPPED_SIG; p->p_xsig = sig; PROC_SLOCK(p); - sig_suspend_threads(td, p, 1); + wakeup_swapper = sig_suspend_threads(td, p, 1); if (p->p_numthreads == p->p_suspcount) { /* * only thread sending signal to another @@ -2341,6 +2341,8 @@ tdsendsignal(struct proc *p, struct thre sigqueue_delete_proc(p, p->p_xsig); } else PROC_SUNLOCK(p); + if (wakeup_swapper) + kick_proc0(); goto out; } } else { @@ -2421,7 +2423,8 @@ tdsigwakeup(struct thread *td, int sig, * Don't awaken a sleeping thread for SIGSTOP if the * STOP signal is deferred. */ - if ((prop & SA_STOP) && (td->td_flags & TDF_SBDRY)) + if ((prop & SA_STOP) != 0 && (td->td_flags & (TDF_SBDRY | + TDF_SERESTART | TDF_SEINTR)) == TDF_SBDRY) goto out; /* @@ -2449,14 +2452,16 @@ out: kick_proc0(); } -static void +static int sig_suspend_threads(struct thread *td, struct proc *p, int sending) { struct thread *td2; + int wakeup_swapper; PROC_LOCK_ASSERT(p, MA_OWNED); PROC_SLOCK_ASSERT(p, MA_OWNED); + wakeup_swapper = 0; FOREACH_THREAD_IN_PROC(p, td2) { thread_lock(td2); td2->td_flags |= TDF_ASTPENDING | TDF_NEEDSUSPCHK; @@ -2465,11 +2470,18 @@ sig_suspend_threads(struct thread *td, s if (td2->td_flags & TDF_SBDRY) { /* * Once a thread is asleep with - * TDF_SBDRY set, it should never + * TDF_SBDRY and without TDF_SERESTART + * or TDF_SEINTR set, it should never * become suspended due to this check. */ KASSERT(!TD_IS_SUSPENDED(td2), ("thread with deferred stops suspended")); + if ((td2->td_flags & (TDF_SERESTART | + TDF_SEINTR)) != 0 && sending) { + wakeup_swapper |= sleepq_abort(td, + (td2->td_flags & TDF_SERESTART) + != 0 ? ERESTART : EINTR); + } } else if (!TD_IS_SUSPENDED(td2)) { thread_suspend_one(td2); } @@ -2483,6 +2495,7 @@ sig_suspend_threads(struct thread *td, s } thread_unlock(td2); } + return (wakeup_swapper); } int @@ -2705,7 +2718,8 @@ issignal(struct thread *td) SIGSETOR(sigpending, p->p_sigqueue.sq_signals); SIGSETNAND(sigpending, td->td_sigmask); - if (p->p_flag & P_PPWAIT || td->td_flags & TDF_SBDRY) + if ((p->p_flag & P_PPWAIT) != 0 || (td->td_flags & + (TDF_SBDRY | TDF_SERESTART | TDF_SEINTR)) == TDF_SBDRY) SIG_STOPSIGMASK(sigpending); if (SIGISEMPTY(sigpending)) /* no signal to send */ return (0); From owner-svn-src-head@freebsd.org Tue Jun 28 16:42:41 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7A985B85A4B; Tue, 28 Jun 2016 16:42:41 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 32C612B46; Tue, 28 Jun 2016 16:42:41 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5SGgeTW061530; Tue, 28 Jun 2016 16:42:40 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5SGge18061528; Tue, 28 Jun 2016 16:42:40 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201606281642.u5SGge18061528@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 28 Jun 2016 16:42:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302251 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Tue, 28 Jun 2016 16:42:41 -0000 Author: kib Date: Tue Jun 28 16:42:40 2016 New Revision: 302251 URL: https://svnweb.freebsd.org/changeset/base/302251 Log: Do not use Giant to prevent parallel calls to CLOCK_SETTIME(). Use private mtx in resettodr(), no implementation of CLOCK_SETTIME() is allowed to sleep. Reviewed by: imp, jhb Sponsored by: The FreeBSD Foundation Approved by: re (gjb) X-Differential revision: https://reviews.freebsd.org/D6825 Modified: head/sys/kern/subr_clock.c head/sys/kern/subr_rtc.c Modified: head/sys/kern/subr_clock.c ============================================================================== --- head/sys/kern/subr_clock.c Tue Jun 28 16:41:50 2016 (r302250) +++ head/sys/kern/subr_clock.c Tue Jun 28 16:42:40 2016 (r302251) @@ -67,8 +67,8 @@ sysctl_machdep_adjkerntz(SYSCTL_HANDLER_ resettodr(); return (error); } -SYSCTL_PROC(_machdep, OID_AUTO, adjkerntz, CTLTYPE_INT|CTLFLAG_RW, - &adjkerntz, 0, sysctl_machdep_adjkerntz, "I", +SYSCTL_PROC(_machdep, OID_AUTO, adjkerntz, CTLTYPE_INT | CTLFLAG_RW | + CTLFLAG_MPSAFE, &adjkerntz, 0, sysctl_machdep_adjkerntz, "I", "Local offset from UTC in seconds"); static int ct_debug; Modified: head/sys/kern/subr_rtc.c ============================================================================== --- head/sys/kern/subr_rtc.c Tue Jun 28 16:41:50 2016 (r302250) +++ head/sys/kern/subr_rtc.c Tue Jun 28 16:42:40 2016 (r302251) @@ -62,6 +62,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include #ifdef FFCLOCK #include @@ -73,6 +75,8 @@ __FBSDID("$FreeBSD$"); static device_t clock_dev = NULL; static long clock_res; static struct timespec clock_adj; +static struct mtx resettodr_lock; +MTX_SYSINIT(resettodr_init, &resettodr_lock, "tod2rl", MTX_DEF); /* XXX: should be kern. now, it's no longer machdep. */ static int disable_rtc_set; @@ -168,11 +172,14 @@ resettodr(void) if (disable_rtc_set || clock_dev == NULL) return; + mtx_lock(&resettodr_lock); getnanotime(&ts); timespecadd(&ts, &clock_adj); ts.tv_sec -= utc_offset(); /* XXX: We should really set all registered RTCs */ - if ((error = CLOCK_SETTIME(clock_dev, &ts)) != 0) + error = CLOCK_SETTIME(clock_dev, &ts); + mtx_unlock(&resettodr_lock); + if (error != 0) printf("warning: clock_settime failed (%d), time-of-day clock " "not adjusted to system time\n", error); } From owner-svn-src-head@freebsd.org Tue Jun 28 16:43:24 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 73ECFB85AAF; Tue, 28 Jun 2016 16:43:24 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 50D7D2CD1; Tue, 28 Jun 2016 16:43:24 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5SGhN43061607; Tue, 28 Jun 2016 16:43:23 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5SGhNsi061606; Tue, 28 Jun 2016 16:43:23 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201606281643.u5SGhNsi061606@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 28 Jun 2016 16:43:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302252 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Tue, 28 Jun 2016 16:43:24 -0000 Author: kib Date: Tue Jun 28 16:43:23 2016 New Revision: 302252 URL: https://svnweb.freebsd.org/changeset/base/302252 Log: Currently the ntptime code and resettodr() are Giant-locked. In particular, the Giant is supposed to protect against parallel ntp_adjtime(2) invocations. But, for instance, sys_ntp_adjtime() does copyout(9) under Giant and then examines time_status to return syscall result. Since copyout(9) could sleep, the syscall result might be inconsistent. Another and more important issue is that if PPS is configured, hardpps(9) is executed without any protection against the parallel top-level code invocation. Potentially, this may result in the inconsistent state of the ntptime state variables, but I cannot say how serious such distortion is. The non-functional splclock() call in sys_ntp_adjtime() protected against clock interrupts calling hardpps() in the pre-SMP era. Modernize the locking. A mutex protects ntptime data. Due to the hardpps() KPI legitimately serving from the interrupt filters (and e.g. uart(4) does call it from filter), the lock cannot be sleepable mutex if PPS_SYNC is defined. Otherwise, use normal sleepable mutex to reduce interrupt latency. Reviewed by: imp, jhb Sponsored by: The FreeBSD Foundation Approved by: re (gjb) Differential revision: https://reviews.freebsd.org/D6825 Modified: head/sys/kern/kern_ntptime.c Modified: head/sys/kern/kern_ntptime.c ============================================================================== --- head/sys/kern/kern_ntptime.c Tue Jun 28 16:42:40 2016 (r302251) +++ head/sys/kern/kern_ntptime.c Tue Jun 28 16:43:23 2016 (r302252) @@ -162,6 +162,30 @@ static l_fp time_adj; /* tick adjust ( static int64_t time_adjtime; /* correction from adjtime(2) (usec) */ +static struct mtx ntpadj_lock; +MTX_SYSINIT(ntpadj, &ntpadj_lock, "ntpadj", +#ifdef PPS_SYNC + MTX_SPIN +#else + MTX_DEF +#endif +); + +/* + * When PPS_SYNC is defined, hardpps() function is provided which can + * be legitimately called from interrupt filters. Due to this, use + * spinlock for ntptime state protection, otherwise sleepable mutex is + * adequate. + */ +#ifdef PPS_SYNC +#define NTPADJ_LOCK() mtx_lock_spin(&ntpadj_lock) +#define NTPADJ_UNLOCK() mtx_unlock_spin(&ntpadj_lock) +#else +#define NTPADJ_LOCK() mtx_lock(&ntpadj_lock) +#define NTPADJ_UNLOCK() mtx_unlock(&ntpadj_lock) +#endif +#define NTPADJ_ASSERT_LOCKED() mtx_assert(&ntpadj_lock, MA_OWNED) + #ifdef PPS_SYNC /* * The following variables are used when a pulse-per-second (PPS) signal @@ -203,11 +227,12 @@ static long pps_errcnt; /* calibration static void ntp_init(void); static void hardupdate(long offset); static void ntp_gettime1(struct ntptimeval *ntvp); -static int ntp_is_time_error(void); +static bool ntp_is_time_error(int tsl); -static int -ntp_is_time_error(void) +static bool +ntp_is_time_error(int tsl) { + /* * Status word error decode. If any of these conditions occur, * an error is returned, instead of the status word. Most @@ -216,30 +241,29 @@ ntp_is_time_error(void) * * Hardware or software error */ - if ((time_status & (STA_UNSYNC | STA_CLOCKERR)) || + if ((tsl & (STA_UNSYNC | STA_CLOCKERR)) || /* * PPS signal lost when either time or frequency synchronization * requested */ - (time_status & (STA_PPSFREQ | STA_PPSTIME) && - !(time_status & STA_PPSSIGNAL)) || + (tsl & (STA_PPSFREQ | STA_PPSTIME) && + !(tsl & STA_PPSSIGNAL)) || /* * PPS jitter exceeded when time synchronization requested */ - (time_status & STA_PPSTIME && - time_status & STA_PPSJITTER) || + (tsl & STA_PPSTIME && tsl & STA_PPSJITTER) || /* * PPS wander exceeded or calibration error when frequency * synchronization requested */ - (time_status & STA_PPSFREQ && - time_status & (STA_PPSWANDER | STA_PPSERROR))) - return (1); + (tsl & STA_PPSFREQ && + tsl & (STA_PPSWANDER | STA_PPSERROR))) + return (true); - return (0); + return (false); } static void @@ -247,7 +271,7 @@ ntp_gettime1(struct ntptimeval *ntvp) { struct timespec atv; /* nanosecond time */ - GIANT_REQUIRED; + NTPADJ_ASSERT_LOCKED(); nanotime(&atv); ntvp->time.tv_sec = atv.tv_sec; @@ -257,7 +281,7 @@ ntp_gettime1(struct ntptimeval *ntvp) ntvp->tai = time_tai; ntvp->time_state = time_state; - if (ntp_is_time_error()) + if (ntp_is_time_error(time_status)) ntvp->time_state = TIME_ERROR; } @@ -278,9 +302,9 @@ sys_ntp_gettime(struct thread *td, struc { struct ntptimeval ntv; - mtx_lock(&Giant); + NTPADJ_LOCK(); ntp_gettime1(&ntv); - mtx_unlock(&Giant); + NTPADJ_UNLOCK(); td->td_retval[0] = ntv.time_state; return (copyout(&ntv, uap->ntvp, sizeof(ntv))); @@ -291,14 +315,17 @@ ntp_sysctl(SYSCTL_HANDLER_ARGS) { struct ntptimeval ntv; /* temporary structure */ + NTPADJ_LOCK(); ntp_gettime1(&ntv); + NTPADJ_UNLOCK(); return (sysctl_handle_opaque(oidp, &ntv, sizeof(ntv), req)); } SYSCTL_NODE(_kern, OID_AUTO, ntp_pll, CTLFLAG_RW, 0, ""); -SYSCTL_PROC(_kern_ntp_pll, OID_AUTO, gettime, CTLTYPE_OPAQUE|CTLFLAG_RD, - 0, sizeof(struct ntptimeval) , ntp_sysctl, "S,ntptimeval", ""); +SYSCTL_PROC(_kern_ntp_pll, OID_AUTO, gettime, CTLTYPE_OPAQUE | CTLFLAG_RD | + CTLFLAG_MPSAFE, 0, sizeof(struct ntptimeval) , ntp_sysctl, "S,ntptimeval", + ""); #ifdef PPS_SYNC SYSCTL_INT(_kern_ntp_pll, OID_AUTO, pps_shiftmax, CTLFLAG_RW, @@ -308,10 +335,12 @@ SYSCTL_INT(_kern_ntp_pll, OID_AUTO, pps_ SYSCTL_LONG(_kern_ntp_pll, OID_AUTO, time_monitor, CTLFLAG_RD, &time_monitor, 0, "Last time offset scaled (ns)"); -SYSCTL_OPAQUE(_kern_ntp_pll, OID_AUTO, pps_freq, CTLFLAG_RD, - &pps_freq, sizeof(pps_freq), "I", "Scaled frequency offset (ns/sec)"); -SYSCTL_OPAQUE(_kern_ntp_pll, OID_AUTO, time_freq, CTLFLAG_RD, - &time_freq, sizeof(time_freq), "I", "Frequency offset (ns/sec)"); +SYSCTL_S64(_kern_ntp_pll, OID_AUTO, pps_freq, CTLFLAG_RD | CTLFLAG_MPSAFE, + &pps_freq, 0, + "Scaled frequency offset (ns/sec)"); +SYSCTL_S64(_kern_ntp_pll, OID_AUTO, time_freq, CTLFLAG_RD | CTLFLAG_MPSAFE, + &time_freq, 0, + "Frequency offset (ns/sec)"); #endif /* @@ -333,12 +362,11 @@ sys_ntp_adjtime(struct thread *td, struc struct timex ntv; /* temporary structure */ long freq; /* frequency ns/s) */ int modes; /* mode bits from structure */ - int s; /* caller priority */ - int error; + int error, retval; error = copyin((caddr_t)uap->tp, (caddr_t)&ntv, sizeof(ntv)); if (error) - return(error); + return (error); /* * Update selected clock variables - only the superuser can @@ -349,13 +377,12 @@ sys_ntp_adjtime(struct thread *td, struc * the STA_PLL bit in the status word is cleared, the state and * status words are reset to the initial values at boot. */ - mtx_lock(&Giant); modes = ntv.modes; if (modes) error = priv_check(td, PRIV_NTP_ADJTIME); - if (error) - goto done2; - s = splclock(); + if (error != 0) + return (error); + NTPADJ_LOCK(); if (modes & MOD_MAXERROR) time_maxerror = ntv.maxerror; if (modes & MOD_ESTERROR) @@ -456,19 +483,12 @@ sys_ntp_adjtime(struct thread *td, struc ntv.jitcnt = pps_jitcnt; ntv.stbcnt = pps_stbcnt; #endif /* PPS_SYNC */ - splx(s); + retval = ntp_is_time_error(time_status) ? TIME_ERROR : time_state; + NTPADJ_UNLOCK(); error = copyout((caddr_t)&ntv, (caddr_t)uap->tp, sizeof(ntv)); - if (error) - goto done2; - - if (ntp_is_time_error()) - td->td_retval[0] = TIME_ERROR; - else - td->td_retval[0] = time_state; - -done2: - mtx_unlock(&Giant); + if (error == 0) + td->td_retval[0] = retval; return (error); } @@ -620,7 +640,7 @@ ntp_update_second(int64_t *adjustment, t * probably be integrated with the code that does that. */ static void -ntp_init() +ntp_init(void) { /* @@ -670,6 +690,8 @@ hardupdate(offset) long mtemp; l_fp ftemp; + NTPADJ_ASSERT_LOCKED(); + /* * Select how the phase is to be controlled and from which * source. If the PPS signal is present and enabled to @@ -750,6 +772,8 @@ hardpps(tsp, nsec) long u_sec, u_nsec, v_nsec; /* temps */ l_fp ftemp; + NTPADJ_LOCK(); + /* * The signal is first processed by a range gate and frequency * discriminator. The range gate rejects noise spikes outside @@ -770,9 +794,8 @@ hardpps(tsp, nsec) u_sec++; } v_nsec = u_nsec - pps_tf[0].tv_nsec; - if (u_sec == pps_tf[0].tv_sec && v_nsec < NANOSECOND - - MAXFREQ) - return; + if (u_sec == pps_tf[0].tv_sec && v_nsec < NANOSECOND - MAXFREQ) + goto out; pps_tf[2] = pps_tf[1]; pps_tf[1] = pps_tf[0]; pps_tf[0].tv_sec = u_sec; @@ -793,7 +816,7 @@ hardpps(tsp, nsec) u_nsec += NANOSECOND; pps_fcount += u_nsec; if (v_nsec > MAXFREQ || v_nsec < -MAXFREQ) - return; + goto out; time_status &= ~STA_PPSJITTER; /* @@ -839,7 +862,7 @@ hardpps(tsp, nsec) * timecounter running faster than 1 GHz the lower bound is 2ns, just * to avoid a nonsensical threshold of zero. */ - if (u_nsec > lmax(pps_jitter << PPS_POPCORN, + if (u_nsec > lmax(pps_jitter << PPS_POPCORN, 2 * (NANOSECOND / (long)qmin(NANOSECOND, tc_getfrequency())))) { time_status |= STA_PPSJITTER; pps_jitcnt++; @@ -850,7 +873,7 @@ hardpps(tsp, nsec) pps_jitter += (u_nsec - pps_jitter) >> PPS_FAVG; u_sec = pps_tf[0].tv_sec - pps_lastsec; if (u_sec < (1 << pps_shift)) - return; + goto out; /* * At the end of the calibration interval the difference between @@ -867,11 +890,10 @@ hardpps(tsp, nsec) pps_lastsec = pps_tf[0].tv_sec; pps_fcount = 0; u_nsec = MAXFREQ << pps_shift; - if (v_nsec > u_nsec || v_nsec < -u_nsec || u_sec != (1 << - pps_shift)) { + if (v_nsec > u_nsec || v_nsec < -u_nsec || u_sec != (1 << pps_shift)) { time_status |= STA_PPSERROR; pps_errcnt++; - return; + goto out; } /* @@ -932,6 +954,9 @@ hardpps(tsp, nsec) L_LINT(pps_freq, -MAXFREQ); if (time_status & STA_PPSFREQ) time_freq = pps_freq; + +out: + NTPADJ_UNLOCK(); } #endif /* PPS_SYNC */ @@ -965,27 +990,29 @@ int kern_adjtime(struct thread *td, struct timeval *delta, struct timeval *olddelta) { struct timeval atv; + int64_t ltr, ltw; int error; - mtx_lock(&Giant); - if (olddelta) { - atv.tv_sec = time_adjtime / 1000000; - atv.tv_usec = time_adjtime % 1000000; + if (delta != NULL) { + error = priv_check(td, PRIV_ADJTIME); + if (error != 0) + return (error); + ltw = (int64_t)delta->tv_sec * 1000000 + delta->tv_usec; + } + NTPADJ_LOCK(); + ltr = time_adjtime; + if (delta != NULL) + time_adjtime = ltw; + NTPADJ_UNLOCK(); + if (olddelta != NULL) { + atv.tv_sec = ltr / 1000000; + atv.tv_usec = ltr % 1000000; if (atv.tv_usec < 0) { atv.tv_usec += 1000000; atv.tv_sec--; } *olddelta = atv; } - if (delta) { - if ((error = priv_check(td, PRIV_ADJTIME))) { - mtx_unlock(&Giant); - return (error); - } - time_adjtime = (int64_t)delta->tv_sec * 1000000 + - delta->tv_usec; - } - mtx_unlock(&Giant); return (0); } @@ -996,11 +1023,12 @@ static void periodic_resettodr(void *arg __unused) { - if (!ntp_is_time_error()) { - mtx_lock(&Giant); + /* + * Read of time_status is lock-less, which is fine since + * ntp_is_time_error() operates on the consistent read value. + */ + if (!ntp_is_time_error(time_status)) resettodr(); - mtx_unlock(&Giant); - } if (resettodr_period > 0) callout_schedule(&resettodr_callout, resettodr_period * hz); } @@ -1010,11 +1038,9 @@ shutdown_resettodr(void *arg __unused, i { callout_drain(&resettodr_callout); - if (resettodr_period > 0 && !ntp_is_time_error()) { - mtx_lock(&Giant); + /* Another unlocked read of time_status */ + if (resettodr_period > 0 && !ntp_is_time_error(time_status)) resettodr(); - mtx_unlock(&Giant); - } } static int @@ -1036,9 +1062,9 @@ done: return (0); } -SYSCTL_PROC(_machdep, OID_AUTO, rtc_save_period, CTLTYPE_INT|CTLFLAG_RWTUN, - &resettodr_period, 1800, sysctl_resettodr_period, "I", - "Save system time to RTC with this period (in seconds)"); +SYSCTL_PROC(_machdep, OID_AUTO, rtc_save_period, CTLTYPE_INT | CTLFLAG_RWTUN | + CTLFLAG_MPSAFE, &resettodr_period, 1800, sysctl_resettodr_period, "I", + "Save system time to RTC with this period (in seconds)"); static void start_periodic_resettodr(void *arg __unused) From owner-svn-src-head@freebsd.org Tue Jun 28 18:08:48 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AD7A4B85177; Tue, 28 Jun 2016 18:08:48 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7759C2B4C; Tue, 28 Jun 2016 18:08:48 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5SI8lXK091907; Tue, 28 Jun 2016 18:08:47 GMT (envelope-from sbruno@FreeBSD.org) Received: (from sbruno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5SI8l7h091906; Tue, 28 Jun 2016 18:08:47 GMT (envelope-from sbruno@FreeBSD.org) Message-Id: <201606281808.u5SI8l7h091906@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sbruno set sender to sbruno@FreeBSD.org using -f From: Sean Bruno Date: Tue, 28 Jun 2016 18:08:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302253 - head/sys/cam/scsi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Tue, 28 Jun 2016 18:08:48 -0000 Author: sbruno Date: Tue Jun 28 18:08:47 2016 New Revision: 302253 URL: https://svnweb.freebsd.org/changeset/base/302253 Log: Correct PERSISTENT RESERVE OUT command and populate scsi_cmd->length. PR: 202625 Submitted by: niakrisn@gmail.com Reviewed by: scottl Approved by: re (hrs) MFC after: 2 weeks Modified: head/sys/cam/scsi/scsi_all.c Modified: head/sys/cam/scsi/scsi_all.c ============================================================================== --- head/sys/cam/scsi/scsi_all.c Tue Jun 28 16:43:23 2016 (r302252) +++ head/sys/cam/scsi/scsi_all.c Tue Jun 28 18:08:47 2016 (r302253) @@ -8788,6 +8788,7 @@ scsi_persistent_reserve_out(struct ccb_s scsi_cmd->opcode = PERSISTENT_RES_OUT; scsi_cmd->action = service_action; scsi_cmd->scope_type = scope | res_type; + scsi_ulto2b(dxfer_len, scsi_cmd->length); cam_fill_csio(csio, retries, From owner-svn-src-head@freebsd.org Tue Jun 28 18:17:59 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A4105B855EA; Tue, 28 Jun 2016 18:17:59 +0000 (UTC) (envelope-from ken@kdm.org) Received: from mithlond.kdm.org (mithlond.kdm.org [96.89.93.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "A1-33714", Issuer "A1-33714" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 7287622CC; Tue, 28 Jun 2016 18:17:59 +0000 (UTC) (envelope-from ken@kdm.org) Received: from [10.0.0.27] (mbp2013-wired.int.kdm.org [10.0.0.27]) (authenticated bits=0) by mithlond.kdm.org (8.15.2/8.14.9) with ESMTPSA id u5SIHpfu016242 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 28 Jun 2016 14:17:52 -0400 (EDT) (envelope-from ken@kdm.org) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Subject: Re: svn commit: r302253 - head/sys/cam/scsi From: Ken Merry In-Reply-To: <201606281808.u5SI8l7h091906@repo.freebsd.org> Date: Tue, 28 Jun 2016 14:17:51 -0400 Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: <71476326-3FAC-4E49-884F-0A2F38177D99@kdm.org> References: <201606281808.u5SI8l7h091906@repo.freebsd.org> To: Sean Bruno X-Mailer: Apple Mail (2.3124) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mithlond.kdm.org [96.89.93.250]); Tue, 28 Jun 2016 14:17:52 -0400 (EDT) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Tue, 28 Jun 2016 18:17:59 -0000 This is incorrect. It should be scsi_ulto4b() instead. The dxfer_len argument to scsi_persistent_reserve_out() is a uint32_t, = and the length field in the CDB structure is 4 bytes long. Sorry I didn=E2=80=99t get around to commenting on the PR, otherwise I = would have caught this previously. Ken =E2=80=94=20 Ken Merry ken@FreeBSD.ORG > On Jun 28, 2016, at 2:08 PM, Sean Bruno wrote: >=20 > Author: sbruno > Date: Tue Jun 28 18:08:47 2016 > New Revision: 302253 > URL: https://svnweb.freebsd.org/changeset/base/302253 >=20 > Log: > Correct PERSISTENT RESERVE OUT command and populate scsi_cmd->length. >=20 > PR: 202625 > Submitted by: niakrisn@gmail.com > Reviewed by: scottl > Approved by: re (hrs) > MFC after: 2 weeks >=20 > Modified: > head/sys/cam/scsi/scsi_all.c >=20 > Modified: head/sys/cam/scsi/scsi_all.c > = =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 > --- head/sys/cam/scsi/scsi_all.c Tue Jun 28 16:43:23 2016 = (r302252) > +++ head/sys/cam/scsi/scsi_all.c Tue Jun 28 18:08:47 2016 = (r302253) > @@ -8788,6 +8788,7 @@ scsi_persistent_reserve_out(struct ccb_s > scsi_cmd->opcode =3D PERSISTENT_RES_OUT; > scsi_cmd->action =3D service_action; > scsi_cmd->scope_type =3D scope | res_type; > + scsi_ulto2b(dxfer_len, scsi_cmd->length); >=20 > cam_fill_csio(csio, > retries, >=20 From owner-svn-src-head@freebsd.org Tue Jun 28 18:27:32 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8E428B8587E; Tue, 28 Jun 2016 18:27:32 +0000 (UTC) (envelope-from sbruno@freebsd.org) Received: from mail.ignoranthack.me (ignoranthack.me [199.102.79.106]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 54BCA2AA3; Tue, 28 Jun 2016 18:27:31 +0000 (UTC) (envelope-from sbruno@freebsd.org) Received: from [10.246.10.193] (wsip-98-172-74-163.ph.ph.cox.net [98.172.74.163]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sbruno@ignoranthack.me) by mail.ignoranthack.me (Postfix) with ESMTPSA id 5840C1928BE; Tue, 28 Jun 2016 18:27:30 +0000 (UTC) Subject: Re: svn commit: r302253 - head/sys/cam/scsi To: Ken Merry References: <201606281808.u5SI8l7h091906@repo.freebsd.org> <71476326-3FAC-4E49-884F-0A2F38177D99@kdm.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org, re@freebsd.org From: Sean Bruno Message-ID: <46721328-61de-e78b-b627-42b06c63e156@freebsd.org> Date: Tue, 28 Jun 2016 11:27:25 -0700 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: <71476326-3FAC-4E49-884F-0A2F38177D99@kdm.org> Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="cfEVp7xlLAglfLvFbi8v9pLtXVFw9VidN" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Tue, 28 Jun 2016 18:27:32 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --cfEVp7xlLAglfLvFbi8v9pLtXVFw9VidN Content-Type: multipart/mixed; boundary="PBdfnsehepddkOiHhRCiQT1clEj7VDdQV" From: Sean Bruno To: Ken Merry Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org, re@freebsd.org Message-ID: <46721328-61de-e78b-b627-42b06c63e156@freebsd.org> Subject: Re: svn commit: r302253 - head/sys/cam/scsi References: <201606281808.u5SI8l7h091906@repo.freebsd.org> <71476326-3FAC-4E49-884F-0A2F38177D99@kdm.org> In-Reply-To: <71476326-3FAC-4E49-884F-0A2F38177D99@kdm.org> --PBdfnsehepddkOiHhRCiQT1clEj7VDdQV Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 06/28/16 11:17, Ken Merry wrote: > This is incorrect. It should be scsi_ulto4b() instead. >=20 > The dxfer_len argument to scsi_persistent_reserve_out() is a uint32_t, = and the length field in the CDB structure is 4 bytes long. >=20 > Sorry I didn=E2=80=99t get around to commenting on the PR, otherwise I = would have caught this previously. >=20 > Ken > =E2=80=94=20 > Ken Merry > ken@FreeBSD.ORG Ok, I shall revert this then generate a new diff for your review and submission to re for commit. sean >=20 >=20 >=20 >> On Jun 28, 2016, at 2:08 PM, Sean Bruno wrote: >> >> Author: sbruno >> Date: Tue Jun 28 18:08:47 2016 >> New Revision: 302253 >> URL: https://svnweb.freebsd.org/changeset/base/302253 >> >> Log: >> Correct PERSISTENT RESERVE OUT command and populate scsi_cmd->length.= >> >> PR: 202625 >> Submitted by: niakrisn@gmail.com >> Reviewed by: scottl >> Approved by: re (hrs) >> MFC after: 2 weeks >> >> Modified: >> head/sys/cam/scsi/scsi_all.c >> >> Modified: head/sys/cam/scsi/scsi_all.c >> =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 >> --- head/sys/cam/scsi/scsi_all.c Tue Jun 28 16:43:23 2016 (r302252) >> +++ head/sys/cam/scsi/scsi_all.c Tue Jun 28 18:08:47 2016 (r302253) >> @@ -8788,6 +8788,7 @@ scsi_persistent_reserve_out(struct ccb_s >> scsi_cmd->opcode =3D PERSISTENT_RES_OUT; >> scsi_cmd->action =3D service_action; >> scsi_cmd->scope_type =3D scope | res_type; >> + scsi_ulto2b(dxfer_len, scsi_cmd->length); >> >> cam_fill_csio(csio, >> retries, >> >=20 >=20 --PBdfnsehepddkOiHhRCiQT1clEj7VDdQV-- --cfEVp7xlLAglfLvFbi8v9pLtXVFw9VidN Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQF8BAEBCgBmBQJXcsGNXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXRCQUFENDYzMkU3MTIxREU4RDIwOTk3REQx MjAxRUZDQTFFNzI3RTY0AAoJEBIB78oecn5kO8sH/jj/kZtjbrUShl8qJl52ladK mYy20MTzg91m8+f+Rr0rJrMloJQn2JaueFv06AXhocwNxsW0AUcREhSFF/Lo7wX9 Ldo0WUQ497NOAuxrwDHXabGsKJ/rSDkHgwoPQZxZqMQuaMNCFVcnFyTsUptSEDUl 1X5DGyu9bJnnGvC5JQ8E7LFGJ/wD/Ong/CeWW6gjZv9XjjsKh6JnqXXE0QEuDSwU ubKKyF/tLxeRqBok0j/eMdYcekZVpFBvl5m+Tv4r6RbX3RHK1eud2SzW99cAMUXY DFF07+sINpJ7QBh2R29IbmkwT7KalWzbXsOLt7gEDYAVARewv5DVi5VZpbKzHLg= =0N52 -----END PGP SIGNATURE----- --cfEVp7xlLAglfLvFbi8v9pLtXVFw9VidN-- From owner-svn-src-head@freebsd.org Tue Jun 28 18:28:40 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C1284B8595C; Tue, 28 Jun 2016 18:28:40 +0000 (UTC) (envelope-from ken@kdm.org) Received: from mithlond.kdm.org (mithlond.kdm.org [96.89.93.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "A1-33714", Issuer "A1-33714" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 88DAB2C38; Tue, 28 Jun 2016 18:28:40 +0000 (UTC) (envelope-from ken@kdm.org) Received: from mithlond.kdm.org (localhost [127.0.0.1]) by mithlond.kdm.org (8.15.2/8.14.9) with ESMTPS id u5SIScY0016434 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 28 Jun 2016 14:28:38 -0400 (EDT) (envelope-from ken@mithlond.kdm.org) Received: (from ken@localhost) by mithlond.kdm.org (8.15.2/8.14.9/Submit) id u5SISc5L016433; Tue, 28 Jun 2016 14:28:38 -0400 (EDT) (envelope-from ken) Date: Tue, 28 Jun 2016 14:28:38 -0400 From: "Kenneth D. Merry" To: Sean Bruno Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org, re@freebsd.org Subject: Re: svn commit: r302253 - head/sys/cam/scsi Message-ID: <20160628182838.GA16229@mithlond.kdm.org> References: <201606281808.u5SI8l7h091906@repo.freebsd.org> <71476326-3FAC-4E49-884F-0A2F38177D99@kdm.org> <46721328-61de-e78b-b627-42b06c63e156@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <46721328-61de-e78b-b627-42b06c63e156@freebsd.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (mithlond.kdm.org [127.0.0.1]); Tue, 28 Jun 2016 14:28:38 -0400 (EDT) X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on mithlond.kdm.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Tue, 28 Jun 2016 18:28:40 -0000 On Tue, Jun 28, 2016 at 11:27:25 -0700, Sean Bruno wrote: > > > On 06/28/16 11:17, Ken Merry wrote: > > This is incorrect. It should be scsi_ulto4b() instead. > > > > The dxfer_len argument to scsi_persistent_reserve_out() is a uint32_t, and the length field in the CDB structure is 4 bytes long. > > > > Sorry I didn???t get around to commenting on the PR, otherwise I would have caught this previously. > > > > Ken > > ??? > > Ken Merry > > ken@FreeBSD.ORG > > Ok, I shall revert this then generate a new diff for your review and > submission to re for commit. Thanks! Ken -- Kenneth Merry ken@FreeBSD.ORG From owner-svn-src-head@freebsd.org Tue Jun 28 18:32:17 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4A115B85ADE; Tue, 28 Jun 2016 18:32:17 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0CB9F2009; Tue, 28 Jun 2016 18:32:16 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5SIWG9Z002534; Tue, 28 Jun 2016 18:32:16 GMT (envelope-from sbruno@FreeBSD.org) Received: (from sbruno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5SIWGnb002533; Tue, 28 Jun 2016 18:32:16 GMT (envelope-from sbruno@FreeBSD.org) Message-Id: <201606281832.u5SIWGnb002533@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sbruno set sender to sbruno@FreeBSD.org using -f From: Sean Bruno Date: Tue, 28 Jun 2016 18:32:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302254 - head/sys/cam/scsi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Tue, 28 Jun 2016 18:32:17 -0000 Author: sbruno Date: Tue Jun 28 18:32:15 2016 New Revision: 302254 URL: https://svnweb.freebsd.org/changeset/base/302254 Log: Revert svn r302253 at the request/review of Ken M. This commit is incorrect. PR: 202625 Approved by: re (implicit) Modified: head/sys/cam/scsi/scsi_all.c Modified: head/sys/cam/scsi/scsi_all.c ============================================================================== --- head/sys/cam/scsi/scsi_all.c Tue Jun 28 18:08:47 2016 (r302253) +++ head/sys/cam/scsi/scsi_all.c Tue Jun 28 18:32:15 2016 (r302254) @@ -8788,7 +8788,6 @@ scsi_persistent_reserve_out(struct ccb_s scsi_cmd->opcode = PERSISTENT_RES_OUT; scsi_cmd->action = service_action; scsi_cmd->scope_type = scope | res_type; - scsi_ulto2b(dxfer_len, scsi_cmd->length); cam_fill_csio(csio, retries, From owner-svn-src-head@freebsd.org Tue Jun 28 19:53:17 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E31B2B86239; Tue, 28 Jun 2016 19:53:17 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B01112E42; Tue, 28 Jun 2016 19:53:17 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5SJrGi4033444; Tue, 28 Jun 2016 19:53:16 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5SJrGmi033442; Tue, 28 Jun 2016 19:53:16 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201606281953.u5SJrGmi033442@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Tue, 28 Jun 2016 19:53:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302255 - in head/lib/libc: rpc yp X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Tue, 28 Jun 2016 19:53:18 -0000 Author: bdrewery Date: Tue Jun 28 19:53:16 2016 New Revision: 302255 URL: https://svnweb.freebsd.org/changeset/base/302255 Log: Use on crypto.x and rpc.x from the source tree. This fixes the build when DESTDIR may be blank or not yet populated. It also fixes reproducibility. Submitted by: brooks Approved by: re (gjb) Differential Revision: https://reviews.freebsd.org/D6455 Modified: head/lib/libc/rpc/Makefile.inc head/lib/libc/yp/Makefile.inc Modified: head/lib/libc/rpc/Makefile.inc ============================================================================== --- head/lib/libc/rpc/Makefile.inc Tue Jun 28 18:32:15 2016 (r302254) +++ head/lib/libc/rpc/Makefile.inc Tue Jun 28 19:53:16 2016 (r302255) @@ -33,7 +33,7 @@ CFLAGS+= -I${LIBC_SRCTOP}/rpc CLEANFILES+= crypt_clnt.c crypt_xdr.c crypt.h -RPCDIR= ${DESTDIR}/usr/include/rpcsvc +RPCDIR= ${SRCTOP}/include/rpcsvc RPCGEN= RPCGEN_CPP=${CPP:Q} rpcgen -C crypt_clnt.c: ${RPCDIR}/crypt.x crypt.h Modified: head/lib/libc/yp/Makefile.inc ============================================================================== --- head/lib/libc/yp/Makefile.inc Tue Jun 28 18:32:15 2016 (r302254) +++ head/lib/libc/yp/Makefile.inc Tue Jun 28 19:53:16 2016 (r302255) @@ -9,7 +9,7 @@ CLEANFILES+= yp.h yp_xdr.c SYM_MAPS+= ${LIBC_SRCTOP}/yp/Symbol.map -RPCSRC= ${DESTDIR}/usr/include/rpcsvc/yp.x +RPCSRC= ${SRCTOP}/include/rpcsvc/yp.x RPCGEN= RPCGEN_CPP=${CPP:Q} rpcgen -C yp_xdr.c: ${RPCSRC} From owner-svn-src-head@freebsd.org Tue Jun 28 20:10:31 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E6ECDB865E7; Tue, 28 Jun 2016 20:10:31 +0000 (UTC) (envelope-from phk@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B435927E0; Tue, 28 Jun 2016 20:10:31 +0000 (UTC) (envelope-from phk@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5SKAUwD037549; Tue, 28 Jun 2016 20:10:30 GMT (envelope-from phk@FreeBSD.org) Received: (from phk@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5SKAUFk037548; Tue, 28 Jun 2016 20:10:30 GMT (envelope-from phk@FreeBSD.org) Message-Id: <201606282010.u5SKAUFk037548@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: phk set sender to phk@FreeBSD.org using -f From: Poul-Henning Kamp Date: Tue, 28 Jun 2016 20:10:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302256 - head/sbin/natd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Tue, 28 Jun 2016 20:10:32 -0000 Author: phk Date: Tue Jun 28 20:10:30 2016 New Revision: 302256 URL: https://svnweb.freebsd.org/changeset/base/302256 Log: Do not coredump if the packet is too long in the global (non-interface associated) instance. The result is that the packet is dropped without an indication that smaller MTU is advisable, which is not optimal, but better than a NULL pointer deref. Approved by: re (glebius) Modified: head/sbin/natd/natd.c Modified: head/sbin/natd/natd.c ============================================================================== --- head/sbin/natd/natd.c Tue Jun 28 19:53:16 2016 (r302255) +++ head/sbin/natd/natd.c Tue Jun 28 20:10:30 2016 (r302256) @@ -618,7 +618,7 @@ static void DoGlobal (int fd) if (wrote != bytes) { - if (errno == EMSGSIZE) { + if (errno == EMSGSIZE && mip != NULL) { if (mip->ifMTU != -1) SendNeedFragIcmp (icmpSock, From owner-svn-src-head@freebsd.org Wed Jun 29 01:50:32 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3899DB82EA8; Wed, 29 Jun 2016 01:50:32 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E3D1E2C5B; Wed, 29 Jun 2016 01:50:31 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5T1oVlf062111; Wed, 29 Jun 2016 01:50:31 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5T1oVMe062109; Wed, 29 Jun 2016 01:50:31 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201606290150.u5T1oVMe062109@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Wed, 29 Jun 2016 01:50:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302257 - head X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Wed, 29 Jun 2016 01:50:32 -0000 Author: bdrewery Date: Wed Jun 29 01:50:30 2016 New Revision: 302257 URL: https://svnweb.freebsd.org/changeset/base/302257 Log: WITH_SYSTEM_COMPILER: Avoid using GCC4.8+ logic on native GCC4.2 platforms. As the XXX notes, these should really be checking MK_GNUCXX since there is already a version check in share/mk/src.opts.mk to disable it. Fixing that here is more complex though. This could also be using X_COMPILER_FEATURES but uses X_COMPILER_VERSION to keep in sync with the src.opts.mk logic. Tested by: andreast Sponsored by: EMC / Isilon Storage Division Approved by: re (gjb) Modified: head/Makefile.inc1 head/Makefile.libcompat Modified: head/Makefile.inc1 ============================================================================== --- head/Makefile.inc1 Tue Jun 28 20:10:30 2016 (r302256) +++ head/Makefile.inc1 Wed Jun 29 01:50:30 2016 (r302257) @@ -549,8 +549,10 @@ TARGET_ABI= gnueabi XCFLAGS+= -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib # Force using libc++ for external GCC. # XXX: This should be checking MK_GNUCXX == no +.if ${X_COMPILER_VERSION} >= 40800 XCXXFLAGS+= -isystem ${WORLDTMP}/usr/include/c++/v1 -std=c++11 \ -nostdinc++ -L${WORLDTMP}/../lib/libc++ +.endif .else TARGET_ABI?= unknown TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.0 Modified: head/Makefile.libcompat ============================================================================== --- head/Makefile.libcompat Tue Jun 28 20:10:30 2016 (r302256) +++ head/Makefile.libcompat Wed Jun 29 01:50:30 2016 (r302257) @@ -81,8 +81,8 @@ LIBCOMPATCFLAGS+= -B${LIBCOMPATTMP}/usr/ LIBCOMPATCFLAGS+= -isystem ${LIBCOMPATTMP}/usr/include # Force using libc++ for external GCC. # XXX: This should be checking MK_GNUCXX == no -.if ${MK_CROSS_COMPILER} == "no" || \ - (${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no") +.if ${X_COMPILER_VERSION} >= 40800 && (${MK_CROSS_COMPILER} == "no" || \ + (${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no")) LIBCOMPATCXXFLAGS+= -isystem ${LIBCOMPATTMP}/usr/include/c++/v1 -std=c++11 \ -nostdinc++ -L${LIBCOMPAT_OBJTREE}${.CURDIR}/lib/libc++ .endif From owner-svn-src-head@freebsd.org Wed Jun 29 05:21:27 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 67685B845AD; Wed, 29 Jun 2016 05:21:27 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3000D25AE; Wed, 29 Jun 2016 05:21:27 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5T5LQdX040398; Wed, 29 Jun 2016 05:21:26 GMT (envelope-from bz@FreeBSD.org) Received: (from bz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5T5LQO7040397; Wed, 29 Jun 2016 05:21:26 GMT (envelope-from bz@FreeBSD.org) Message-Id: <201606290521.u5T5LQO7040397@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org using -f From: "Bjoern A. Zeeb" Date: Wed, 29 Jun 2016 05:21:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302258 - head/sys/net X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Wed, 29 Jun 2016 05:21:27 -0000 Author: bz Date: Wed Jun 29 05:21:25 2016 New Revision: 302258 URL: https://svnweb.freebsd.org/changeset/base/302258 Log: Several device drivers call if_alloc() and then do further checks and will cal if_free() in case of conflict, error, .. if_free() however sets the VNET instance from the ifp->if_vnet which was not yet initialized but would only in if_attach(). Fix this by setting the curvnet from where we allocate the interface in if_alloc(). if_attach() will later overwrite this as needed. We do not set the home_vnet early on as we only want to prevent the if_free() panic but not change any of the other housekeeping, e.g., triggered through ifioctl()s. Reviewed by: brooks Approved by: re (gjb) MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D7010 Modified: head/sys/net/if.c Modified: head/sys/net/if.c ============================================================================== --- head/sys/net/if.c Wed Jun 29 01:50:30 2016 (r302257) +++ head/sys/net/if.c Wed Jun 29 05:21:25 2016 (r302258) @@ -455,6 +455,9 @@ if_alloc(u_char type) ifp->if_index = idx; ifp->if_type = type; ifp->if_alloctype = type; +#ifdef VIMAGE + ifp->if_vnet = curvnet; +#endif if (if_com_alloc[type] != NULL) { ifp->if_l2com = if_com_alloc[type](type, ifp); if (ifp->if_l2com == NULL) { From owner-svn-src-head@freebsd.org Wed Jun 29 06:42:21 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9BECFB868A3; Wed, 29 Jun 2016 06:42:21 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6A63B2F07; Wed, 29 Jun 2016 06:42:21 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5T6gKwj072939; Wed, 29 Jun 2016 06:42:20 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5T6gKIF072935; Wed, 29 Jun 2016 06:42:20 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201606290642.u5T6gKIF072935@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: "Conrad E. Meyer" Date: Wed, 29 Jun 2016 06:42:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302262 - in head/sys/dev/usb: . quirk X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Wed, 29 Jun 2016 06:42:21 -0000 Author: cem Date: Wed Jun 29 06:42:20 2016 New Revision: 302262 URL: https://svnweb.freebsd.org/changeset/base/302262 Log: USB: Add Garmin FR230 device quirk (broken INQUIRY) PR: 210544 Reviewed by: hps Approved by: re Modified: head/sys/dev/usb/quirk/usb_quirk.c head/sys/dev/usb/usbdevs Modified: head/sys/dev/usb/quirk/usb_quirk.c ============================================================================== --- head/sys/dev/usb/quirk/usb_quirk.c Wed Jun 29 06:25:23 2016 (r302261) +++ head/sys/dev/usb/quirk/usb_quirk.c Wed Jun 29 06:42:20 2016 (r302262) @@ -200,6 +200,7 @@ static struct usb_quirk_entry usb_quirks USB_QUIRK(FREECOM, DVD, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI), USB_QUIRK(FUJIPHOTO, MASS0100, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI_I, UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_NO_RS_CLEAR_UA, UQ_MSC_NO_SYNC_CACHE), + USB_QUIRK(GARMIN, FORERUNNER230, 0x0000, 0xffff, UQ_MSC_NO_INQUIRY), USB_QUIRK(GENESYS, GL641USB2IDE, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_FORCE_SHORT_INQ, UQ_MSC_NO_START_STOP, UQ_MSC_IGNORE_RESIDUE, UQ_MSC_NO_SYNC_CACHE), Modified: head/sys/dev/usb/usbdevs ============================================================================== --- head/sys/dev/usb/usbdevs Wed Jun 29 06:25:23 2016 (r302261) +++ head/sys/dev/usb/usbdevs Wed Jun 29 06:42:20 2016 (r302262) @@ -2151,6 +2151,7 @@ product FUJITSU AH_F401U 0x105b AH-F401U product FUJITSUSIEMENS SCR 0x0009 Fujitsu-Siemens SCR USB Reader /* Garmin products */ +product GARMIN FORERUNNER230 0x086d ForeRunner 230 product GARMIN IQUE_3600 0x0004 iQue 3600 /* Gemalto products */ From owner-svn-src-head@freebsd.org Wed Jun 29 06:55:31 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9B560B86AC3; Wed, 29 Jun 2016 06:55:31 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5258726CB; Wed, 29 Jun 2016 06:55:31 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5T6tUM4076810; Wed, 29 Jun 2016 06:55:30 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5T6tUEe076808; Wed, 29 Jun 2016 06:55:30 GMT (envelope-from np@FreeBSD.org) Message-Id: <201606290655.u5T6tUEe076808@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Wed, 29 Jun 2016 06:55:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302263 - in head/sys/dev/cxgbe: . tom X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Wed, 29 Jun 2016 06:55:31 -0000 Author: np Date: Wed Jun 29 06:55:30 2016 New Revision: 302263 URL: https://svnweb.freebsd.org/changeset/base/302263 Log: cxgbe(4): Do not bring up an interface when IFCAP_TOE is enabled on it. The interface's queues are functional after VI_INIT_DONE (which is short of interface-up) and that's all that's needed for t4_tom to communicate with the chip. Approved by: re@ (gjb@) Sponsored by: Chelsio Communications Modified: head/sys/dev/cxgbe/t4_main.c head/sys/dev/cxgbe/tom/t4_listen.c Modified: head/sys/dev/cxgbe/t4_main.c ============================================================================== --- head/sys/dev/cxgbe/t4_main.c Wed Jun 29 06:42:20 2016 (r302262) +++ head/sys/dev/cxgbe/t4_main.c Wed Jun 29 06:55:30 2016 (r302263) @@ -8981,12 +8981,12 @@ toe_capability(struct vi_info *vi, int e * port has never been UP'd administratively. */ if (!(vi->flags & VI_INIT_DONE)) { - rc = cxgbe_init_synchronized(vi); + rc = vi_full_init(vi); if (rc) return (rc); } if (!(pi->vi[0].flags & VI_INIT_DONE)) { - rc = cxgbe_init_synchronized(&pi->vi[0]); + rc = vi_full_init(&pi->vi[0]); if (rc) return (rc); } Modified: head/sys/dev/cxgbe/tom/t4_listen.c ============================================================================== --- head/sys/dev/cxgbe/tom/t4_listen.c Wed Jun 29 06:42:20 2016 (r302262) +++ head/sys/dev/cxgbe/tom/t4_listen.c Wed Jun 29 06:55:30 2016 (r302263) @@ -532,7 +532,7 @@ t4_listen_start(struct toedev *tod, stru #endif /* - * Find a running VI with IFCAP_TOE (4 or 6). We'll use the first + * Find an initialized VI with IFCAP_TOE (4 or 6). We'll use the first * such VI's queues to send the passive open and receive the reply to * it. * @@ -543,7 +543,7 @@ t4_listen_start(struct toedev *tod, stru for_each_port(sc, i) { pi = sc->port[i]; for_each_vi(pi, v, vi) { - if (vi->ifp->if_drv_flags & IFF_DRV_RUNNING && + if (vi->flags & VI_INIT_DONE && vi->ifp->if_capenable & IFCAP_TOE) goto found; } From owner-svn-src-head@freebsd.org Wed Jun 29 07:55:46 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 82CBDB86A1F; Wed, 29 Jun 2016 07:55:46 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 40A5527A7; Wed, 29 Jun 2016 07:55:46 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5T7tjoX099053; Wed, 29 Jun 2016 07:55:45 GMT (envelope-from smh@FreeBSD.org) Received: (from smh@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5T7tjTs099051; Wed, 29 Jun 2016 07:55:45 GMT (envelope-from smh@FreeBSD.org) Message-Id: <201606290755.u5T7tjTs099051@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: smh set sender to smh@FreeBSD.org using -f From: Steven Hartland Date: Wed, 29 Jun 2016 07:55:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302265 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Wed, 29 Jun 2016 07:55:46 -0000 Author: smh Date: Wed Jun 29 07:55:45 2016 New Revision: 302265 URL: https://svnweb.freebsd.org/changeset/base/302265 Log: Allow ZFS ARC min / max to be tuned at runtime Prior to this change ZFS ARC min / max could only be changed using boot time tunables, this allows the values to be tuned at runtime using the sysctls: * vfs.zfs.arc_max * vfs.zfs.arc_min When adjusting ZFS ARC minimum the memory used will only reduce to the new minimum given memory pressure. Reviewed by: allanjude Approved by: re (gjb) MFC after: 2 weeks Relnotes: yes Sponsored by: Multiplay Differential Revision: https://reviews.freebsd.org/D5907 Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Wed Jun 29 07:00:15 2016 (r302264) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Wed Jun 29 07:55:45 2016 (r302265) @@ -238,10 +238,15 @@ int zfs_disable_dup_eviction = 0; uint64_t zfs_arc_average_blocksize = 8 * 1024; /* 8KB */ u_int zfs_arc_free_target = 0; +/* Absolute min for arc min / max is 16MB. */ +static uint64_t arc_abs_min = 16 << 20; + static int sysctl_vfs_zfs_arc_free_target(SYSCTL_HANDLER_ARGS); static int sysctl_vfs_zfs_arc_meta_limit(SYSCTL_HANDLER_ARGS); +static int sysctl_vfs_zfs_arc_max(SYSCTL_HANDLER_ARGS); +static int sysctl_vfs_zfs_arc_min(SYSCTL_HANDLER_ARGS); -#ifdef _KERNEL +#if defined(__FreeBSD__) && defined(_KERNEL) static void arc_free_target_init(void *unused __unused) { @@ -255,10 +260,10 @@ TUNABLE_QUAD("vfs.zfs.arc_meta_limit", & TUNABLE_QUAD("vfs.zfs.arc_meta_min", &zfs_arc_meta_min); TUNABLE_INT("vfs.zfs.arc_shrink_shift", &zfs_arc_shrink_shift); SYSCTL_DECL(_vfs_zfs); -SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, arc_max, CTLFLAG_RDTUN, &zfs_arc_max, 0, - "Maximum ARC size"); -SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, arc_min, CTLFLAG_RDTUN, &zfs_arc_min, 0, - "Minimum ARC size"); +SYSCTL_PROC(_vfs_zfs, OID_AUTO, arc_max, CTLTYPE_U64 | CTLFLAG_RWTUN, + 0, sizeof(uint64_t), sysctl_vfs_zfs_arc_max, "QU", "Maximum ARC size"); +SYSCTL_PROC(_vfs_zfs, OID_AUTO, arc_min, CTLTYPE_U64 | CTLFLAG_RWTUN, + 0, sizeof(uint64_t), sysctl_vfs_zfs_arc_min, "QU", "Minimum ARC size"); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, arc_average_blocksize, CTLFLAG_RDTUN, &zfs_arc_average_blocksize, 0, "ARC average blocksize"); @@ -884,7 +889,7 @@ struct arc_buf_hdr { l1arc_buf_hdr_t b_l1hdr; }; -#ifdef _KERNEL +#if defined(__FreeBSD__) && defined(_KERNEL) static int sysctl_vfs_zfs_arc_meta_limit(SYSCTL_HANDLER_ARGS) { @@ -902,6 +907,70 @@ sysctl_vfs_zfs_arc_meta_limit(SYSCTL_HAN arc_meta_limit = val; return (0); } + +static int +sysctl_vfs_zfs_arc_max(SYSCTL_HANDLER_ARGS) +{ + uint64_t val; + int err; + + val = zfs_arc_max; + err = sysctl_handle_64(oidp, &val, 0, req); + if (err != 0 || req->newptr == NULL) + return (err); + + if (val < arc_abs_min || val > kmem_size()) + return (EINVAL); + if (val < arc_c_min) + return (EINVAL); + if (zfs_arc_meta_limit > 0 && val < zfs_arc_meta_limit) + return (EINVAL); + + arc_c_max = val; + + arc_c = arc_c_max; + arc_p = (arc_c >> 1); + + if (zfs_arc_meta_limit == 0) { + /* limit meta-data to 1/4 of the arc capacity */ + arc_meta_limit = arc_c_max / 4; + } + + /* if kmem_flags are set, lets try to use less memory */ + if (kmem_debugging()) + arc_c = arc_c / 2; + + zfs_arc_max = arc_c; + + return (0); +} + +static int +sysctl_vfs_zfs_arc_min(SYSCTL_HANDLER_ARGS) +{ + uint64_t val; + int err; + + val = zfs_arc_min; + err = sysctl_handle_64(oidp, &val, 0, req); + if (err != 0 || req->newptr == NULL) + return (err); + + if (val < arc_abs_min || val > arc_c_max) + return (EINVAL); + + arc_c_min = val; + + if (zfs_arc_meta_min == 0) + arc_meta_min = arc_c_min / 2; + + if (arc_c < arc_c_min) + arc_c = arc_c_min; + + zfs_arc_min = arc_c_min; + + return (0); +} #endif static arc_buf_t *arc_eviction_list; @@ -5385,8 +5454,8 @@ arc_init(void) arc_c = MIN(arc_c, vmem_size(heap_arena, VMEM_ALLOC | VMEM_FREE) / 8); #endif #endif /* illumos */ - /* set min cache to 1/32 of all memory, or 16MB, whichever is more */ - arc_c_min = MAX(arc_c / 4, 16 << 20); + /* set min cache to 1/32 of all memory, or arc_abs_min, whichever is more */ + arc_c_min = MAX(arc_c / 4, arc_abs_min); /* set max to 1/2 of all memory, or all but 1GB, whichever is more */ if (arc_c * 8 >= 1 << 30) arc_c_max = (arc_c * 8) - (1 << 30); @@ -5407,11 +5476,11 @@ arc_init(void) #ifdef _KERNEL /* * Allow the tunables to override our calculations if they are - * reasonable (ie. over 16MB) + * reasonable. */ - if (zfs_arc_max > 16 << 20 && zfs_arc_max < kmem_size()) + if (zfs_arc_max > arc_abs_min && zfs_arc_max < kmem_size()) arc_c_max = zfs_arc_max; - if (zfs_arc_min > 16 << 20 && zfs_arc_min <= arc_c_max) + if (zfs_arc_min > arc_abs_min && zfs_arc_min <= arc_c_max) arc_c_min = zfs_arc_min; #endif Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c Wed Jun 29 07:00:15 2016 (r302264) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c Wed Jun 29 07:55:45 2016 (r302265) @@ -49,8 +49,8 @@ #include #if defined(__FreeBSD__) && defined(_KERNEL) -#include #include +#include #endif /* From owner-svn-src-head@freebsd.org Wed Jun 29 07:58:18 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0F181B86B1E; Wed, 29 Jun 2016 07:58:18 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail107.syd.optusnet.com.au (mail107.syd.optusnet.com.au [211.29.132.53]) by mx1.freebsd.org (Postfix) with ESMTP id B2B8429E2; Wed, 29 Jun 2016 07:58:17 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from besplex.bde.org (c110-21-100-149.carlnfd1.nsw.optusnet.com.au [110.21.100.149]) by mail107.syd.optusnet.com.au (Postfix) with ESMTPS id 95BD5D4FC80; Wed, 29 Jun 2016 17:58:05 +1000 (AEST) Date: Wed, 29 Jun 2016 17:58:05 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Konstantin Belousov cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r302251 - head/sys/kern In-Reply-To: <201606281642.u5SGge18061528@repo.freebsd.org> Message-ID: <20160629154400.F968@besplex.bde.org> References: <201606281642.u5SGge18061528@repo.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=OtmysHLt c=1 sm=1 tr=0 a=XDAe9YG+7EcdVXYrgT+/UQ==:117 a=XDAe9YG+7EcdVXYrgT+/UQ==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=RdlyHFHmpbaWVazvlCcA:9 a=CjuIK1q_8ugA:10 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Wed, 29 Jun 2016 07:58:18 -0000 On Tue, 28 Jun 2016, Konstantin Belousov wrote: > Log: > Do not use Giant to prevent parallel calls to CLOCK_SETTIME(). Use > private mtx in resettodr(), no implementation of CLOCK_SETTIME() is > allowed to sleep. Thanks. As you know, clock locking is still quite broken. The most obvious bugs near here are now: - settime() still begins with splclock(). This gave fewer bugs in clock locking when it last worked in FreeBSD-4. Now it is just a hint that the clock locking has still not been converted to use mutexes. - bitrot near the end of settime() removed the splx() that should be paired with the splclock(). - the locking should be stronger than mutexes (or splclock()) to minimise the delay between deciding to set the time and actually setting it. The delay between making the decision in userland and acquiring a lock in the kernel is hard to control, so this would be better handled by another API, and often is by using the adjtime(x) API to apply a small adjustment. The only safe way to set an absolute time with POSIX APIs seems to be sometime like: - clock_gettime(CLOCK_MONOTONIC, &start) - clock_settime(CLOCK_REALTIME, &now) - clock_gettime(CLOCK_MONOTONIC, &finish) - loop doing this while 'finish' is too much later than 'start'. My kernel code for reading (but not writing) does this, but without the loop (except it loops for an average of 0.5 seconds before starting to synchronize). It just prints the difference finish - start. Even though this is all at a low level, the difference is typically about 40 usec on a 2GHz i386 system (since reading the AT rtc registers is slow). A delay of 40 usec is too much using ntpd if you want closer to microseconds accuracy than milliseconds. However, ntpd mostly uses adjtimex(). The software part of setting the time can be much faster. This requires ordering things carefully. settime() now uses the reasonable order of tc_setclock() first. The AT rtc register only has a resolution and precision of 1 second, and sloppy programming gives it an accuracy of at most 1 second too. Uncontrolled delays in settime() don't matter compared with the larger sloppiness at lower levels. My version fixes this for some cases, so that the rtc can be used to restore the software time to within ~40 microseconds after interrupts have been stopped by ddb. Similar methods would work for restoring the software time accurately enough to avoid steps in ntp after suspend/resume. - settime() still does bogus Giant locking at the end (where it lost the splx()): X mtx_lock(&Giant); X tc_setclock(&ts); X resettodr(); X mtx_unlock(&Giant); Giant locking for tc_setlock() is even less necessary and/or sufficient than it is for the resettodr(). Locking for tc_setclock() is more important than for the rtc, but it has no locking except for this Giant locking, and none of the variables accessed by it is locked by Giant. - more below, with references to changes in this commit. > Modified: head/sys/kern/subr_rtc.c > ============================================================================== > --- head/sys/kern/subr_rtc.c Tue Jun 28 16:41:50 2016 (r302250) > +++ head/sys/kern/subr_rtc.c Tue Jun 28 16:42:40 2016 (r302251) > @@ -62,6 +62,8 @@ __FBSDID("$FreeBSD$"); > #include > #include > #include > +#include > +#include > #include > #ifdef FFCLOCK > #include > @@ -73,6 +75,8 @@ __FBSDID("$FreeBSD$"); > static device_t clock_dev = NULL; > static long clock_res; > static struct timespec clock_adj; > +static struct mtx resettodr_lock; > +MTX_SYSINIT(resettodr_init, &resettodr_lock, "tod2rl", MTX_DEF); > > /* XXX: should be kern. now, it's no longer machdep. */ > static int disable_rtc_set; > @@ -168,11 +172,14 @@ resettodr(void) > if (disable_rtc_set || clock_dev == NULL) > return; > > + mtx_lock(&resettodr_lock); This could be later (only around the hardware parts) since we are sloppy with the delays. > getnanotime(&ts); This doesn't even try to get nanoseconds accuracy. > timespecadd(&ts, &clock_adj); > ts.tv_sec -= utc_offset(); Who knows what utc_offset() is locked by? Certainly not this new locking, since it is set in another file but the new locking is only in this file. It still seems to be most under Giant :-(. The change in the other part of the diff is related to this, and doesn't seem quite right. utc_offset() uses the variables tz_minuteswest, wall_cmos_clock and adjkerntz: - tz_minuteswest is set with no locking in kern_settimeofday(), just after the settime() call. This last had a chance of being correct when the kernel was UP and not preemptible. But it is broken in a more fundamental way back to at least FreeBSD-1: resettodr() is called _before_ updating the timezone, so it uses an out-of-date tz_minuteswest. - wall_cmos_clock is still under a simple (not MPSAFE) sysctl - adjkerntz is under a PROC sysctl, and you just changed this sysctl to be MPSAFE. The sysctl calls here, so we don't want all of it giant-locked. But it now does unlocked accesses to the adjkerntz variable, and the access to the disable_rtc_set variable is unlocked because we do it before acquiring the lock in this function (this variable is still under a simple (not MPSAFE) sysctl. Most of the variables are ints, so access to them are atomic, but without locking the correct order only occurs accidentally and is hard to understand. > /* XXX: We should really set all registered RTCs */ > - if ((error = CLOCK_SETTIME(clock_dev, &ts)) != 0) > + error = CLOCK_SETTIME(clock_dev, &ts); > + mtx_unlock(&resettodr_lock); > + if (error != 0) > printf("warning: clock_settime failed (%d), time-of-day clock " > "not adjusted to system time\n", error); > } The lock needs to cover all high-level accesses to the rtc and related variables to avoid races, and a bit more to minimise delays. In particular, inittodr() should be under this lock, and there is a problem with "show rtc" in ddb. ddb commands can't be under any lock since that gives deadlock, but "show rtc" uses rtcin() which already uses RTC_LOCK. RTC_LOCK locks the rtc at a lower level, but that is not enough for either resettodr() or inittodr() or a combination. This commit fixes the problem for resettodr() only. This is not a large problem in practice because it is rare for these functions to be called concurrently, and it is only easy to arrange for concurrent calls to resettodr(), but that takes root privilege and in normal operation settime() is only called once from userland (for initialization) since ntpd mostly uses adjtimex(). It might be useful to have an MI "show todr" ddb command. This would be easier to lock. The MD "show rtc" command is still useful for showing status registers. BTW, subr_rtc.c is misnamed. rtcs are MD things, and subr_rtc mostly handles higher level things which have the even worse, but historical name "todr". Since the MD interfaces have the even worse still name CLOCK_*TIME, the only rtc names in subr_rtc.c is just one due to another namespace error -- disable_rtc_set. The only other public function in subr_rtc.c is another namespace error -- clock_register(), which might belong in subr_clock.c. The namespace error utc_offset() is in subr_clock.c. "show rtc" now deadlocks when rtc clock is single stepped through. To fix this, use the usual kdb_active hack or mtx_trylock(), and make rtcin() reentrant when it can't acquire the lock. Then in resettodr() and inittodr(), "show rtc" won't destroy the state. Just stopping resettodr() or inittodr() (or any time-related function) in ddb breaks the timing like preemption does, but usually for longer. If there is any error handling for the preempted casse then it works for the ddb case too. Bruce From owner-svn-src-head@freebsd.org Wed Jun 29 10:08:17 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F0E4CB86F8C; Wed, 29 Jun 2016 10:08:17 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail106.syd.optusnet.com.au (mail106.syd.optusnet.com.au [211.29.132.42]) by mx1.freebsd.org (Postfix) with ESMTP id A0F532752; Wed, 29 Jun 2016 10:08:17 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from besplex.bde.org (c110-21-100-149.carlnfd1.nsw.optusnet.com.au [110.21.100.149]) by mail106.syd.optusnet.com.au (Postfix) with ESMTPS id A08DC3D031F; Wed, 29 Jun 2016 19:39:45 +1000 (AEST) Date: Wed, 29 Jun 2016 19:39:45 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Konstantin Belousov cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r302252 - head/sys/kern In-Reply-To: <201606281643.u5SGhNsi061606@repo.freebsd.org> Message-ID: <20160629175917.O968@besplex.bde.org> References: <201606281643.u5SGhNsi061606@repo.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=EfU1O6SC c=1 sm=1 tr=0 a=XDAe9YG+7EcdVXYrgT+/UQ==:117 a=XDAe9YG+7EcdVXYrgT+/UQ==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=YBTR0DOa03FoEZgt01gA:9 a=To-spq41Ae8Nz7We:21 a=wCAWHQOgn0QvNm88:21 a=CjuIK1q_8ugA:10 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Wed, 29 Jun 2016 10:08:18 -0000 On Tue, 28 Jun 2016, Konstantin Belousov wrote: > Log: > Currently the ntptime code and resettodr() are Giant-locked. In > particular, the Giant is supposed to protect against parallel > ntp_adjtime(2) invocations. But, for instance, sys_ntp_adjtime() does > copyout(9) under Giant and then examines time_status to return syscall > result. Since copyout(9) could sleep, the syscall result might be > inconsistent. Thanks. As you know, there are still many errors near here. This is more complicated than for settime() vs resettodr() so I won't try to remember them all. Some are: - kern_ntptime.c still says that "all routines must run priority splclock or higher". Since spls are null, this just points to missing locking. The pointers are quite weak since it only calls splclock() once internally and explicit splclock() calls have been removed from all callers. There was only this one call in kern_ntptime.c as far back as FreeBSD-3. Then the syscalls didn't have any locking, so I think there were lots of races even with UP non-preemptible kernels. > Another and more important issue is that if PPS is configured, > hardpps(9) is executed without any protection against the parallel > top-level code invocation. Potentially, this may result in the > inconsistent state of the ntptime state variables, but I cannot say > how serious such distortion is. The non-functional splclock() call in It is surprising how unserious it is. > sys_ntp_adjtime() protected against clock interrupts calling hardpps() > in the pre-SMP era. > > Modernize the locking. A mutex protects ntptime data. Due to the > hardpps() KPI legitimately serving from the interrupt filters (and > e.g. uart(4) does call it from filter), the lock cannot be sleepable > mutex if PPS_SYNC is defined. Otherwise, use normal sleepable mutex > to reduce interrupt latency. The largest locking errors that I knew about were for pps and ntp_update_second(). I still don't trust calling time code from fast interrupt handlers (now misnamed filters) and don't allow it in my version. So my hardclock(), statclock() and profclock() interrupt handlers are not fast, although this adds large overheads (nearly 1% at low hz and np profileing). I have a pps handler in the RTC interrupt handler. I didn't get around to fixing the pps locking, but since the handler is not fast the fixes using sleep locks would be easier. I have a pps handler in sio. sio normally uses fast interrupts, but I never use pps for it so I didn't need to fix this. > Modified: head/sys/kern/kern_ntptime.c > ============================================================================== > --- head/sys/kern/kern_ntptime.c Tue Jun 28 16:42:40 2016 (r302251) > +++ head/sys/kern/kern_ntptime.c Tue Jun 28 16:43:23 2016 (r302252) > @@ -162,6 +162,30 @@ static l_fp time_adj; /* tick adjust ( > > static int64_t time_adjtime; /* correction from adjtime(2) (usec) */ > > +static struct mtx ntpadj_lock; > +MTX_SYSINIT(ntpadj, &ntpadj_lock, "ntpadj", > +#ifdef PPS_SYNC > + MTX_SPIN > +#else > + MTX_DEF > +#endif > +); This needs to be a spinlock in all cases, since ntp_update_second() needs to be locked and ntp_update_second() is called from tc_windup() is usually called from a fast interrupt handler. ntp_update_second() is still unlocked. It accesses lots of variables, so it obviously needs locking. E.g., its very first access is time_maxerror += MAXFREQ / 1000. This has the usual non-atomicity for a read-modify write. This obiously races with the locked access on the 28th linke of sys_ntp_adjtime(). Only the latter is locked now. > + > +/* > + * When PPS_SYNC is defined, hardpps() function is provided which can > + * be legitimately called from interrupt filters. Due to this, use > + * spinlock for ntptime state protection, otherwise sleepable mutex is > + * adequate. > + */ > +#ifdef PPS_SYNC > +#define NTPADJ_LOCK() mtx_lock_spin(&ntpadj_lock) > +#define NTPADJ_UNLOCK() mtx_unlock_spin(&ntpadj_lock) > +#else > +#define NTPADJ_LOCK() mtx_lock(&ntpadj_lock) > +#define NTPADJ_UNLOCK() mtx_unlock(&ntpadj_lock) > +#endif > +#define NTPADJ_ASSERT_LOCKED() mtx_assert(&ntpadj_lock, MA_OWNED) *ADJ* and *adj* are not good names, since much more than ntp_adj*() needs to be locked. Probably the locking should be shared with kern_tc.c. tc_windup() still uses only fancy time-domaind/atomic-op locking. This mostly works, but is quite broken by calling tc_windup() from places other than hardclock(). The most problematic other place is from tc_setclock(). That is unlocked, except accidentally by callers with only Giant locking, so it races with the fast interrupt handler. tc_windup() doesn't need the fancy locking for efficiency -- it only needs it to be consistent with binuptime() and friends. So it may as well use the same lock as ntp. Its lock must be around the whole function to protect it from tc_setclock(). Then the same lock works for ntp_update_second() and pps. Any lock that is only acquired once per second is not worth optimizing. Hopefully the same for ntp's other locks. ntp syscalls should only be frequent under unusual/malicious loads, so they shouldn't cause much contention with the tc_windup() lock. > @@ -203,11 +227,12 @@ static long pps_errcnt; /* calibration > static void ntp_init(void); > static void hardupdate(long offset); > static void ntp_gettime1(struct ntptimeval *ntvp); > -static int ntp_is_time_error(void); > +static bool ntp_is_time_error(int tsl); > > -static int > -ntp_is_time_error(void) > +static bool > +ntp_is_time_error(int tsl) > { > + Is it worth changing this to make a single variable less volatile? bool shoudn't be used in old portable code. > ... > @@ -291,14 +315,17 @@ ntp_sysctl(SYSCTL_HANDLER_ARGS) > { > struct ntptimeval ntv; /* temporary structure */ > > + NTPADJ_LOCK(); > ntp_gettime1(&ntv); > + NTPADJ_UNLOCK(); > > return (sysctl_handle_opaque(oidp, &ntv, sizeof(ntv), req)); > } > #ifdef PPS_SYNC > SYSCTL_INT(_kern_ntp_pll, OID_AUTO, pps_shiftmax, CTLFLAG_RW, > @@ -308,10 +335,12 @@ SYSCTL_INT(_kern_ntp_pll, OID_AUTO, pps_ > SYSCTL_LONG(_kern_ntp_pll, OID_AUTO, time_monitor, CTLFLAG_RD, > &time_monitor, 0, "Last time offset scaled (ns)"); > > -SYSCTL_OPAQUE(_kern_ntp_pll, OID_AUTO, pps_freq, CTLFLAG_RD, > - &pps_freq, sizeof(pps_freq), "I", "Scaled frequency offset (ns/sec)"); > -SYSCTL_OPAQUE(_kern_ntp_pll, OID_AUTO, time_freq, CTLFLAG_RD, > - &time_freq, sizeof(time_freq), "I", "Frequency offset (ns/sec)"); > +SYSCTL_S64(_kern_ntp_pll, OID_AUTO, pps_freq, CTLFLAG_RD | CTLFLAG_MPSAFE, > + &pps_freq, 0, > + "Scaled frequency offset (ns/sec)"); > +SYSCTL_S64(_kern_ntp_pll, OID_AUTO, time_freq, CTLFLAG_RD | CTLFLAG_MPSAFE, > + &time_freq, 0, > + "Frequency offset (ns/sec)"); > #endif These are not really MPSAFE, and OPAQUE was better than S64 since it doesn't hard-code the size. None of the simple sysctl handlers actually gives atomic/coherent data. They just attempt it, and have comments ad nauseum saying this even for the int8_t case where the access is surely (?) atomic. For OPAQUE 64 bits and S64, the accesses are equally non-atomic for 32-bit arches. pps_freq and time_freq are volatile, so it is technically necessary to use a SYSCTL_PROC() to copy them to a local variable with locking as above. S64 does give better printing that OPAQUE. My version adds sysctls for some more variables (mainly time_offset and time_adj). I still use OPAQUE, and with this, at least i386 the variables are printed confusingly as 2 decimal intergers. Bruce From owner-svn-src-head@freebsd.org Wed Jun 29 11:48:43 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 80D47B86338; Wed, 29 Jun 2016 11:48:43 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3A7ED2991; Wed, 29 Jun 2016 11:48:43 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5TBmgKt083683; Wed, 29 Jun 2016 11:48:42 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5TBmgUJ083682; Wed, 29 Jun 2016 11:48:42 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201606291148.u5TBmgUJ083682@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Wed, 29 Jun 2016 11:48:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302278 - head/lib/libcxxrt X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Wed, 29 Jun 2016 11:48:43 -0000 Author: emaste Date: Wed Jun 29 11:48:42 2016 New Revision: 302278 URL: https://svnweb.freebsd.org/changeset/base/302278 Log: libcxxrt: correct mangled "typeinfo name" symbols in Version.map r260553 added missing C++ typinfos to libcxxrt's version script. It appears that a number of duplicate mangled symbols were added due to a cut and paste error. Switch the second instances to _ZTS*, typeinfo name for *. Found by lld, which produces an error or warning for duplicate symbols. Reviewed by: dim Approved by: re (gjb) MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D7011 Modified: head/lib/libcxxrt/Version.map Modified: head/lib/libcxxrt/Version.map ============================================================================== --- head/lib/libcxxrt/Version.map Wed Jun 29 11:39:37 2016 (r302277) +++ head/lib/libcxxrt/Version.map Wed Jun 29 11:48:42 2016 (r302278) @@ -209,19 +209,19 @@ CXXABI_1.3 { "typeinfo name for void*"; "typeinfo name for unsigned int*"; "typeinfo name for float*"; - # C++11 typeinfo not understood by our linker + # C++11 typeinfo name not understood by our linker # std::nullptr_t - _ZTSDn;_ZTIPDn;_ZTIPKDn; + _ZTSDn;_ZTSPDn;_ZTSPKDn; # char16_t - _ZTSDi;_ZTIPDi;_ZTIPKDi; + _ZTSDi;_ZTSPDi;_ZTSPKDi; # char32_t - _ZTSDs;_ZTIPDs;_ZTIPKDs; + _ZTSDs;_ZTSPDs;_ZTSPKDs; # IEEE 754r decimal floating point - _ZTSDd;_ZTIPDd;_ZTIPKDd; - _ZTSDe;_ZTIPDe;_ZTIPKDe; - _ZTSDf;_ZTIPDf;_ZTIPKDf; + _ZTSDd;_ZTSPDd;_ZTSPKDd; + _ZTSDe;_ZTSPDe;_ZTSPKDe; + _ZTSDf;_ZTSPDf;_ZTSPKDf; # IEEE 754r half-precision floating point - _ZTSDh;_ZTIPDh;_ZTIPKDh; + _ZTSDh;_ZTSPDh;_ZTSPKDh; "typeinfo name for __cxxabiv1::__array_type_info"; "typeinfo name for __cxxabiv1::__class_type_info"; From owner-svn-src-head@freebsd.org Wed Jun 29 14:40:45 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5A8E3B85805; Wed, 29 Jun 2016 14:40:45 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 112122AF7; Wed, 29 Jun 2016 14:40:44 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5TEeinw047889; Wed, 29 Jun 2016 14:40:44 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5TEeieA047887; Wed, 29 Jun 2016 14:40:44 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201606291440.u5TEeieA047887@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Wed, 29 Jun 2016 14:40:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302279 - in head/sys/powerpc: aim powerpc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Wed, 29 Jun 2016 14:40:45 -0000 Author: nwhitehorn Date: Wed Jun 29 14:40:43 2016 New Revision: 302279 URL: https://svnweb.freebsd.org/changeset/base/302279 Log: Do not rely on firmware having pre-enabled the MMU in a reasonable way for late boot: enable it explicitly after installing the page tables. If booting from an FDT, also make sure to escape the firmware's MMU context early before overwriting firmware page tables. Approved by: re (gjb) Modified: head/sys/powerpc/aim/mmu_oea.c head/sys/powerpc/powerpc/machdep.c Modified: head/sys/powerpc/aim/mmu_oea.c ============================================================================== --- head/sys/powerpc/aim/mmu_oea.c Wed Jun 29 11:48:42 2016 (r302278) +++ head/sys/powerpc/aim/mmu_oea.c Wed Jun 29 14:40:43 2016 (r302279) @@ -921,7 +921,7 @@ moea_bootstrap(mmu_t mmup, vm_offset_t k Maxmem = powerpc_btop(phys_avail[i + 1]); moea_cpu_bootstrap(mmup,0); - + mtmsr(mfmsr() | PSL_DR | PSL_IR); pmap_bootstrapped++; /* Modified: head/sys/powerpc/powerpc/machdep.c ============================================================================== --- head/sys/powerpc/powerpc/machdep.c Wed Jun 29 11:48:42 2016 (r302278) +++ head/sys/powerpc/powerpc/machdep.c Wed Jun 29 14:40:43 2016 (r302279) @@ -251,6 +251,18 @@ powerpc_init(vm_offset_t fdt, vm_offset_ if (mdp == (void *)0x65504150) mdp = NULL; +#if AIM + /* + * If running from an FDT, make sure we are in real mode to avoid + * tromping on firmware page tables. Everything in the kernel assumes + * 1:1 mappings out of firmware, so this won't break anything not + * already broken. This doesn't work if there is live OF, since OF + * may internally use non-1:1 mappings. + */ + if (ofentry == 0) + mtmsr(mfmsr() & ~(PSL_IR | PSL_DR)); +#endif + /* * Parse metadata if present and fetch parameters. Must be done * before console is inited so cninit gets the right value of From owner-svn-src-head@freebsd.org Wed Jun 29 14:54:53 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 61A5BB85C99; Wed, 29 Jun 2016 14:54:53 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C590528CD; Wed, 29 Jun 2016 14:54:52 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u5TEsi9C062787 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Wed, 29 Jun 2016 17:54:45 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u5TEsi9C062787 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id u5TEshO8062786; Wed, 29 Jun 2016 17:54:43 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 29 Jun 2016 17:54:43 +0300 From: Konstantin Belousov To: Bruce Evans Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r302252 - head/sys/kern Message-ID: <20160629145443.GG38613@kib.kiev.ua> References: <201606281643.u5SGhNsi061606@repo.freebsd.org> <20160629175917.O968@besplex.bde.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160629175917.O968@besplex.bde.org> User-Agent: Mutt/1.6.1 (2016-04-27) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Wed, 29 Jun 2016 14:54:53 -0000 This is a reply to two mails in one, both for r302251 and r302252 threads. On Wed, Jun 29, 2016 at 05:58:05PM +1000, Bruce Evans wrote: > On Tue, 28 Jun 2016, Konstantin Belousov wrote: > > > Log: > > Do not use Giant to prevent parallel calls to CLOCK_SETTIME(). Use > > private mtx in resettodr(), no implementation of CLOCK_SETTIME() is > > allowed to sleep. > > Thanks. > > As you know, clock locking is still quite broken. The most obvious > bugs near here are now: > - settime() still begins with splclock(). This gave fewer bugs in > clock locking when it last worked in FreeBSD-4. Now it is just > a hint that the clock locking has still not been converted to use > mutexes. > - bitrot near the end of settime() removed the splx() that should > be paired with the splclock(). Yes, I am aware of both splclock() and Giant braces in the setclock(). I did not wanted to even look at tc_setclock() at all, for that change. See below. > - the locking should be stronger than mutexes (or splclock()) to > minimise the delay between deciding to set the time and actually > setting it. ... This is separate issue. Might be a critical section around the code is the right approximation for reducing delays there. > > + mtx_lock(&resettodr_lock); > > This could be later (only around the hardware parts) since we are sloppy > with the delays. Done. > > > getnanotime(&ts); > > This doesn't even try to get nanoseconds accuracy. > > > timespecadd(&ts, &clock_adj); > > ts.tv_sec -= utc_offset(); > > Who knows what utc_offset() is locked by? Certainly not this new locking, > since it is set in another file but the new locking is only in this file. > It still seems to be most under Giant :-(. utc_offset() uses several variables, updates to each of the variable is atomic. There is no even an attempt to provide userspace with an interface which would makes updates to the components used by utc_offset() consistent. Thus I do not see a need in any locking there. > > The change in the other part of the diff is related to this, and doesn't > seem quite right. utc_offset() uses the variables tz_minuteswest, > wall_cmos_clock and adjkerntz: > - tz_minuteswest is set with no locking in kern_settimeofday(), just > after the settime() call. This last had a chance of being correct > when the kernel was UP and not preemptible. But it is broken in > a more fundamental way back to at least FreeBSD-1: resettodr() is > called _before_ updating the timezone, so it uses an out-of-date > tz_minuteswest. First, the man page is not correct, saying that 'this information is kept outside the kernel'. Second, why does settime(), logicall, need the updated timezone ? I understand that resettodr() is called on successful update of the wall clock. But shouldn't the need to reset not-GMT RTC clock in kern_settimeofday() satisfied by yet another call to resettodr() if tzp != NULL, after the tz_* vars update ? > - wall_cmos_clock is still under a simple (not MPSAFE) sysctl > - adjkerntz is under a PROC sysctl, and you just changed this sysctl to > be MPSAFE. The sysctl calls here, so we don't want all of it > giant-locked. But it now does unlocked accesses to the adjkerntz > variable, and the access to the disable_rtc_set variable is unlocked > because we do it before acquiring the lock in this function (this > variable is still under a simple (not MPSAFE) sysctl. > > Most of the variables are ints, so access to them are atomic, but without > locking the correct order only occurs accidentally and is hard to > understand. I think there is no any global consistency, mostly caused by existence of separate interfaces to control all of them. IMO it is not worth to try to ensure any. > > > /* XXX: We should really set all registered RTCs */ > > - if ((error = CLOCK_SETTIME(clock_dev, &ts)) != 0) > > + error = CLOCK_SETTIME(clock_dev, &ts); > > + mtx_unlock(&resettodr_lock); > > + if (error != 0) > > printf("warning: clock_settime failed (%d), time-of-day clock " > > "not adjusted to system time\n", error); > > } > > The lock needs to cover all high-level accesses to the rtc and related > variables to avoid races, and a bit more to minimise delays. In particular, > inittodr() should be under this lock, and there is a problem with > "show rtc" in ddb. I do not think that inittodr() actually needs that locking. This code is executed at the initialization stage, or at the resume stage. Do you mean that CLOCK_GETTIME() hardware access should be made exclusive with CLOCK_SETTIME() ? Is there a hardware that rely on exclusivity and not enforce that internally, how x86 rtc does ? DDB access to rtc is separate problem. On Wed, Jun 29, 2016 at 07:39:45PM +1000, Bruce Evans wrote: > On Tue, 28 Jun 2016, Konstantin Belousov wrote: > > static int64_t time_adjtime; /* correction from adjtime(2) (usec) */ > > > > +static struct mtx ntpadj_lock; > > +MTX_SYSINIT(ntpadj, &ntpadj_lock, "ntpadj", > > +#ifdef PPS_SYNC > > + MTX_SPIN > > +#else > > + MTX_DEF > > +#endif > > +); > > This needs to be a spinlock in all cases, since ntp_update_second() needs > to be locked and ntp_update_second() is called from tc_windup() is usually > called from a fast interrupt handler. Oh, I see. > > ntp_update_second() is still unlocked. It accesses lots of variables, so > it obviously needs locking. E.g., its very first access is > time_maxerror += MAXFREQ / 1000. This has the usual non-atomicity for > a read-modify write. This obiously races with the locked access on the > 28th linke of sys_ntp_adjtime(). Only the latter is locked now. > > > + > > +/* > > + * When PPS_SYNC is defined, hardpps() function is provided which can > > + * be legitimately called from interrupt filters. Due to this, use > > + * spinlock for ntptime state protection, otherwise sleepable mutex is > > + * adequate. > > + */ > > +#ifdef PPS_SYNC > > +#define NTPADJ_LOCK() mtx_lock_spin(&ntpadj_lock) > > +#define NTPADJ_UNLOCK() mtx_unlock_spin(&ntpadj_lock) > > +#else > > +#define NTPADJ_LOCK() mtx_lock(&ntpadj_lock) > > +#define NTPADJ_UNLOCK() mtx_unlock(&ntpadj_lock) > > +#endif > > +#define NTPADJ_ASSERT_LOCKED() mtx_assert(&ntpadj_lock, MA_OWNED) > > *ADJ* and *adj* are not good names, since much more than ntp_adj*() needs > to be locked. Do you have a suggestion for a better name ? > > Probably the locking should be shared with kern_tc.c. tc_windup() still > uses only fancy time-domaind/atomic-op locking. This mostly works, but > is quite broken by calling tc_windup() from places other than hardclock(). > The most problematic other place is from tc_setclock(). That is unlocked, > except accidentally by callers with only Giant locking, so it races with > the fast interrupt handler. > > tc_windup() doesn't need the fancy locking for efficiency -- it only needs > it to be consistent with binuptime() and friends. So it may as well use > the same lock as ntp. Its lock must be around the whole function to > protect it from tc_setclock(). Then the same lock works for > ntp_update_second() and pps. Any lock that is only acquired once per > second is not worth optimizing. Hopefully the same for ntp's other locks. > ntp syscalls should only be frequent under unusual/malicious loads, so > they shouldn't cause much contention with the tc_windup() lock. So I postponed looking at tc_windup(), and it seems that it was useful. After you note above, it is mostly clear that we can skip some tc_windup() calls which conflicts with currently active windup calls. E.g., the hardclock update, which is done simultaneously with the setclock(), could be just skipped. But we must not skip the tc_windup() call from setclock(). As an additional, but probably excessive measure, invocation of tc_windup() from hardclock could ask the setclock() to re-execute tc_windup() after its call is done. > > -static int > > -ntp_is_time_error(void) > > +static bool > > +ntp_is_time_error(int tsl) > > { > > + > > Is it worth changing this to make a single variable less volatile? Yes, to rely on single-variable read being atomic and avoiding locking in callout. [Skipped the S64/OPAQUE stuff] Patch does the following: - change the ntpadj_lock to spinlock. - acquire the ntpadj_lock around ntp_update_second(). - prevent parallel tc_windup() invocations, while not allowing to skip calls coming from kernel top half. - move resettodr_lock acquisition in resettodr() later. diff --git a/sys/kern/kern_ntptime.c b/sys/kern/kern_ntptime.c index d352ee7..34b29d9 100644 --- a/sys/kern/kern_ntptime.c +++ b/sys/kern/kern_ntptime.c @@ -163,27 +163,10 @@ static l_fp time_adj; /* tick adjust (ns/s) */ static int64_t time_adjtime; /* correction from adjtime(2) (usec) */ static struct mtx ntpadj_lock; -MTX_SYSINIT(ntpadj, &ntpadj_lock, "ntpadj", -#ifdef PPS_SYNC - MTX_SPIN -#else - MTX_DEF -#endif -); +MTX_SYSINIT(ntpadj, &ntpadj_lock, "ntpadj", MTX_SPIN); -/* - * When PPS_SYNC is defined, hardpps() function is provided which can - * be legitimately called from interrupt filters. Due to this, use - * spinlock for ntptime state protection, otherwise sleepable mutex is - * adequate. - */ -#ifdef PPS_SYNC #define NTPADJ_LOCK() mtx_lock_spin(&ntpadj_lock) #define NTPADJ_UNLOCK() mtx_unlock_spin(&ntpadj_lock) -#else -#define NTPADJ_LOCK() mtx_lock(&ntpadj_lock) -#define NTPADJ_UNLOCK() mtx_unlock(&ntpadj_lock) -#endif #define NTPADJ_ASSERT_LOCKED() mtx_assert(&ntpadj_lock, MA_OWNED) #ifdef PPS_SYNC @@ -506,6 +489,8 @@ ntp_update_second(int64_t *adjustment, time_t *newsec) int tickrate; l_fp ftemp; /* 32/64-bit temporary */ + NTPADJ_LOCK(); + /* * On rollover of the second both the nanosecond and microsecond * clocks are updated and the state machine cranked as @@ -627,6 +612,8 @@ ntp_update_second(int64_t *adjustment, time_t *newsec) else time_status &= ~STA_PPSSIGNAL; #endif /* PPS_SYNC */ + + NTPADJ_UNLOCK(); } /* diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index 0f015b3..b738083 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -135,7 +135,8 @@ SYSCTL_PROC(_kern_timecounter, OID_AUTO, alloweddeviation, static int tc_chosen; /* Non-zero if a specific tc was chosen via sysctl. */ -static void tc_windup(void); +static void tc_windup(bool top_call); +static void tc_windup_locked(void); static void cpu_tick_calibrate(int); void dtrace_getnanotime(struct timespec *tsp); @@ -1247,7 +1248,7 @@ tc_setclock(struct timespec *ts) bintime2timeval(&bt, &boottime); /* XXX fiddle all the little crinkly bits around the fiords... */ - tc_windup(); + tc_windup(true); nanotime(&taft); if (timestepwarnings) { log(LOG_INFO, @@ -1259,13 +1260,30 @@ tc_setclock(struct timespec *ts) cpu_tick_calibrate(1); } +static volatile int tc_windup_lock; +static void +tc_windup(bool top_call) +{ + + for (;;) { + if (atomic_cmpset_int(&tc_windup_lock, 0, 1)) { + atomic_thread_fence_acq(); + tc_windup_locked(); + atomic_store_rel_int(&tc_windup_lock, 0); + break; + } else if (!top_call) { + break; + } + } +} + /* * Initialize the next struct timehands in the ring and make * it the active timehands. Along the way we might switch to a different * timecounter and/or do seconds processing in NTP. Slightly magic. */ static void -tc_windup(void) +tc_windup_locked(void) { struct bintime bt; struct timehands *th, *tho; @@ -1846,7 +1864,7 @@ tc_ticktock(int cnt) if (count < tc_tick) return; count = 0; - tc_windup(); + tc_windup(false); } static void __inline @@ -1921,7 +1939,7 @@ inittimecounter(void *dummy) /* warm up new timecounter (again) and get rolling. */ (void)timecounter->tc_get_timecount(timecounter); (void)timecounter->tc_get_timecount(timecounter); - tc_windup(); + tc_windup(true); } SYSINIT(timecounter, SI_SUB_CLOCKS, SI_ORDER_SECOND, inittimecounter, NULL); diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index 148da2b..82710f7 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -115,9 +115,7 @@ settime(struct thread *td, struct timeval *tv) struct timeval delta, tv1, tv2; static struct timeval maxtime, laststep; struct timespec ts; - int s; - s = splclock(); microtime(&tv1); delta = *tv; timevalsub(&delta, &tv1); @@ -147,10 +145,8 @@ settime(struct thread *td, struct timeval *tv) printf("Time adjustment clamped to -1 second\n"); } } else { - if (tv1.tv_sec == laststep.tv_sec) { - splx(s); + if (tv1.tv_sec == laststep.tv_sec) return (EPERM); - } if (delta.tv_sec > 1) { tv->tv_sec = tv1.tv_sec + 1; printf("Time adjustment clamped to +1 second\n"); @@ -161,10 +157,8 @@ settime(struct thread *td, struct timeval *tv) ts.tv_sec = tv->tv_sec; ts.tv_nsec = tv->tv_usec * 1000; - mtx_lock(&Giant); tc_setclock(&ts); resettodr(); - mtx_unlock(&Giant); return (0); } diff --git a/sys/kern/subr_rtc.c b/sys/kern/subr_rtc.c index dbad36d..4bac324 100644 --- a/sys/kern/subr_rtc.c +++ b/sys/kern/subr_rtc.c @@ -172,11 +172,11 @@ resettodr(void) if (disable_rtc_set || clock_dev == NULL) return; - mtx_lock(&resettodr_lock); getnanotime(&ts); timespecadd(&ts, &clock_adj); ts.tv_sec -= utc_offset(); /* XXX: We should really set all registered RTCs */ + mtx_lock(&resettodr_lock); error = CLOCK_SETTIME(clock_dev, &ts); mtx_unlock(&resettodr_lock); if (error != 0) From owner-svn-src-head@freebsd.org Wed Jun 29 15:32:46 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 028CEB866C2; Wed, 29 Jun 2016 15:32:46 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4901C24C5; Wed, 29 Jun 2016 15:32:45 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u5TFWX28072367 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Wed, 29 Jun 2016 18:32:33 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u5TFWX28072367 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id u5TFWXPM072366; Wed, 29 Jun 2016 18:32:33 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 29 Jun 2016 18:32:33 +0300 From: Konstantin Belousov To: Bruce Evans Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r302252 - head/sys/kern Message-ID: <20160629153233.GI38613@kib.kiev.ua> References: <201606281643.u5SGhNsi061606@repo.freebsd.org> <20160629175917.O968@besplex.bde.org> <20160629145443.GG38613@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160629145443.GG38613@kib.kiev.ua> User-Agent: Mutt/1.6.1 (2016-04-27) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Wed, 29 Jun 2016 15:32:46 -0000 On Wed, Jun 29, 2016 at 05:54:43PM +0300, Konstantin Belousov wrote: > This is a reply to two mails in one, both for r302251 and r302252 threads. > > On Wed, Jun 29, 2016 at 05:58:05PM +1000, Bruce Evans wrote: > > On Tue, 28 Jun 2016, Konstantin Belousov wrote: > > > > > Log: > > > Do not use Giant to prevent parallel calls to CLOCK_SETTIME(). Use > > > private mtx in resettodr(), no implementation of CLOCK_SETTIME() is > > > allowed to sleep. > > > > Thanks. > > > > As you know, clock locking is still quite broken. The most obvious > > bugs near here are now: > > - settime() still begins with splclock(). This gave fewer bugs in > > clock locking when it last worked in FreeBSD-4. Now it is just > > a hint that the clock locking has still not been converted to use > > mutexes. > > - bitrot near the end of settime() removed the splx() that should > > be paired with the splclock(). > Yes, I am aware of both splclock() and Giant braces in the setclock(). > I did not wanted to even look at tc_setclock() at all, for that change. > See below. > > > - the locking should be stronger than mutexes (or splclock()) to > > minimise the delay between deciding to set the time and actually > > setting it. > ... > This is separate issue. Might be a critical section around the code > is the right approximation for reducing delays there. > > > > + mtx_lock(&resettodr_lock); > > > > This could be later (only around the hardware parts) since we are sloppy > > with the delays. > Done. > > > > > > getnanotime(&ts); > > > > This doesn't even try to get nanoseconds accuracy. > > > > > timespecadd(&ts, &clock_adj); > > > ts.tv_sec -= utc_offset(); > > > > Who knows what utc_offset() is locked by? Certainly not this new locking, > > since it is set in another file but the new locking is only in this file. > > It still seems to be most under Giant :-(. > utc_offset() uses several variables, updates to each of the variable is > atomic. There is no even an attempt to provide userspace with an interface > which would makes updates to the components used by utc_offset() consistent. > Thus I do not see a need in any locking there. > > > > > The change in the other part of the diff is related to this, and doesn't > > seem quite right. utc_offset() uses the variables tz_minuteswest, > > wall_cmos_clock and adjkerntz: > > - tz_minuteswest is set with no locking in kern_settimeofday(), just > > after the settime() call. This last had a chance of being correct > > when the kernel was UP and not preemptible. But it is broken in > > a more fundamental way back to at least FreeBSD-1: resettodr() is > > called _before_ updating the timezone, so it uses an out-of-date > > tz_minuteswest. > First, the man page is not correct, saying that 'this information is > kept outside the kernel'. > > Second, why does settime(), logicall, need the updated timezone ? > I understand that resettodr() is called on successful update of > the wall clock. But shouldn't the need to reset not-GMT RTC clock > in kern_settimeofday() satisfied by yet another call to resettodr() > if tzp != NULL, after the tz_* vars update ? > > > - wall_cmos_clock is still under a simple (not MPSAFE) sysctl > > - adjkerntz is under a PROC sysctl, and you just changed this sysctl to > > be MPSAFE. The sysctl calls here, so we don't want all of it > > giant-locked. But it now does unlocked accesses to the adjkerntz > > variable, and the access to the disable_rtc_set variable is unlocked > > because we do it before acquiring the lock in this function (this > > variable is still under a simple (not MPSAFE) sysctl. > > > > Most of the variables are ints, so access to them are atomic, but without > > locking the correct order only occurs accidentally and is hard to > > understand. > I think there is no any global consistency, mostly caused by existence > of separate interfaces to control all of them. IMO it is not worth to > try to ensure any. > > > > > > /* XXX: We should really set all registered RTCs */ > > > - if ((error = CLOCK_SETTIME(clock_dev, &ts)) != 0) > > > + error = CLOCK_SETTIME(clock_dev, &ts); > > > + mtx_unlock(&resettodr_lock); > > > + if (error != 0) > > > printf("warning: clock_settime failed (%d), time-of-day clock " > > > "not adjusted to system time\n", error); > > > } > > > > The lock needs to cover all high-level accesses to the rtc and related > > variables to avoid races, and a bit more to minimise delays. In particular, > > inittodr() should be under this lock, and there is a problem with > > "show rtc" in ddb. > I do not think that inittodr() actually needs that locking. This code > is executed at the initialization stage, or at the resume stage. > > Do you mean that CLOCK_GETTIME() hardware access should be made exclusive > with CLOCK_SETTIME() ? Is there a hardware that rely on exclusivity and > not enforce that internally, how x86 rtc does ? > > DDB access to rtc is separate problem. > > On Wed, Jun 29, 2016 at 07:39:45PM +1000, Bruce Evans wrote: > > On Tue, 28 Jun 2016, Konstantin Belousov wrote: > > > static int64_t time_adjtime; /* correction from adjtime(2) (usec) */ > > > > > > +static struct mtx ntpadj_lock; > > > +MTX_SYSINIT(ntpadj, &ntpadj_lock, "ntpadj", > > > +#ifdef PPS_SYNC > > > + MTX_SPIN > > > +#else > > > + MTX_DEF > > > +#endif > > > +); > > > > This needs to be a spinlock in all cases, since ntp_update_second() needs > > to be locked and ntp_update_second() is called from tc_windup() is usually > > called from a fast interrupt handler. > Oh, I see. > > > > > ntp_update_second() is still unlocked. It accesses lots of variables, so > > it obviously needs locking. E.g., its very first access is > > time_maxerror += MAXFREQ / 1000. This has the usual non-atomicity for > > a read-modify write. This obiously races with the locked access on the > > 28th linke of sys_ntp_adjtime(). Only the latter is locked now. > > > > > + > > > +/* > > > + * When PPS_SYNC is defined, hardpps() function is provided which can > > > + * be legitimately called from interrupt filters. Due to this, use > > > + * spinlock for ntptime state protection, otherwise sleepable mutex is > > > + * adequate. > > > + */ > > > +#ifdef PPS_SYNC > > > +#define NTPADJ_LOCK() mtx_lock_spin(&ntpadj_lock) > > > +#define NTPADJ_UNLOCK() mtx_unlock_spin(&ntpadj_lock) > > > +#else > > > +#define NTPADJ_LOCK() mtx_lock(&ntpadj_lock) > > > +#define NTPADJ_UNLOCK() mtx_unlock(&ntpadj_lock) > > > +#endif > > > +#define NTPADJ_ASSERT_LOCKED() mtx_assert(&ntpadj_lock, MA_OWNED) > > > > *ADJ* and *adj* are not good names, since much more than ntp_adj*() needs > > to be locked. > Do you have a suggestion for a better name ? > > > > > Probably the locking should be shared with kern_tc.c. tc_windup() still > > uses only fancy time-domaind/atomic-op locking. This mostly works, but > > is quite broken by calling tc_windup() from places other than hardclock(). > > The most problematic other place is from tc_setclock(). That is unlocked, > > except accidentally by callers with only Giant locking, so it races with > > the fast interrupt handler. > > > > tc_windup() doesn't need the fancy locking for efficiency -- it only needs > > it to be consistent with binuptime() and friends. So it may as well use > > the same lock as ntp. Its lock must be around the whole function to > > protect it from tc_setclock(). Then the same lock works for > > ntp_update_second() and pps. Any lock that is only acquired once per > > second is not worth optimizing. Hopefully the same for ntp's other locks. > > ntp syscalls should only be frequent under unusual/malicious loads, so > > they shouldn't cause much contention with the tc_windup() lock. > So I postponed looking at tc_windup(), and it seems that it was > useful. After you note above, it is mostly clear that we can skip some > tc_windup() calls which conflicts with currently active windup calls. > E.g., the hardclock update, which is done simultaneously with the > setclock(), could be just skipped. But we must not skip the tc_windup() > call from setclock(). > > As an additional, but probably excessive measure, invocation of > tc_windup() from hardclock could ask the setclock() to re-execute > tc_windup() after its call is done. > > > > -static int > > > -ntp_is_time_error(void) > > > +static bool > > > +ntp_is_time_error(int tsl) > > > { > > > + > > > > Is it worth changing this to make a single variable less volatile? > Yes, to rely on single-variable read being atomic and avoiding locking > in callout. > > [Skipped the S64/OPAQUE stuff] > > Patch does the following: > - change the ntpadj_lock to spinlock. > - acquire the ntpadj_lock around ntp_update_second(). > - prevent parallel tc_windup() invocations, while not allowing to > skip calls coming from kernel top half. > - move resettodr_lock acquisition in resettodr() later. I now think that the lock around tc_windup() should have more flavor of real spinlocks. Ideally the spinlock_enter() should be taken around it, but it might be too extreme. Just a critical section in tc_setclock() is good enough. diff --git a/sys/kern/kern_ntptime.c b/sys/kern/kern_ntptime.c index d352ee7..34b29d9 100644 --- a/sys/kern/kern_ntptime.c +++ b/sys/kern/kern_ntptime.c @@ -163,27 +163,10 @@ static l_fp time_adj; /* tick adjust (ns/s) */ static int64_t time_adjtime; /* correction from adjtime(2) (usec) */ static struct mtx ntpadj_lock; -MTX_SYSINIT(ntpadj, &ntpadj_lock, "ntpadj", -#ifdef PPS_SYNC - MTX_SPIN -#else - MTX_DEF -#endif -); +MTX_SYSINIT(ntpadj, &ntpadj_lock, "ntpadj", MTX_SPIN); -/* - * When PPS_SYNC is defined, hardpps() function is provided which can - * be legitimately called from interrupt filters. Due to this, use - * spinlock for ntptime state protection, otherwise sleepable mutex is - * adequate. - */ -#ifdef PPS_SYNC #define NTPADJ_LOCK() mtx_lock_spin(&ntpadj_lock) #define NTPADJ_UNLOCK() mtx_unlock_spin(&ntpadj_lock) -#else -#define NTPADJ_LOCK() mtx_lock(&ntpadj_lock) -#define NTPADJ_UNLOCK() mtx_unlock(&ntpadj_lock) -#endif #define NTPADJ_ASSERT_LOCKED() mtx_assert(&ntpadj_lock, MA_OWNED) #ifdef PPS_SYNC @@ -506,6 +489,8 @@ ntp_update_second(int64_t *adjustment, time_t *newsec) int tickrate; l_fp ftemp; /* 32/64-bit temporary */ + NTPADJ_LOCK(); + /* * On rollover of the second both the nanosecond and microsecond * clocks are updated and the state machine cranked as @@ -627,6 +612,8 @@ ntp_update_second(int64_t *adjustment, time_t *newsec) else time_status &= ~STA_PPSSIGNAL; #endif /* PPS_SYNC */ + + NTPADJ_UNLOCK(); } /* diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index 0f015b3..a5776d2 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -135,7 +135,8 @@ SYSCTL_PROC(_kern_timecounter, OID_AUTO, alloweddeviation, static int tc_chosen; /* Non-zero if a specific tc was chosen via sysctl. */ -static void tc_windup(void); +static void tc_windup(bool top_call); +static void tc_windup_locked(void); static void cpu_tick_calibrate(int); void dtrace_getnanotime(struct timespec *tsp); @@ -1237,6 +1238,7 @@ tc_setclock(struct timespec *ts) struct timespec tbef, taft; struct bintime bt, bt2; + critical_enter(); cpu_tick_calibrate(1); nanotime(&tbef); timespec2bintime(ts, &bt); @@ -1247,8 +1249,10 @@ tc_setclock(struct timespec *ts) bintime2timeval(&bt, &boottime); /* XXX fiddle all the little crinkly bits around the fiords... */ - tc_windup(); + tc_windup(true); nanotime(&taft); + cpu_tick_calibrate(1); + critical_exit(); if (timestepwarnings) { log(LOG_INFO, "Time stepped from %jd.%09ld to %jd.%09ld (%jd.%09ld)\n", @@ -1256,7 +1260,23 @@ tc_setclock(struct timespec *ts) (intmax_t)taft.tv_sec, taft.tv_nsec, (intmax_t)ts->tv_sec, ts->tv_nsec); } - cpu_tick_calibrate(1); +} + +static volatile int tc_windup_lock; +static void +tc_windup(bool top_call) +{ + + for (;;) { + if (atomic_cmpset_int(&tc_windup_lock, 0, 1)) { + atomic_thread_fence_acq(); + tc_windup_locked(); + atomic_store_rel_int(&tc_windup_lock, 0); + break; + } else if (!top_call) { + break; + } + } } /* @@ -1265,7 +1285,7 @@ tc_setclock(struct timespec *ts) * timecounter and/or do seconds processing in NTP. Slightly magic. */ static void -tc_windup(void) +tc_windup_locked(void) { struct bintime bt; struct timehands *th, *tho; @@ -1846,7 +1866,7 @@ tc_ticktock(int cnt) if (count < tc_tick) return; count = 0; - tc_windup(); + tc_windup(false); } static void __inline @@ -1921,7 +1941,7 @@ inittimecounter(void *dummy) /* warm up new timecounter (again) and get rolling. */ (void)timecounter->tc_get_timecount(timecounter); (void)timecounter->tc_get_timecount(timecounter); - tc_windup(); + tc_windup(true); } SYSINIT(timecounter, SI_SUB_CLOCKS, SI_ORDER_SECOND, inittimecounter, NULL); diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index 148da2b..82710f7 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -115,9 +115,7 @@ settime(struct thread *td, struct timeval *tv) struct timeval delta, tv1, tv2; static struct timeval maxtime, laststep; struct timespec ts; - int s; - s = splclock(); microtime(&tv1); delta = *tv; timevalsub(&delta, &tv1); @@ -147,10 +145,8 @@ settime(struct thread *td, struct timeval *tv) printf("Time adjustment clamped to -1 second\n"); } } else { - if (tv1.tv_sec == laststep.tv_sec) { - splx(s); + if (tv1.tv_sec == laststep.tv_sec) return (EPERM); - } if (delta.tv_sec > 1) { tv->tv_sec = tv1.tv_sec + 1; printf("Time adjustment clamped to +1 second\n"); @@ -161,10 +157,8 @@ settime(struct thread *td, struct timeval *tv) ts.tv_sec = tv->tv_sec; ts.tv_nsec = tv->tv_usec * 1000; - mtx_lock(&Giant); tc_setclock(&ts); resettodr(); - mtx_unlock(&Giant); return (0); } diff --git a/sys/kern/subr_rtc.c b/sys/kern/subr_rtc.c index dbad36d..4bac324 100644 --- a/sys/kern/subr_rtc.c +++ b/sys/kern/subr_rtc.c @@ -172,11 +172,11 @@ resettodr(void) if (disable_rtc_set || clock_dev == NULL) return; - mtx_lock(&resettodr_lock); getnanotime(&ts); timespecadd(&ts, &clock_adj); ts.tv_sec -= utc_offset(); /* XXX: We should really set all registered RTCs */ + mtx_lock(&resettodr_lock); error = CLOCK_SETTIME(clock_dev, &ts); mtx_unlock(&resettodr_lock); if (error != 0) From owner-svn-src-head@freebsd.org Wed Jun 29 16:34:57 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B5AE4B861DF; Wed, 29 Jun 2016 16:34:57 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 740AD2792; Wed, 29 Jun 2016 16:34:57 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5TGYuD9092536; Wed, 29 Jun 2016 16:34:56 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5TGYu0M092535; Wed, 29 Jun 2016 16:34:56 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201606291634.u5TGYu0M092535@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Wed, 29 Jun 2016 16:34:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302280 - head/sys/powerpc/powerpc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Wed, 29 Jun 2016 16:34:57 -0000 Author: nwhitehorn Date: Wed Jun 29 16:34:56 2016 New Revision: 302280 URL: https://svnweb.freebsd.org/changeset/base/302280 Log: Fix fat-fingering: #if AIM should have been #ifdef AIM to avoid failures on Book-E kernels. Approved by: re (gjb) Pointy hat to: nwhitehorn Modified: head/sys/powerpc/powerpc/machdep.c Modified: head/sys/powerpc/powerpc/machdep.c ============================================================================== --- head/sys/powerpc/powerpc/machdep.c Wed Jun 29 14:40:43 2016 (r302279) +++ head/sys/powerpc/powerpc/machdep.c Wed Jun 29 16:34:56 2016 (r302280) @@ -251,7 +251,7 @@ powerpc_init(vm_offset_t fdt, vm_offset_ if (mdp == (void *)0x65504150) mdp = NULL; -#if AIM +#ifdef AIM /* * If running from an FDT, make sure we are in real mode to avoid * tromping on firmware page tables. Everything in the kernel assumes From owner-svn-src-head@freebsd.org Wed Jun 29 16:41:38 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5C3A3B8637C; Wed, 29 Jun 2016 16:41:38 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2AB342CD0; Wed, 29 Jun 2016 16:41:38 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5TGfbIM094263; Wed, 29 Jun 2016 16:41:37 GMT (envelope-from sbruno@FreeBSD.org) Received: (from sbruno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5TGfb42094262; Wed, 29 Jun 2016 16:41:37 GMT (envelope-from sbruno@FreeBSD.org) Message-Id: <201606291641.u5TGfb42094262@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sbruno set sender to sbruno@FreeBSD.org using -f From: Sean Bruno Date: Wed, 29 Jun 2016 16:41:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302281 - head/sys/cam/scsi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Wed, 29 Jun 2016 16:41:38 -0000 Author: sbruno Date: Wed Jun 29 16:41:37 2016 New Revision: 302281 URL: https://svnweb.freebsd.org/changeset/base/302281 Log: Correct PERSISTENT RESERVE OUT command and populate scsi_cmd->length. PR: 202625 Submitted by: niakrisn@gmail.com Reviewed by: scottl kenm Approved by: re (gjb) MFC after: 2 weeks Modified: head/sys/cam/scsi/scsi_all.c Modified: head/sys/cam/scsi/scsi_all.c ============================================================================== --- head/sys/cam/scsi/scsi_all.c Wed Jun 29 16:34:56 2016 (r302280) +++ head/sys/cam/scsi/scsi_all.c Wed Jun 29 16:41:37 2016 (r302281) @@ -8788,6 +8788,7 @@ scsi_persistent_reserve_out(struct ccb_s scsi_cmd->opcode = PERSISTENT_RES_OUT; scsi_cmd->action = service_action; scsi_cmd->scope_type = scope | res_type; + scsi_ulto4b(dxfer_len, scsi_cmd->length); cam_fill_csio(csio, retries, From owner-svn-src-head@freebsd.org Wed Jun 29 16:45:03 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0AC0FB8652D; Wed, 29 Jun 2016 16:45:03 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CEDE92FBD; Wed, 29 Jun 2016 16:45:02 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5TGj2iV096428; Wed, 29 Jun 2016 16:45:02 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5TGj2eJ096427; Wed, 29 Jun 2016 16:45:02 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201606291645.u5TGj2eJ096427@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Wed, 29 Jun 2016 16:45:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302282 - head/share/mk X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Wed, 29 Jun 2016 16:45:03 -0000 Author: bdrewery Date: Wed Jun 29 16:45:01 2016 New Revision: 302282 URL: https://svnweb.freebsd.org/changeset/base/302282 Log: Don't warn about needing filemon for makeman. r287879 wasn't quite enough here since Makefile.inc1 is running 'make -C release -V VERSION' and hitting the warning. Reported by: lattera Sponsored by: EMC / Isilon Storage Division Approved by: re (blanket, META_MODE) Modified: head/share/mk/bsd.init.mk Modified: head/share/mk/bsd.init.mk ============================================================================== --- head/share/mk/bsd.init.mk Wed Jun 29 16:41:37 2016 (r302281) +++ head/share/mk/bsd.init.mk Wed Jun 29 16:45:01 2016 (r302282) @@ -31,7 +31,7 @@ _SKIP_BUILD = not building at level 0 .if ${MK_META_MODE} == "yes" .if !exists(/dev/filemon) && \ ${UPDATE_DEPENDFILE:Uyes:tl} != "no" && !defined(NO_FILEMON) && \ - !make(showconfig) + !make(showconfig) && ${.MAKEFLAGS:M-V} == "" .warning The filemon module (/dev/filemon) is not loaded. .warning META_MODE is less useful for incremental builds without filemon. .warning 'kldload filemon' or pass -DNO_FILEMON to suppress this warning. From owner-svn-src-head@freebsd.org Wed Jun 29 17:25:48 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 35A5BB86DB9; Wed, 29 Jun 2016 17:25:48 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1152124F4; Wed, 29 Jun 2016 17:25:47 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5THPleF011752; Wed, 29 Jun 2016 17:25:47 GMT (envelope-from avos@FreeBSD.org) Received: (from avos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5THPk0Y011747; Wed, 29 Jun 2016 17:25:46 GMT (envelope-from avos@FreeBSD.org) Message-Id: <201606291725.u5THPk0Y011747@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avos set sender to avos@FreeBSD.org using -f From: Andriy Voskoboinyk Date: Wed, 29 Jun 2016 17:25:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302283 - head/sys/net80211 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Wed, 29 Jun 2016 17:25:48 -0000 Author: avos Date: Wed Jun 29 17:25:46 2016 New Revision: 302283 URL: https://svnweb.freebsd.org/changeset/base/302283 Log: net80211: fix LOR/deadlock in ieee80211_ff_node_cleanup(). Add new lock for stageq (part of ieee80211_superg structure) and ni_tx_superg (part of ieee80211_node structure); drop com_lock protection where it is used to protect them. While here, drop duplicate OPACKETS counter incrementation. ni_tx_ampdu is not protected with it (however, it is also used without locking in other places; probably, it requires some other solution to be thread-safe). Tested with RTL8188CUS (AP) and RTL8188EU (STA). NOTE: Since this change breaks KBI, all wireless drivers need to be recompiled. Reviewed by: adrian Approved by: re (gjb) Differential Revision: https://reviews.freebsd.org/D6958 Modified: head/sys/net80211/ieee80211_ddb.c head/sys/net80211/ieee80211_freebsd.h head/sys/net80211/ieee80211_superg.c head/sys/net80211/ieee80211_superg.h head/sys/net80211/ieee80211_var.h Modified: head/sys/net80211/ieee80211_ddb.c ============================================================================== --- head/sys/net80211/ieee80211_ddb.c Wed Jun 29 16:45:01 2016 (r302282) +++ head/sys/net80211/ieee80211_ddb.c Wed Jun 29 17:25:46 2016 (r302283) @@ -506,6 +506,8 @@ _db_show_com(const struct ieee80211com * db_printf("\tsoftc %p", ic->ic_softc); db_printf("\tname %s", ic->ic_name); db_printf(" comlock %p", &ic->ic_comlock); + db_printf(" txlock %p", &ic->ic_txlock); + db_printf(" fflock %p", &ic->ic_fflock); db_printf("\n"); db_printf("\theadroom %d", ic->ic_headroom); db_printf(" phytype %d", ic->ic_phytype); Modified: head/sys/net80211/ieee80211_freebsd.h ============================================================================== --- head/sys/net80211/ieee80211_freebsd.h Wed Jun 29 16:45:01 2016 (r302282) +++ head/sys/net80211/ieee80211_freebsd.h Wed Jun 29 17:25:46 2016 (r302283) @@ -83,6 +83,25 @@ typedef struct { mtx_assert(IEEE80211_TX_LOCK_OBJ(_ic), MA_NOTOWNED) /* + * Stageq / ni_tx_superg lock + */ +typedef struct { + char name[16]; /* e.g. "ath0_ff_lock" */ + struct mtx mtx; +} ieee80211_ff_lock_t; +#define IEEE80211_FF_LOCK_INIT(_ic, _name) do { \ + ieee80211_ff_lock_t *fl = &(_ic)->ic_fflock; \ + snprintf(fl->name, sizeof(fl->name), "%s_ff_lock", _name); \ + mtx_init(&fl->mtx, fl->name, NULL, MTX_DEF); \ +} while (0) +#define IEEE80211_FF_LOCK_OBJ(_ic) (&(_ic)->ic_fflock.mtx) +#define IEEE80211_FF_LOCK_DESTROY(_ic) mtx_destroy(IEEE80211_FF_LOCK_OBJ(_ic)) +#define IEEE80211_FF_LOCK(_ic) mtx_lock(IEEE80211_FF_LOCK_OBJ(_ic)) +#define IEEE80211_FF_UNLOCK(_ic) mtx_unlock(IEEE80211_FF_LOCK_OBJ(_ic)) +#define IEEE80211_FF_LOCK_ASSERT(_ic) \ + mtx_assert(IEEE80211_FF_LOCK_OBJ(_ic), MA_OWNED) + +/* * Node locking definitions. */ typedef struct { Modified: head/sys/net80211/ieee80211_superg.c ============================================================================== --- head/sys/net80211/ieee80211_superg.c Wed Jun 29 16:45:01 2016 (r302282) +++ head/sys/net80211/ieee80211_superg.c Wed Jun 29 17:25:46 2016 (r302283) @@ -99,6 +99,8 @@ ieee80211_superg_attach(struct ieee80211 { struct ieee80211_superg *sg; + IEEE80211_FF_LOCK_INIT(ic, ic->ic_name); + sg = (struct ieee80211_superg *) IEEE80211_MALLOC( sizeof(struct ieee80211_superg), M_80211_VAP, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); @@ -120,6 +122,8 @@ ieee80211_superg_attach(struct ieee80211 void ieee80211_superg_detach(struct ieee80211com *ic) { + IEEE80211_FF_LOCK_DESTROY(ic); + if (ic->ic_superg != NULL) { IEEE80211_FREE(ic->ic_superg, M_80211_VAP); ic->ic_superg = NULL; @@ -575,19 +579,14 @@ ff_transmit(struct ieee80211_node *ni, s { struct ieee80211vap *vap = ni->ni_vap; struct ieee80211com *ic = ni->ni_ic; - int error; - IEEE80211_TX_LOCK_ASSERT(vap->iv_ic); + IEEE80211_TX_LOCK_ASSERT(ic); /* encap and xmit */ m = ieee80211_encap(vap, ni, m); - if (m != NULL) { - struct ifnet *ifp = vap->iv_ifp; - - error = ieee80211_parent_xmitpkt(ic, m); - if (!error) - if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); - } else + if (m != NULL) + (void) ieee80211_parent_xmitpkt(ic, m); + else ieee80211_free_node(ni); } @@ -620,14 +619,6 @@ ff_flush(struct mbuf *head, struct mbuf /* * Age frames on the staging queue. - * - * This is called without the comlock held, but it does all its work - * behind the comlock. Because of this, it's possible that the - * staging queue will be serviced between the function which called - * it and now; thus simply checking that the queue has work in it - * may fail. - * - * See PR kern/174283 for more details. */ void ieee80211_ff_age(struct ieee80211com *ic, struct ieee80211_stageq *sq, @@ -636,11 +627,14 @@ ieee80211_ff_age(struct ieee80211com *ic struct mbuf *m, *head; struct ieee80211_node *ni; -#if 0 + IEEE80211_FF_LOCK(ic); + if (sq->depth == 0) { + IEEE80211_FF_UNLOCK(ic); + return; /* nothing to do */ + } + KASSERT(sq->head != NULL, ("stageq empty")); -#endif - IEEE80211_LOCK(ic); head = sq->head; while ((m = sq->head) != NULL && M_AGE_GET(m) < quanta) { int tid = WME_AC_TO_TID(M_WME_GETAC(m)); @@ -657,7 +651,7 @@ ieee80211_ff_age(struct ieee80211com *ic sq->tail = NULL; else M_AGE_SUB(m, quanta); - IEEE80211_UNLOCK(ic); + IEEE80211_FF_UNLOCK(ic); IEEE80211_TX_LOCK(ic); ff_flush(head, m); @@ -669,7 +663,7 @@ stageq_add(struct ieee80211com *ic, stru { int age = ieee80211_ffagemax; - IEEE80211_LOCK_ASSERT(ic); + IEEE80211_FF_LOCK_ASSERT(ic); if (sq->tail != NULL) { sq->tail->m_nextpkt = m; @@ -688,7 +682,7 @@ stageq_remove(struct ieee80211com *ic, s { struct mbuf *m, *mprev; - IEEE80211_LOCK_ASSERT(ic); + IEEE80211_FF_LOCK_ASSERT(ic); mprev = NULL; for (m = sq->head; m != NULL; m = m->m_nextpkt) { @@ -767,6 +761,11 @@ ieee80211_ff_check(struct ieee80211_node IEEE80211_TX_UNLOCK_ASSERT(ic); + IEEE80211_LOCK(ic); + limit = IEEE80211_TXOP_TO_US( + ic->ic_wme.wme_chanParams.cap_wmeParams[pri].wmep_txopLimit); + IEEE80211_UNLOCK(ic); + /* * Check if the supplied frame can be aggregated. * @@ -774,7 +773,7 @@ ieee80211_ff_check(struct ieee80211_node * Do 802.1x EAPOL frames proceed in the clear? Then they couldn't * be aggregated with other types of frames when encryption is on? */ - IEEE80211_LOCK(ic); + IEEE80211_FF_LOCK(ic); tap = &ni->ni_tx_ampdu[WME_AC_TO_TID(pri)]; mstaged = ni->ni_tx_superg[WME_AC_TO_TID(pri)]; /* XXX NOTE: reusing packet counter state from A-MPDU */ @@ -792,7 +791,7 @@ ieee80211_ff_check(struct ieee80211_node if (vap->iv_opmode != IEEE80211_M_STA && ETHER_IS_MULTICAST(mtod(m, struct ether_header *)->ether_dhost)) { /* XXX flush staged frame? */ - IEEE80211_UNLOCK(ic); + IEEE80211_FF_UNLOCK(ic); return m; } /* @@ -801,15 +800,13 @@ ieee80211_ff_check(struct ieee80211_node */ if (mstaged == NULL && ieee80211_txampdu_getpps(tap) < ieee80211_ffppsmin) { - IEEE80211_UNLOCK(ic); + IEEE80211_FF_UNLOCK(ic); return m; } sq = &sg->ff_stageq[pri]; /* * Check the txop limit to insure the aggregate fits. */ - limit = IEEE80211_TXOP_TO_US( - ic->ic_wme.wme_chanParams.cap_wmeParams[pri].wmep_txopLimit); if (limit != 0 && (txtime = ff_approx_txtime(ni, m, mstaged)) > limit) { /* @@ -824,7 +821,7 @@ ieee80211_ff_check(struct ieee80211_node ni->ni_tx_superg[WME_AC_TO_TID(pri)] = NULL; if (mstaged != NULL) stageq_remove(ic, sq, mstaged); - IEEE80211_UNLOCK(ic); + IEEE80211_FF_UNLOCK(ic); if (mstaged != NULL) { IEEE80211_TX_LOCK(ic); @@ -846,7 +843,7 @@ ieee80211_ff_check(struct ieee80211_node if (mstaged != NULL) { ni->ni_tx_superg[WME_AC_TO_TID(pri)] = NULL; stageq_remove(ic, sq, mstaged); - IEEE80211_UNLOCK(ic); + IEEE80211_FF_UNLOCK(ic); IEEE80211_NOTE(vap, IEEE80211_MSG_SUPERG, ni, "%s: aggregate fast-frame", __func__); @@ -862,13 +859,13 @@ ieee80211_ff_check(struct ieee80211_node mstaged->m_nextpkt = m; mstaged->m_flags |= M_FF; /* NB: mark for encap work */ } else { - KASSERT(ni->ni_tx_superg[WME_AC_TO_TID(pri)]== NULL, + KASSERT(ni->ni_tx_superg[WME_AC_TO_TID(pri)] == NULL, ("ni_tx_superg[]: %p", ni->ni_tx_superg[WME_AC_TO_TID(pri)])); ni->ni_tx_superg[WME_AC_TO_TID(pri)] = m; stageq_add(ic, sq, m); - IEEE80211_UNLOCK(ic); + IEEE80211_FF_UNLOCK(ic); IEEE80211_NOTE(vap, IEEE80211_MSG_SUPERG, ni, "%s: stage frame, %u queued", __func__, sq->depth); @@ -926,7 +923,7 @@ ieee80211_ff_node_cleanup(struct ieee802 struct mbuf *m, *next_m, *head; int tid; - IEEE80211_LOCK(ic); + IEEE80211_FF_LOCK(ic); head = NULL; for (tid = 0; tid < WME_NUM_TID; tid++) { int ac = TID_TO_WME_AC(tid); @@ -945,7 +942,7 @@ ieee80211_ff_node_cleanup(struct ieee802 head = m; } } - IEEE80211_UNLOCK(ic); + IEEE80211_FF_UNLOCK(ic); /* * Free mbufs, taking care to not dereference the mbuf after Modified: head/sys/net80211/ieee80211_superg.h ============================================================================== --- head/sys/net80211/ieee80211_superg.h Wed Jun 29 16:45:01 2016 (r302282) +++ head/sys/net80211/ieee80211_superg.h Wed Jun 29 17:25:46 2016 (r302283) @@ -107,38 +107,32 @@ struct mbuf *ieee80211_ff_check(struct i void ieee80211_ff_age(struct ieee80211com *, struct ieee80211_stageq *, int quanta); -/* - * See ieee80211_ff_age() for a description of the locking - * expectation here. - */ static __inline void -ieee80211_ff_flush(struct ieee80211com *ic, int ac) +ieee80211_ff_age_all(struct ieee80211com *ic, int quanta) { struct ieee80211_superg *sg = ic->ic_superg; - if (sg != NULL && sg->ff_stageq[ac].depth) - ieee80211_ff_age(ic, &sg->ff_stageq[ac], 0x7fffffff); + if (sg != NULL) { + ieee80211_ff_age(ic, &sg->ff_stageq[WME_AC_VO], quanta); + ieee80211_ff_age(ic, &sg->ff_stageq[WME_AC_VI], quanta); + ieee80211_ff_age(ic, &sg->ff_stageq[WME_AC_BE], quanta); + ieee80211_ff_age(ic, &sg->ff_stageq[WME_AC_BK], quanta); + } } -/* - * See ieee80211_ff_age() for a description of the locking - * expectation here. - */ static __inline void -ieee80211_ff_age_all(struct ieee80211com *ic, int quanta) +ieee80211_ff_flush(struct ieee80211com *ic, int ac) { struct ieee80211_superg *sg = ic->ic_superg; - if (sg != NULL) { - if (sg->ff_stageq[WME_AC_VO].depth) - ieee80211_ff_age(ic, &sg->ff_stageq[WME_AC_VO], quanta); - if (sg->ff_stageq[WME_AC_VI].depth) - ieee80211_ff_age(ic, &sg->ff_stageq[WME_AC_VI], quanta); - if (sg->ff_stageq[WME_AC_BE].depth) - ieee80211_ff_age(ic, &sg->ff_stageq[WME_AC_BE], quanta); - if (sg->ff_stageq[WME_AC_BK].depth) - ieee80211_ff_age(ic, &sg->ff_stageq[WME_AC_BK], quanta); - } + if (sg != NULL) + ieee80211_ff_age(ic, &sg->ff_stageq[ac], 0x7fffffff); +} + +static __inline void +ieee80211_ff_flush_all(struct ieee80211com *ic) +{ + ieee80211_ff_age_all(ic, 0x7fffffff); } struct mbuf *ieee80211_ff_encap(struct ieee80211vap *, struct mbuf *, Modified: head/sys/net80211/ieee80211_var.h ============================================================================== --- head/sys/net80211/ieee80211_var.h Wed Jun 29 16:45:01 2016 (r302282) +++ head/sys/net80211/ieee80211_var.h Wed Jun 29 17:25:46 2016 (r302283) @@ -121,6 +121,7 @@ struct ieee80211com { const char *ic_name; /* usually device name */ ieee80211_com_lock_t ic_comlock; /* state update lock */ ieee80211_tx_lock_t ic_txlock; /* ic/vap TX lock */ + ieee80211_ff_lock_t ic_fflock; /* stageq/ni_tx_superg lock */ LIST_ENTRY(ieee80211com) ic_next; /* on global list */ TAILQ_HEAD(, ieee80211vap) ic_vaps; /* list of vap instances */ int ic_headroom; /* driver tx headroom needs */ From owner-svn-src-head@freebsd.org Wed Jun 29 17:36:29 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 01463B860B7; Wed, 29 Jun 2016 17:36:28 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id D58412DBD; Wed, 29 Jun 2016 17:36:28 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from mail.xzibition.com (localhost [IPv6:::1]) by freefall.freebsd.org (Postfix) with ESMTP id CA73D1A0C; Wed, 29 Jun 2016 17:36:28 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from mail.xzibition.com (localhost [172.31.3.2]) by mail.xzibition.com (Postfix) with ESMTP id 7DB3621DBC; Wed, 29 Jun 2016 17:36:28 +0000 (UTC) X-Virus-Scanned: amavisd-new at mail.xzibition.com Received: from mail.xzibition.com ([172.31.3.2]) by mail.xzibition.com (mail.xzibition.com [172.31.3.2]) (amavisd-new, port 10026) with LMTP id q--zsv3nNlu4; Wed, 29 Jun 2016 17:36:21 +0000 (UTC) Subject: Re: svn commit: r302283 - head/sys/net80211 DKIM-Filter: OpenDKIM Filter v2.9.2 mail.xzibition.com 37E3A21DB0 To: Andriy Voskoboinyk , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201606291725.u5THPk0Y011747@repo.freebsd.org> From: Bryan Drewery Organization: FreeBSD Message-ID: Date: Wed, 29 Jun 2016 10:36:18 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: <201606291725.u5THPk0Y011747@repo.freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Wed, 29 Jun 2016 17:36:29 -0000 On 6/29/16 10:25 AM, Andriy Voskoboinyk wrote: > NOTE: Since this change breaks KBI, all wireless drivers need to be > recompiled. __FreeBSD_version should probably be bumped in sys/sys/param.h -- Regards, Bryan Drewery From owner-svn-src-head@freebsd.org Wed Jun 29 18:19:07 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 465C5B869C6; Wed, 29 Jun 2016 18:19:07 +0000 (UTC) (envelope-from sobomax@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 233B520D3; Wed, 29 Jun 2016 18:19:07 +0000 (UTC) (envelope-from sobomax@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5TIJ6XI030915; Wed, 29 Jun 2016 18:19:06 GMT (envelope-from sobomax@FreeBSD.org) Received: (from sobomax@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5TIJ69s030911; Wed, 29 Jun 2016 18:19:06 GMT (envelope-from sobomax@FreeBSD.org) Message-Id: <201606291819.u5TIJ69s030911@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sobomax set sender to sobomax@FreeBSD.org using -f From: Maxim Sobolev Date: Wed, 29 Jun 2016 18:19:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302284 - head/sys/geom/uzip X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Wed, 29 Jun 2016 18:19:07 -0000 Author: sobomax Date: Wed Jun 29 18:19:05 2016 New Revision: 302284 URL: https://svnweb.freebsd.org/changeset/base/302284 Log: 1.Improve handling around last compressed block of the file, which is necessary because CLOOP format lacks explicit EOF or length, so that in the presence of padding or when the CLOOP is put onto a larger partition upper level provider size may be larger. Bound amount of extra data that we might touch to the max length of the compressed block and detect zero-padding in the last cluster, which when sector is all-zero might cause us to emit bogus I/O error after decompression of that fails. To not make code any more complicated that it needs to be deal with it in lazy-manner, i.e. when we first access that specific cluster. This change also fixes stupid mistake in the LZMA code, inherited from geom_lzma, which does not share length of the output buffer buffer with the decompression routine, so that in the presence of corrupted or purposedly tailored data may easily cause heap overflow and kernel memory corruption. Beef up validation of the CLOOP TOC by checking that lengths of all but the last compressed clusters match upper limit set by the decompressor and improve some error diagnostic output while I am here. 2.Add kern.geom.uzip.attach_to tunable to artifically limit attaching uzip to certain devices in the dev tree only. For example the following only makes us attaching to the GPT labels: kern.geom.uzip.attach_to="gpt/*" 3.Add kern.geom.uzip.noattach_to, which does opposite to the (2) above, i.e. prevents geom_uzip from tasting / attaching to providers matching some pattern. By default we don't attach to our own kind, i.e. kern.geom.uzip.noattach_to="*.uzip". It saves us quite some CPU cycles, esp on low-end embedded systems. Approved by: re (gjb) Differential Revision: https://reviews.freebsd.org/D7013 Modified: head/sys/geom/uzip/g_uzip.c head/sys/geom/uzip/g_uzip_dapi.h head/sys/geom/uzip/g_uzip_lzma.c head/sys/geom/uzip/g_uzip_zlib.c Modified: head/sys/geom/uzip/g_uzip.c ============================================================================== --- head/sys/geom/uzip/g_uzip.c Wed Jun 29 17:25:46 2016 (r302283) +++ head/sys/geom/uzip/g_uzip.c Wed Jun 29 18:19:05 2016 (r302284) @@ -60,6 +60,8 @@ FEATURE(geom_uzip, "GEOM read-only compr struct g_uzip_blk { uint64_t offset; uint32_t blen; + unsigned char last:1; + unsigned char padded:1; #define BLEN_UNDEF UINT32_MAX }; @@ -84,6 +86,16 @@ struct g_uzip_blk { #define GUZ_DBG_IO 3 #define GUZ_DBG_TOC 4 +#define GUZ_DEV_SUFX ".uzip" +#define GUZ_DEV_NAME(p) (p GUZ_DEV_SUFX) + +static char g_uzip_attach_to[MAXPATHLEN] = {"*"}; +static char g_uzip_noattach_to[MAXPATHLEN] = {GUZ_DEV_NAME("*")}; +TUNABLE_STR("kern.geom.uzip.attach_to", g_uzip_attach_to, + sizeof(g_uzip_attach_to)); +TUNABLE_STR("kern.geom.uzip.noattach_to", g_uzip_noattach_to, + sizeof(g_uzip_noattach_to)); + SYSCTL_DECL(_kern_geom); SYSCTL_NODE(_kern_geom, OID_AUTO, uzip, CTLFLAG_RW, 0, "GEOM_UZIP stuff"); static u_int g_uzip_debug = GEOM_UZIP_DBG_DEFAULT; @@ -258,8 +270,9 @@ g_uzip_request(struct g_geom *gp, struct } DPRINTF_BRNG(GUZ_DBG_IO, start_blk, end_blk, ("%s/%s: %p: " - "start=%u (%ju), end=%u (%ju)\n", __func__, gp->name, bp, + "start=%u (%ju[%jd]), end=%u (%ju)\n", __func__, gp->name, bp, (u_int)start_blk, (uintmax_t)sc->toc[start_blk].offset, + (intmax_t)sc->toc[start_blk].blen, (u_int)end_blk, (uintmax_t)BLK_ENDS(sc, end_blk - 1))); bp2 = g_clone_bio(bp); @@ -272,16 +285,18 @@ g_uzip_request(struct g_geom *gp, struct bp2->bio_offset = TOFF_2_BOFF(sc, pp, start_blk); while (1) { bp2->bio_length = TLEN_2_BLEN(sc, pp, bp2, end_blk - 1); - if (bp2->bio_length <= MAXPHYS) + if (bp2->bio_length <= MAXPHYS) { break; + } if (end_blk == (start_blk + 1)) { break; } end_blk--; } - DPRINTF(GUZ_DBG_IO, ("%s/%s: bp2->bio_length = %jd\n", - __func__, gp->name, (intmax_t)bp2->bio_length)); + DPRINTF(GUZ_DBG_IO, ("%s/%s: bp2->bio_length = %jd, " + "bp2->bio_offset = %jd\n", __func__, gp->name, + (intmax_t)bp2->bio_length, (intmax_t)bp2->bio_offset)); bp2->bio_data = malloc(bp2->bio_length, M_GEOM_UZIP, M_NOWAIT); if (bp2->bio_data == NULL) { @@ -315,6 +330,15 @@ g_uzip_read_done(struct bio *bp) wakeup(sc); } +static int +g_uzip_memvcmp(const void *memory, unsigned char val, size_t size) +{ + const u_char *mm; + + mm = (const u_char *)memory; + return (*mm == val) && memcmp(mm, mm + 1, size - 1) == 0; +} + static void g_uzip_do(struct g_uzip_softc *sc, struct bio *bp) { @@ -362,18 +386,33 @@ g_uzip_do(struct g_uzip_softc *sc, struc bp->bio_completed, data2, (u_int)ulen, data, (u_int)len)); if (len == 0) { /* All zero block: no cache update */ +zero_block: bzero(data2, ulen); } else if (len <= bp->bio_completed) { mtx_lock(&sc->last_mtx); err = sc->dcp->decompress(sc->dcp, gp->name, data, len, sc->last_buf); + if (err != 0 && sc->toc[blk].last != 0) { + /* + * Last block decompression has failed, check + * if it's just zero padding. + */ + if (g_uzip_memvcmp(data, '\0', len) == 0) { + sc->toc[blk].blen = 0; + sc->last_blk = -1; + mtx_unlock(&sc->last_mtx); + len = 0; + goto zero_block; + } + } if (err != 0) { sc->last_blk = -1; mtx_unlock(&sc->last_mtx); bp2->bio_error = EILSEQ; DPRINTF(GUZ_DBG_ERR, ("%s/%s: decompress" - "(%p) failed\n", __func__, gp->name, - sc->dcp)); + "(%p, %ju, %ju) failed\n", __func__, + gp->name, sc->dcp, (uintmax_t)blk, + (uintmax_t)len)); goto done; } sc->last_blk = blk; @@ -471,6 +510,7 @@ g_uzip_spoiled(struct g_consumer *cp) { struct g_geom *gp; + G_VALID_CONSUMER(cp); gp = cp->geom; g_trace(G_T_TOPOLOGY, "%s(%p/%s)", __func__, cp, gp->name); g_topology_assert(); @@ -486,10 +526,12 @@ g_uzip_parse_toc(struct g_uzip_softc *sc { uint32_t i, j, backref_to; uint64_t max_offset, min_offset; + struct g_uzip_blk *last_blk; min_offset = sizeof(struct cloop_header) + (sc->nblocks + 1) * sizeof(uint64_t); max_offset = sc->toc[0].offset - 1; + last_blk = &sc->toc[0]; for (i = 0; i < sc->nblocks; i++) { /* First do some bounds checking */ if ((sc->toc[i].offset < min_offset) || @@ -497,7 +539,7 @@ g_uzip_parse_toc(struct g_uzip_softc *sc goto error_offset; } DPRINTF_BLK(GUZ_DBG_IO, i, ("%s: cluster #%u " - "sc->toc[i].offset=%ju max_offset=%ju\n", gp->name, + "offset=%ju max_offset=%ju\n", gp->name, (u_int)i, (uintmax_t)sc->toc[i].offset, (uintmax_t)max_offset)); backref_to = BLEN_UNDEF; @@ -523,6 +565,7 @@ g_uzip_parse_toc(struct g_uzip_softc *sc sc->toc[i].blen = sc->toc[j].blen; backref_to = j; } else { + last_blk = &sc->toc[i]; /* * For the "normal blocks" seek forward until we hit * block whose offset is larger than ours and assume @@ -557,6 +600,25 @@ g_uzip_parse_toc(struct g_uzip_softc *sc } DPRINTF_BLK(GUZ_DBG_TOC, i, ("\n")); } + last_blk->last = 1; + /* Do a second pass to validate block lengths */ + for (i = 0; i < sc->nblocks; i++) { + if (sc->toc[i].blen > sc->dcp->max_blen) { + if (sc->toc[i].last == 0) { + DPRINTF(GUZ_DBG_ERR, ("%s: cluster #%u " + "length (%ju) exceeds " + "max_blen (%ju)\n", gp->name, i, + (uintmax_t)sc->toc[i].blen, + (uintmax_t)sc->dcp->max_blen)); + return (-1); + } + DPRINTF(GUZ_DBG_INFO, ("%s: cluster #%u extra " + "padding is detected, trimmed to %ju\n", + gp->name, i, (uintmax_t)sc->dcp->max_blen)); + sc->toc[i].blen = sc->dcp->max_blen; + sc->toc[i].padded = 1; + } + } return (0); error_offset: @@ -589,12 +651,19 @@ g_uzip_taste(struct g_class *mp, struct if (pp->acw > 0) return (NULL); + if ((fnmatch(g_uzip_attach_to, pp->name, 0) != 0) || + (fnmatch(g_uzip_noattach_to, pp->name, 0) == 0)) { + DPRINTF(GUZ_DBG_INFO, ("%s(%s,%s), ignoring\n", __func__, + mp->name, pp->name)); + return (NULL); + } + buf = NULL; /* * Create geom instance. */ - gp = g_new_geomf(mp, "%s.uzip", pp->name); + gp = g_new_geomf(mp, GUZ_DEV_NAME("%s"), pp->name); cp = g_new_consumer(gp); error = g_attach(cp, pp); if (error == 0) @@ -712,6 +781,16 @@ g_uzip_taste(struct g_class *mp, struct sc->nblocks < offsets_read ? "more" : "less")); goto e5; } + + if (type == G_UZIP) { + sc->dcp = g_uzip_zlib_ctor(sc->blksz); + } else { + sc->dcp = g_uzip_lzma_ctor(sc->blksz); + } + if (sc->dcp == NULL) { + goto e5; + } + /* * "Fake" last+1 block, to make it easier for the TOC parser to * iterate without making the last element a special case. @@ -720,7 +799,7 @@ g_uzip_taste(struct g_class *mp, struct /* Massage TOC (table of contents), make sure it is sound */ if (g_uzip_parse_toc(sc, pp, gp) != 0) { DPRINTF(GUZ_DBG_ERR, ("%s: TOC error\n", gp->name)); - goto e5; + goto e6; } mtx_init(&sc->last_mtx, "geom_uzip cache", NULL, MTX_DEF); mtx_init(&sc->queue_mtx, "geom_uzip wrkthread", NULL, MTX_DEF); @@ -730,15 +809,6 @@ g_uzip_taste(struct g_class *mp, struct sc->req_total = 0; sc->req_cached = 0; - if (type == G_UZIP) { - sc->dcp = g_uzip_zlib_ctor(sc->blksz); - } else { - sc->dcp = g_uzip_lzma_ctor(sc->blksz); - } - if (sc->dcp == NULL) { - goto e6; - } - sc->uzip_do = &g_uzip_do; error = kproc_create(g_uzip_wrkthr, sc, &sc->procp, 0, 0, "%s", @@ -764,11 +834,11 @@ g_uzip_taste(struct g_class *mp, struct return (gp); e7: - sc->dcp->free(sc->dcp); -e6: free(sc->last_buf, M_GEOM); mtx_destroy(&sc->queue_mtx); mtx_destroy(&sc->last_mtx); +e6: + sc->dcp->free(sc->dcp); e5: free(sc->toc, M_GEOM); e4: Modified: head/sys/geom/uzip/g_uzip_dapi.h ============================================================================== --- head/sys/geom/uzip/g_uzip_dapi.h Wed Jun 29 17:25:46 2016 (r302283) +++ head/sys/geom/uzip/g_uzip_dapi.h Wed Jun 29 18:19:05 2016 (r302284) @@ -38,4 +38,5 @@ struct g_uzip_dapi { g_uzip_dapi_free_t free; g_uzip_dapi_rewind_t rewind; void *pvt; + int max_blen; }; Modified: head/sys/geom/uzip/g_uzip_lzma.c ============================================================================== --- head/sys/geom/uzip/g_uzip_lzma.c Wed Jun 29 17:25:46 2016 (r302283) +++ head/sys/geom/uzip/g_uzip_lzma.c Wed Jun 29 18:19:05 2016 (r302284) @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include @@ -41,6 +42,7 @@ __FBSDID("$FreeBSD$"); struct g_uzip_lzma { struct g_uzip_dapi pub; + uint32_t blksz; /* XZ decoder structs */ struct xz_buf b; struct xz_dec *s; @@ -75,13 +77,26 @@ g_uzip_lzma_decompress(struct g_uzip_dap lzp->b.out = obp; lzp->b.in_pos = lzp->b.out_pos = 0; lzp->b.in_size = ilen; - lzp->b.out_size = (size_t)-1; + lzp->b.out_size = lzp->blksz; err = (xz_dec_run(lzp->s, &lzp->b) != XZ_STREAM_END) ? 1 : 0; /* TODO decoder recovery, if needed */ + if (err != 0) { + printf("%s: ibp=%p, obp=%p, in_pos=%jd, out_pos=%jd, " + "in_size=%jd, out_size=%jd\n", __func__, ibp, obp, + (intmax_t)lzp->b.in_pos, (intmax_t)lzp->b.out_pos, + (intmax_t)lzp->b.in_size, (intmax_t)lzp->b.out_size); + } return (err); } +static int +LZ4_compressBound(int isize) +{ + + return (isize + (isize / 255) + 16); +} + struct g_uzip_dapi * g_uzip_lzma_ctor(uint32_t blksz) { @@ -93,6 +108,8 @@ g_uzip_lzma_ctor(uint32_t blksz) if (lzp->s == NULL) { goto e1; } + lzp->blksz = blksz; + lzp->pub.max_blen = LZ4_compressBound(blksz); lzp->pub.decompress = &g_uzip_lzma_decompress; lzp->pub.free = &g_uzip_lzma_free; lzp->pub.rewind = &g_uzip_lzma_nop; Modified: head/sys/geom/uzip/g_uzip_zlib.c ============================================================================== --- head/sys/geom/uzip/g_uzip_zlib.c Wed Jun 29 17:25:46 2016 (r302283) +++ head/sys/geom/uzip/g_uzip_zlib.c Wed Jun 29 18:19:05 2016 (r302284) @@ -97,6 +97,13 @@ g_uzip_zlib_rewind(struct g_uzip_dapi *z return (err); } +static int +z_compressBound(int len) +{ + + return (len + (len >> 12) + (len >> 14) + 11); +} + struct g_uzip_dapi * g_uzip_zlib_ctor(uint32_t blksz) { @@ -109,6 +116,7 @@ g_uzip_zlib_ctor(uint32_t blksz) goto e1; } zp->blksz = blksz; + zp->pub.max_blen = z_compressBound(blksz); zp->pub.decompress = &g_uzip_zlib_decompress; zp->pub.free = &g_uzip_zlib_free; zp->pub.rewind = &g_uzip_zlib_rewind; From owner-svn-src-head@freebsd.org Wed Jun 29 19:47:45 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 604C6B85196; Wed, 29 Jun 2016 19:47:45 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail107.syd.optusnet.com.au (mail107.syd.optusnet.com.au [211.29.132.53]) by mx1.freebsd.org (Postfix) with ESMTP id C707D25D7; Wed, 29 Jun 2016 19:47:44 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from besplex.bde.org (c110-21-100-149.carlnfd1.nsw.optusnet.com.au [110.21.100.149]) by mail107.syd.optusnet.com.au (Postfix) with ESMTPS id F07FFD4563B; Thu, 30 Jun 2016 05:47:42 +1000 (AEST) Date: Thu, 30 Jun 2016 05:47:39 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Konstantin Belousov cc: Bruce Evans , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r302252 - head/sys/kern In-Reply-To: <20160629153233.GI38613@kib.kiev.ua> Message-ID: <20160630040123.F791@besplex.bde.org> References: <201606281643.u5SGhNsi061606@repo.freebsd.org> <20160629175917.O968@besplex.bde.org> <20160629145443.GG38613@kib.kiev.ua> <20160629153233.GI38613@kib.kiev.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=M8SwUHEs c=1 sm=1 tr=0 a=XDAe9YG+7EcdVXYrgT+/UQ==:117 a=XDAe9YG+7EcdVXYrgT+/UQ==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=g-2O5F1047fdS1yRY-EA:9 a=CjuIK1q_8ugA:10 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Wed, 29 Jun 2016 19:47:45 -0000 On Wed, 29 Jun 2016, Konstantin Belousov wrote: > On Wed, Jun 29, 2016 at 05:54:43PM +0300, Konstantin Belousov wrote: >> This is a reply to two mails in one, both for r302251 and r302252 threads. Reply to your second reply. >> On Wed, Jun 29, 2016 at 05:58:05PM +1000, Bruce Evans wrote: >>> On Tue, 28 Jun 2016, Konstantin Belousov wrote: >> ... >>> - the locking should be stronger than mutexes (or splclock()) to >>> minimise the delay between deciding to set the time and actually >>> setting it. >> ... >> This is separate issue. Might be a critical section around the code >> is the right approximation for reducing delays there. Spinlocks give a critical section automatically, but we might not want to put either around the whole clock_gettime() syscall and if we don't do that then neither works for reducing delays (preemption is especially likely when the critical region is left). >>>... >>>> timespecadd(&ts, &clock_adj); >>>> ts.tv_sec -= utc_offset(); >>> >>> Who knows what utc_offset() is locked by? Certainly not this new locking, >>> since it is set in another file but the new locking is only in this file. >>> It still seems to be most under Giant :-(. >> utc_offset() uses several variables, updates to each of the variable is >> atomic. There is no even an attempt to provide userspace with an interface >> which would makes updates to the components used by utc_offset() consistent. >> Thus I do not see a need in any locking there. After removing the foot-shooting tz_minuteswest variable from utc_offset(), all of the variables in it are ones set by adjkerntz sysctls. The settings are normally ordered by not running more than 1 instance of adjkerntz. When adjkerntz starts, this instance shouldn't have any contention with other initialization doing resettodr(). There is contention every 6 months if wall_cmos_clock when adjkerntz changes the offset for daylight savings time. The chances of this used to be tiny since resettodr() was almost never called, but now there is the periodic resettodr() in kern_ntptime.c. >>> ... >>> The change in the other part of the diff is related to this, and doesn't >>> seem quite right. utc_offset() uses the variables tz_minuteswest, >>> wall_cmos_clock and adjkerntz: >>> - tz_minuteswest is set with no locking in kern_settimeofday(), just >>> after the settime() call. This last had a chance of being correct >>> when the kernel was UP and not preemptible. But it is broken in >>> a more fundamental way back to at least FreeBSD-1: resettodr() is >>> called _before_ updating the timezone, so it uses an out-of-date >>> tz_minuteswest. >> First, the man page is not correct, saying that 'this information is >> kept outside the kernel'. We deprecate the timezone support in settimeofday(), but use wrong wording for this here. The info set by this sysctl is of course kept in the kernel, and I think the man page is trying to say that this info is never used outside of the kernel. The man page doesn't say enough about deprecation, or that we only use this info for foot-shooting in the kernel, only (?) in utc_offset(). utc_offset() does: return (tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0)); If !wall_cmos_clock, then the offset should be 0, so any setting of tz_minutewest using the timezone info breaks the offset and this breaks the rtc _not being on wall time. If wall_cmos_clock, then adjkerntz(8) normally maintains the offset in the adjkerntz variable, so again tz_minuteswest must be 0 to work and any setting of it to nonzero using the timezone info breaks the offset. >> Second, why does settime(), logicall, need the updated timezone ? >> I understand that resettodr() is called on successful update of >> the wall clock. But shouldn't the need to reset not-GMT RTC clock c The timezone updates just give foot-shooting, but we need an up to date adjkerntz variable initially and on every daylight saving change in the wall_cmos_clock case. This is the normal way to keep the rtc on wall time after every daylight saving changes -- adjkerntz() runs, and it should change the adjkerntz variable first and then call settimeofday() with a "null" change to get the side effect of calling resettodr() which does a large change of the rtc. It is impossible to make a really null change of the software clock using settimeofday(), but I don't know of any better API to do this. I think the locking that you just added is enough -- adjkerntz() just has to arrange a call to resettodr() strictly after it updates the variable, and that happens almost automatically. >>>> /* XXX: We should really set all registered RTCs */ >>>> - if ((error = CLOCK_SETTIME(clock_dev, &ts)) != 0) >>>> + error = CLOCK_SETTIME(clock_dev, &ts); >>>> + mtx_unlock(&resettodr_lock); >>>> + if (error != 0) >>>> printf("warning: clock_settime failed (%d), time-of-day clock " >>>> "not adjusted to system time\n", error); >>>> } >>> >>> The lock needs to cover all high-level accesses to the rtc and related >>> variables to avoid races, and a bit more to minimise delays. In particular, >>> inittodr() should be under this lock, and there is a problem with >>> "show rtc" in ddb. >> I do not think that inittodr() actually needs that locking. This code >> is executed at the initialization stage, or at the resume stage. Perhaps, but resume runs more often than every 6 months for the daylight savings time race, and it isn't clear if anything stops resettodr() running concurrently then. In my version, something like inittodr() runs 3 seconds after every exit from ddb. Stopping in ddb is a bit like a short suspend-resume -- it stops or breaks some timers, and inittodr() is a way to fix up the software real time using an unstopped timer. >*... >>>> +/* >>>> + * When PPS_SYNC is defined, hardpps() function is provided which can >>>> + * be legitimately called from interrupt filters. Due to this, use >>>> + * spinlock for ntptime state protection, otherwise sleepable mutex is >>>> + * adequate. >>>> + */ >>>> +#ifdef PPS_SYNC >>>> +#define NTPADJ_LOCK() mtx_lock_spin(&ntpadj_lock) >>>> +#define NTPADJ_UNLOCK() mtx_unlock_spin(&ntpadj_lock) >>>> +#else >>>> +#define NTPADJ_LOCK() mtx_lock(&ntpadj_lock) >>>> +#define NTPADJ_UNLOCK() mtx_unlock(&ntpadj_lock) >>>> +#endif >>>> +#define NTPADJ_ASSERT_LOCKED() mtx_assert(&ntpadj_lock, MA_OWNED) >>> >>> *ADJ* and *adj* are not good names, since much more than ntp_adj*() needs >>> to be locked. >> Do you have a suggestion for a better name ? Just a general name like ntp_lock for ntp or t_lock if the same lock is used for timecounters. I also prefer not to use macros except for development versions, and then name the lock as xxx_mtx, not xxx_lock. We depend on special properties of (spin) mutexes. >*... >>> Probably the locking should be shared with kern_tc.c. tc_windup() still >>> uses only fancy time-domaind/atomic-op locking. This mostly works, but >>> is quite broken by calling tc_windup() from places other than hardclock(). >>> The most problematic other place is from tc_setclock(). That is unlocked, >>> except accidentally by callers with only Giant locking, so it races with >>> the fast interrupt handler. >>> >>> tc_windup() doesn't need the fancy locking for efficiency -- it only needs >>> it to be consistent with binuptime() and friends. So it may as well use >>> the same lock as ntp. Its lock must be around the whole function to >>> protect it from tc_setclock(). Then the same lock works for >>> ntp_update_second() and pps. Any lock that is only acquired once per >>> second is not worth optimizing. Hopefully the same for ntp's other locks. >>> ntp syscalls should only be frequent under unusual/malicious loads, so >>> they shouldn't cause much contention with the tc_windup() lock. >> So I postponed looking at tc_windup(), and it seems that it was >> useful. After you note above, it is mostly clear that we can skip some >> tc_windup() calls which conflicts with currently active windup calls. >> E.g., the hardclock update, which is done simultaneously with the >> setclock(), could be just skipped. But we must not skip the tc_windup() >> call from setclock(). Several things could be deferred, but I think that would just be more complicated. >> As an additional, but probably excessive measure, invocation of >> tc_windup() from hardclock could ask the setclock() to re-execute >> tc_windup() after its call is done. I don't quite understand this. hardclock -> tc_windup() normally doesn't have interference from tc_setclock(). >> ... >> Patch does the following: >> - change the ntpadj_lock to spinlock. >> - acquire the ntpadj_lock around ntp_update_second(). >> - prevent parallel tc_windup() invocations, while not allowing to >> skip calls coming from kernel top half. tc_setclock() needs locking even more than tc_windup(). >> - move resettodr_lock acquisition in resettodr() later. > > I now think that the lock around tc_windup() should have more flavor of > real spinlocks. Ideally the spinlock_enter() should be taken around it, > but it might be too extreme. Just a critical section in tc_setclock() > is good enough. No, it must have a full lock since it does read-write-modify on critical variables. > ... > diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c > index 0f015b3..a5776d2 100644 > --- a/sys/kern/kern_tc.c > +++ b/sys/kern/kern_tc.c > ... > @@ -1237,6 +1238,7 @@ tc_setclock(struct timespec *ts) > struct timespec tbef, taft; > struct bintime bt, bt2; > > + critical_enter(); > cpu_tick_calibrate(1); > nanotime(&tbef); > timespec2bintime(ts, &bt); > @@ -1247,8 +1249,10 @@ tc_setclock(struct timespec *ts) > bintime2timeval(&bt, &boottime); boottime is one of the critical variables. Before this, there are 2 accesses to boottimebin. The Giant locking that you just removed gave only some protection here. It prevented concurrent acccess by malicious/stress-testing code doing settime(). It didn't prevent nanotime() and friends seeing boottime in an in-between state. Oops, mutex locking won't fix that either. I think the update of these variables needs to be moved into tc_windup() where it will hopefully automatically be protected by the generation count, like the timehands offsets already are. bootime is also accessed with no locking in the kern.boottime sysctl. There is also ffclock_boottime. I don't like the duplication for ffclock, but it doesn't have much duplication for initializing ffsclock_boottime. > > /* XXX fiddle all the little crinkly bits around the fiords... */ > - tc_windup(); > + tc_windup(true); > nanotime(&taft); > + cpu_tick_calibrate(1); The 2 calls to cpu_tick_calibrate() in this function are excessive. These calls are just a hack to recalibrate after suspend/resume as a side effect of calling here. The first call suffices, since cpu ticks have nothing to do with any time variable that is set here. > + critical_exit(); > if (timestepwarnings) { > log(LOG_INFO, > "Time stepped from %jd.%09ld to %jd.%09ld (%jd.%09ld)\n", > @@ -1256,7 +1260,23 @@ tc_setclock(struct timespec *ts) > (intmax_t)taft.tv_sec, taft.tv_nsec, > (intmax_t)ts->tv_sec, ts->tv_nsec); > } > - cpu_tick_calibrate(1); > +} > + > +static volatile int tc_windup_lock; > +static void > +tc_windup(bool top_call) > +{ > + > + for (;;) { > + if (atomic_cmpset_int(&tc_windup_lock, 0, 1)) { > + atomic_thread_fence_acq(); > + tc_windup_locked(); > + atomic_store_rel_int(&tc_windup_lock, 0); > + break; > + } else if (!top_call) { > + break; > + } > + } > } I like to write optimized locking like that, but don't see why you want it here. Also, how does WITNESS work for almost any new lock that we don't add to the witness list? WITNESS of course doesn't work for special locking like this. MTX_NOWITNESS gives mutexes that are almost as efficient as the above, but with with no witnessing of course. I prefer to witness almost everything so that it can be debugged. Bruce From owner-svn-src-head@freebsd.org Wed Jun 29 21:20:08 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 69E0AB86951; Wed, 29 Jun 2016 21:20:08 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DE147269B; Wed, 29 Jun 2016 21:20:07 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u5TLJr9l054159 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Thu, 30 Jun 2016 00:19:54 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u5TLJr9l054159 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id u5TLJrUw054158; Thu, 30 Jun 2016 00:19:53 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 30 Jun 2016 00:19:53 +0300 From: Konstantin Belousov To: Bruce Evans Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r302252 - head/sys/kern Message-ID: <20160629211953.GK38613@kib.kiev.ua> References: <201606281643.u5SGhNsi061606@repo.freebsd.org> <20160629175917.O968@besplex.bde.org> <20160629145443.GG38613@kib.kiev.ua> <20160629153233.GI38613@kib.kiev.ua> <20160630040123.F791@besplex.bde.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160630040123.F791@besplex.bde.org> User-Agent: Mutt/1.6.1 (2016-04-27) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Wed, 29 Jun 2016 21:20:08 -0000 On Thu, Jun 30, 2016 at 05:47:39AM +1000, Bruce Evans wrote: > On Wed, 29 Jun 2016, Konstantin Belousov wrote: > > > On Wed, Jun 29, 2016 at 05:54:43PM +0300, Konstantin Belousov wrote: > >> This is a reply to two mails in one, both for r302251 and r302252 threads. > > After removing the foot-shooting tz_minuteswest variable from utc_offset(), > all of the variables in it are ones set by adjkerntz sysctls. The settings > are normally ordered by not running more than 1 instance of adjkerntz. > When adjkerntz starts, this instance shouldn't have any contention with > other initialization doing resettodr(). There is contention every 6 > months if wall_cmos_clock when adjkerntz changes the offset for daylight > savings time. The chances of this used to be tiny since resettodr() was > almost never called, but now there is the periodic resettodr() in > kern_ntptime.c. I do not see how your text above changes anything I said about consistency. Each sysctl sets or fetches integer variable, so individually it is atomic. Inter-dependencies between wall_cmos_clock and adjkerntz settings are completely up to user, no locking can change it while keeping separate sysctls to set and fetch each var individually. The only side-effects in resettodr() are possible in CLOCK_SETTIME(), which is protected against parallel invocation by resettodr_lock. > > > >>> ... > >>> The change in the other part of the diff is related to this, and doesn't > >>> seem quite right. utc_offset() uses the variables tz_minuteswest, > >>> wall_cmos_clock and adjkerntz: > >>> - tz_minuteswest is set with no locking in kern_settimeofday(), just > >>> after the settime() call. This last had a chance of being correct > >>> when the kernel was UP and not preemptible. But it is broken in > >>> a more fundamental way back to at least FreeBSD-1: resettodr() is > >>> called _before_ updating the timezone, so it uses an out-of-date > >>> tz_minuteswest. > >> First, the man page is not correct, saying that 'this information is > >> kept outside the kernel'. > > We deprecate the timezone support in settimeofday(), but use wrong wording > for this here. The info set by this sysctl is of course kept in the kernel, > and I think the man page is trying to say that this info is never used > outside of the kernel. How the later statement could be true, since that information is returned by gettimeofday(), and we do not control what programs a user might run on his machine. > > The man page doesn't say enough about deprecation, or that we only use this > info for foot-shooting in the kernel, only (?) in utc_offset(). utc_offset() > does: > > return (tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0)); > > If !wall_cmos_clock, then the offset should be 0, so any setting of > tz_minutewest using the timezone info breaks the offset and this breaks > the rtc _not being on wall time. > > If wall_cmos_clock, then adjkerntz(8) normally maintains the offset in > the adjkerntz variable, so again tz_minuteswest must be 0 to work and > any setting of it to nonzero using the timezone info breaks the offset. > > >> Second, why does settime(), logicall, need the updated timezone ? > >> I understand that resettodr() is called on successful update of > >> the wall clock. But shouldn't the need to reset not-GMT RTC clock > c > > The timezone updates just give foot-shooting, but we need an up to > date adjkerntz variable initially and on every daylight saving change > in the wall_cmos_clock case. This is the normal way to keep the rtc > on wall time after every daylight saving changes -- adjkerntz() runs, > and it should change the adjkerntz variable first and then call > settimeofday() with a "null" change to get the side effect of calling > resettodr() which does a large change of the rtc. It is impossible > to make a really null change of the software clock using settimeofday(), > but I don't know of any better API to do this. I think the locking that > you just added is enough -- adjkerntz() just has to arrange a call to > resettodr() strictly after it updates the variable, and that happens > almost automatically. I think that the way it is done is just by doing sysctl machdep.adjkerntz, which calls resettodr(). Old wisdom to re-sync RTC to kernel-maintained time was to run the sysctl from cron, but Andrey added the callout several years ago. > >> I do not think that inittodr() actually needs that locking. This code > >> is executed at the initialization stage, or at the resume stage. > > Perhaps, but resume runs more often than every 6 months for the daylight > savings time race, and it isn't clear if anything stops resettodr() running > concurrently then. > > In my version, something like inittodr() runs 3 seconds after every exit > from ddb. Stopping in ddb is a bit like a short suspend-resume -- it > stops or breaks some timers, and inittodr() is a way to fix up the > software real time using an unstopped timer. Lets postpone this. Might be, a resettodr_lock can be applied to inittodr() as a whole, and additionally merged with some other lock. BUt I think inittodr() is not very important right now. > >>> *ADJ* and *adj* are not good names, since much more than ntp_adj*() needs > >>> to be locked. > >> Do you have a suggestion for a better name ? > > Just a general name like ntp_lock for ntp or t_lock if the same lock is > used for timecounters. I also prefer not to use macros except for > development versions, and then name the lock as xxx_mtx, not xxx_lock. > We depend on special properties of (spin) mutexes. I want to keep this macroized. Yes, it is at development stage right now. > >> So I postponed looking at tc_windup(), and it seems that it was > >> useful. After you note above, it is mostly clear that we can skip some > >> tc_windup() calls which conflicts with currently active windup calls. > >> E.g., the hardclock update, which is done simultaneously with the > >> setclock(), could be just skipped. But we must not skip the tc_windup() > >> call from setclock(). > > Several things could be deferred, but I think that would just be more > complicated. > > >> As an additional, but probably excessive measure, invocation of > >> tc_windup() from hardclock could ask the setclock() to re-execute > >> tc_windup() after its call is done. > > I don't quite understand this. hardclock -> tc_windup() normally doesn't > have interference from tc_setclock(). In what sense it does not have interference ? tc_windup() may be executed from hardclock/hardclock_cnt (low half) and concurrently from setclock() (top half). And this is exactly what we want to avoid, isn't it ? > tc_setclock() needs locking even more than tc_windup(). ... > > I now think that the lock around tc_windup() should have more flavor of > > real spinlocks. Ideally the spinlock_enter() should be taken around it, > > but it might be too extreme. Just a critical section in tc_setclock() > > is good enough. > > No, it must have a full lock since it does read-write-modify on critical > variables. I talked only about tc_windup(). Parallel invocations of tc_setclock() should be guarded, indeed. I added a private mutex for it. > > > ... > > diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c > > index 0f015b3..a5776d2 100644 > > --- a/sys/kern/kern_tc.c > > +++ b/sys/kern/kern_tc.c > > ... > > @@ -1237,6 +1238,7 @@ tc_setclock(struct timespec *ts) > > struct timespec tbef, taft; > > struct bintime bt, bt2; > > > > + critical_enter(); > > cpu_tick_calibrate(1); > > nanotime(&tbef); > > timespec2bintime(ts, &bt); > > @@ -1247,8 +1249,10 @@ tc_setclock(struct timespec *ts) > > bintime2timeval(&bt, &boottime); > > boottime is one of the critical variables. Before this, there are 2 > accesses to boottimebin. The Giant locking that you just removed gave > only some protection here. It prevented concurrent acccess by > malicious/stress-testing code doing settime(). It didn't prevent > nanotime() and friends seeing boottime in an in-between state. Oops, > mutex locking won't fix that either. I think the update of these > variables needs to be moved into tc_windup() where it will hopefully > automatically be protected by the generation count, like the timehands > offsets already are. I do not understand how that would help. Do you mean to move the vars into current timehands ? > > bootime is also accessed with no locking in the kern.boottime sysctl. > > There is also ffclock_boottime. I don't like the duplication for > ffclock, but it doesn't have much duplication for initializing > ffsclock_boottime. > > > > > /* XXX fiddle all the little crinkly bits around the fiords... */ > > - tc_windup(); > > + tc_windup(true); > > nanotime(&taft); > > + cpu_tick_calibrate(1); > > The 2 calls to cpu_tick_calibrate() in this function are excessive. These > calls are just a hack to recalibrate after suspend/resume as a side effect > of calling here. The first call suffices, since cpu ticks have nothing to > do with any time variable that is set here. Ok. > > +static volatile int tc_windup_lock; > > +static void > > +tc_windup(bool top_call) > > +{ > > + > > + for (;;) { > > + if (atomic_cmpset_int(&tc_windup_lock, 0, 1)) { > > + atomic_thread_fence_acq(); > > + tc_windup_locked(); > > + atomic_store_rel_int(&tc_windup_lock, 0); > > + break; > > + } else if (!top_call) { > > + break; > > + } > > + } > > } > > I like to write optimized locking like that, but don't see why you > want it here. Because I do not want the fast clock interrupt handler to wait on lock, which neccessary becomes spinlock. The ntp_lock is bad enough already. What I coded above is not real lock. In contention case it bails out, so there is no blocking. In particular, witness is not relevant to it. diff --git a/sys/kern/kern_ntptime.c b/sys/kern/kern_ntptime.c index d352ee7..efc3713 100644 --- a/sys/kern/kern_ntptime.c +++ b/sys/kern/kern_ntptime.c @@ -162,29 +162,12 @@ static l_fp time_adj; /* tick adjust (ns/s) */ static int64_t time_adjtime; /* correction from adjtime(2) (usec) */ -static struct mtx ntpadj_lock; -MTX_SYSINIT(ntpadj, &ntpadj_lock, "ntpadj", -#ifdef PPS_SYNC - MTX_SPIN -#else - MTX_DEF -#endif -); +static struct mtx ntp_lock; +MTX_SYSINIT(ntp, &ntp_lock, "ntp", MTX_SPIN); -/* - * When PPS_SYNC is defined, hardpps() function is provided which can - * be legitimately called from interrupt filters. Due to this, use - * spinlock for ntptime state protection, otherwise sleepable mutex is - * adequate. - */ -#ifdef PPS_SYNC -#define NTPADJ_LOCK() mtx_lock_spin(&ntpadj_lock) -#define NTPADJ_UNLOCK() mtx_unlock_spin(&ntpadj_lock) -#else -#define NTPADJ_LOCK() mtx_lock(&ntpadj_lock) -#define NTPADJ_UNLOCK() mtx_unlock(&ntpadj_lock) -#endif -#define NTPADJ_ASSERT_LOCKED() mtx_assert(&ntpadj_lock, MA_OWNED) +#define NTP_LOCK() mtx_lock_spin(&ntp_lock) +#define NTP_UNLOCK() mtx_unlock_spin(&ntp_lock) +#define NTP_ASSERT_LOCKED() mtx_assert(&ntp_lock, MA_OWNED) #ifdef PPS_SYNC /* @@ -271,7 +254,7 @@ ntp_gettime1(struct ntptimeval *ntvp) { struct timespec atv; /* nanosecond time */ - NTPADJ_ASSERT_LOCKED(); + NTP_ASSERT_LOCKED(); nanotime(&atv); ntvp->time.tv_sec = atv.tv_sec; @@ -302,9 +285,9 @@ sys_ntp_gettime(struct thread *td, struct ntp_gettime_args *uap) { struct ntptimeval ntv; - NTPADJ_LOCK(); + NTP_LOCK(); ntp_gettime1(&ntv); - NTPADJ_UNLOCK(); + NTP_UNLOCK(); td->td_retval[0] = ntv.time_state; return (copyout(&ntv, uap->ntvp, sizeof(ntv))); @@ -315,9 +298,9 @@ ntp_sysctl(SYSCTL_HANDLER_ARGS) { struct ntptimeval ntv; /* temporary structure */ - NTPADJ_LOCK(); + NTP_LOCK(); ntp_gettime1(&ntv); - NTPADJ_UNLOCK(); + NTP_UNLOCK(); return (sysctl_handle_opaque(oidp, &ntv, sizeof(ntv), req)); } @@ -382,7 +365,7 @@ sys_ntp_adjtime(struct thread *td, struct ntp_adjtime_args *uap) error = priv_check(td, PRIV_NTP_ADJTIME); if (error != 0) return (error); - NTPADJ_LOCK(); + NTP_LOCK(); if (modes & MOD_MAXERROR) time_maxerror = ntv.maxerror; if (modes & MOD_ESTERROR) @@ -484,7 +467,7 @@ sys_ntp_adjtime(struct thread *td, struct ntp_adjtime_args *uap) ntv.stbcnt = pps_stbcnt; #endif /* PPS_SYNC */ retval = ntp_is_time_error(time_status) ? TIME_ERROR : time_state; - NTPADJ_UNLOCK(); + NTP_UNLOCK(); error = copyout((caddr_t)&ntv, (caddr_t)uap->tp, sizeof(ntv)); if (error == 0) @@ -506,6 +489,8 @@ ntp_update_second(int64_t *adjustment, time_t *newsec) int tickrate; l_fp ftemp; /* 32/64-bit temporary */ + NTP_LOCK(); + /* * On rollover of the second both the nanosecond and microsecond * clocks are updated and the state machine cranked as @@ -627,6 +612,8 @@ ntp_update_second(int64_t *adjustment, time_t *newsec) else time_status &= ~STA_PPSSIGNAL; #endif /* PPS_SYNC */ + + NTP_UNLOCK(); } /* @@ -690,7 +677,7 @@ hardupdate(offset) long mtemp; l_fp ftemp; - NTPADJ_ASSERT_LOCKED(); + NTP_ASSERT_LOCKED(); /* * Select how the phase is to be controlled and from which @@ -772,7 +759,7 @@ hardpps(tsp, nsec) long u_sec, u_nsec, v_nsec; /* temps */ l_fp ftemp; - NTPADJ_LOCK(); + NTP_LOCK(); /* * The signal is first processed by a range gate and frequency @@ -956,7 +943,7 @@ hardpps(tsp, nsec) time_freq = pps_freq; out: - NTPADJ_UNLOCK(); + NTP_UNLOCK(); } #endif /* PPS_SYNC */ @@ -999,11 +986,11 @@ kern_adjtime(struct thread *td, struct timeval *delta, struct timeval *olddelta) return (error); ltw = (int64_t)delta->tv_sec * 1000000 + delta->tv_usec; } - NTPADJ_LOCK(); + NTP_LOCK(); ltr = time_adjtime; if (delta != NULL) time_adjtime = ltw; - NTPADJ_UNLOCK(); + NTP_UNLOCK(); if (olddelta != NULL) { atv.tv_sec = ltr / 1000000; atv.tv_usec = ltr % 1000000; diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index 0f015b3..7bb767c 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -135,7 +135,8 @@ SYSCTL_PROC(_kern_timecounter, OID_AUTO, alloweddeviation, static int tc_chosen; /* Non-zero if a specific tc was chosen via sysctl. */ -static void tc_windup(void); +static void tc_windup(bool top_call); +static void tc_windup_locked(void); static void cpu_tick_calibrate(int); void dtrace_getnanotime(struct timespec *tsp); @@ -1226,10 +1227,12 @@ tc_getfrequency(void) return (timehands->th_counter->tc_frequency); } +static struct mtx tc_setclock_mtx; +MTX_SYSINIT(tc_setclock_init, &tc_setclock_mtx, "tcsetc", MTX_DEF); + /* * Step our concept of UTC. This is done by modifying our estimate of * when we booted. - * XXX: not locked. */ void tc_setclock(struct timespec *ts) @@ -1237,6 +1240,8 @@ tc_setclock(struct timespec *ts) struct timespec tbef, taft; struct bintime bt, bt2; + mtx_lock(&tc_setclock_mtx); + critical_enter(); cpu_tick_calibrate(1); nanotime(&tbef); timespec2bintime(ts, &bt); @@ -1247,8 +1252,10 @@ tc_setclock(struct timespec *ts) bintime2timeval(&bt, &boottime); /* XXX fiddle all the little crinkly bits around the fiords... */ - tc_windup(); + tc_windup(true); nanotime(&taft); + critical_exit(); + mtx_unlock(&tc_setclock_mtx); if (timestepwarnings) { log(LOG_INFO, "Time stepped from %jd.%09ld to %jd.%09ld (%jd.%09ld)\n", @@ -1256,7 +1263,23 @@ tc_setclock(struct timespec *ts) (intmax_t)taft.tv_sec, taft.tv_nsec, (intmax_t)ts->tv_sec, ts->tv_nsec); } - cpu_tick_calibrate(1); +} + +static volatile int tc_windup_lock; +static void +tc_windup(bool top_call) +{ + + for (;;) { + if (atomic_cmpset_int(&tc_windup_lock, 0, 1)) { + atomic_thread_fence_acq(); + tc_windup_locked(); + atomic_store_rel_int(&tc_windup_lock, 0); + break; + } else if (!top_call) { + break; + } + } } /* @@ -1265,7 +1288,7 @@ tc_setclock(struct timespec *ts) * timecounter and/or do seconds processing in NTP. Slightly magic. */ static void -tc_windup(void) +tc_windup_locked(void) { struct bintime bt; struct timehands *th, *tho; @@ -1846,7 +1869,7 @@ tc_ticktock(int cnt) if (count < tc_tick) return; count = 0; - tc_windup(); + tc_windup(false); } static void __inline @@ -1921,7 +1944,7 @@ inittimecounter(void *dummy) /* warm up new timecounter (again) and get rolling. */ (void)timecounter->tc_get_timecount(timecounter); (void)timecounter->tc_get_timecount(timecounter); - tc_windup(); + tc_windup(true); } SYSINIT(timecounter, SI_SUB_CLOCKS, SI_ORDER_SECOND, inittimecounter, NULL); diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index 148da2b..82710f7 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -115,9 +115,7 @@ settime(struct thread *td, struct timeval *tv) struct timeval delta, tv1, tv2; static struct timeval maxtime, laststep; struct timespec ts; - int s; - s = splclock(); microtime(&tv1); delta = *tv; timevalsub(&delta, &tv1); @@ -147,10 +145,8 @@ settime(struct thread *td, struct timeval *tv) printf("Time adjustment clamped to -1 second\n"); } } else { - if (tv1.tv_sec == laststep.tv_sec) { - splx(s); + if (tv1.tv_sec == laststep.tv_sec) return (EPERM); - } if (delta.tv_sec > 1) { tv->tv_sec = tv1.tv_sec + 1; printf("Time adjustment clamped to +1 second\n"); @@ -161,10 +157,8 @@ settime(struct thread *td, struct timeval *tv) ts.tv_sec = tv->tv_sec; ts.tv_nsec = tv->tv_usec * 1000; - mtx_lock(&Giant); tc_setclock(&ts); resettodr(); - mtx_unlock(&Giant); return (0); } diff --git a/sys/kern/subr_rtc.c b/sys/kern/subr_rtc.c index dbad36d..4bac324 100644 --- a/sys/kern/subr_rtc.c +++ b/sys/kern/subr_rtc.c @@ -172,11 +172,11 @@ resettodr(void) if (disable_rtc_set || clock_dev == NULL) return; - mtx_lock(&resettodr_lock); getnanotime(&ts); timespecadd(&ts, &clock_adj); ts.tv_sec -= utc_offset(); /* XXX: We should really set all registered RTCs */ + mtx_lock(&resettodr_lock); error = CLOCK_SETTIME(clock_dev, &ts); mtx_unlock(&resettodr_lock); if (error != 0) From owner-svn-src-head@freebsd.org Wed Jun 29 22:39:23 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 59562B86F36; Wed, 29 Jun 2016 22:39:23 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1E71F2BAD; Wed, 29 Jun 2016 22:39:23 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5TMdM9t027674; Wed, 29 Jun 2016 22:39:22 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5TMdMom027673; Wed, 29 Jun 2016 22:39:22 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201606292239.u5TMdMom027673@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Wed, 29 Jun 2016 22:39:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302285 - head/sys/modules/aic7xxx/ahd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Wed, 29 Jun 2016 22:39:23 -0000 Author: bdrewery Date: Wed Jun 29 22:39:22 2016 New Revision: 302285 URL: https://svnweb.freebsd.org/changeset/base/302285 Log: WITH_META_MODE: Avoid false-positive error due to missing .meta with build commands. Sponsored by: EMC / Isilon Storage Division Approved by: re (blanket, META_MODE) Modified: head/sys/modules/aic7xxx/ahd/Makefile Modified: head/sys/modules/aic7xxx/ahd/Makefile ============================================================================== --- head/sys/modules/aic7xxx/ahd/Makefile Wed Jun 29 18:19:05 2016 (r302284) +++ head/sys/modules/aic7xxx/ahd/Makefile Wed Jun 29 22:39:22 2016 (r302285) @@ -26,7 +26,7 @@ ${GENSRCS}: \ -i ${.CURDIR}/../../../dev/aic7xxx/aic79xx_osm.h \ ${.CURDIR}/../../../dev/aic7xxx/aic79xx.seq .else -${GENSRCS}: +${GENSRCS}: .NOMETA @echo "Error: ${.TARGET} is missing. Run 'make ahdfirmware'." .endif From owner-svn-src-head@freebsd.org Wed Jun 29 22:54:03 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2D15EB86453; Wed, 29 Jun 2016 22:54:03 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F1FC2241C; Wed, 29 Jun 2016 22:54:02 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5TMs2pt034865; Wed, 29 Jun 2016 22:54:02 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5TMs2Pg034864; Wed, 29 Jun 2016 22:54:02 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201606292254.u5TMs2Pg034864@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Wed, 29 Jun 2016 22:54:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302286 - head/contrib/bmake X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Wed, 29 Jun 2016 22:54:03 -0000 Author: bdrewery Date: Wed Jun 29 22:54:01 2016 New Revision: 302286 URL: https://svnweb.freebsd.org/changeset/base/302286 Log: Flush every line when using meta mode and no -j or with -B. Otherwise the output is buffered and it appears that make is stuck on something long-running. This problem is not present with -j as it uses different code that was already flushing. Discussed with: sjg Approved by: re (blanket, META_MODE) Sponsored by: EMC / Isilon Storage Division Modified: head/contrib/bmake/meta.c Modified: head/contrib/bmake/meta.c ============================================================================== --- head/contrib/bmake/meta.c Wed Jun 29 22:39:22 2016 (r302285) +++ head/contrib/bmake/meta.c Wed Jun 29 22:54:01 2016 (r302286) @@ -1547,6 +1547,7 @@ meta_compat_parent(void) while (fgets(buf, sizeof(buf), fp)) { meta_job_output(NULL, buf, ""); printf("%s", buf); + (void)fflush(stdout); } fclose(fp); } From owner-svn-src-head@freebsd.org Wed Jun 29 23:33:45 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6B28FB86D0C; Wed, 29 Jun 2016 23:33:45 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1BE9221F4; Wed, 29 Jun 2016 23:33:45 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5TNXiQQ049470; Wed, 29 Jun 2016 23:33:44 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5TNXiqF049469; Wed, 29 Jun 2016 23:33:44 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201606292333.u5TNXiqF049469@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Wed, 29 Jun 2016 23:33:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302287 - head/sys/mips/malta X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Wed, 29 Jun 2016 23:33:45 -0000 Author: gonzo Date: Wed Jun 29 23:33:44 2016 New Revision: 302287 URL: https://svnweb.freebsd.org/changeset/base/302287 Log: Fixed FreeBSD/mips MALTA support for QEMU Recource management functions in GT PCI controller driver treated memory/IO resources as KSEG1 addresses, later during activation these values would be increased by KSEG1 base again rendering the address invalid and causing "bus error" trap. Actual logic was converted to use real physical addresses, so mapping takes place only during activation. Submitted by: Aleksandr Rybalko Approved by: re (gjb) Modified: head/sys/mips/malta/gt_pci.c Modified: head/sys/mips/malta/gt_pci.c ============================================================================== --- head/sys/mips/malta/gt_pci.c Wed Jun 29 22:54:01 2016 (r302286) +++ head/sys/mips/malta/gt_pci.c Wed Jun 29 23:33:44 2016 (r302287) @@ -272,7 +272,7 @@ gt_pci_attach(device_t dev) sc->sc_st = mips_bus_space_generic; /* Use KSEG1 to access IO ports for it is uncached */ - sc->sc_io = MIPS_PHYS_TO_KSEG1(MALTA_PCI0_IO_BASE); + sc->sc_io = MALTA_PCI0_IO_BASE; sc->sc_io_rman.rm_type = RMAN_ARRAY; sc->sc_io_rman.rm_descr = "GT64120 PCI I/O Ports"; /* @@ -285,7 +285,7 @@ gt_pci_attach(device_t dev) } /* Use KSEG1 to access PCI memory for it is uncached */ - sc->sc_mem = MIPS_PHYS_TO_KSEG1(MALTA_PCIMEM1_BASE); + sc->sc_mem = MALTA_PCIMEM1_BASE; sc->sc_mem_rman.rm_type = RMAN_ARRAY; sc->sc_mem_rman.rm_descr = "GT64120 PCI Memory"; if (rman_init(&sc->sc_mem_rman) != 0 || @@ -310,9 +310,9 @@ gt_pci_attach(device_t dev) if (bus_space_map(sc->sc_st, IO_ICU2, 2, 0, &sc->sc_ioh_icu2) != 0) device_printf(dev, "unable to map ICU2 registers\n"); #else - sc->sc_ioh_elcr = sc->sc_io + 0x4d0; - sc->sc_ioh_icu1 = sc->sc_io + IO_ICU1; - sc->sc_ioh_icu2 = sc->sc_io + IO_ICU2; + sc->sc_ioh_elcr = MIPS_PHYS_TO_KSEG1(sc->sc_io + 0x4d0); + sc->sc_ioh_icu1 = MIPS_PHYS_TO_KSEG1(sc->sc_io + IO_ICU1); + sc->sc_ioh_icu2 = MIPS_PHYS_TO_KSEG1(sc->sc_io + IO_ICU2); #endif From owner-svn-src-head@freebsd.org Wed Jun 29 23:56:25 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B705EB8715D; Wed, 29 Jun 2016 23:56:25 +0000 (UTC) (envelope-from cperciva@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 79BCA2B92; Wed, 29 Jun 2016 23:56:25 +0000 (UTC) (envelope-from cperciva@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5TNuOl3057122; Wed, 29 Jun 2016 23:56:24 GMT (envelope-from cperciva@FreeBSD.org) Received: (from cperciva@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5TNuODh057121; Wed, 29 Jun 2016 23:56:24 GMT (envelope-from cperciva@FreeBSD.org) Message-Id: <201606292356.u5TNuODh057121@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cperciva set sender to cperciva@FreeBSD.org using -f From: Colin Percival Date: Wed, 29 Jun 2016 23:56:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302288 - head/release/tools X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Wed, 29 Jun 2016 23:56:25 -0000 Author: cperciva Date: Wed Jun 29 23:56:24 2016 New Revision: 302288 URL: https://svnweb.freebsd.org/changeset/base/302288 Log: Enable indirect segment I/Os by default in the Xen blkfront driver when running on EC2. Due to improvements in EC2, the performance penalty which was present on some EC2 instances no longer exists, and enabling this feature now consistently yields ~20% higher throughput with equal or lower latency. Reverts: r286063 Approved by: re (gjb) MFC after: 2 weeks Relnotes: Improved disk throughput on EC2 Modified: head/release/tools/ec2.conf Modified: head/release/tools/ec2.conf ============================================================================== --- head/release/tools/ec2.conf Wed Jun 29 23:33:44 2016 (r302287) +++ head/release/tools/ec2.conf Wed Jun 29 23:56:24 2016 (r302288) @@ -72,11 +72,6 @@ vm_extra_pre_umount() { # nodes, but apply the workaround just in case. echo 'hw.broken_txfifo="1"' >> ${DESTDIR}/boot/loader.conf - # Some EC2 instances suffer a significant (~40%) reduction in - # throughput when using blkif indirect segment I/Os. Disable this - # by default for now. - echo 'hw.xbd.xbd_enable_indirect="0"' >> ${DESTDIR}/boot/loader.conf - # Some EC2 instances run on a version of Xen which has a bug relating # to the migration of MSI-X interrupts; this is visible as SR-IOV # networking (aka. "EC2 Enhanced Networking") not being able to pass From owner-svn-src-head@freebsd.org Thu Jun 30 00:01:32 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8BA52B8745E; Thu, 30 Jun 2016 00:01:32 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id 6E9302E6B; Thu, 30 Jun 2016 00:01:32 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from mail.xzibition.com (localhost [IPv6:::1]) by freefall.freebsd.org (Postfix) with ESMTP id 67B1A1D0E; Thu, 30 Jun 2016 00:01:32 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from mail.xzibition.com (localhost [172.31.3.2]) by mail.xzibition.com (Postfix) with ESMTP id 1B09D233F2; Thu, 30 Jun 2016 00:01:32 +0000 (UTC) X-Virus-Scanned: amavisd-new at mail.xzibition.com Received: from mail.xzibition.com ([172.31.3.2]) by mail.xzibition.com (mail.xzibition.com [172.31.3.2]) (amavisd-new, port 10026) with LMTP id UGwrLVY-YFKU; Thu, 30 Jun 2016 00:01:29 +0000 (UTC) Subject: Re: svn commit: r302288 - head/release/tools DKIM-Filter: OpenDKIM Filter v2.9.2 mail.xzibition.com BB3F1233ED To: Colin Percival , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201606292356.u5TNuODh057121@repo.freebsd.org> From: Bryan Drewery Openpgp: id=F9173CB2C3AAEA7A5C8A1F0935D771BB6E4697CF; url=http://www.shatow.net/bryan/bryan2.asc Organization: FreeBSD Message-ID: <7a41dac2-87b8-c255-391d-fce3d57e835a@FreeBSD.org> Date: Wed, 29 Jun 2016 17:01:28 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: <201606292356.u5TNuODh057121@repo.freebsd.org> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="kFAJlTvqXbleNAlEF6hDkXpRO6RcgDN24" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Thu, 30 Jun 2016 00:01:32 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --kFAJlTvqXbleNAlEF6hDkXpRO6RcgDN24 Content-Type: multipart/mixed; boundary="tUvFVvcWuusfVLbU95PubWgdOKgVx7iNk" From: Bryan Drewery To: Colin Percival , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Message-ID: <7a41dac2-87b8-c255-391d-fce3d57e835a@FreeBSD.org> Subject: Re: svn commit: r302288 - head/release/tools References: <201606292356.u5TNuODh057121@repo.freebsd.org> In-Reply-To: <201606292356.u5TNuODh057121@repo.freebsd.org> --tUvFVvcWuusfVLbU95PubWgdOKgVx7iNk Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 6/29/2016 4:56 PM, Colin Percival wrote: > Author: cperciva > Date: Wed Jun 29 23:56:24 2016 > New Revision: 302288 > URL: https://svnweb.freebsd.org/changeset/base/302288 >=20 > Log: > Enable indirect segment I/Os by default in the Xen blkfront driver wh= en > running on EC2. Due to improvements in EC2, the performance penalty = which > was present on some EC2 instances no longer exists, and enabling this= > feature now consistently yields ~20% higher throughput with equal or = lower > latency. Does this rely on any driver updates / is it safe to make the same change on my existing 10.2 system? > =20 > Reverts: r286063 > Approved by: re (gjb) > MFC after: 2 weeks > Relnotes: Improved disk throughput on EC2 >=20 > Modified: > head/release/tools/ec2.conf >=20 > Modified: head/release/tools/ec2.conf > =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 > --- head/release/tools/ec2.conf Wed Jun 29 23:33:44 2016 (r302287) > +++ head/release/tools/ec2.conf Wed Jun 29 23:56:24 2016 (r302288) > @@ -72,11 +72,6 @@ vm_extra_pre_umount() { > # nodes, but apply the workaround just in case. > echo 'hw.broken_txfifo=3D"1"' >> ${DESTDIR}/boot/loader.conf > =20 > - # Some EC2 instances suffer a significant (~40%) reduction in > - # throughput when using blkif indirect segment I/Os. Disable this > - # by default for now. > - echo 'hw.xbd.xbd_enable_indirect=3D"0"' >> ${DESTDIR}/boot/loader.con= f > - > # Some EC2 instances run on a version of Xen which has a bug relating= > # to the migration of MSI-X interrupts; this is visible as SR-IOV > # networking (aka. "EC2 Enhanced Networking") not being able to pass >=20 --=20 Regards, Bryan Drewery --tUvFVvcWuusfVLbU95PubWgdOKgVx7iNk-- --kFAJlTvqXbleNAlEF6hDkXpRO6RcgDN24 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBAgAGBQJXdGFYAAoJEDXXcbtuRpfPhOQIANnWpgD14s0bbiapmsAXohGL Aw4ZpTz0SNKF4z7bBFdFDWFuUoFdqXDsmz8CLDQCFFqWL3Okph+49A52jWvKLC+B ovnGP9M+qook/a8J7QM75yrJUxOgK6Q1JmFaO5H8D7WYVKGnNvKTL10mzzsJ6unI Wu7en3JbEAhSnRygmDybSSneVlQorCntQg0JCLYM4blclX2bHASE0TvvQjBVksP7 FkAmN1/qWe+/wz98n7RR6rRgZQGMRTJ+0UsZrk2uW3CjscVIiAK0UygXcur9DKJC K0ADT8iVo28hY8QSoQ/3iXu/1bGP9G2TymFgqGrGSffV37bVOIQS8mkAjoc+19I= =oAHN -----END PGP SIGNATURE----- --kFAJlTvqXbleNAlEF6hDkXpRO6RcgDN24-- From owner-svn-src-head@freebsd.org Thu Jun 30 01:08:16 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 67E2AB85513 for ; Thu, 30 Jun 2016 01:08:16 +0000 (UTC) (envelope-from bounces+73574-9504-svn-src-head=freebsd.org@sendgrid.net) Received: from o1.l99.sendgrid.net (o1.l99.sendgrid.net [198.37.153.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5802028B5 for ; Thu, 30 Jun 2016 01:08:14 +0000 (UTC) (envelope-from bounces+73574-9504-svn-src-head=freebsd.org@sendgrid.net) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.info; h=subject:to:references:from:mime-version:in-reply-to:content-type:content-transfer-encoding; s=smtpapi; bh=te6roGlD8rlrivdNIUEW3nFkS3A=; b=fCWci/y7zX7tmsu2o9 E1PDJNmW/syL12USwrZ3NrB1cdvdCt+OTtpLe0NclwJzkKOnbEE85TjIkWIlbLiR O8rbQp9MdoDCq9RqKfXDiCUWLMWLzY0V6tfMpNnpxACidwXnUvrwcGWk8ugD2rse Ne2bMg/Wccitl2Ihonk3IatvY= Received: by filter0644p1mdw1.sendgrid.net with SMTP id filter0644p1mdw1.27991.577470FB34 2016-06-30 01:08:11.838746888 +0000 UTC Received: from mail.tarsnap.com (ec2-54-86-246-204.compute-1.amazonaws.com [54.86.246.204]) by ismtpd0006p1iad1.sendgrid.net (SG) with ESMTP id fNJPUUyLTbKv_xxeM_R34g for ; Thu, 30 Jun 2016 01:08:11.853 +0000 (UTC) Received: (qmail 13809 invoked from network); 30 Jun 2016 01:07:24 -0000 Received: from unknown (HELO clamshell.daemonology.net) (127.0.0.1) by ec2-107-20-205-189.compute-1.amazonaws.com with ESMTP; 30 Jun 2016 01:07:24 -0000 Received: (qmail 97416 invoked from network); 30 Jun 2016 01:08:11 -0000 Received: from unknown (HELO clamshell.daemonology.net) (127.0.0.1) by clamshell.daemonology.net with SMTP; 30 Jun 2016 01:08:11 -0000 Subject: Re: svn commit: r302288 - head/release/tools To: Bryan Drewery , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201606292356.u5TNuODh057121@repo.freebsd.org> <7a41dac2-87b8-c255-391d-fce3d57e835a@FreeBSD.org> From: Colin Percival Message-ID: Date: Wed, 29 Jun 2016 18:08:11 -0700 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: <7a41dac2-87b8-c255-391d-fce3d57e835a@FreeBSD.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SG-EID: EvYvoie/qnEezyq2t4eRKjDm9X7ZKbCMt75WvXA+XNGMLzjMINESrqn7pKJlngprgVJd4eA5PI8ZpS H0oLH2E4LvHA6cRl9gBimXRiOGE94+PFO+PS5g9NM9IDfaH4kpAUvebPVTtRoYWEIvY9K3srMpNNA9 G/NH7FpO4Wu6RAcjE+YiWTij6t+OCAAcIM0CLzqC5Xp2PMgwI85I0XY4OlB7Jre1FUIIWGcSENf9te U= X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Thu, 30 Jun 2016 01:08:16 -0000 On 06/29/16 17:01, Bryan Drewery wrote: > On 6/29/2016 4:56 PM, Colin Percival wrote: >> Author: cperciva >> Date: Wed Jun 29 23:56:24 2016 >> New Revision: 302288 >> URL: https://svnweb.freebsd.org/changeset/base/302288 >> >> Log: >> Enable indirect segment I/Os by default in the Xen blkfront driver when >> running on EC2. Due to improvements in EC2, the performance penalty which >> was present on some EC2 instances no longer exists, and enabling this >> feature now consistently yields ~20% higher throughput with equal or lower >> latency. > > Does this rely on any driver updates / is it safe to make the same > change on my existing 10.2 system? The relevant driver code is only in 10.3 and later. I'm not absolutely certain if already-running EC2 instances have the EC2 performance fix, either; you might need to launch a new instance in order to be guaranteed of the performance benefits. -- Colin Percival Security Officer Emeritus, FreeBSD | The power to serve Founder, Tarsnap | www.tarsnap.com | Online backups for the truly paranoid From owner-svn-src-head@freebsd.org Thu Jun 30 01:32:14 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 25C76B85EB3; Thu, 30 Jun 2016 01:32:14 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F1C1A29D3; Thu, 30 Jun 2016 01:32:13 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5U1WDkr093380; Thu, 30 Jun 2016 01:32:13 GMT (envelope-from bz@FreeBSD.org) Received: (from bz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5U1WCUa093377; Thu, 30 Jun 2016 01:32:12 GMT (envelope-from bz@FreeBSD.org) Message-Id: <201606300132.u5U1WCUa093377@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org using -f From: "Bjoern A. Zeeb" Date: Thu, 30 Jun 2016 01:32:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302289 - head/sys/contrib/ipfilter/netinet X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Thu, 30 Jun 2016 01:32:14 -0000 Author: bz Date: Thu Jun 30 01:32:12 2016 New Revision: 302289 URL: https://svnweb.freebsd.org/changeset/base/302289 Log: Remove unused global variables as well as unused memory allocations from ipfilter in preparation for VNET support. Suggested by: cy (see D7000) Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Approved by: re (gjb) Modified: head/sys/contrib/ipfilter/netinet/ip_fil.h head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c head/sys/contrib/ipfilter/netinet/ip_nat.c Modified: head/sys/contrib/ipfilter/netinet/ip_fil.h ============================================================================== --- head/sys/contrib/ipfilter/netinet/ip_fil.h Wed Jun 29 23:56:24 2016 (r302288) +++ head/sys/contrib/ipfilter/netinet/ip_fil.h Thu Jun 30 01:32:12 2016 (r302289) @@ -1710,7 +1710,6 @@ typedef struct ipf_main_softc_s { #ifndef _KERNEL extern int ipf_check __P((void *, struct ip *, int, void *, int, mb_t **)); -extern int (*ipf_checkp) __P((ip_t *, int, void *, int, mb_t **)); extern struct ifnet *get_unit __P((char *, int)); extern char *get_ifname __P((struct ifnet *)); extern int ipfioctl __P((ipf_main_softc_t *, int, ioctlcmd_t, Modified: head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c ============================================================================== --- head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c Wed Jun 29 23:56:24 2016 (r302288) +++ head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c Thu Jun 30 01:32:12 2016 (r302289) @@ -99,10 +99,8 @@ MALLOC_DEFINE(M_IPFILTER, "ipfilter", "I # endif -static int (*ipf_savep) __P((void *, ip_t *, int, void *, int, struct mbuf **)); static int ipf_send_ip __P((fr_info_t *, mb_t *)); static void ipf_timer_func __P((void *arg)); -int ipf_locks_done = 0; ipf_main_softc_t ipfmain; @@ -110,10 +108,6 @@ ipf_main_softc_t ipfmain; # if defined(NETBSD_PF) # include # endif /* NETBSD_PF */ -/* - * We provide the ipf_checkp name just to minimize changes later. - */ -int (*ipf_checkp) __P((void *, ip_t *ip, int hlen, void *ifp, int out, mb_t **mp)); static eventhandler_tag ipf_arrivetag, ipf_departtag, ipf_clonetag; @@ -221,11 +215,6 @@ ipfattach(softc) } - if (ipf_checkp != ipf_check) { - ipf_savep = ipf_checkp; - ipf_checkp = ipf_check; - } - bzero((char *)ipfmain.ipf_selwait, sizeof(ipfmain.ipf_selwait)); softc->ipf_running = 1; @@ -268,12 +257,6 @@ ipfdetach(softc) #endif callout_drain(&softc->ipf_slow_ch); -#ifndef NETBSD_PF - if (ipf_checkp != NULL) - ipf_checkp = ipf_savep; - ipf_savep = NULL; -#endif - ipf_fini_all(softc); softc->ipf_running = -2; Modified: head/sys/contrib/ipfilter/netinet/ip_nat.c ============================================================================== --- head/sys/contrib/ipfilter/netinet/ip_nat.c Wed Jun 29 23:56:24 2016 (r302288) +++ head/sys/contrib/ipfilter/netinet/ip_nat.c Thu Jun 30 01:32:12 2016 (r302289) @@ -133,8 +133,6 @@ static const char rcsid[] = "@(#)$FreeBS #define NBUMPSIDEDF(y,x)do { softn->ipf_nat_stats.ns_side[y].x++; \ DT1(x, fr_info_t *, fin); } while (0) -frentry_t ipfnatblock; - static ipftuneable_t ipf_nat_tuneables[] = { /* nat */ { { (void *)offsetof(ipf_nat_softc_t, ipf_nat_lock) }, @@ -275,9 +273,6 @@ static void ipf_nat_tabmove __P((ipf_nat int ipf_nat_main_load() { - bzero((char *)&ipfnatblock, sizeof(ipfnatblock)); - ipfnatblock.fr_flags = FR_BLOCK|FR_QUICK; - ipfnatblock.fr_ref = 1; return 0; } From owner-svn-src-head@freebsd.org Thu Jun 30 01:33:15 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 522F8B85F3F; Thu, 30 Jun 2016 01:33:15 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2FF4B2B88; Thu, 30 Jun 2016 01:33:15 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5U1XE2K094059; Thu, 30 Jun 2016 01:33:14 GMT (envelope-from bz@FreeBSD.org) Received: (from bz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5U1XErn094057; Thu, 30 Jun 2016 01:33:14 GMT (envelope-from bz@FreeBSD.org) Message-Id: <201606300133.u5U1XErn094057@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org using -f From: "Bjoern A. Zeeb" Date: Thu, 30 Jun 2016 01:33:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302290 - head/sys/netpfil/ipfw X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Thu, 30 Jun 2016 01:33:15 -0000 Author: bz Date: Thu Jun 30 01:33:14 2016 New Revision: 302290 URL: https://svnweb.freebsd.org/changeset/base/302290 Log: Move the ipfw_log_bpf() calls from global module initialisation to per-VNET initialisation and virtualise the interface cloning to allow a dedicated ipfw log interface per VNET. Approved by: re (gjb) MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Modified: head/sys/netpfil/ipfw/ip_fw2.c head/sys/netpfil/ipfw/ip_fw_log.c Modified: head/sys/netpfil/ipfw/ip_fw2.c ============================================================================== --- head/sys/netpfil/ipfw/ip_fw2.c Thu Jun 30 01:32:12 2016 (r302289) +++ head/sys/netpfil/ipfw/ip_fw2.c Thu Jun 30 01:33:14 2016 (r302290) @@ -2691,7 +2691,6 @@ ipfw_init(void) default_fw_tables = IPFW_TABLES_MAX; ipfw_init_sopt_handler(); - ipfw_log_bpf(1); /* init */ ipfw_iface_init(); return (error); } @@ -2704,7 +2703,6 @@ ipfw_destroy(void) { ipfw_iface_destroy(); - ipfw_log_bpf(0); /* uninit */ ipfw_destroy_sopt_handler(); printf("IP firewall unloaded\n"); } @@ -2793,6 +2791,7 @@ vnet_ipfw_init(const void *unused) * is checked on each packet because there are no pfil hooks. */ V_ip_fw_ctl_ptr = ipfw_ctl3; + ipfw_log_bpf(1); /* init */ error = ipfw_attach_hooks(1); return (error); } @@ -2816,6 +2815,8 @@ vnet_ipfw_uninit(const void *unused) (void)ipfw_attach_hooks(0 /* detach */); V_ip_fw_ctl_ptr = NULL; + ipfw_log_bpf(0); /* uninit */ + last = IS_DEFAULT_VNET(curvnet) ? 1 : 0; IPFW_UH_WLOCK(chain); Modified: head/sys/netpfil/ipfw/ip_fw_log.c ============================================================================== --- head/sys/netpfil/ipfw/ip_fw_log.c Thu Jun 30 01:32:12 2016 (r302289) +++ head/sys/netpfil/ipfw/ip_fw_log.c Thu Jun 30 01:33:14 2016 (r302290) @@ -102,7 +102,8 @@ ipfw_log_bpf(int onoff) { } #else /* !WITHOUT_BPF */ -static struct ifnet *log_if; /* hook to attach to bpf */ +static VNET_DEFINE(struct ifnet *, log_if); /* hook to attach to bpf */ +#define V_log_if VNET(log_if) static struct rwlock log_if_lock; #define LOGIF_LOCK_INIT(x) rw_init(&log_if_lock, "ipfw log_if lock") #define LOGIF_LOCK_DESTROY(x) rw_destroy(&log_if_lock) @@ -182,8 +183,8 @@ ipfw_log_clone_create(struct if_clone *i ifp->if_baudrate = IF_Mbps(10); LOGIF_WLOCK(); - if (log_if == NULL) - log_if = ifp; + if (V_log_if == NULL) + V_log_if = ifp; else { LOGIF_WUNLOCK(); if_free(ifp); @@ -206,8 +207,8 @@ ipfw_log_clone_destroy(struct if_clone * return (0); LOGIF_WLOCK(); - if (log_if != NULL && ifp == log_if) - log_if = NULL; + if (V_log_if != NULL && ifp == V_log_if) + V_log_if = NULL; else { LOGIF_WUNLOCK(); return (EINVAL); @@ -223,20 +224,23 @@ ipfw_log_clone_destroy(struct if_clone * return (0); } -static struct if_clone *ipfw_log_cloner; +static VNET_DEFINE(struct if_clone *, ipfw_log_cloner); +#define V_ipfw_log_cloner VNET(ipfw_log_cloner) void ipfw_log_bpf(int onoff) { if (onoff) { - LOGIF_LOCK_INIT(); - ipfw_log_cloner = if_clone_advanced(ipfwname, 0, + if (IS_DEFAULT_VNET(curvnet)) + LOGIF_LOCK_INIT(); + V_ipfw_log_cloner = if_clone_advanced(ipfwname, 0, ipfw_log_clone_match, ipfw_log_clone_create, ipfw_log_clone_destroy); } else { - if_clone_detach(ipfw_log_cloner); - LOGIF_LOCK_DESTROY(); + if_clone_detach(V_ipfw_log_cloner); + if (IS_DEFAULT_VNET(curvnet)) + LOGIF_LOCK_DESTROY(); } } #endif /* !WITHOUT_BPF */ @@ -258,24 +262,24 @@ ipfw_log(struct ip_fw_chain *chain, stru if (V_fw_verbose == 0) { #ifndef WITHOUT_BPF LOGIF_RLOCK(); - if (log_if == NULL || log_if->if_bpf == NULL) { + if (V_log_if == NULL || V_log_if->if_bpf == NULL) { LOGIF_RUNLOCK(); return; } if (args->eh) /* layer2, use orig hdr */ - BPF_MTAP2(log_if, args->eh, ETHER_HDR_LEN, m); + BPF_MTAP2(V_log_if, args->eh, ETHER_HDR_LEN, m); else { /* Add fake header. Later we will store * more info in the header. */ if (ip->ip_v == 4) - BPF_MTAP2(log_if, "DDDDDDSSSSSS\x08\x00", ETHER_HDR_LEN, m); + BPF_MTAP2(V_log_if, "DDDDDDSSSSSS\x08\x00", ETHER_HDR_LEN, m); else if (ip->ip_v == 6) - BPF_MTAP2(log_if, "DDDDDDSSSSSS\x86\xdd", ETHER_HDR_LEN, m); + BPF_MTAP2(V_log_if, "DDDDDDSSSSSS\x86\xdd", ETHER_HDR_LEN, m); else /* Obviously bogus EtherType. */ - BPF_MTAP2(log_if, "DDDDDDSSSSSS\xff\xff", ETHER_HDR_LEN, m); + BPF_MTAP2(V_log_if, "DDDDDDSSSSSS\xff\xff", ETHER_HDR_LEN, m); } LOGIF_RUNLOCK(); #endif /* !WITHOUT_BPF */ From owner-svn-src-head@freebsd.org Thu Jun 30 03:03:08 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 41E45B867C2; Thu, 30 Jun 2016 03:03:08 +0000 (UTC) (envelope-from cy.schubert@komquats.com) Received: from smtp-out-so.shaw.ca (smtp-out-so.shaw.ca [64.59.136.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id B132821C5; Thu, 30 Jun 2016 03:03:07 +0000 (UTC) (envelope-from cy.schubert@komquats.com) Received: from spqr.komquats.com ([96.50.22.10]) by shaw.ca with SMTP id ISFpbR3ldBLFmISFqbsbeu; Wed, 29 Jun 2016 21:03:05 -0600 X-Authority-Analysis: v=2.2 cv=W5d6blek c=1 sm=1 tr=0 a=jvE2nwUzI0ECrNeyr98KWA==:117 a=jvE2nwUzI0ECrNeyr98KWA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=pD_ry4oyNxEA:10 a=6I5d2MoRAAAA:8 a=YxBL1-UpAAAA:8 a=HQEh2bmjY8YPF31ghtgA:9 a=IjZwj45LgO3ly-622nXo:22 a=Ia-lj3WSrqcvXOmTRaiG:22 Received: from slippy.cwsent.com (slippy [10.1.1.91]) by spqr.komquats.com (Postfix) with ESMTPS id A1B4B13752; Wed, 29 Jun 2016 20:03:01 -0700 (PDT) Received: from slippy (localhost [127.0.0.1]) by slippy.cwsent.com (8.15.2/8.15.2) with ESMTP id u5U331J9003137; Wed, 29 Jun 2016 20:03:01 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Message-Id: <201606300303.u5U331J9003137@slippy.cwsent.com> X-Mailer: exmh version 2.8.0 04/21/2012 with nmh-1.6 Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.cschubert.com/ To: "Bjoern A. Zeeb" cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r302289 - head/sys/contrib/ipfilter/netinet In-Reply-To: Message from "Bjoern A. Zeeb" of "Thu, 30 Jun 2016 01:32:12 -0000." <201606300132.u5U1WCUa093377@repo.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Wed, 29 Jun 2016 20:03:01 -0700 X-CMAE-Envelope: MS4wfC55ZjDQ4p416sKVDKps0ICyW4clbr7rN0nviFT5FGxAziqbdBOuP/yz2e4T0rge+f8rZ8EQRCkuILMv+0s6z/hKDe6J0iql6qg1xxfb/dpaTjLH+Btg RMWMIECoyYCt/51RKpBI92UO1oRGtc5/9Pv72XeU8ooP1VIU0lhLg+2unwWZDIO++8qCdWC163cHD7mcF9kta/HmOE0JIpAjHnTOC2gCU2Te3KmEExHAD1Qk 3ilN9QCOPv85EiRTKwskHIpvuNMfndllOBgytX2gJOWOHeqaOSRBnxSwo1wxvZ2F X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Thu, 30 Jun 2016 03:03:08 -0000 In message <201606300132.u5U1WCUa093377@repo.freebsd.org>, "Bjoern A. Zeeb" wri tes: > Author: bz > Date: Thu Jun 30 01:32:12 2016 > New Revision: 302289 > URL: https://svnweb.freebsd.org/changeset/base/302289 > > Log: > Remove unused global variables as well as unused memory > allocations from ipfilter in preparation for VNET support. > > Suggested by: cy (see D7000) > Sponsored by: The FreeBSD Foundation > MFC after: 2 weeks > Approved by: re (gjb) > > Modified: > head/sys/contrib/ipfilter/netinet/ip_fil.h > head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c > head/sys/contrib/ipfilter/netinet/ip_nat.c > > Modified: head/sys/contrib/ipfilter/netinet/ip_fil.h > ============================================================================= > = > --- head/sys/contrib/ipfilter/netinet/ip_fil.h Wed Jun 29 23:56:24 201 > 6 (r302288) > +++ head/sys/contrib/ipfilter/netinet/ip_fil.h Thu Jun 30 01:32:12 201 > 6 (r302289) > @@ -1710,7 +1710,6 @@ typedef struct ipf_main_softc_s { > > #ifndef _KERNEL > extern int ipf_check __P((void *, struct ip *, int, void *, int, m > b_t **)); > -extern int (*ipf_checkp) __P((ip_t *, int, void *, int, mb_t **)); > extern struct ifnet *get_unit __P((char *, int)); > extern char *get_ifname __P((struct ifnet *)); > extern int ipfioctl __P((ipf_main_softc_t *, int, ioctlcmd_t, > > Modified: head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c > ============================================================================= > = > --- head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c Wed Jun 29 23:5 > 6:24 2016 (r302288) > +++ head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c Thu Jun 30 01:3 > 2:12 2016 (r302289) > @@ -99,10 +99,8 @@ MALLOC_DEFINE(M_IPFILTER, "ipfilter", "I > # endif > > > -static int (*ipf_savep) __P((void *, ip_t *, int, void *, int, str > uct mbuf **)); > static int ipf_send_ip __P((fr_info_t *, mb_t *)); > static void ipf_timer_func __P((void *arg)); > -int ipf_locks_done = 0; > > ipf_main_softc_t ipfmain; > > @@ -110,10 +108,6 @@ ipf_main_softc_t ipfmain; > # if defined(NETBSD_PF) > # include > # endif /* NETBSD_PF */ > -/* > - * We provide the ipf_checkp name just to minimize changes later. > - */ > -int (*ipf_checkp) __P((void *, ip_t *ip, int hlen, void *ifp, int out, mb_t > **mp)); > > > static eventhandler_tag ipf_arrivetag, ipf_departtag, ipf_clonetag; > @@ -221,11 +215,6 @@ ipfattach(softc) > } > > > - if (ipf_checkp != ipf_check) { > - ipf_savep = ipf_checkp; > - ipf_checkp = ipf_check; > - } > - > bzero((char *)ipfmain.ipf_selwait, sizeof(ipfmain.ipf_selwait)); > softc->ipf_running = 1; > > @@ -268,12 +257,6 @@ ipfdetach(softc) > #endif > callout_drain(&softc->ipf_slow_ch); > > -#ifndef NETBSD_PF > - if (ipf_checkp != NULL) > - ipf_checkp = ipf_savep; > - ipf_savep = NULL; > -#endif > - > ipf_fini_all(softc); > > softc->ipf_running = -2; > > Modified: head/sys/contrib/ipfilter/netinet/ip_nat.c > ============================================================================= > = > --- head/sys/contrib/ipfilter/netinet/ip_nat.c Wed Jun 29 23:56:24 201 > 6 (r302288) > +++ head/sys/contrib/ipfilter/netinet/ip_nat.c Thu Jun 30 01:32:12 201 > 6 (r302289) > @@ -133,8 +133,6 @@ static const char rcsid[] = "@(#)$FreeBS > #define NBUMPSIDEDF(y,x)do { softn->ipf_nat_stats.ns_side[y].x++; \ > DT1(x, fr_info_t *, fin); } while (0) > > -frentry_t ipfnatblock; > - > static ipftuneable_t ipf_nat_tuneables[] = { > /* nat */ > { { (void *)offsetof(ipf_nat_softc_t, ipf_nat_lock) }, > @@ -275,9 +273,6 @@ static void ipf_nat_tabmove __P((ipf_nat > int > ipf_nat_main_load() > { > - bzero((char *)&ipfnatblock, sizeof(ipfnatblock)); > - ipfnatblock.fr_flags = FR_BLOCK|FR_QUICK; > - ipfnatblock.fr_ref = 1; > > return 0; > } > > Thank you Bjoern. -- Cheers, Cy Schubert FreeBSD UNIX: Web: http://www.FreeBSD.org The need of the many outweighs the greed of the few. From owner-svn-src-head@freebsd.org Thu Jun 30 04:58:21 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 02379B863DA; Thu, 30 Jun 2016 04:58:20 +0000 (UTC) (envelope-from wma@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B909A20BA; Thu, 30 Jun 2016 04:58:20 +0000 (UTC) (envelope-from wma@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5U4wJw3068419; Thu, 30 Jun 2016 04:58:19 GMT (envelope-from wma@FreeBSD.org) Received: (from wma@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5U4wJS9068418; Thu, 30 Jun 2016 04:58:19 GMT (envelope-from wma@FreeBSD.org) Message-Id: <201606300458.u5U4wJS9068418@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: wma set sender to wma@FreeBSD.org using -f From: Wojciech Macek Date: Thu, 30 Jun 2016 04:58:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302291 - head/sys/arm64/include X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Thu, 30 Jun 2016 04:58:21 -0000 Author: wma Date: Thu Jun 30 04:58:19 2016 New Revision: 302291 URL: https://svnweb.freebsd.org/changeset/base/302291 Log: ARM64: fix DMAP calculation Use arithmetic operators instead of logical. This fixes DMAP ranges calculation for ThunderX Dual Socket. Obtained from: Semihalf Sponsored by: Cavium Reviewed by: zbb Differential Revision: https://reviews.freebsd.org/D7023 Approved by: re (gjb) Modified: head/sys/arm64/include/vmparam.h Modified: head/sys/arm64/include/vmparam.h ============================================================================== --- head/sys/arm64/include/vmparam.h Thu Jun 30 01:33:14 2016 (r302290) +++ head/sys/arm64/include/vmparam.h Thu Jun 30 04:58:19 2016 (r302291) @@ -181,7 +181,7 @@ KASSERT(PHYS_IN_DMAP(pa), \ ("%s: PA out of range, PA: 0x%lx", __func__, \ (vm_paddr_t)(pa))); \ - ((pa) - dmap_phys_base) | DMAP_MIN_ADDRESS; \ + ((pa) - dmap_phys_base) + DMAP_MIN_ADDRESS; \ }) #define DMAP_TO_PHYS(va) \ @@ -189,7 +189,7 @@ KASSERT(VIRT_IN_DMAP(va), \ ("%s: VA out of range, VA: 0x%lx", __func__, \ (vm_offset_t)(va))); \ - ((va) & ~DMAP_MIN_ADDRESS) + dmap_phys_base; \ + ((va) - DMAP_MIN_ADDRESS) + dmap_phys_base; \ }) #define VM_MIN_USER_ADDRESS (0x0000000000000000UL) From owner-svn-src-head@freebsd.org Thu Jun 30 05:18:38 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7BF62B8683B; Thu, 30 Jun 2016 05:18:38 +0000 (UTC) (envelope-from wma@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 22C4E2950; Thu, 30 Jun 2016 05:18:38 +0000 (UTC) (envelope-from wma@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5U5IbDN075642; Thu, 30 Jun 2016 05:18:37 GMT (envelope-from wma@FreeBSD.org) Received: (from wma@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5U5IbT5075641; Thu, 30 Jun 2016 05:18:37 GMT (envelope-from wma@FreeBSD.org) Message-Id: <201606300518.u5U5IbT5075641@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: wma set sender to wma@FreeBSD.org using -f From: Wojciech Macek Date: Thu, 30 Jun 2016 05:18:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302292 - head/sys/sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Thu, 30 Jun 2016 05:18:38 -0000 Author: wma Date: Thu Jun 30 05:18:37 2016 New Revision: 302292 URL: https://svnweb.freebsd.org/changeset/base/302292 Log: ARM, ARM64: Workaround for buf_ring reordering This patch offers a workaround to buf_ring reordering visible on armv7 and armv8. This is supposed to be removed once new buf_ring implementation is integrated into the tree. Obtained from: Semihalf Reviewed by: alc,emaste Differential Revision: https://reviews.freebsd.org/D6986 Approved by: re (gjb) Modified: head/sys/sys/buf_ring.h Modified: head/sys/sys/buf_ring.h ============================================================================== --- head/sys/sys/buf_ring.h Thu Jun 30 04:58:19 2016 (r302291) +++ head/sys/sys/buf_ring.h Thu Jun 30 05:18:37 2016 (r302292) @@ -161,9 +161,38 @@ buf_ring_dequeue_sc(struct buf_ring *br) #endif uint32_t prod_tail; void *buf; - + + /* + * This is a workaround to allow using buf_ring on ARM and ARM64. + * ARM64TODO: Fix buf_ring in a generic way. + * REMARKS: It is suspected that br_cons_head does not require + * load_acq operation, but this change was extensively tested + * and confirmed it's working. To be reviewed once again in + * FreeBSD-12. + * + * Preventing following situation: + + * Core(0) - buf_ring_enqueue() Core(1) - buf_ring_dequeue_sc() + * ----------------------------------------- ---------------------------------------------- + * + * cons_head = br->br_cons_head; + * atomic_cmpset_acq_32(&br->br_prod_head, ...)); + * buf = br->br_ring[cons_head]; > + * br->br_ring[prod_head] = buf; + * atomic_store_rel_32(&br->br_prod_tail, ...); + * prod_tail = br->br_prod_tail; + * if (cons_head == prod_tail) + * return (NULL); + * ` + * + * <1> Load (on core 1) from br->br_ring[cons_head] can be reordered (speculative readed) by CPU. + */ +#if defined(__arm__) || defined(__aarch64__) + cons_head = atomic_load_acq_32(&br->br_cons_head); +#else cons_head = br->br_cons_head; - prod_tail = br->br_prod_tail; +#endif + prod_tail = atomic_load_acq_32(&br->br_prod_tail); cons_next = (cons_head + 1) & br->br_cons_mask; #ifdef PREFETCH_DEFINED From owner-svn-src-head@freebsd.org Thu Jun 30 06:06:36 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 654F2B87529; Thu, 30 Jun 2016 06:06:36 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1E0682FC6; Thu, 30 Jun 2016 06:06:36 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5U66ZDt094403; Thu, 30 Jun 2016 06:06:35 GMT (envelope-from tuexen@FreeBSD.org) Received: (from tuexen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5U66ZUw094402; Thu, 30 Jun 2016 06:06:35 GMT (envelope-from tuexen@FreeBSD.org) Message-Id: <201606300606.u5U66ZUw094402@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tuexen set sender to tuexen@FreeBSD.org using -f From: Michael Tuexen Date: Thu, 30 Jun 2016 06:06:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302293 - head/sys/netinet X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Thu, 30 Jun 2016 06:06:36 -0000 Author: tuexen Date: Thu Jun 30 06:06:35 2016 New Revision: 302293 URL: https://svnweb.freebsd.org/changeset/base/302293 Log: This patch fixes two bugs related to the setting of the I-Bit for SCTP DATA and I-DATA chunks. * For fragmented user messages, set the I-Bit only on the last fragment. * When using explicit EOR mode, set the I-Bit on the last fragment, whenever SCTP_SACK_IMMEDIATELY was set in snd_flags for any of the send() calls. Approved by: re (hrs) MFC after: 1 week Modified: head/sys/netinet/sctp_output.c Modified: head/sys/netinet/sctp_output.c ============================================================================== --- head/sys/netinet/sctp_output.c Thu Jun 30 05:18:37 2016 (r302292) +++ head/sys/netinet/sctp_output.c Thu Jun 30 06:06:35 2016 (r302293) @@ -7325,10 +7325,12 @@ re_look: /* All of it fits in the MTU */ if (sp->some_taken) { rcv_flags |= SCTP_DATA_LAST_FRAG; - sp->put_last_out = 1; } else { rcv_flags |= SCTP_DATA_NOT_FRAG; - sp->put_last_out = 1; + } + sp->put_last_out = 1; + if (sp->sinfo_flags & SCTP_SACK_IMMEDIATELY) { + rcv_flags |= SCTP_DATA_SACK_IMMEDIATELY; } } else { /* Not all of it fits, we fragment */ @@ -7396,8 +7398,8 @@ re_look: if (sp->sinfo_flags & SCTP_UNORDERED) { rcv_flags |= SCTP_DATA_UNORDERED; } - if ((SCTP_BASE_SYSCTL(sctp_enable_sack_immediately) && ((sp->sinfo_flags & SCTP_EOF) == SCTP_EOF)) || - ((sp->sinfo_flags & SCTP_SACK_IMMEDIATELY) == SCTP_SACK_IMMEDIATELY)) { + if (SCTP_BASE_SYSCTL(sctp_enable_sack_immediately) && + (sp->sinfo_flags & SCTP_EOF) == SCTP_EOF) { rcv_flags |= SCTP_DATA_SACK_IMMEDIATELY; } /* clear out the chunk before setting up */ @@ -13280,7 +13282,9 @@ skip_preblock: sctp_snd_sb_alloc(stcb, sndout); atomic_add_int(&sp->length, sndout); len += sndout; - + if (srcv->sinfo_flags & SCTP_SACK_IMMEDIATELY) { + sp->sinfo_flags |= SCTP_SACK_IMMEDIATELY; + } /* Did we reach EOR? */ if ((uio->uio_resid == 0) && ((user_marks_eor == 0) || From owner-svn-src-head@freebsd.org Thu Jun 30 08:51:52 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9209DB87CA6; Thu, 30 Jun 2016 08:51:52 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 558CB2A58; Thu, 30 Jun 2016 08:51:52 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5U8ppiE055750; Thu, 30 Jun 2016 08:51:51 GMT (envelope-from mm@FreeBSD.org) Received: (from mm@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5U8ppCM055743; Thu, 30 Jun 2016 08:51:51 GMT (envelope-from mm@FreeBSD.org) Message-Id: <201606300851.u5U8ppCM055743@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mm set sender to mm@FreeBSD.org using -f From: Martin Matuska Date: Thu, 30 Jun 2016 08:51:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302294 - in head/contrib/libarchive: libarchive libarchive/test libarchive_fe X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Thu, 30 Jun 2016 08:51:52 -0000 Author: mm Date: Thu Jun 30 08:51:50 2016 New Revision: 302294 URL: https://svnweb.freebsd.org/changeset/base/302294 Log: MFV r302264: Sync libarchive with vendor, bugfixes for tests: - fix tests on filesystems without birthtime support, e.g. UFS1 (1) - vendor issue #729: avoid use of C99 for-scope declarations in test_write_format_gnutar_filenames.c MFC after: 1 week PR: 204157 (1) Approved by: re (hrs) Modified: head/contrib/libarchive/libarchive/archive_read_disk_posix.c head/contrib/libarchive/libarchive/archive_string.c head/contrib/libarchive/libarchive/archive_write_disk_posix.c head/contrib/libarchive/libarchive/test/main.c head/contrib/libarchive/libarchive/test/test_write_format_gnutar_filenames.c head/contrib/libarchive/libarchive_fe/passphrase.c Directory Properties: head/contrib/libarchive/ (props changed) head/contrib/libarchive/libarchive/ (props changed) head/contrib/libarchive/libarchive_fe/ (props changed) Modified: head/contrib/libarchive/libarchive/archive_read_disk_posix.c ============================================================================== --- head/contrib/libarchive/libarchive/archive_read_disk_posix.c Thu Jun 30 06:06:35 2016 (r302293) +++ head/contrib/libarchive/libarchive/archive_read_disk_posix.c Thu Jun 30 08:51:50 2016 (r302294) @@ -1504,7 +1504,11 @@ setup_current_filesystem(struct archive_ struct tree *t = a->tree; struct statfs sfs; #if defined(HAVE_GETVFSBYNAME) && defined(VFCF_SYNTHETIC) +# if defined(HAVE_STRUCT_VFSCONF) + struct vfsconf vfc; +# else struct xvfsconf vfc; +# endif #endif int r, xr = 0; #if !defined(HAVE_STRUCT_STATFS_F_NAMEMAX) Modified: head/contrib/libarchive/libarchive/archive_string.c ============================================================================== --- head/contrib/libarchive/libarchive/archive_string.c Thu Jun 30 06:06:35 2016 (r302293) +++ head/contrib/libarchive/libarchive/archive_string.c Thu Jun 30 08:51:50 2016 (r302294) @@ -559,7 +559,8 @@ archive_wstring_append_from_mbs_in_codep } if (count == 0 && length != 0) ret = -1; - } while (0); + break; + } while (1); } dest->length += count; dest->s[dest->length] = L'\0'; @@ -3552,18 +3553,19 @@ win_strncat_from_utf16(struct archive_st ll = WideCharToMultiByte(sc->to_cp, 0, (LPCWSTR)u16, (int)bytes>>1, mbs, (int)mbs_size, NULL, &defchar); - if (ll == 0 && - GetLastError() == ERROR_INSUFFICIENT_BUFFER) { - /* Need more buffer for MBS. */ - ll = WideCharToMultiByte(sc->to_cp, 0, - (LPCWSTR)u16, (int)bytes, NULL, 0, NULL, NULL); - if (archive_string_ensure(as, ll +1) == NULL) - return (-1); - mbs = as->s + as->length; - mbs_size = as->buffer_length - as->length -1; - continue; + /* Exit loop if we succeeded */ + if (ll != 0 || + GetLastError() != ERROR_INSUFFICIENT_BUFFER) { + break; } - } while (0); + /* Else expand buffer and loop to try again. */ + ll = WideCharToMultiByte(sc->to_cp, 0, + (LPCWSTR)u16, (int)bytes, NULL, 0, NULL, NULL); + if (archive_string_ensure(as, ll +1) == NULL) + return (-1); + mbs = as->s + as->length; + mbs_size = as->buffer_length - as->length -1; + } while (1); archive_string_free(&tmp); as->length += ll; as->s[as->length] = '\0'; @@ -3634,19 +3636,20 @@ win_strncat_to_utf16(struct archive_stri do { count = MultiByteToWideChar(sc->from_cp, MB_PRECOMPOSED, s, (int)length, (LPWSTR)u16, (int)avail>>1); - if (count == 0 && - GetLastError() == ERROR_INSUFFICIENT_BUFFER) { - /* Need more buffer for UTF-16 string */ - count = MultiByteToWideChar(sc->from_cp, - MB_PRECOMPOSED, s, (int)length, NULL, 0); - if (archive_string_ensure(as16, (count +1) * 2) - == NULL) - return (-1); - u16 = as16->s + as16->length; - avail = as16->buffer_length - 2; - continue; + /* Exit loop if we succeeded */ + if (count != 0 || + GetLastError() != ERROR_INSUFFICIENT_BUFFER) { + break; } - } while (0); + /* Expand buffer and try again */ + count = MultiByteToWideChar(sc->from_cp, + MB_PRECOMPOSED, s, (int)length, NULL, 0); + if (archive_string_ensure(as16, (count +1) * 2) + == NULL) + return (-1); + u16 = as16->s + as16->length; + avail = as16->buffer_length - 2; + } while (1); as16->length += count * 2; as16->s[as16->length] = 0; as16->s[as16->length+1] = 0; Modified: head/contrib/libarchive/libarchive/archive_write_disk_posix.c ============================================================================== --- head/contrib/libarchive/libarchive/archive_write_disk_posix.c Thu Jun 30 06:06:35 2016 (r302293) +++ head/contrib/libarchive/libarchive/archive_write_disk_posix.c Thu Jun 30 08:51:50 2016 (r302294) @@ -3487,6 +3487,9 @@ exit_xattr: static int copy_acls(struct archive_write_disk *a, int tmpfd, int dffd) { +#ifndef HAVE_SYS_ACL_H + return 0; +#else acl_t acl, dfacl = NULL; int acl_r, ret = ARCHIVE_OK; @@ -3514,6 +3517,7 @@ exit_acl: if (dfacl) acl_free(dfacl); return (ret); +#endif } static int Modified: head/contrib/libarchive/libarchive/test/main.c ============================================================================== --- head/contrib/libarchive/libarchive/test/main.c Thu Jun 30 06:06:35 2016 (r302293) +++ head/contrib/libarchive/libarchive/test/main.c Thu Jun 30 08:51:50 2016 (r302294) @@ -1292,6 +1292,11 @@ assertion_file_time(const char *file, in switch (type) { case 'a': filet_nsec = st.st_atimespec.tv_nsec; break; case 'b': filet = st.st_birthtime; + /* FreeBSD filesystems that don't support birthtime + * (e.g., UFS1) always return -1 here. */ + if (filet == -1) { + return (1); + } filet_nsec = st.st_birthtimespec.tv_nsec; break; case 'm': filet_nsec = st.st_mtimespec.tv_nsec; break; default: fprintf(stderr, "INTERNAL: Bad type %c for file time", type); Modified: head/contrib/libarchive/libarchive/test/test_write_format_gnutar_filenames.c ============================================================================== --- head/contrib/libarchive/libarchive/test/test_write_format_gnutar_filenames.c Thu Jun 30 06:06:35 2016 (r302293) +++ head/contrib/libarchive/libarchive/test/test_write_format_gnutar_filenames.c Thu Jun 30 08:51:50 2016 (r302294) @@ -42,6 +42,7 @@ DEFINE_TEST(test_write_format_gnutar_fil struct archive_entry *ae, *template; struct archive *a; size_t used; + int i; buff = malloc(buffsize); /* million bytes of work area */ assert(buff != NULL); @@ -55,7 +56,7 @@ DEFINE_TEST(test_write_format_gnutar_fil archive_entry_set_mode(template, S_IFREG | 0755); archive_entry_set_size(template, 8); - for (int i = 0; i < 2000; ++i) { + for (i = 0; i < 2000; ++i) { filename[i] = 'a'; filename[i + 1] = '\0'; archive_entry_copy_pathname(template, filename); @@ -97,6 +98,7 @@ DEFINE_TEST(test_write_format_gnutar_lin struct archive_entry *ae, *template; struct archive *a; size_t used; + int i; buff = malloc(buffsize); /* million bytes of work area */ assert(buff != NULL); @@ -110,7 +112,7 @@ DEFINE_TEST(test_write_format_gnutar_lin archive_entry_set_mode(template, S_IFLNK | 0755); archive_entry_copy_pathname(template, "link"); - for (int i = 0; i < 2000; ++i) { + for (i = 0; i < 2000; ++i) { filename[i] = 'a'; filename[i + 1] = '\0'; archive_entry_copy_symlink(template, filename); Modified: head/contrib/libarchive/libarchive_fe/passphrase.c ============================================================================== --- head/contrib/libarchive/libarchive_fe/passphrase.c Thu Jun 30 06:06:35 2016 (r302293) +++ head/contrib/libarchive/libarchive_fe/passphrase.c Thu Jun 30 08:51:50 2016 (r302294) @@ -132,6 +132,10 @@ readpassphrase(const char *prompt, char #include #include +#ifndef _PATH_TTY +#define _PATH_TTY "/dev/tty" +#endif + #ifdef TCSASOFT # define _T_FLUSH (TCSAFLUSH|TCSASOFT) #else From owner-svn-src-head@freebsd.org Thu Jun 30 14:53:47 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 82A7CB873EB; Thu, 30 Jun 2016 14:53:47 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5372B2004; Thu, 30 Jun 2016 14:53:47 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5UErk2x090521; Thu, 30 Jun 2016 14:53:46 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5UErkRj090520; Thu, 30 Jun 2016 14:53:46 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201606301453.u5UErkRj090520@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Thu, 30 Jun 2016 14:53:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302296 - head/contrib/ipfilter/tools X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Thu, 30 Jun 2016 14:53:47 -0000 Author: cy Date: Thu Jun 30 14:53:46 2016 New Revision: 302296 URL: https://svnweb.freebsd.org/changeset/base/302296 Log: Remove dead code. Approved by: re@ (hrs@) MFC after: 1 week Modified: head/contrib/ipfilter/tools/ipf.c Modified: head/contrib/ipfilter/tools/ipf.c ============================================================================== --- head/contrib/ipfilter/tools/ipf.c Thu Jun 30 12:44:15 2016 (r302295) +++ head/contrib/ipfilter/tools/ipf.c Thu Jun 30 14:53:46 2016 (r302296) @@ -410,23 +410,6 @@ static void flushfilter(arg, filter) return; } -#ifdef SIOCIPFFA - if (!strcmp(arg, "u")) { - closedevice(); - /* - * Flush auth rules and packets - */ - if (opendevice(IPL_AUTH, 1) == -1) - perror("open(IPL_AUTH)"); - else { - if (ioctl(fd, SIOCIPFFA, &fl) == -1) - ipferror(fd, "ioctl(SIOCIPFFA)"); - } - closedevice(); - return; - } -#endif - if (strchr(arg, 'i') || strchr(arg, 'I')) fl = FR_INQUE; if (strchr(arg, 'o') || strchr(arg, 'O')) From owner-svn-src-head@freebsd.org Thu Jun 30 14:55:50 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B23D9B874C4; Thu, 30 Jun 2016 14:55:50 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7AF2321A8; Thu, 30 Jun 2016 14:55:50 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5UEtnqk090651; Thu, 30 Jun 2016 14:55:49 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5UEtnLs090648; Thu, 30 Jun 2016 14:55:49 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201606301455.u5UEtnLs090648@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 30 Jun 2016 14:55:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302297 - in head/sys/cddl/contrib/opensolaris: common/acl uts/common/fs/zfs uts/common/sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Thu, 30 Jun 2016 14:55:50 -0000 Author: mav Date: Thu Jun 30 14:55:49 2016 New Revision: 302297 URL: https://svnweb.freebsd.org/changeset/base/302297 Log: Revert r299454 and r299448. Those changes were found confusing FreeBSD libc ACL code, that doesn't differentiate ACL for directories and files, and report ACLs for all directories created after those patches as non-trivial. On the other side these changes were considered wrong from POSIX and NFSv4 points of view. Until further investigation done upstream, revert those changes locally in preparation for FreeBSD 11.0 release. Approved by: re (hrs) Modified: head/sys/cddl/contrib/opensolaris/common/acl/acl_common.c head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c head/sys/cddl/contrib/opensolaris/uts/common/sys/acl.h Modified: head/sys/cddl/contrib/opensolaris/common/acl/acl_common.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/common/acl/acl_common.c Thu Jun 30 14:53:46 2016 (r302296) +++ head/sys/cddl/contrib/opensolaris/common/acl/acl_common.c Thu Jun 30 14:55:49 2016 (r302297) @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright 2014 Nexenta Systems, Inc. All rights reserved. + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. */ #include @@ -1580,8 +1580,7 @@ acl_trivial_access_masks(mode_t mode, bo uint32_t write_mask = ACE_WRITE_DATA|ACE_APPEND_DATA; uint32_t execute_mask = ACE_EXECUTE; - if (isdir) - write_mask |= ACE_DELETE_CHILD; + (void) isdir; /* will need this later */ masks->deny1 = 0; if (!(mode & S_IRUSR) && (mode & (S_IRGRP|S_IROTH))) @@ -1725,17 +1724,10 @@ ace_trivial_common(void *acep, int aclcn return (1); /* - * Delete permission is never set by default - */ - if (mask & ACE_DELETE) - return (1); - - /* - * Child delete permission should be accompanied by write + * Delete permissions are never set by default */ - if ((mask & ACE_DELETE_CHILD) && !(mask & ACE_WRITE_DATA)) + if (mask & (ACE_DELETE|ACE_DELETE_CHILD)) return (1); - /* * only allow owner@ to have * write_acl/write_owner/write_attributes/write_xattr/ Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c Thu Jun 30 14:53:46 2016 (r302296) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c Thu Jun 30 14:55:49 2016 (r302297) @@ -20,8 +20,8 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2013 by Delphix. All rights reserved. - * Copyright 2014 Nexenta Systems, Inc. All rights reserved. */ #include @@ -2085,7 +2085,7 @@ zfs_zaccess_dataset_check(znode_t *zp, u * placed into the working_mode, giving the caller a mask of denied * accesses. Returns: * 0 if all AoI granted - * EACCES if the denied mask is non-zero + * EACCESS if the denied mask is non-zero * other error if abnormal failure (e.g., IO error) * * A secondary usage of the function is to determine if any of the @@ -2532,32 +2532,46 @@ zfs_zaccess_unix(znode_t *zp, mode_t mod return (zfs_zaccess(zp, v4_mode, 0, B_FALSE, cr)); } -/* See zfs_zaccess_delete() */ -int zfs_write_implies_delete_child = 1; +static int +zfs_delete_final_check(znode_t *zp, znode_t *dzp, + mode_t available_perms, cred_t *cr) +{ + int error; + uid_t downer; + + downer = zfs_fuid_map_id(dzp->z_zfsvfs, dzp->z_uid, cr, ZFS_OWNER); + + error = secpolicy_vnode_access2(cr, ZTOV(dzp), + downer, available_perms, VWRITE|VEXEC); + + if (error == 0) + error = zfs_sticky_remove_access(dzp, zp, cr); + + return (error); +} /* - * Determine whether delete access should be granted. + * Determine whether Access should be granted/deny, without + * consulting least priv subsystem. * - * The following chart outlines how we handle delete permissions which is - * how recent versions of windows (Windows 2008) handles it. The efficiency - * comes from not having to check the parent ACL where the object itself grants - * delete: + * The following chart is the recommended NFSv4 enforcement for + * ability to delete an object. * * ------------------------------------------------------- - * | Parent Dir | Target Object Permissions | + * | Parent Dir | Target Object Permissions | * | permissions | | * ------------------------------------------------------- * | | ACL Allows | ACL Denies| Delete | * | | Delete | Delete | unspecified| * ------------------------------------------------------- - * | ACL Allows | Permit | Deny * | Permit | - * | DELETE_CHILD | | | | + * | ACL Allows | Permit | Permit | Permit | + * | DELETE_CHILD | | * ------------------------------------------------------- - * | ACL Denies | Permit | Deny | Deny | - * | DELETE_CHILD | | | | + * | ACL Denies | Permit | Deny | Deny | + * | DELETE_CHILD | | | | * ------------------------------------------------------- * | ACL specifies | | | | - * | only allow | Permit | Deny * | Permit | + * | only allow | Permit | Permit | Permit | * | write and | | | | * | execute | | | | * ------------------------------------------------------- @@ -2567,171 +2581,91 @@ int zfs_write_implies_delete_child = 1; * ------------------------------------------------------- * ^ * | - * Re. execute permission on the directory: if that's missing, - * the vnode lookup of the target will fail before we get here. - * - * Re [*] in the table above: NFSv4 would normally Permit delete for - * these two cells of the matrix. - * See acl.h for notes on which ACE_... flags should be checked for which - * operations. Specifically, the NFSv4 committee recommendation is in - * conflict with the Windows interpretation of DENY ACEs, where DENY ACEs - * should take precedence ahead of ALLOW ACEs. - * - * This implementation always consults the target object's ACL first. - * If a DENY ACE is present on the target object that specifies ACE_DELETE, - * delete access is denied. If an ALLOW ACE with ACE_DELETE is present on - * the target object, access is allowed. If and only if no entries with - * ACE_DELETE are present in the object's ACL, check the container's ACL - * for entries with ACE_DELETE_CHILD. - * - * A summary of the logic implemented from the table above is as follows: + * No search privilege, can't even look up file? * - * First check for DENY ACEs that apply. - * If either target or container has a deny, EACCES. - * - * Delete access can then be summarized as follows: - * 1: The object to be deleted grants ACE_DELETE, or - * 2: The containing directory grants ACE_DELETE_CHILD. - * In a Windows system, that would be the end of the story. - * In this system, (2) has some complications... - * 2a: "sticky" bit on a directory adds restrictions, and - * 2b: existing ACEs from previous versions of ZFS may - * not carry ACE_DELETE_CHILD where they should, so we - * also allow delete when ACE_WRITE_DATA is granted. - * - * Note: 2b is technically a work-around for a prior bug, - * which hopefully can go away some day. For those who - * no longer need the work around, and for testing, this - * work-around is made conditional via the tunable: - * zfs_write_implies_delete_child */ int zfs_zaccess_delete(znode_t *dzp, znode_t *zp, cred_t *cr) { - uint32_t wanted_dirperms; uint32_t dzp_working_mode = 0; uint32_t zp_working_mode = 0; int dzp_error, zp_error; - boolean_t dzpcheck_privs; - boolean_t zpcheck_privs; + mode_t available_perms; + boolean_t dzpcheck_privs = B_TRUE; + boolean_t zpcheck_privs = B_TRUE; + + /* + * We want specific DELETE permissions to + * take precedence over WRITE/EXECUTE. We don't + * want an ACL such as this to mess us up. + * user:joe:write_data:deny,user:joe:delete:allow + * + * However, deny permissions may ultimately be overridden + * by secpolicy_vnode_access(). + * + * We will ask for all of the necessary permissions and then + * look at the working modes from the directory and target object + * to determine what was found. + */ if (zp->z_pflags & (ZFS_IMMUTABLE | ZFS_NOUNLINK)) return (SET_ERROR(EPERM)); /* - * Case 1: - * If target object grants ACE_DELETE then we are done. This is - * indicated by a return value of 0. For this case we don't worry - * about the sticky bit because sticky only applies to the parent - * directory and this is the child access result. - * - * If we encounter a DENY ACE here, we're also done (EACCES). - * Note that if we hit a DENY ACE here (on the target) it should - * take precedence over a DENY ACE on the container, so that when - * we have more complete auditing support we will be able to - * report an access failure against the specific target. - * (This is part of why we're checking the target first.) - */ - zp_error = zfs_zaccess_common(zp, ACE_DELETE, &zp_working_mode, - &zpcheck_privs, B_FALSE, cr); - if (zp_error == EACCES) { - /* We hit a DENY ACE. */ - if (!zpcheck_privs) - return (SET_ERROR(zp_error)); - return (secpolicy_vnode_remove(ZTOV(dzp), cr)); /* XXXPJD: s/dzp/zp/ ? */ - - } - if (zp_error == 0) + * First row + * If the directory permissions allow the delete, we are done. + */ + if ((dzp_error = zfs_zaccess_common(dzp, ACE_DELETE_CHILD, + &dzp_working_mode, &dzpcheck_privs, B_FALSE, cr)) == 0) return (0); /* - * Case 2: - * If the containing directory grants ACE_DELETE_CHILD, - * or we're in backward compatibility mode and the - * containing directory has ACE_WRITE_DATA, allow. - * Case 2b is handled with wanted_dirperms. - */ - wanted_dirperms = ACE_DELETE_CHILD; - if (zfs_write_implies_delete_child) - wanted_dirperms |= ACE_WRITE_DATA; - dzp_error = zfs_zaccess_common(dzp, wanted_dirperms, - &dzp_working_mode, &dzpcheck_privs, B_FALSE, cr); - if (dzp_error == EACCES) { - /* We hit a DENY ACE. */ - if (!dzpcheck_privs) - return (SET_ERROR(dzp_error)); - return (secpolicy_vnode_remove(ZTOV(dzp), cr)); /* XXXPJD: s/dzp/zp/ ? */ - } + * If target object has delete permission then we are done + */ + if ((zp_error = zfs_zaccess_common(zp, ACE_DELETE, &zp_working_mode, + &zpcheck_privs, B_FALSE, cr)) == 0) + return (0); - /* - * Cases 2a, 2b (continued) - * - * Note: dzp_working_mode now contains any permissions - * that were NOT granted. Therefore, if any of the - * wanted_dirperms WERE granted, we will have: - * dzp_working_mode != wanted_dirperms - * We're really asking if ANY of those permissions - * were granted, and if so, grant delete access. - */ - if (dzp_working_mode != wanted_dirperms) - dzp_error = 0; + ASSERT(dzp_error && zp_error); + + if (!dzpcheck_privs) + return (dzp_error); + if (!zpcheck_privs) + return (zp_error); /* - * dzp_error is 0 if the container granted us permissions to "modify". - * If we do not have permission via one or more ACEs, our current - * privileges may still permit us to modify the container. + * Second row * - * dzpcheck_privs is false when i.e. the FS is read-only. - * Otherwise, do privilege checks for the container. + * If directory returns EACCES then delete_child was denied + * due to deny delete_child. In this case send the request through + * secpolicy_vnode_remove(). We don't use zfs_delete_final_check() + * since that *could* allow the delete based on write/execute permission + * and we want delete permissions to override write/execute. */ - if (dzp_error != 0 && dzpcheck_privs) { - uid_t owner; - /* - * The secpolicy call needs the requested access and - * the current access mode of the container, but it - * only knows about Unix-style modes (VEXEC, VWRITE), - * so this must condense the fine-grained ACE bits into - * Unix modes. - * - * The VEXEC flag is easy, because we know that has - * always been checked before we get here (during the - * lookup of the target vnode). The container has not - * granted us permissions to "modify", so we do not set - * the VWRITE flag in the current access mode. - */ - owner = zfs_fuid_map_id(dzp->z_zfsvfs, dzp->z_uid, cr, - ZFS_OWNER); - dzp_error = secpolicy_vnode_access2(cr, ZTOV(dzp), - owner, VEXEC, VWRITE|VEXEC); - } - if (dzp_error != 0) { - /* - * Note: We may have dzp_error = -1 here (from - * zfs_zacess_common). Don't return that. - */ - return (SET_ERROR(EACCES)); - } + if (dzp_error == EACCES) + return (secpolicy_vnode_remove(ZTOV(dzp), cr)); /* XXXPJD: s/dzp/zp/ ? */ /* - * At this point, we know that the directory permissions allow - * us to modify, but we still need to check for the additional - * restrictions that apply when the "sticky bit" is set. - * - * Yes, zfs_sticky_remove_access() also checks this bit, but - * checking it here and skipping the call below is nice when - * you're watching all of this with dtrace. + * Third Row + * only need to see if we have write/execute on directory. */ - if ((dzp->z_mode & S_ISVTX) == 0) - return (0); + + dzp_error = zfs_zaccess_common(dzp, ACE_EXECUTE|ACE_WRITE_DATA, + &dzp_working_mode, &dzpcheck_privs, B_FALSE, cr); + + if (dzp_error != 0 && !dzpcheck_privs) + return (dzp_error); /* - * zfs_sticky_remove_access will succeed if: - * 1. The sticky bit is absent. - * 2. We pass the sticky bit restrictions. - * 3. We have privileges that always allow file removal. + * Fourth row */ - return (zfs_sticky_remove_access(dzp, zp, cr)); + + available_perms = (dzp_working_mode & ACE_WRITE_DATA) ? 0 : VWRITE; + available_perms |= (dzp_working_mode & ACE_EXECUTE) ? 0 : VEXEC; + + return (zfs_delete_final_check(zp, dzp, available_perms, cr)); + } int Modified: head/sys/cddl/contrib/opensolaris/uts/common/sys/acl.h ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/sys/acl.h Thu Jun 30 14:53:46 2016 (r302296) +++ head/sys/cddl/contrib/opensolaris/uts/common/sys/acl.h Thu Jun 30 14:55:49 2016 (r302297) @@ -23,8 +23,6 @@ * * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. - * - * Copyright 2014 Nexenta Systems, Inc. All rights reserved. */ #ifndef _SYS_ACL_H @@ -90,55 +88,37 @@ typedef struct acl_info acl_t; /* * The following are defined for ace_t. - * - * Note, these are intentionally the same as the Windows - * "File Access Rights Constants" you can find on MSDN. - * (See also: "Standard Access Rights" on MSDN). - * - * The equivalent Windows names for these are just like - * those show below, with FILE_ in place of ACE_, except - * as noted below. Also note that Windows uses a special - * privilege: BYPASS_TRAVERSE_CHECKING, normally granted - * to everyone, that causes the absence of ACE_TRAVERSE - * to be ignored. - */ -#define ACE_READ_DATA 0x00000001 /* file: read data */ -#define ACE_LIST_DIRECTORY 0x00000001 /* dir: list files */ -#define ACE_WRITE_DATA 0x00000002 /* file: write data */ -#define ACE_ADD_FILE 0x00000002 /* dir: create file */ -#define ACE_APPEND_DATA 0x00000004 /* file: append data */ -#define ACE_ADD_SUBDIRECTORY 0x00000004 /* dir: create subdir */ -#define ACE_READ_NAMED_ATTRS 0x00000008 /* FILE_READ_EA */ -#define ACE_WRITE_NAMED_ATTRS 0x00000010 /* FILE_WRITE_EA */ -#define ACE_EXECUTE 0x00000020 /* file: execute */ -#define ACE_TRAVERSE 0x00000020 /* dir: lookup name */ -#define ACE_DELETE_CHILD 0x00000040 /* dir: unlink child */ -#define ACE_READ_ATTRIBUTES 0x00000080 /* (all) stat, etc. */ -#define ACE_WRITE_ATTRIBUTES 0x00000100 /* (all) utimes, etc. */ -#define ACE_DELETE 0x00010000 /* (all) unlink self */ -#define ACE_READ_ACL 0x00020000 /* (all) getsecattr */ -#define ACE_WRITE_ACL 0x00040000 /* (all) setsecattr */ -#define ACE_WRITE_OWNER 0x00080000 /* (all) chown */ -#define ACE_SYNCHRONIZE 0x00100000 /* (all) see MSDN */ - -/* - * Some of the following are the same as Windows uses. (but NOT ALL!) - * See the "ACE_HEADER" structure description on MSDN for details. - * Comments show relations to the MSDN names. */ -#define ACE_FILE_INHERIT_ACE 0x0001 /* = OBJECT_INHERIT_ACE */ -#define ACE_DIRECTORY_INHERIT_ACE 0x0002 /* = CONTAINER_INHERIT_ACE */ -#define ACE_NO_PROPAGATE_INHERIT_ACE 0x0004 /* = NO_PROPAGATE_INHERIT_ACE */ -#define ACE_INHERIT_ONLY_ACE 0x0008 /* = INHERIT_ONLY_ACE */ +#define ACE_READ_DATA 0x00000001 +#define ACE_LIST_DIRECTORY 0x00000001 +#define ACE_WRITE_DATA 0x00000002 +#define ACE_ADD_FILE 0x00000002 +#define ACE_APPEND_DATA 0x00000004 +#define ACE_ADD_SUBDIRECTORY 0x00000004 +#define ACE_READ_NAMED_ATTRS 0x00000008 +#define ACE_WRITE_NAMED_ATTRS 0x00000010 +#define ACE_EXECUTE 0x00000020 +#define ACE_DELETE_CHILD 0x00000040 +#define ACE_READ_ATTRIBUTES 0x00000080 +#define ACE_WRITE_ATTRIBUTES 0x00000100 +#define ACE_DELETE 0x00010000 +#define ACE_READ_ACL 0x00020000 +#define ACE_WRITE_ACL 0x00040000 +#define ACE_WRITE_OWNER 0x00080000 +#define ACE_SYNCHRONIZE 0x00100000 + +#define ACE_FILE_INHERIT_ACE 0x0001 +#define ACE_DIRECTORY_INHERIT_ACE 0x0002 +#define ACE_NO_PROPAGATE_INHERIT_ACE 0x0004 +#define ACE_INHERIT_ONLY_ACE 0x0008 #define ACE_SUCCESSFUL_ACCESS_ACE_FLAG 0x0010 #define ACE_FAILED_ACCESS_ACE_FLAG 0x0020 #define ACE_IDENTIFIER_GROUP 0x0040 -#define ACE_INHERITED_ACE 0x0080 /* INHERITED_ACE, 0x10 on NT */ +#define ACE_INHERITED_ACE 0x0080 #define ACE_OWNER 0x1000 #define ACE_GROUP 0x2000 #define ACE_EVERYONE 0x4000 -/* These four are the same as Windows, but with an ACE_ prefix added. */ #define ACE_ACCESS_ALLOWED_ACE_TYPE 0x0000 #define ACE_ACCESS_DENIED_ACE_TYPE 0x0001 #define ACE_SYSTEM_AUDIT_ACE_TYPE 0x0002 @@ -154,7 +134,6 @@ typedef struct acl_info acl_t; /* * These are only applicable in a CIFS context. - * Here again, same as Windows, but with an ACE_ prefix added. */ #define ACE_ACCESS_ALLOWED_COMPOUND_ACE_TYPE 0x04 #define ACE_ACCESS_ALLOWED_OBJECT_ACE_TYPE 0x05 From owner-svn-src-head@freebsd.org Thu Jun 30 15:01:09 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3D64CB87789; Thu, 30 Jun 2016 15:01:09 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 069A82674; Thu, 30 Jun 2016 15:01:08 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5UF1819091560; Thu, 30 Jun 2016 15:01:08 GMT (envelope-from bz@FreeBSD.org) Received: (from bz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5UF17WV091555; Thu, 30 Jun 2016 15:01:07 GMT (envelope-from bz@FreeBSD.org) Message-Id: <201606301501.u5UF17WV091555@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org using -f From: "Bjoern A. Zeeb" Date: Thu, 30 Jun 2016 15:01:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302298 - head/sys/contrib/ipfilter/netinet X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Thu, 30 Jun 2016 15:01:09 -0000 Author: bz Date: Thu Jun 30 15:01:07 2016 New Revision: 302298 URL: https://svnweb.freebsd.org/changeset/base/302298 Log: Virtualise ipfilter. Split initializzation an teardown into module (global state) and VNET (per virtual network stack) parts. Virtualise global state, which is not "const". Cleanup eventhandlers, so that we can make use of the passed in argument to get the vnet state from the ifp; disable the "cloner" event as it is too early, has no state, and can fire before initialisation (see comment in the source). Handle the dynamic sysctls specially. The problem is that "ipmain" is the virtualized struct, but the fields used for the sysctls are hanging off memory allocated and attached to the virtualized "ipmain" thus standard VNET macros and sysctl handling do not work. We still say it is VNET sysctls to get the proper protection checks in the VIMAGE case; to solve the problem of accessing the right bit of memory hanging of each per-VNET ipmain, we use a dedicated handler function wrapping around sysctl_ipf_int() undoing the base calculation from kern_sysctl.c and then adding the passed-in offset into the right struct depending on handler. A bit of a mess exposing VNET-internals this way but the only way to keep the code without having to massively restructure ipf internals. Approved by: re (hrs) Sponsored by: The FreeBSD Foundation Obtained from: projects/vnet MFC after: 2 weeks Reviewed by: cy Differential Revision: https://reviews.freebsd.org/D7000 Modified: head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c head/sys/contrib/ipfilter/netinet/ip_proxy.c head/sys/contrib/ipfilter/netinet/ip_rpcb_pxy.c head/sys/contrib/ipfilter/netinet/ip_rules.c head/sys/contrib/ipfilter/netinet/mlfk_ipl.c Modified: head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c ============================================================================== --- head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c Thu Jun 30 14:55:49 2016 (r302297) +++ head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c Thu Jun 30 15:01:07 2016 (r302298) @@ -62,6 +62,9 @@ static const char rcsid[] = "@(#)$Id$"; #else #define CURVNET_SET(arg) #define CURVNET_RESTORE() +#define VNET_DEFINE(_t, _v) _t _v +#define VNET_DECLARE(_t, _v) extern _t _v +#define VNET(arg) arg #endif #if defined(__osf__) # include @@ -102,22 +105,40 @@ MALLOC_DEFINE(M_IPFILTER, "ipfilter", "I static int ipf_send_ip __P((fr_info_t *, mb_t *)); static void ipf_timer_func __P((void *arg)); -ipf_main_softc_t ipfmain; +VNET_DEFINE(ipf_main_softc_t, ipfmain) = { + .ipf_running = -2, +}; +#define V_ipfmain VNET(ipfmain) # include # if defined(NETBSD_PF) # include # endif /* NETBSD_PF */ +static eventhandler_tag ipf_arrivetag, ipf_departtag; +#if 0 +/* + * Disable the "cloner" event handler; we are getting interface + * events before the firewall is fully initiallized and also no vnet + * information thus leading to uninitialised memory accesses. + * In addition it is unclear why we need it in first place. + * If it turns out to be needed, well need a dedicated event handler + * for it to deal with the ifc and the correct vnet. + */ +static eventhandler_tag ipf_clonetag; +#endif -static eventhandler_tag ipf_arrivetag, ipf_departtag, ipf_clonetag; - -static void ipf_ifevent(void *arg); +static void ipf_ifevent(void *arg, struct ifnet *ifp); -static void ipf_ifevent(arg) +static void ipf_ifevent(arg, ifp) void *arg; + struct ifnet *ifp; { - ipf_sync(arg, NULL); + + CURVNET_SET(ifp->if_vnet); + if (V_ipfmain.ipf_running > 0) + ipf_sync(&V_ipfmain, NULL); + CURVNET_RESTORE(); } @@ -135,8 +156,10 @@ ipf_check_wrapper(void *arg, struct mbuf ip->ip_len = htons(ip->ip_len); ip->ip_off = htons(ip->ip_off); #endif - rv = ipf_check(&ipfmain, ip, ip->ip_hl << 2, ifp, (dir == PFIL_OUT), + CURVNET_SET(ifp->if_vnet); + rv = ipf_check(&V_ipfmain, ip, ip->ip_hl << 2, ifp, (dir == PFIL_OUT), mp); + CURVNET_RESTORE(); #if (__FreeBSD_version < 1000019) if ((rv == 0) && (*mp != NULL)) { ip = mtod(*mp, struct ip *); @@ -153,8 +176,13 @@ ipf_check_wrapper(void *arg, struct mbuf static int ipf_check_wrapper6(void *arg, struct mbuf **mp, struct ifnet *ifp, int dir) { - return (ipf_check(&ipfmain, mtod(*mp, struct ip *), - sizeof(struct ip6_hdr), ifp, (dir == PFIL_OUT), mp)); + int error; + + CURVNET_SET(ifp->if_vnet); + error = ipf_check(&V_ipfmain, mtod(*mp, struct ip *), + sizeof(struct ip6_hdr), ifp, (dir == PFIL_OUT), mp); + CURVNET_RESTORE(); + return (error); } # endif #if defined(IPFILTER_LKM) @@ -215,7 +243,7 @@ ipfattach(softc) } - bzero((char *)ipfmain.ipf_selwait, sizeof(ipfmain.ipf_selwait)); + bzero((char *)V_ipfmain.ipf_selwait, sizeof(V_ipfmain.ipf_selwait)); softc->ipf_running = 1; if (softc->ipf_control_forwarding & 1) @@ -284,38 +312,42 @@ ipfioctl(dev, cmd, data, mode int error = 0, unit = 0; SPL_INT(s); + CURVNET_SET(TD_TO_VNET(p)); #if (BSD >= 199306) if (securelevel_ge(p->p_cred, 3) && (mode & FWRITE)) { - ipfmain.ipf_interror = 130001; + V_ipfmain.ipf_interror = 130001; + CURVNET_RESTORE(); return EPERM; } #endif unit = GET_MINOR(dev); if ((IPL_LOGMAX < unit) || (unit < 0)) { - ipfmain.ipf_interror = 130002; + V_ipfmain.ipf_interror = 130002; + CURVNET_RESTORE(); return ENXIO; } - if (ipfmain.ipf_running <= 0) { + if (V_ipfmain.ipf_running <= 0) { if (unit != IPL_LOGIPF && cmd != SIOCIPFINTERROR) { - ipfmain.ipf_interror = 130003; + V_ipfmain.ipf_interror = 130003; + CURVNET_RESTORE(); return EIO; } if (cmd != SIOCIPFGETNEXT && cmd != SIOCIPFGET && cmd != SIOCIPFSET && cmd != SIOCFRENB && cmd != SIOCGETFS && cmd != SIOCGETFF && cmd != SIOCIPFINTERROR) { - ipfmain.ipf_interror = 130004; + V_ipfmain.ipf_interror = 130004; + CURVNET_RESTORE(); return EIO; } } SPL_NET(s); - CURVNET_SET(TD_TO_VNET(p)); - error = ipf_ioctlswitch(&ipfmain, unit, data, cmd, mode, p->p_uid, p); + error = ipf_ioctlswitch(&V_ipfmain, unit, data, cmd, mode, p->p_uid, p); CURVNET_RESTORE(); if (error != -1) { SPL_X(s); @@ -563,7 +595,7 @@ ipf_send_icmp_err(type, fin, dst) } if (dst == 0) { - if (ipf_ifpaddr(&ipfmain, 4, FRI_NORMAL, ifp, + if (ipf_ifpaddr(&V_ipfmain, 4, FRI_NORMAL, ifp, &dst6, NULL) == -1) { FREE_MB_T(m); return -1; @@ -600,7 +632,7 @@ ipf_send_icmp_err(type, fin, dst) xtra = MIN(fin->fin_plen, avail - iclen - max_linkhdr); xtra = MIN(xtra, IPV6_MMTU - iclen); if (dst == 0) { - if (ipf_ifpaddr(&ipfmain, 6, FRI_NORMAL, ifp, + if (ipf_ifpaddr(&V_ipfmain, 6, FRI_NORMAL, ifp, &dst6, NULL) == -1) { FREE_MB_T(m); return -1; @@ -924,9 +956,9 @@ sendorfree: } done: if (!error) - ipfmain.ipf_frouteok[0]++; + V_ipfmain.ipf_frouteok[0]++; else - ipfmain.ipf_frouteok[1]++; + V_ipfmain.ipf_frouteok[1]++; if (has_nhop) fib4_free_nh_ext(fibnum, &nh4); @@ -1388,13 +1420,15 @@ void ipf_event_reg(void) { ipf_arrivetag = EVENTHANDLER_REGISTER(ifnet_arrival_event, \ - ipf_ifevent, &ipfmain, \ + ipf_ifevent, NULL, \ EVENTHANDLER_PRI_ANY); ipf_departtag = EVENTHANDLER_REGISTER(ifnet_departure_event, \ - ipf_ifevent, &ipfmain, \ + ipf_ifevent, NULL, \ EVENTHANDLER_PRI_ANY); +#if 0 ipf_clonetag = EVENTHANDLER_REGISTER(if_clone_event, ipf_ifevent, \ - &ipfmain, EVENTHANDLER_PRI_ANY); + NULL, EVENTHANDLER_PRI_ANY); +#endif } void @@ -1406,9 +1440,11 @@ ipf_event_dereg(void) if (ipf_departtag != NULL) { EVENTHANDLER_DEREGISTER(ifnet_departure_event, ipf_departtag); } +#if 0 if (ipf_clonetag != NULL) { EVENTHANDLER_DEREGISTER(if_clone_event, ipf_clonetag); } +#endif } Modified: head/sys/contrib/ipfilter/netinet/ip_proxy.c ============================================================================== --- head/sys/contrib/ipfilter/netinet/ip_proxy.c Thu Jun 30 14:55:49 2016 (r302297) +++ head/sys/contrib/ipfilter/netinet/ip_proxy.c Thu Jun 30 15:01:07 2016 (r302298) @@ -64,6 +64,15 @@ struct file; # include #endif #include +#if defined(__FreeBSD_version) && (__FreeBSD_version >= 800000) && defined(_KERNEL) +#include +#else +#define CURVNET_SET(arg) +#define CURVNET_RESTORE() +#define VNET_DEFINE(_t, _v) _t _v +#define VNET_DECLARE(_t, _v) extern _t _v +#define VNET(arg) arg +#endif #ifdef sun # include #endif Modified: head/sys/contrib/ipfilter/netinet/ip_rpcb_pxy.c ============================================================================== --- head/sys/contrib/ipfilter/netinet/ip_rpcb_pxy.c Thu Jun 30 14:55:49 2016 (r302297) +++ head/sys/contrib/ipfilter/netinet/ip_rpcb_pxy.c Thu Jun 30 15:01:07 2016 (r302298) @@ -80,7 +80,9 @@ static void ipf_p_rpcb_fixlen __P((f */ static frentry_t rpcbfr; /* Skeleton rule for reference by entities this proxy creates. */ -static int rpcbcnt; /* Upper bound of allocated RPCB sessions. */ +static VNET_DEFINE(int, rpcbcnt); +#define V_rpcbcnt VNET(rpcbcnt) + /* Upper bound of allocated RPCB sessions. */ /* XXX rpcbcnt still requires locking. */ static int rpcb_proxy_init = 0; @@ -107,7 +109,7 @@ static int rpcb_proxy_init = 0; void ipf_p_rpcb_main_load() { - rpcbcnt = 0; + V_rpcbcnt = 0; bzero((char *)&rpcbfr, sizeof(rpcbfr)); rpcbfr.fr_ref = 1; @@ -581,7 +583,7 @@ ipf_p_rpcb_insert(rs, rx) return(0); } - if (rpcbcnt == RPCB_MAXREQS) + if (V_rpcbcnt == RPCB_MAXREQS) return(-1); KMALLOC(rxp, rpcb_xact_t *); @@ -599,7 +601,7 @@ ipf_p_rpcb_insert(rs, rx) rxp->rx_ref = 1; - ++rpcbcnt; + ++V_rpcbcnt; return(0); } @@ -1084,7 +1086,7 @@ ipf_p_rpcb_deref(rs, rx) KFREE(rx); - --rpcbcnt; + --V_rpcbcnt; } /* -------------------------------------------------------------------- */ Modified: head/sys/contrib/ipfilter/netinet/ip_rules.c ============================================================================== --- head/sys/contrib/ipfilter/netinet/ip_rules.c Thu Jun 30 14:55:49 2016 (r302297) +++ head/sys/contrib/ipfilter/netinet/ip_rules.c Thu Jun 30 15:01:07 2016 (r302298) @@ -32,6 +32,15 @@ #endif #if defined(__FreeBSD__) && (__FreeBSD_version > 220000) # include +#if defined(__FreeBSD_version) && (__FreeBSD_version >= 800000) && defined(_KERNEL) +#include +#else +#define CURVNET_SET(arg) +#define CURVNET_RESTORE() +#define VNET_DEFINE(_t, _v) _t _v +#define VNET_DECLARE(_t, _v) extern _t _v +#define VNET(arg) arg +#endif #else # include #endif /* FreeBSD */ @@ -51,7 +60,8 @@ #ifdef IPFILTER_COMPILED -extern ipf_main_softc_t ipfmain; +VNET_DECLARE(ipf_main_softc_t, ipfmain); +#define V_ipfmain VNET(ipfmain) static u_long in_rule__0[] = { @@ -129,8 +139,8 @@ int ipfrule_add_out_() fp->fr_dsize = sizeof(ipf_rules_out_[0]); fp->fr_family = AF_INET; fp->fr_func = (ipfunc_t)ipfrule_match_out_; - err = frrequest(&ipfmain, IPL_LOGIPF, SIOCADDFR, (caddr_t)fp, - ipfmain.ipf_active, 0); + err = frrequest(&V_ipfmain, IPL_LOGIPF, SIOCADDFR, (caddr_t)fp, + V_ipfmain.ipf_active, 0); return err; } @@ -156,9 +166,9 @@ int ipfrule_remove_out_() } } if (err == 0) - err = frrequest(&ipfmain, IPL_LOGIPF, SIOCDELFR, + err = frrequest(&V_ipfmain, IPL_LOGIPF, SIOCDELFR, (caddr_t)&ipfrule_out_, - ipfmain.ipf_active, 0); + V_ipfmain.ipf_active, 0); if (err) return err; @@ -198,8 +208,8 @@ int ipfrule_add_in_() fp->fr_dsize = sizeof(ipf_rules_in_[0]); fp->fr_family = AF_INET; fp->fr_func = (ipfunc_t)ipfrule_match_in_; - err = frrequest(&ipfmain, IPL_LOGIPF, SIOCADDFR, (caddr_t)fp, - ipfmain.ipf_active, 0); + err = frrequest(&V_ipfmain, IPL_LOGIPF, SIOCADDFR, (caddr_t)fp, + V_ipfmain.ipf_active, 0); return err; } @@ -225,9 +235,9 @@ int ipfrule_remove_in_() } } if (err == 0) - err = frrequest(&ipfmain, IPL_LOGIPF, SIOCDELFR, + err = frrequest(&V_ipfmain, IPL_LOGIPF, SIOCDELFR, (caddr_t)&ipfrule_in_, - ipfmain.ipf_active, 0); + V_ipfmain.ipf_active, 0); if (err) return err; Modified: head/sys/contrib/ipfilter/netinet/mlfk_ipl.c ============================================================================== --- head/sys/contrib/ipfilter/netinet/mlfk_ipl.c Thu Jun 30 14:55:49 2016 (r302297) +++ head/sys/contrib/ipfilter/netinet/mlfk_ipl.c Thu Jun 30 15:01:07 2016 (r302298) @@ -7,6 +7,12 @@ * See the IPFILTER.LICENCE file for details on licencing. */ +#if defined(KERNEL) || defined(_KERNEL) +# undef KERNEL +# undef _KERNEL +# define KERNEL 1 +# define _KERNEL 1 +#endif #include #include @@ -18,6 +24,16 @@ #include #if __FreeBSD_version >= 500000 # include +# include +#endif +#if defined(__FreeBSD_version) && (__FreeBSD_version >= 800000) && defined(_KERNEL) +#include +#else +#define CURVNET_SET(arg) +#define CURVNET_RESTORE() +#define VNET_DEFINE(_t, _v) _t _v +#define VNET_DECLARE(_t, _v) extern _t _v +#define VNET(arg) arg #endif #include #include @@ -33,7 +49,8 @@ #include "netinet/ip_frag.h" #include "netinet/ip_sync.h" -extern ipf_main_softc_t ipfmain; +VNET_DECLARE(ipf_main_softc_t, ipfmain); +#define V_ipfmain VNET(ipfmain) #if __FreeBSD_version >= 502116 static struct cdev *ipf_devs[IPL_LOGSIZE]; @@ -42,10 +59,14 @@ static dev_t ipf_devs[IPL_LOGSIZE]; #endif static int sysctl_ipf_int ( SYSCTL_HANDLER_ARGS ); +static int sysctl_ipf_int_nat ( SYSCTL_HANDLER_ARGS ); +static int sysctl_ipf_int_state ( SYSCTL_HANDLER_ARGS ); +static int sysctl_ipf_int_auth ( SYSCTL_HANDLER_ARGS ); +static int sysctl_ipf_int_frag ( SYSCTL_HANDLER_ARGS ); static int ipf_modload(void); static int ipf_modunload(void); -static int ipf_fbsd_sysctl_create(ipf_main_softc_t*); -static int ipf_fbsd_sysctl_destroy(ipf_main_softc_t*); +static int ipf_fbsd_sysctl_create(void); +static int ipf_fbsd_sysctl_destroy(void); #if (__FreeBSD_version >= 500024) # if (__FreeBSD_version >= 502116) @@ -70,40 +91,49 @@ static int ipfwrite __P((dev_t, struct u SYSCTL_DECL(_net_inet); #define SYSCTL_IPF(parent, nbr, name, access, ptr, val, descr) \ - SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|access, \ - ptr, val, sysctl_ipf_int, "I", descr); -#define SYSCTL_DYN_IPF(parent, nbr, name, access,ptr, val, descr) \ + SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|CTLFLAG_VNET|access, \ + ptr, val, sysctl_ipf_int, "I", descr) +#define SYSCTL_DYN_IPF_NAT(parent, nbr, name, access,ptr, val, descr) \ + SYSCTL_ADD_OID(&ipf_clist, SYSCTL_STATIC_CHILDREN(parent), nbr, name, \ + CTLFLAG_DYN|CTLTYPE_INT|CTLFLAG_VNET|access, ptr, val, sysctl_ipf_int_nat, "I", descr) +#define SYSCTL_DYN_IPF_STATE(parent, nbr, name, access,ptr, val, descr) \ SYSCTL_ADD_OID(&ipf_clist, SYSCTL_STATIC_CHILDREN(parent), nbr, name, \ - CTLFLAG_DYN|CTLTYPE_INT|access, ptr, val, sysctl_ipf_int, "I", descr) + CTLFLAG_DYN|CTLTYPE_INT|CTLFLAG_VNET|access, ptr, val, sysctl_ipf_int_state, "I", descr) +#define SYSCTL_DYN_IPF_FRAG(parent, nbr, name, access,ptr, val, descr) \ + SYSCTL_ADD_OID(&ipf_clist, SYSCTL_STATIC_CHILDREN(parent), nbr, name, \ + CTLFLAG_DYN|CTLTYPE_INT|CTLFLAG_VNET|access, ptr, val, sysctl_ipf_int_frag, "I", descr) +#define SYSCTL_DYN_IPF_AUTH(parent, nbr, name, access,ptr, val, descr) \ + SYSCTL_ADD_OID(&ipf_clist, SYSCTL_STATIC_CHILDREN(parent), nbr, name, \ + CTLFLAG_DYN|CTLTYPE_INT|CTLFLAG_VNET|access, ptr, val, sysctl_ipf_int_auth, "I", descr) static struct sysctl_ctx_list ipf_clist; #define CTLFLAG_OFF 0x00800000 /* IPFilter must be disabled */ #define CTLFLAG_RWO (CTLFLAG_RW|CTLFLAG_OFF) SYSCTL_NODE(_net_inet, OID_AUTO, ipf, CTLFLAG_RW, 0, "IPF"); -SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_flags, CTLFLAG_RW, &ipfmain.ipf_flags, 0, "IPF flags"); -SYSCTL_IPF(_net_inet_ipf, OID_AUTO, ipf_pass, CTLFLAG_RW, &ipfmain.ipf_pass, 0, "default pass/block"); -SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_active, CTLFLAG_RD, &ipfmain.ipf_active, 0, "IPF is active"); +SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_flags, CTLFLAG_RW, &VNET_NAME(ipfmain.ipf_flags), 0, "IPF flags"); +SYSCTL_IPF(_net_inet_ipf, OID_AUTO, ipf_pass, CTLFLAG_RW, &VNET_NAME(ipfmain.ipf_pass), 0, "default pass/block"); +SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_active, CTLFLAG_RD, &VNET_NAME(ipfmain.ipf_active), 0, "IPF is active"); SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_tcpidletimeout, CTLFLAG_RWO, - &ipfmain.ipf_tcpidletimeout, 0, "TCP idle timeout in seconds"); + &VNET_NAME(ipfmain.ipf_tcpidletimeout), 0, "TCP idle timeout in seconds"); SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_tcphalfclosed, CTLFLAG_RWO, - &ipfmain.ipf_tcphalfclosed, 0, "timeout for half closed TCP sessions"); + &VNET_NAME(ipfmain.ipf_tcphalfclosed), 0, "timeout for half closed TCP sessions"); SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_tcpclosewait, CTLFLAG_RWO, - &ipfmain.ipf_tcpclosewait, 0, "timeout for TCP sessions in closewait status"); + &VNET_NAME(ipfmain.ipf_tcpclosewait), 0, "timeout for TCP sessions in closewait status"); SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_tcplastack, CTLFLAG_RWO, - &ipfmain.ipf_tcplastack, 0, "timeout for TCP sessions in last ack status"); + &VNET_NAME(ipfmain.ipf_tcplastack), 0, "timeout for TCP sessions in last ack status"); SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_tcptimeout, CTLFLAG_RWO, - &ipfmain.ipf_tcptimeout, 0, ""); + &VNET_NAME(ipfmain.ipf_tcptimeout), 0, ""); SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_tcpclosed, CTLFLAG_RWO, - &ipfmain.ipf_tcpclosed, 0, ""); + &VNET_NAME(ipfmain.ipf_tcpclosed), 0, ""); SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_udptimeout, CTLFLAG_RWO, - &ipfmain.ipf_udptimeout, 0, "UDP timeout"); + &VNET_NAME(ipfmain.ipf_udptimeout), 0, "UDP timeout"); SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_udpacktimeout, CTLFLAG_RWO, - &ipfmain.ipf_udpacktimeout, 0, ""); + &VNET_NAME(ipfmain.ipf_udpacktimeout), 0, ""); SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_icmptimeout, CTLFLAG_RWO, - &ipfmain.ipf_icmptimeout, 0, "ICMP timeout"); + &VNET_NAME(ipfmain.ipf_icmptimeout), 0, "ICMP timeout"); SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_running, CTLFLAG_RD, - &ipfmain.ipf_running, 0, "IPF is running"); -SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_chksrc, CTLFLAG_RW, &ipfmain.ipf_chksrc, 0, ""); -SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_minttl, CTLFLAG_RW, &ipfmain.ipf_minttl, 0, ""); + &VNET_NAME(ipfmain.ipf_running), 0, "IPF is running"); +SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_chksrc, CTLFLAG_RW, &VNET_NAME(ipfmain.ipf_chksrc), 0, ""); +SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_minttl, CTLFLAG_RW, &VNET_NAME(ipfmain.ipf_minttl), 0, ""); #define CDEV_MAJOR 79 #include @@ -178,28 +208,61 @@ ipfilter_modevent(module_t mod, int type } +static void +vnet_ipf_init(void) +{ + char *defpass; + int error; + + if (ipf_create_all(&V_ipfmain) == NULL) + return; + + error = ipfattach(&V_ipfmain); + if (error) { + ipf_destroy_all(&V_ipfmain); + return; + } + + if (FR_ISPASS(V_ipfmain.ipf_pass)) + defpass = "pass"; + else if (FR_ISBLOCK(V_ipfmain.ipf_pass)) + defpass = "block"; + else + defpass = "no-match -> block"; + + if (IS_DEFAULT_VNET(curvnet)) + printf("%s initialized. Default = %s all, Logging = %s%s\n", + ipfilter_version, defpass, +#ifdef IPFILTER_LOG + "enabled", +#else + "disabled", +#endif +#ifdef IPFILTER_COMPILED + " (COMPILED)" +#else + "" +#endif + ); +} +VNET_SYSINIT(vnet_ipf_init, SI_SUB_PROTO_FIREWALL, SI_ORDER_THIRD, + vnet_ipf_init, NULL); + static int ipf_modload() { - char *defpass, *c, *str; + char *c, *str; int i, j, error; if (ipf_load_all() != 0) return EIO; - if (ipf_create_all(&ipfmain) == NULL) - return EIO; - - if (ipf_fbsd_sysctl_create(&ipfmain) != 0) + if (ipf_fbsd_sysctl_create() != 0) { return EIO; - - error = ipfattach(&ipfmain); - if (error) - return error; + } for (i = 0; i < IPL_LOGSIZE; i++) ipf_devs[i] = NULL; - for (i = 0; (str = ipf_devfiles[i]); i++) { c = NULL; for(j = strlen(str); j > 0; j--) @@ -217,63 +280,48 @@ ipf_modload() return error; ipf_event_reg(); - if (FR_ISPASS(ipfmain.ipf_pass)) - defpass = "pass"; - else if (FR_ISBLOCK(ipfmain.ipf_pass)) - defpass = "block"; - else - defpass = "no-match -> block"; - - printf("%s initialized. Default = %s all, Logging = %s%s\n", - ipfilter_version, defpass, -#ifdef IPFILTER_LOG - "enabled", -#else - "disabled", -#endif -#ifdef IPFILTER_COMPILED - " (COMPILED)" -#else - "" -#endif - ); return 0; } +static void +vnet_ipf_uninit(void) +{ + + if (V_ipfmain.ipf_refcnt) + return; + + if (V_ipfmain.ipf_running >= 0) { + if (ipfdetach(&V_ipfmain) != 0) + return; + + ipf_destroy_all(&V_ipfmain); + } + + V_ipfmain.ipf_running = -2; +} +VNET_SYSUNINIT(vnet_ipf_uninit, SI_SUB_PROTO_FIREWALL, SI_ORDER_THIRD, + vnet_ipf_uninit, NULL); static int ipf_modunload() { int error, i; - if (ipfmain.ipf_refcnt) - return EBUSY; + ipf_event_dereg(); - if (ipf_fbsd_sysctl_destroy(&ipfmain) != 0) - return EIO; + ipf_fbsd_sysctl_destroy(); error = ipf_pfil_unhook(); if (error != 0) return error; - if (ipfmain.ipf_running >= 0) { - error = ipfdetach(&ipfmain); - if (error != 0) - return error; - - ipf_fbsd_sysctl_destroy(&ipfmain); - ipf_destroy_all(&ipfmain); - ipf_unload_all(); - } else - error = 0; - - ipfmain.ipf_running = -2; - for (i = 0; ipf_devfiles[i]; i++) { if (ipf_devs[i] != NULL) destroy_dev(ipf_devs[i]); } + ipf_unload_all(); + printf("%s unloaded\n", ipfilter_version); return error; @@ -287,7 +335,7 @@ static moduledata_t ipfiltermod = { }; -DECLARE_MODULE(ipfilter, ipfiltermod, SI_SUB_PROTO_FIREWALL, SI_ORDER_ANY); +DECLARE_MODULE(ipfilter, ipfiltermod, SI_SUB_PROTO_FIREWALL, SI_ORDER_SECOND); #ifdef MODULE_VERSION MODULE_VERSION(ipfilter, 1); #endif @@ -310,13 +358,87 @@ sysctl_ipf_int ( SYSCTL_HANDLER_ARGS ) if (!arg1) error = EPERM; else { - if ((oidp->oid_kind & CTLFLAG_OFF) && (ipfmain.ipf_running > 0)) + if ((oidp->oid_kind & CTLFLAG_OFF) && (V_ipfmain.ipf_running > 0)) error = EBUSY; else error = SYSCTL_IN(req, arg1, sizeof(int)); } return (error); } + +/* + * In the VIMAGE case kern_sysctl.c already adds the vnet base address given + * we set CTLFLAG_VNET to get proper access checks. Have to undo this. + * Then we add the given offset to the specific malloced struct hanging off + * virtualized ipmain struct. + */ +static int +sysctl_ipf_int_nat ( SYSCTL_HANDLER_ARGS ) +{ + + if (arg1) { + ipf_nat_softc_t *nat_softc; + + nat_softc = V_ipfmain.ipf_nat_soft; +#ifdef VIMAGE + arg1 = (void *)((uintptr_t)arg1 - curvnet->vnet_data_base); +#endif + arg1 = (void *)((uintptr_t)nat_softc + (uintptr_t)arg1); + } + + return (sysctl_ipf_int(oidp, arg1, arg2, req)); +} + +static int +sysctl_ipf_int_state ( SYSCTL_HANDLER_ARGS ) +{ + + if (arg1) { + ipf_state_softc_t *state_softc; + + state_softc = V_ipfmain.ipf_state_soft; +#ifdef VIMAGE + arg1 = (void *)((uintptr_t)arg1 - curvnet->vnet_data_base); +#endif + arg1 = (void *)((uintptr_t)state_softc + (uintptr_t)arg1); + } + + return (sysctl_ipf_int(oidp, arg1, arg2, req)); +} + +static int +sysctl_ipf_int_auth ( SYSCTL_HANDLER_ARGS ) +{ + + if (arg1) { + ipf_auth_softc_t *auth_softc; + + auth_softc = V_ipfmain.ipf_auth_soft; +#ifdef VIMAGE + arg1 = (void *)((uintptr_t)arg1 - curvnet->vnet_data_base); +#endif + arg1 = (void *)((uintptr_t)auth_softc + (uintptr_t)arg1); + } + + return (sysctl_ipf_int(oidp, arg1, arg2, req)); +} + +static int +sysctl_ipf_int_frag ( SYSCTL_HANDLER_ARGS ) +{ + + if (arg1) { + ipf_frag_softc_t *frag_softc; + + frag_softc = V_ipfmain.ipf_frag_soft; +#ifdef VIMAGE + arg1 = (void *)((uintptr_t)arg1 - curvnet->vnet_data_base); +#endif + arg1 = (void *)((uintptr_t)frag_softc + (uintptr_t)arg1); + } + + return (sysctl_ipf_int(oidp, arg1, arg2, req)); +} #endif @@ -335,24 +457,25 @@ ipfpoll(dev_t dev, int events, struct pr revents = 0; + CURVNET_SET(TD_TO_VNET(td)); switch (unit) { case IPL_LOGIPF : case IPL_LOGNAT : case IPL_LOGSTATE : #ifdef IPFILTER_LOG - if ((events & (POLLIN | POLLRDNORM)) && ipf_log_canread(&ipfmain, unit)) + if ((events & (POLLIN | POLLRDNORM)) && ipf_log_canread(&V_ipfmain, unit)) revents |= events & (POLLIN | POLLRDNORM); #endif break; case IPL_LOGAUTH : - if ((events & (POLLIN | POLLRDNORM)) && ipf_auth_waiting(&ipfmain)) + if ((events & (POLLIN | POLLRDNORM)) && ipf_auth_waiting(&V_ipfmain)) revents |= events & (POLLIN | POLLRDNORM); break; case IPL_LOGSYNC : - if ((events & (POLLIN | POLLRDNORM)) && ipf_sync_canread(&ipfmain)) + if ((events & (POLLIN | POLLRDNORM)) && ipf_sync_canread(&V_ipfmain)) revents |= events & (POLLIN | POLLRDNORM); - if ((events & (POLLOUT | POLLWRNORM)) && ipf_sync_canwrite(&ipfmain)) + if ((events & (POLLOUT | POLLWRNORM)) && ipf_sync_canwrite(&V_ipfmain)) revents |= events & (POLLOUT | POLLWRNORM); break; case IPL_LOGSCAN : @@ -362,7 +485,8 @@ ipfpoll(dev_t dev, int events, struct pr } if ((revents == 0) && ((events & (POLLIN|POLLRDNORM)) != 0)) - selrecord(td, &ipfmain.ipf_selwait[unit]); + selrecord(td, &V_ipfmain.ipf_selwait[unit]); + CURVNET_RESTORE(); return revents; } @@ -465,22 +589,31 @@ static int ipfread(dev, uio) #endif struct uio *uio; { + int error; int unit = GET_MINOR(dev); if (unit < 0) return ENXIO; - if (ipfmain.ipf_running < 1) + CURVNET_SET(TD_TO_VNET(curthread)); + if (V_ipfmain.ipf_running < 1) { + CURVNET_RESTORE(); return EIO; + } - if (unit == IPL_LOGSYNC) - return ipf_sync_read(&ipfmain, uio); + if (unit == IPL_LOGSYNC) { + error = ipf_sync_read(&V_ipfmain, uio); + CURVNET_RESTORE(); + return error; + } #ifdef IPFILTER_LOG - return ipf_log_read(&ipfmain, unit, uio); + error = ipf_log_read(&V_ipfmain, unit, uio); #else - return ENXIO; + error = ENXIO; #endif + CURVNET_RESTORE(); + return error; } @@ -503,61 +636,57 @@ static int ipfwrite(dev, uio) #endif struct uio *uio; { + int error; - if (ipfmain.ipf_running < 1) + CURVNET_SET(TD_TO_VNET(curthread)); + if (V_ipfmain.ipf_running < 1) { + CURVNET_RESTORE(); return EIO; + } - if (GET_MINOR(dev) == IPL_LOGSYNC) - return ipf_sync_write(&ipfmain, uio); + if (GET_MINOR(dev) == IPL_LOGSYNC) { + error = ipf_sync_write(&V_ipfmain, uio); + CURVNET_RESTORE(); + return error; + } return ENXIO; } static int -ipf_fbsd_sysctl_create(main_softc) - ipf_main_softc_t *main_softc; +ipf_fbsd_sysctl_create(void) { - ipf_nat_softc_t *nat_softc; - ipf_state_softc_t *state_softc; - ipf_auth_softc_t *auth_softc; - ipf_frag_softc_t *frag_softc; - - nat_softc = main_softc->ipf_nat_soft; - state_softc = main_softc->ipf_state_soft; - auth_softc = main_softc->ipf_auth_soft; - frag_softc = main_softc->ipf_frag_soft; sysctl_ctx_init(&ipf_clist); - SYSCTL_DYN_IPF(_net_inet_ipf, OID_AUTO, "fr_defnatage", CTLFLAG_RWO, - &nat_softc->ipf_nat_defage, 0, ""); - SYSCTL_DYN_IPF(_net_inet_ipf, OID_AUTO, "fr_statesize", CTLFLAG_RWO, - &state_softc->ipf_state_size, 0, ""); - SYSCTL_DYN_IPF(_net_inet_ipf, OID_AUTO, "fr_statemax", CTLFLAG_RWO, - &state_softc->ipf_state_max, 0, ""); - SYSCTL_DYN_IPF(_net_inet_ipf, OID_AUTO, "ipf_nattable_max", CTLFLAG_RWO, - &nat_softc->ipf_nat_table_max, 0, ""); - SYSCTL_DYN_IPF(_net_inet_ipf, OID_AUTO, "ipf_nattable_sz", CTLFLAG_RWO, - &nat_softc->ipf_nat_table_sz, 0, ""); - SYSCTL_DYN_IPF(_net_inet_ipf, OID_AUTO, "ipf_natrules_sz", CTLFLAG_RWO, - &nat_softc->ipf_nat_maprules_sz, 0, ""); - SYSCTL_DYN_IPF(_net_inet_ipf, OID_AUTO, "ipf_rdrrules_sz", CTLFLAG_RWO, - &nat_softc->ipf_nat_rdrrules_sz, 0, ""); - SYSCTL_DYN_IPF(_net_inet_ipf, OID_AUTO, "ipf_hostmap_sz", CTLFLAG_RWO, - &nat_softc->ipf_nat_hostmap_sz, 0, ""); - SYSCTL_DYN_IPF(_net_inet_ipf, OID_AUTO, "fr_authsize", CTLFLAG_RWO, - &auth_softc->ipf_auth_size, 0, ""); - SYSCTL_DYN_IPF(_net_inet_ipf, OID_AUTO, "fr_authused", CTLFLAG_RD, - &auth_softc->ipf_auth_used, 0, ""); - SYSCTL_DYN_IPF(_net_inet_ipf, OID_AUTO, "fr_defaultauthage", CTLFLAG_RW, - &auth_softc->ipf_auth_defaultage, 0, ""); - SYSCTL_DYN_IPF(_net_inet_ipf, OID_AUTO, "fr_ipfrttl", CTLFLAG_RW, - &frag_softc->ipfr_ttl, 0, ""); + SYSCTL_DYN_IPF_NAT(_net_inet_ipf, OID_AUTO, "fr_defnatage", CTLFLAG_RWO, + (void *)offsetof(ipf_nat_softc_t, ipf_nat_defage), 0, ""); + SYSCTL_DYN_IPF_STATE(_net_inet_ipf, OID_AUTO, "fr_statesize", CTLFLAG_RWO, + (void *)offsetof(ipf_state_softc_t, ipf_state_size), 0, ""); + SYSCTL_DYN_IPF_STATE(_net_inet_ipf, OID_AUTO, "fr_statemax", CTLFLAG_RWO, + (void *)offsetof(ipf_state_softc_t, ipf_state_max), 0, ""); + SYSCTL_DYN_IPF_NAT(_net_inet_ipf, OID_AUTO, "ipf_nattable_max", CTLFLAG_RWO, + (void *)offsetof(ipf_nat_softc_t, ipf_nat_table_max), 0, ""); + SYSCTL_DYN_IPF_NAT(_net_inet_ipf, OID_AUTO, "ipf_nattable_sz", CTLFLAG_RWO, + (void *)offsetof(ipf_nat_softc_t, ipf_nat_table_sz), 0, ""); + SYSCTL_DYN_IPF_NAT(_net_inet_ipf, OID_AUTO, "ipf_natrules_sz", CTLFLAG_RWO, + (void *)offsetof(ipf_nat_softc_t, ipf_nat_maprules_sz), 0, ""); + SYSCTL_DYN_IPF_NAT(_net_inet_ipf, OID_AUTO, "ipf_rdrrules_sz", CTLFLAG_RWO, + (void *)offsetof(ipf_nat_softc_t, ipf_nat_rdrrules_sz), 0, ""); + SYSCTL_DYN_IPF_NAT(_net_inet_ipf, OID_AUTO, "ipf_hostmap_sz", CTLFLAG_RWO, + (void *)offsetof(ipf_nat_softc_t, ipf_nat_hostmap_sz), 0, ""); + SYSCTL_DYN_IPF_AUTH(_net_inet_ipf, OID_AUTO, "fr_authsize", CTLFLAG_RWO, + (void *)offsetof(ipf_auth_softc_t, ipf_auth_size), 0, ""); + SYSCTL_DYN_IPF_AUTH(_net_inet_ipf, OID_AUTO, "fr_authused", CTLFLAG_RD, + (void *)offsetof(ipf_auth_softc_t, ipf_auth_used), 0, ""); + SYSCTL_DYN_IPF_AUTH(_net_inet_ipf, OID_AUTO, "fr_defaultauthage", CTLFLAG_RW, + (void *)offsetof(ipf_auth_softc_t, ipf_auth_defaultage), 0, ""); + SYSCTL_DYN_IPF_FRAG(_net_inet_ipf, OID_AUTO, "fr_ipfrttl", CTLFLAG_RW, + (void *)offsetof(ipf_frag_softc_t, ipfr_ttl), 0, ""); return 0; } static int -ipf_fbsd_sysctl_destroy(main_softc) - ipf_main_softc_t *main_softc; +ipf_fbsd_sysctl_destroy(void) { if (sysctl_ctx_free(&ipf_clist)) { printf("sysctl_ctx_free failed"); From owner-svn-src-head@freebsd.org Thu Jun 30 18:01:16 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CA5C6B873B8; Thu, 30 Jun 2016 18:01:16 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 74DF82CE4; Thu, 30 Jun 2016 18:01:16 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u5UI17dX094765 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Thu, 30 Jun 2016 21:01:07 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u5UI17dX094765 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id u5UI16RM094736; Thu, 30 Jun 2016 21:01:06 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 30 Jun 2016 21:01:06 +0300 From: Konstantin Belousov To: Bruce Evans Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r302252 - head/sys/kern Message-ID: <20160630180106.GU38613@kib.kiev.ua> References: <201606281643.u5SGhNsi061606@repo.freebsd.org> <20160629175917.O968@besplex.bde.org> <20160629145443.GG38613@kib.kiev.ua> <20160629153233.GI38613@kib.kiev.ua> <20160630040123.F791@besplex.bde.org> <20160629211953.GK38613@kib.kiev.ua> <20160701005401.Q1084@besplex.bde.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160701005401.Q1084@besplex.bde.org> User-Agent: Mutt/1.6.1 (2016-04-27) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Thu, 30 Jun 2016 18:01:16 -0000 On Fri, Jul 01, 2016 at 03:30:41AM +1000, Bruce Evans wrote: > On Thu, 30 Jun 2016, Konstantin Belousov wrote: > > > On Thu, Jun 30, 2016 at 05:47:39AM +1000, Bruce Evans wrote: > >> On Wed, 29 Jun 2016, Konstantin Belousov wrote: > >> > >>> On Wed, Jun 29, 2016 at 05:54:43PM +0300, Konstantin Belousov wrote: > >>>> As an additional, but probably excessive measure, invocation of > >>>> tc_windup() from hardclock could ask the setclock() to re-execute > >>>> tc_windup() after its call is done. > >> > >> I don't quite understand this. hardclock -> tc_windup() normally doesn't > >> have interference from tc_setclock(). > > In what sense it does not have interference ? tc_windup() may be executed > > from hardclock/hardclock_cnt (low half) and concurrently from setclock() > > (top half). And this is exactly what we want to avoid, isn't it ? > > Ues, but you seemed to be saying that hardclock should schedule or call > tc_setclock(). That makes no sense. So I thought that you meant > tc_setclock() calling or scheduling tc_windup() in a different way than > it does now (it just calls it now). More precisely, I mean that hardclock, when not able to execute tc_windup() due to the top-half currently executing tc_windup(), may ask top-half to re-execute tc_windup() (and not tc_setclock()) once the current invocation finishes. > > >>> ... > >>> diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c > >>> index 0f015b3..a5776d2 100644 > >>> --- a/sys/kern/kern_tc.c > >>> +++ b/sys/kern/kern_tc.c > >>> ... > >>> @@ -1237,6 +1238,7 @@ tc_setclock(struct timespec *ts) > >>> struct timespec tbef, taft; > >>> struct bintime bt, bt2; > >>> > >>> + critical_enter(); > >>> cpu_tick_calibrate(1); > >>> nanotime(&tbef); > >>> timespec2bintime(ts, &bt); > >>> @@ -1247,8 +1249,10 @@ tc_setclock(struct timespec *ts) > >>> bintime2timeval(&bt, &boottime); > >> > >> boottime is one of the critical variables. Before this, there are 2 > >> accesses to boottimebin. The Giant locking that you just removed gave > >> only some protection here. It prevented concurrent acccess by > >> malicious/stress-testing code doing settime(). It didn't prevent > >> nanotime() and friends seeing boottime in an in-between state. Oops, > >> mutex locking won't fix that either. I think the update of these > >> variables needs to be moved into tc_windup() where it will hopefully > >> automatically be protected by the generation count, like the timehands > >> offsets already are. > > I do not understand how that would help. Do you mean to move the vars > > into current timehands ? > > I hoped that it would just work without putting it in timehands, but > now I don't see a better way that putting it in timehands. The space > wastage is not too bad, and we might need it in timehands for other > reasons. One is that the actual boot time is invariant, but FreeBSD > varies it; a global is needed for the actual boot time and then it is > natural to put the fudged boot time in timehands (it is not a boot > time, but an offset which is sometimes close to the boot time). > > Note that boottimebin is also updated in tc_windup() (for leap seconds). > The new mutex doesn't protect it there. This is the next of other > reasons to put it in timehands. Yes. > > >*... > >>> + for (;;) { > >>> + if (atomic_cmpset_int(&tc_windup_lock, 0, 1)) { > >>> + atomic_thread_fence_acq(); > >>> + tc_windup_locked(); > >>> + atomic_store_rel_int(&tc_windup_lock, 0); > >>> + break; > >>> + } else if (!top_call) { > >>> + break; > >>> + } > >>> + } > >>> } > >> > >> I like to write optimized locking like that, but don't see why you > >> want it here. > > Because I do not want the fast clock interrupt handler to wait on lock, > > which neccessary becomes spinlock. The ntp_lock is bad enough already. > > What I coded above is not real lock. In contention case it bails out, > > so there is no blocking. In particular, witness is not relevant to it. > > I think this is too complicated. Spinlocks aren't very expensive, and > hardclock() already has some. I think it has several. It has at least > one silly one -- in hardclock_cpu(), a thread locking to lock a single > flags update. hardclock() and tc_windup() just aren't called enough > for the locking overhead or contention to matter, even at too-large hz. Spinlocks are quite expensive. They delay interrupt delivery. I do not want the fast interrupt handler to be delayed due to the top-half of the kernel executing settimeofday(2) in loop. > > > ... > > diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c > > index 0f015b3..7bb767c 100644 > > --- a/sys/kern/kern_tc.c > > +++ b/sys/kern/kern_tc.c > >... > > +static struct mtx tc_setclock_mtx; > > +MTX_SYSINIT(tc_setclock_init, &tc_setclock_mtx, "tcsetc", MTX_DEF); > > I thought it would be a spinlock. The sleep lock is better if you can > make ot work, but this is complicated. For mutual exclusion of invocation of tc_setclock(), I do not see why sleepable lock would not suffice. > > > + > > /* > > * Step our concept of UTC. This is done by modifying our estimate of > > * when we booted. > > - * XXX: not locked. > > */ > > Now "not properly locked" -). > > > void > > tc_setclock(struct timespec *ts) > > @@ -1237,6 +1240,8 @@ tc_setclock(struct timespec *ts) > > struct timespec tbef, taft; > > struct bintime bt, bt2; > > > > + mtx_lock(&tc_setclock_mtx); > > + critical_enter(); > > I thought at first that this critical section was redundant, since a > spinlock would already have it. It is not spinlock. > > > cpu_tick_calibrate(1); > > nanotime(&tbef); > > timespec2bintime(ts, &bt); > > @@ -1247,8 +1252,10 @@ tc_setclock(struct timespec *ts) > > bintime2timeval(&bt, &boottime); > > The leap second update to boottimebin in tc_windup() races with the > update to boottimebin here. This can be fixed partially by using the > same locking there. Then the locking would have to be a spin mutex > (or special). This still doesn't fix non-atomic accesses to boottimebin > in nanotime() and friends. Putting it in timehands seems to be best for > fixing that. Yes, timehands for bootimebin should be the solution, but not in the scope of this patch. I will work on this right after the current changeset lands in svn. > boottime is easier to fix (and doesn't need to be in timehands). It > is only used to copy it out in a historical sysctl. The locking for > that is buggy. We convert boottimebin to boottime here (now with locking) > but in the sysctl we copy out boottime non-atomically. Do we need boottime at all ? Can't it be calculated from boottimebin on the sysctl invocation ? From owner-svn-src-head@freebsd.org Thu Jun 30 18:02:38 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 48F22B87527; Thu, 30 Jun 2016 18:02:38 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail108.syd.optusnet.com.au (mail108.syd.optusnet.com.au [211.29.132.59]) by mx1.freebsd.org (Postfix) with ESMTP id AFD352F16; Thu, 30 Jun 2016 18:02:37 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from besplex.bde.org (c110-21-100-149.carlnfd1.nsw.optusnet.com.au [110.21.100.149]) by mail108.syd.optusnet.com.au (Postfix) with ESMTPS id AC7D71A21F0; Fri, 1 Jul 2016 03:30:41 +1000 (AEST) Date: Fri, 1 Jul 2016 03:30:41 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Konstantin Belousov cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r302252 - head/sys/kern In-Reply-To: <20160629211953.GK38613@kib.kiev.ua> Message-ID: <20160701005401.Q1084@besplex.bde.org> References: <201606281643.u5SGhNsi061606@repo.freebsd.org> <20160629175917.O968@besplex.bde.org> <20160629145443.GG38613@kib.kiev.ua> <20160629153233.GI38613@kib.kiev.ua> <20160630040123.F791@besplex.bde.org> <20160629211953.GK38613@kib.kiev.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=OtmysHLt c=1 sm=1 tr=0 a=XDAe9YG+7EcdVXYrgT+/UQ==:117 a=XDAe9YG+7EcdVXYrgT+/UQ==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=rSq5_t48hvnpDHZ03tAA:9 a=YlvRzp75ULENEib-:21 a=7WTdreb3hoYc-uwb:21 a=CjuIK1q_8ugA:10 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Thu, 30 Jun 2016 18:02:38 -0000 On Thu, 30 Jun 2016, Konstantin Belousov wrote: > On Thu, Jun 30, 2016 at 05:47:39AM +1000, Bruce Evans wrote: >> On Wed, 29 Jun 2016, Konstantin Belousov wrote: >> >>> On Wed, Jun 29, 2016 at 05:54:43PM +0300, Konstantin Belousov wrote: >>>> This is a reply to two mails in one, both for r302251 and r302252 threads. > >> After removing the foot-shooting tz_minuteswest variable from utc_offset(), >> all of the variables in it are ones set by adjkerntz sysctls. The settings >> are normally ordered by not running more than 1 instance of adjkerntz. >> When adjkerntz starts, this instance shouldn't have any contention with >> other initialization doing resettodr(). There is contention every 6 >> months if wall_cmos_clock when adjkerntz changes the offset for daylight >> savings time. The chances of this used to be tiny since resettodr() was >> almost never called, but now there is the periodic resettodr() in >> kern_ntptime.c. > I do not see how your text above changes anything I said about consistency. > Each sysctl sets or fetches integer variable, so individually it is atomic. > Inter-dependencies between wall_cmos_clock and adjkerntz settings are > completely up to user, no locking can change it while keeping separate > sysctls to set and fetch each var individually. > > The only side-effects in resettodr() are possible in CLOCK_SETTIME(), > which is protected against parallel invocation by resettodr_lock. It says that the users are sufficiently limited and careful about ordering for the problem to be small. >>>>> ... >>>>> The change in the other part of the diff is related to this, and doesn't >>>>> seem quite right. utc_offset() uses the variables tz_minuteswest, >>>>> wall_cmos_clock and adjkerntz: >>>>> - tz_minuteswest is set with no locking in kern_settimeofday(), just >>>>> after the settime() call. This last had a chance of being correct >>>>> when the kernel was UP and not preemptible. But it is broken in >>>>> a more fundamental way back to at least FreeBSD-1: resettodr() is >>>>> called _before_ updating the timezone, so it uses an out-of-date >>>>> tz_minuteswest. >>>> First, the man page is not correct, saying that 'this information is >>>> kept outside the kernel'. >> >> We deprecate the timezone support in settimeofday(), but use wrong wording >> for this here. The info set by this sysctl is of course kept in the kernel, >> and I think the man page is trying to say that this info is never used >> outside of the kernel. > How the later statement could be true, since that information is > returned by gettimeofday(), and we do not control what programs a user > might run on his machine. Indeed. The man page is only trying to say that this info is not used by libc (and therefore should not be used by any program). >*... >>>> Second, why does settime(), logicall, need the updated timezone ? >>>> I understand that resettodr() is called on successful update of >>>> the wall clock. But shouldn't the need to reset not-GMT RTC clock >> >> The timezone updates just give foot-shooting, but we need an up to >> date adjkerntz variable initially and on every daylight saving change >> in the wall_cmos_clock case. This is the normal way to keep the rtc >> on wall time after every daylight saving changes -- adjkerntz() runs, >> and it should change the adjkerntz variable first and then call >> settimeofday() with a "null" change to get the side effect of calling >> resettodr() which does a large change of the rtc. It is impossible >> to make a really null change of the software clock using settimeofday(), >> but I don't know of any better API to do this. I think the locking that >> you just added is enough -- adjkerntz() just has to arrange a call to >> resettodr() strictly after it updates the variable, and that happens >> almost automatically. > I think that the way it is done is just by doing sysctl machdep.adjkerntz, > which calls resettodr(). I probably knew that once, but had forgotten it. > Old wisdom to re-sync RTC to kernel-maintained > time was to run the sysctl from cron, but Andrey added the callout > several years ago. I never knew that old wisdom, and just avoided re-syncing the RTC. >>>> I do not think that inittodr() actually needs that locking. This code >>>> is executed at the initialization stage, or at the resume stage. >> >> Perhaps, but resume runs more often than every 6 months for the daylight >> savings time race, and it isn't clear if anything stops resettodr() running >> concurrently then. >> >> In my version, something like inittodr() runs 3 seconds after every exit >> from ddb. Stopping in ddb is a bit like a short suspend-resume -- it >> stops or breaks some timers, and inittodr() is a way to fix up the >> software real time using an unstopped timer. > Lets postpone this. Might be, a resettodr_lock can be applied to > inittodr() as a whole, and additionally merged with some other lock. > BUt I think inittodr() is not very important right now. I see some more things that need the common lock: - the RTC interrupt handler. resettodr() begins by disabling RTC interrupts. This is to prevent interference from the interrupt handler, but it only works for UP systems. For SMP systems, the interrupt handler might already be running, or scheduled to run, on another CPU. The interrupt handler doesn't do many RTC accesses (except in my version), but it does delicate interrupt re-enabling by reading the volatile status register. resettodr() ends by re-enabling RTC interrupts and reading the volatile status register. I think all orderings work, but it would be simpler to not allow the contention or maybe to allow it intentionally by not disabling RTC interrupts. - atc_restore(). This runs mainly for resume. It resets the same status register as resettodr() and another status registers. It must not be allowed to run concurrently with resettodr(). Resume call it before allowing any callouts. It is unclear if this is guaranteed. >*... >>>> So I postponed looking at tc_windup(), and it seems that it was >>>> useful. After you note above, it is mostly clear that we can skip some >>>> tc_windup() calls which conflicts with currently active windup calls. >>>> E.g., the hardclock update, which is done simultaneously with the >>>> setclock(), could be just skipped. But we must not skip the tc_windup() >>>> call from setclock(). >> >> Several things could be deferred, but I think that would just be more >> complicated. >> >>>> As an additional, but probably excessive measure, invocation of >>>> tc_windup() from hardclock could ask the setclock() to re-execute >>>> tc_windup() after its call is done. >> >> I don't quite understand this. hardclock -> tc_windup() normally doesn't >> have interference from tc_setclock(). > In what sense it does not have interference ? tc_windup() may be executed > from hardclock/hardclock_cnt (low half) and concurrently from setclock() > (top half). And this is exactly what we want to avoid, isn't it ? Ues, but you seemed to be saying that hardclock should schedule or call tc_setclock(). That makes no sense. So I thought that you meant tc_setclock() calling or scheduling tc_windup() in a different way than it does now (it just calls it now). >>> ... >>> diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c >>> index 0f015b3..a5776d2 100644 >>> --- a/sys/kern/kern_tc.c >>> +++ b/sys/kern/kern_tc.c >>> ... >>> @@ -1237,6 +1238,7 @@ tc_setclock(struct timespec *ts) >>> struct timespec tbef, taft; >>> struct bintime bt, bt2; >>> >>> + critical_enter(); >>> cpu_tick_calibrate(1); >>> nanotime(&tbef); >>> timespec2bintime(ts, &bt); >>> @@ -1247,8 +1249,10 @@ tc_setclock(struct timespec *ts) >>> bintime2timeval(&bt, &boottime); >> >> boottime is one of the critical variables. Before this, there are 2 >> accesses to boottimebin. The Giant locking that you just removed gave >> only some protection here. It prevented concurrent acccess by >> malicious/stress-testing code doing settime(). It didn't prevent >> nanotime() and friends seeing boottime in an in-between state. Oops, >> mutex locking won't fix that either. I think the update of these >> variables needs to be moved into tc_windup() where it will hopefully >> automatically be protected by the generation count, like the timehands >> offsets already are. > I do not understand how that would help. Do you mean to move the vars > into current timehands ? I hoped that it would just work without putting it in timehands, but now I don't see a better way that putting it in timehands. The space wastage is not too bad, and we might need it in timehands for other reasons. One is that the actual boot time is invariant, but FreeBSD varies it; a global is needed for the actual boot time and then it is natural to put the fudged boot time in timehands (it is not a boot time, but an offset which is sometimes close to the boot time). Note that boottimebin is also updated in tc_windup() (for leap seconds). The new mutex doesn't protect it there. This is the next of other reasons to put it in timehands. >*... >>> + for (;;) { >>> + if (atomic_cmpset_int(&tc_windup_lock, 0, 1)) { >>> + atomic_thread_fence_acq(); >>> + tc_windup_locked(); >>> + atomic_store_rel_int(&tc_windup_lock, 0); >>> + break; >>> + } else if (!top_call) { >>> + break; >>> + } >>> + } >>> } >> >> I like to write optimized locking like that, but don't see why you >> want it here. > Because I do not want the fast clock interrupt handler to wait on lock, > which neccessary becomes spinlock. The ntp_lock is bad enough already. > What I coded above is not real lock. In contention case it bails out, > so there is no blocking. In particular, witness is not relevant to it. I think this is too complicated. Spinlocks aren't very expensive, and hardclock() already has some. I think it has several. It has at least one silly one -- in hardclock_cpu(), a thread locking to lock a single flags update. hardclock() and tc_windup() just aren't called enough for the locking overhead or contention to matter, even at too-large hz. > ... > diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c > index 0f015b3..7bb767c 100644 > --- a/sys/kern/kern_tc.c > +++ b/sys/kern/kern_tc.c >... > +static struct mtx tc_setclock_mtx; > +MTX_SYSINIT(tc_setclock_init, &tc_setclock_mtx, "tcsetc", MTX_DEF); I thought it would be a spinlock. The sleep lock is better if you can make ot work, but this is complicated. > + > /* > * Step our concept of UTC. This is done by modifying our estimate of > * when we booted. > - * XXX: not locked. > */ Now "not properly locked" -). > void > tc_setclock(struct timespec *ts) > @@ -1237,6 +1240,8 @@ tc_setclock(struct timespec *ts) > struct timespec tbef, taft; > struct bintime bt, bt2; > > + mtx_lock(&tc_setclock_mtx); > + critical_enter(); I thought at first that this critical section was redundant, since a spinlock would already have it. > cpu_tick_calibrate(1); > nanotime(&tbef); > timespec2bintime(ts, &bt); > @@ -1247,8 +1252,10 @@ tc_setclock(struct timespec *ts) > bintime2timeval(&bt, &boottime); The leap second update to boottimebin in tc_windup() races with the update to boottimebin here. This can be fixed partially by using the same locking there. Then the locking would have to be a spin mutex (or special). This still doesn't fix non-atomic accesses to boottimebin in nanotime() and friends. Putting it in timehands seems to be best for fixing that. boottime is easier to fix (and doesn't need to be in timehands). It is only used to copy it out in a historical sysctl. The locking for that is buggy. We convert boottimebin to boottime here (now with locking) but in the sysctl we copy out boottime non-atomically. Bruce From owner-svn-src-head@freebsd.org Thu Jun 30 19:32:46 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EFBEAB87880; Thu, 30 Jun 2016 19:32:46 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BFE5C2A09; Thu, 30 Jun 2016 19:32:46 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5UJWjOP095282; Thu, 30 Jun 2016 19:32:45 GMT (envelope-from bz@FreeBSD.org) Received: (from bz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5UJWjW8095281; Thu, 30 Jun 2016 19:32:45 GMT (envelope-from bz@FreeBSD.org) Message-Id: <201606301932.u5UJWjW8095281@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org using -f From: "Bjoern A. Zeeb" Date: Thu, 30 Jun 2016 19:32:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302302 - head/sys/netpfil/ipfw X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Thu, 30 Jun 2016 19:32:47 -0000 Author: bz Date: Thu Jun 30 19:32:45 2016 New Revision: 302302 URL: https://svnweb.freebsd.org/changeset/base/302302 Log: In case of the global eventhandler make sure the current VNET is still operational before doing any work; otherwise we might run into, e.g., destroyed locks. PR: 210724 Reported by: olevole olevole.ru Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Obtained from: projects/vnet Approved by: re (gjb) Modified: head/sys/netpfil/ipfw/ip_fw_nat.c Modified: head/sys/netpfil/ipfw/ip_fw_nat.c ============================================================================== --- head/sys/netpfil/ipfw/ip_fw_nat.c Thu Jun 30 19:09:44 2016 (r302301) +++ head/sys/netpfil/ipfw/ip_fw_nat.c Thu Jun 30 19:32:45 2016 (r302302) @@ -104,6 +104,10 @@ ifaddr_change(void *arg __unused, struct KASSERT(curvnet == ifp->if_vnet, ("curvnet(%p) differs from iface vnet(%p)", curvnet, ifp->if_vnet)); + + if (V_ipfw_vnet_ready == 0 || V_ipfw_nat_ready == 0) + return; + chain = &V_layer3_chain; IPFW_UH_WLOCK(chain); /* Check every nat entry... */ @@ -1145,12 +1149,12 @@ vnet_ipfw_nat_uninit(const void *arg __u chain = &V_layer3_chain; IPFW_WLOCK(chain); + V_ipfw_nat_ready = 0; LIST_FOREACH_SAFE(ptr, &chain->nat, _next, ptr_temp) { LIST_REMOVE(ptr, _next); free_nat_instance(ptr); } flush_nat_ptrs(chain, -1 /* flush all */); - V_ipfw_nat_ready = 0; IPFW_WUNLOCK(chain); return (0); } From owner-svn-src-head@freebsd.org Fri Jul 1 00:00:36 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D2408B874F4; Fri, 1 Jul 2016 00:00:36 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A32532E44; Fri, 1 Jul 2016 00:00:36 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6100ZdG093386; Fri, 1 Jul 2016 00:00:35 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6100Z3J093385; Fri, 1 Jul 2016 00:00:35 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201607010000.u6100Z3J093385@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Fri, 1 Jul 2016 00:00:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302303 - head/sys/conf X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Fri, 01 Jul 2016 00:00:36 -0000 Author: gjb Date: Fri Jul 1 00:00:35 2016 New Revision: 302303 URL: https://svnweb.freebsd.org/changeset/base/302303 Log: Update 11.0 to ALPHA6. Approved by: re (implicit) Sponsored by: The FreeBSD Foundation Modified: head/sys/conf/newvers.sh Modified: head/sys/conf/newvers.sh ============================================================================== --- head/sys/conf/newvers.sh Thu Jun 30 19:32:45 2016 (r302302) +++ head/sys/conf/newvers.sh Fri Jul 1 00:00:35 2016 (r302303) @@ -32,7 +32,7 @@ TYPE="FreeBSD" REVISION="11.0" -BRANCH="ALPHA5" +BRANCH="ALPHA6" if [ -n "${BRANCH_OVERRIDE}" ]; then BRANCH=${BRANCH_OVERRIDE} fi From owner-svn-src-head@freebsd.org Fri Jul 1 03:16:09 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 123E1B860CF; Fri, 1 Jul 2016 03:16:09 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6ED1F29C1; Fri, 1 Jul 2016 03:16:08 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u613Fo7x031721 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Fri, 1 Jul 2016 06:15:51 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u613Fo7x031721 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id u613Fo06031717; Fri, 1 Jul 2016 06:15:50 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 1 Jul 2016 06:15:50 +0300 From: Konstantin Belousov To: Bruce Evans Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r302252 - head/sys/kern Message-ID: <20160701031549.GV38613@kib.kiev.ua> References: <201606281643.u5SGhNsi061606@repo.freebsd.org> <20160629175917.O968@besplex.bde.org> <20160629145443.GG38613@kib.kiev.ua> <20160629153233.GI38613@kib.kiev.ua> <20160630040123.F791@besplex.bde.org> <20160629211953.GK38613@kib.kiev.ua> <20160701005401.Q1084@besplex.bde.org> <20160630180106.GU38613@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160630180106.GU38613@kib.kiev.ua> User-Agent: Mutt/1.6.1 (2016-04-27) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Fri, 01 Jul 2016 03:16:09 -0000 On Thu, Jun 30, 2016 at 09:01:06PM +0300, Konstantin Belousov wrote: > Yes, timehands for bootimebin should be the solution, but > not in the scope of this patch. I will work on this right after the > current changeset lands in svn. Well, there is the move of boottimebin into timehands. I also reduced the number of timehands to two, this was discussed many times before. The feed-forward code is probably broken right now, I did not even compile it. diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c index 56b2ade..a0dce47 100644 --- a/sys/compat/linprocfs/linprocfs.c +++ b/sys/compat/linprocfs/linprocfs.c @@ -447,9 +447,11 @@ linprocfs_dostat(PFS_FILL_ARGS) struct pcpu *pcpu; long cp_time[CPUSTATES]; long *cp; + struct timeval boottime; int i; read_cpu_time(cp_time); + getboottime(&boottime); sbuf_printf(sb, "cpu %ld %ld %ld %ld\n", T2J(cp_time[CP_USER]), T2J(cp_time[CP_NICE]), @@ -624,10 +626,12 @@ static int linprocfs_doprocstat(PFS_FILL_ARGS) { struct kinfo_proc kp; + struct timeval boottime; char state; static int ratelimit = 0; vm_offset_t startcode, startdata; + getboottime(&boottime); sx_slock(&proctree_lock); PROC_LOCK(p); fill_kinfo_proc(p, &kp); diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c index 7cc0f9e..afa3da4 100644 --- a/sys/fs/devfs/devfs_vnops.c +++ b/sys/fs/devfs/devfs_vnops.c @@ -707,10 +707,11 @@ devfs_getattr(struct vop_getattr_args *ap) { struct vnode *vp = ap->a_vp; struct vattr *vap = ap->a_vap; - int error; struct devfs_dirent *de; struct devfs_mount *dmp; struct cdev *dev; + struct timeval boottime; + int error; error = devfs_populate_vp(vp); if (error != 0) @@ -740,6 +741,7 @@ devfs_getattr(struct vop_getattr_args *ap) vap->va_blocksize = DEV_BSIZE; vap->va_type = vp->v_type; + getboottime(&boottime); #define fix(aa) \ do { \ if ((aa).tv_sec <= 3600) { \ diff --git a/sys/fs/fdescfs/fdesc_vnops.c b/sys/fs/fdescfs/fdesc_vnops.c index 4f6e1b9..65b8a54 100644 --- a/sys/fs/fdescfs/fdesc_vnops.c +++ b/sys/fs/fdescfs/fdesc_vnops.c @@ -394,7 +394,9 @@ fdesc_getattr(struct vop_getattr_args *ap) { struct vnode *vp = ap->a_vp; struct vattr *vap = ap->a_vap; + struct timeval boottime; + getboottime(&boottime); vap->va_mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH; vap->va_fileid = VTOFDESC(vp)->fd_ix; vap->va_uid = 0; diff --git a/sys/fs/nfs/nfsport.h b/sys/fs/nfs/nfsport.h index 921df2d..6b41e2f 100644 --- a/sys/fs/nfs/nfsport.h +++ b/sys/fs/nfs/nfsport.h @@ -872,7 +872,7 @@ int newnfs_realign(struct mbuf **, int); /* * Set boottime. */ -#define NFSSETBOOTTIME(b) ((b) = boottime) +#define NFSSETBOOTTIME(b) (getboottime(&b)) /* * The size of directory blocks in the buffer cache. diff --git a/sys/fs/procfs/procfs_status.c b/sys/fs/procfs/procfs_status.c index 5a00ee1..defdec3 100644 --- a/sys/fs/procfs/procfs_status.c +++ b/sys/fs/procfs/procfs_status.c @@ -70,6 +70,7 @@ procfs_doprocstatus(PFS_FILL_ARGS) const char *wmesg; char *pc; char *sep; + struct timeval boottime; int pid, ppid, pgid, sid; int i; @@ -129,6 +130,7 @@ procfs_doprocstatus(PFS_FILL_ARGS) calcru(p, &ut, &st); PROC_STATUNLOCK(p); start = p->p_stats->p_start; + getboottime(&boottime); timevaladd(&start, &boottime); sbuf_printf(sb, " %jd,%ld %jd,%ld %jd,%ld", (intmax_t)start.tv_sec, start.tv_usec, diff --git a/sys/kern/kern_acct.c b/sys/kern/kern_acct.c index ef3fd2e..46e6d9b 100644 --- a/sys/kern/kern_acct.c +++ b/sys/kern/kern_acct.c @@ -389,7 +389,7 @@ acct_process(struct thread *td) acct.ac_stime = encode_timeval(st); /* (4) The elapsed time the command ran (and its starting time) */ - tmp = boottime; + getboottime(&tmp); timevaladd(&tmp, &p->p_stats->p_start); acct.ac_btime = tmp.tv_sec; microuptime(&tmp); diff --git a/sys/kern/kern_ntptime.c b/sys/kern/kern_ntptime.c index d352ee7..efc3713 100644 --- a/sys/kern/kern_ntptime.c +++ b/sys/kern/kern_ntptime.c @@ -162,29 +162,12 @@ static l_fp time_adj; /* tick adjust (ns/s) */ static int64_t time_adjtime; /* correction from adjtime(2) (usec) */ -static struct mtx ntpadj_lock; -MTX_SYSINIT(ntpadj, &ntpadj_lock, "ntpadj", -#ifdef PPS_SYNC - MTX_SPIN -#else - MTX_DEF -#endif -); +static struct mtx ntp_lock; +MTX_SYSINIT(ntp, &ntp_lock, "ntp", MTX_SPIN); -/* - * When PPS_SYNC is defined, hardpps() function is provided which can - * be legitimately called from interrupt filters. Due to this, use - * spinlock for ntptime state protection, otherwise sleepable mutex is - * adequate. - */ -#ifdef PPS_SYNC -#define NTPADJ_LOCK() mtx_lock_spin(&ntpadj_lock) -#define NTPADJ_UNLOCK() mtx_unlock_spin(&ntpadj_lock) -#else -#define NTPADJ_LOCK() mtx_lock(&ntpadj_lock) -#define NTPADJ_UNLOCK() mtx_unlock(&ntpadj_lock) -#endif -#define NTPADJ_ASSERT_LOCKED() mtx_assert(&ntpadj_lock, MA_OWNED) +#define NTP_LOCK() mtx_lock_spin(&ntp_lock) +#define NTP_UNLOCK() mtx_unlock_spin(&ntp_lock) +#define NTP_ASSERT_LOCKED() mtx_assert(&ntp_lock, MA_OWNED) #ifdef PPS_SYNC /* @@ -271,7 +254,7 @@ ntp_gettime1(struct ntptimeval *ntvp) { struct timespec atv; /* nanosecond time */ - NTPADJ_ASSERT_LOCKED(); + NTP_ASSERT_LOCKED(); nanotime(&atv); ntvp->time.tv_sec = atv.tv_sec; @@ -302,9 +285,9 @@ sys_ntp_gettime(struct thread *td, struct ntp_gettime_args *uap) { struct ntptimeval ntv; - NTPADJ_LOCK(); + NTP_LOCK(); ntp_gettime1(&ntv); - NTPADJ_UNLOCK(); + NTP_UNLOCK(); td->td_retval[0] = ntv.time_state; return (copyout(&ntv, uap->ntvp, sizeof(ntv))); @@ -315,9 +298,9 @@ ntp_sysctl(SYSCTL_HANDLER_ARGS) { struct ntptimeval ntv; /* temporary structure */ - NTPADJ_LOCK(); + NTP_LOCK(); ntp_gettime1(&ntv); - NTPADJ_UNLOCK(); + NTP_UNLOCK(); return (sysctl_handle_opaque(oidp, &ntv, sizeof(ntv), req)); } @@ -382,7 +365,7 @@ sys_ntp_adjtime(struct thread *td, struct ntp_adjtime_args *uap) error = priv_check(td, PRIV_NTP_ADJTIME); if (error != 0) return (error); - NTPADJ_LOCK(); + NTP_LOCK(); if (modes & MOD_MAXERROR) time_maxerror = ntv.maxerror; if (modes & MOD_ESTERROR) @@ -484,7 +467,7 @@ sys_ntp_adjtime(struct thread *td, struct ntp_adjtime_args *uap) ntv.stbcnt = pps_stbcnt; #endif /* PPS_SYNC */ retval = ntp_is_time_error(time_status) ? TIME_ERROR : time_state; - NTPADJ_UNLOCK(); + NTP_UNLOCK(); error = copyout((caddr_t)&ntv, (caddr_t)uap->tp, sizeof(ntv)); if (error == 0) @@ -506,6 +489,8 @@ ntp_update_second(int64_t *adjustment, time_t *newsec) int tickrate; l_fp ftemp; /* 32/64-bit temporary */ + NTP_LOCK(); + /* * On rollover of the second both the nanosecond and microsecond * clocks are updated and the state machine cranked as @@ -627,6 +612,8 @@ ntp_update_second(int64_t *adjustment, time_t *newsec) else time_status &= ~STA_PPSSIGNAL; #endif /* PPS_SYNC */ + + NTP_UNLOCK(); } /* @@ -690,7 +677,7 @@ hardupdate(offset) long mtemp; l_fp ftemp; - NTPADJ_ASSERT_LOCKED(); + NTP_ASSERT_LOCKED(); /* * Select how the phase is to be controlled and from which @@ -772,7 +759,7 @@ hardpps(tsp, nsec) long u_sec, u_nsec, v_nsec; /* temps */ l_fp ftemp; - NTPADJ_LOCK(); + NTP_LOCK(); /* * The signal is first processed by a range gate and frequency @@ -956,7 +943,7 @@ hardpps(tsp, nsec) time_freq = pps_freq; out: - NTPADJ_UNLOCK(); + NTP_UNLOCK(); } #endif /* PPS_SYNC */ @@ -999,11 +986,11 @@ kern_adjtime(struct thread *td, struct timeval *delta, struct timeval *olddelta) return (error); ltw = (int64_t)delta->tv_sec * 1000000 + delta->tv_usec; } - NTPADJ_LOCK(); + NTP_LOCK(); ltr = time_adjtime; if (delta != NULL) time_adjtime = ltw; - NTPADJ_UNLOCK(); + NTP_UNLOCK(); if (olddelta != NULL) { atv.tv_sec = ltr / 1000000; atv.tv_usec = ltr % 1000000; diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index 2f1f620..892b23a 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -872,6 +872,7 @@ fill_kinfo_proc_only(struct proc *p, struct kinfo_proc *kp) struct session *sp; struct ucred *cred; struct sigacts *ps; + struct timeval boottime; /* For proc_realparent. */ sx_assert(&proctree_lock, SX_LOCKED); @@ -953,6 +954,7 @@ fill_kinfo_proc_only(struct proc *p, struct kinfo_proc *kp) kp->ki_nice = p->p_nice; kp->ki_fibnum = p->p_fibnum; kp->ki_start = p->p_stats->p_start; + getboottime(&boottime); timevaladd(&kp->ki_start, &boottime); PROC_STATLOCK(p); rufetch(p, &kp->ki_rusage); diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index 0f015b3..1c2d562 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -70,31 +70,36 @@ struct timehands { struct bintime th_offset; struct timeval th_microtime; struct timespec th_nanotime; + struct bintime th_boottime; /* Fields not to be copied in tc_windup start with th_generation. */ u_int th_generation; struct timehands *th_next; }; static struct timehands th0; -static struct timehands th9 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th0}; -static struct timehands th8 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th9}; -static struct timehands th7 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th8}; -static struct timehands th6 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th7}; -static struct timehands th5 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th6}; -static struct timehands th4 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th5}; -static struct timehands th3 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th4}; -static struct timehands th2 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th3}; -static struct timehands th1 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th2}; +static struct timehands th1 = { + .th_counter = NULL, + .th_adjustment = 0, + .th_scale = 0, + .th_offset_count = 0, + .th_offset = {0, 0}, + .th_microtime = {0, 0}, + .th_nanotime = {0, 0}, + .th_boottime = {0, 0}, + .th_generation = 0, + .th_next = &th0 +}; static struct timehands th0 = { - &dummy_timecounter, - 0, - (uint64_t)-1 / 1000000, - 0, - {1, 0}, - {0, 0}, - {0, 0}, - 1, - &th1 + .th_counter = &dummy_timecounter, + .th_adjustment = 0, + .th_scale = (uint64_t)-1 / 1000000, + .th_offset_count = 0, + .th_offset = {1, 0}, + .th_microtime = {0, 0}, + .th_nanotime = {0, 0}, + .th_boottime = {0, 0}, + .th_generation = 1, + .th_next = &th1 }; static struct timehands *volatile timehands = &th0; @@ -106,8 +111,6 @@ int tc_min_ticktock_freq = 1; volatile time_t time_second = 1; volatile time_t time_uptime = 1; -struct bintime boottimebin; -struct timeval boottime; static int sysctl_kern_boottime(SYSCTL_HANDLER_ARGS); SYSCTL_PROC(_kern, KERN_BOOTTIME, boottime, CTLTYPE_STRUCT|CTLFLAG_RD, NULL, 0, sysctl_kern_boottime, "S,timeval", "System boottime"); @@ -135,14 +138,22 @@ SYSCTL_PROC(_kern_timecounter, OID_AUTO, alloweddeviation, static int tc_chosen; /* Non-zero if a specific tc was chosen via sysctl. */ -static void tc_windup(void); +static void tc_windup(bool top_call, struct bintime *new_boottimebin); +static void tc_windup_locked(struct bintime *new_boottimebin); static void cpu_tick_calibrate(int); +static void binuptime1(struct bintime *bt, struct bintime *boottimebin); void dtrace_getnanotime(struct timespec *tsp); static int sysctl_kern_boottime(SYSCTL_HANDLER_ARGS) { + struct bintime boottimebin; + struct timeval boottime; + + binuptime1(NULL, &boottimebin); + bintime2timeval(&boottimebin, &boottime); + #ifndef __mips__ #ifdef SCTL_MASK32 int tv[2]; @@ -150,11 +161,11 @@ sysctl_kern_boottime(SYSCTL_HANDLER_ARGS) if (req->flags & SCTL_MASK32) { tv[0] = boottime.tv_sec; tv[1] = boottime.tv_usec; - return SYSCTL_OUT(req, tv, sizeof(tv)); - } else + return (SYSCTL_OUT(req, tv, sizeof(tv))); + } #endif #endif - return SYSCTL_OUT(req, &boottime, sizeof(boottime)); + return (SYSCTL_OUT(req, &boottime, sizeof(boottime))); } static int @@ -164,7 +175,7 @@ sysctl_kern_timecounter_get(SYSCTL_HANDLER_ARGS) struct timecounter *tc = arg1; ncount = tc->tc_get_timecount(tc); - return sysctl_handle_int(oidp, &ncount, 0, req); + return (sysctl_handle_int(oidp, &ncount, 0, req)); } static int @@ -174,7 +185,7 @@ sysctl_kern_timecounter_freq(SYSCTL_HANDLER_ARGS) struct timecounter *tc = arg1; freq = tc->tc_frequency; - return sysctl_handle_64(oidp, &freq, 0, req); + return (sysctl_handle_64(oidp, &freq, 0, req)); } /* @@ -198,8 +209,8 @@ tc_delta(struct timehands *th) */ #ifdef FFCLOCK -void -fbclock_binuptime(struct bintime *bt) +static void +fbclock_binuptime1(struct bintime *bt, struct bintime *boottimebin) { struct timehands *th; unsigned int gen; @@ -209,11 +220,20 @@ fbclock_binuptime(struct bintime *bt) gen = atomic_load_acq_int(&th->th_generation); *bt = th->th_offset; bintime_addx(bt, th->th_scale * tc_delta(th)); + if (boottimebin != NULL) + *boottimebin = th->th_boottime; atomic_thread_fence_acq(); } while (gen == 0 || gen != th->th_generation); } void +fbclock_binuptime(struct bintime *bt) +{ + + fbclock_binuptime1(bt, NULL); +} + +void fbclock_nanouptime(struct timespec *tsp) { struct bintime bt; @@ -234,8 +254,9 @@ fbclock_microuptime(struct timeval *tvp) void fbclock_bintime(struct bintime *bt) { + struct bintime boottimebin; - fbclock_binuptime(bt); + fbclock_binuptime1(bt, &boottimebin); bintime_add(bt, &boottimebin); } @@ -303,12 +324,14 @@ void fbclock_getbintime(struct bintime *bt) { struct timehands *th; + struct bintime boottimebin; unsigned int gen; do { th = timehands; gen = atomic_load_acq_int(&th->th_generation); *bt = th->th_offset; + boottimebin = th->th_boottime; atomic_thread_fence_acq(); } while (gen == 0 || gen != th->th_generation); bintime_add(bt, &boottimebin); @@ -342,8 +365,8 @@ fbclock_getmicrotime(struct timeval *tvp) } while (gen == 0 || gen != th->th_generation); } #else /* !FFCLOCK */ -void -binuptime(struct bintime *bt) +static void +binuptime1(struct bintime *bt, struct bintime *boottimebin) { struct timehands *th; u_int gen; @@ -351,13 +374,24 @@ binuptime(struct bintime *bt) do { th = timehands; gen = atomic_load_acq_int(&th->th_generation); - *bt = th->th_offset; - bintime_addx(bt, th->th_scale * tc_delta(th)); + if (bt != NULL) { + *bt = th->th_offset; + bintime_addx(bt, th->th_scale * tc_delta(th)); + } + if (boottimebin != NULL) + *boottimebin = th->th_boottime; atomic_thread_fence_acq(); } while (gen == 0 || gen != th->th_generation); } void +binuptime(struct bintime *bt) +{ + + binuptime1(bt, NULL); +} + +void nanouptime(struct timespec *tsp) { struct bintime bt; @@ -378,8 +412,9 @@ microuptime(struct timeval *tvp) void bintime(struct bintime *bt) { + struct bintime boottimebin; - binuptime(bt); + binuptime1(bt, &boottimebin); bintime_add(bt, &boottimebin); } @@ -447,12 +482,14 @@ void getbintime(struct bintime *bt) { struct timehands *th; + struct bintime boottimebin; u_int gen; do { th = timehands; gen = atomic_load_acq_int(&th->th_generation); *bt = th->th_offset; + boottimebin = th->th_boottime; atomic_thread_fence_acq(); } while (gen == 0 || gen != th->th_generation); bintime_add(bt, &boottimebin); @@ -487,6 +524,22 @@ getmicrotime(struct timeval *tvp) } #endif /* FFCLOCK */ +void +getboottime(struct timeval *boottime) +{ + struct bintime boottimebin; + + binuptime1(NULL, &boottimebin); + bintime2timeval(&boottimebin, boottime); +} + +void +getboottimebin(struct bintime *boottimebin) +{ + + binuptime1(NULL, boottimebin); +} + #ifdef FFCLOCK /* * Support for feed-forward synchronization algorithms. This is heavily inspired @@ -1103,6 +1156,7 @@ int sysclock_snap2bintime(struct sysclock_snap *cs, struct bintime *bt, int whichclock, uint32_t flags) { + struct bintime boottimebin; #ifdef FFCLOCK struct bintime bt2; uint64_t period; @@ -1116,8 +1170,10 @@ sysclock_snap2bintime(struct sysclock_snap *cs, struct bintime *bt, if (cs->delta > 0) bintime_addx(bt, cs->fb_info.th_scale * cs->delta); - if ((flags & FBCLOCK_UPTIME) == 0) + if ((flags & FBCLOCK_UPTIME) == 0) { + binuptime1(NULL, &boottimebin); bintime_add(bt, &boottimebin); + } break; #ifdef FFCLOCK case SYSCLOCK_FFWD: @@ -1226,10 +1282,12 @@ tc_getfrequency(void) return (timehands->th_counter->tc_frequency); } +static struct mtx tc_setclock_mtx; +MTX_SYSINIT(tc_setclock_init, &tc_setclock_mtx, "tcsetc", MTX_DEF); + /* * Step our concept of UTC. This is done by modifying our estimate of * when we booted. - * XXX: not locked. */ void tc_setclock(struct timespec *ts) @@ -1237,26 +1295,43 @@ tc_setclock(struct timespec *ts) struct timespec tbef, taft; struct bintime bt, bt2; - cpu_tick_calibrate(1); - nanotime(&tbef); timespec2bintime(ts, &bt); + nanotime(&tbef); + mtx_lock(&tc_setclock_mtx); + critical_enter(); + cpu_tick_calibrate(1); binuptime(&bt2); bintime_sub(&bt, &bt2); - bintime_add(&bt2, &boottimebin); - boottimebin = bt; - bintime2timeval(&bt, &boottime); /* XXX fiddle all the little crinkly bits around the fiords... */ - tc_windup(); - nanotime(&taft); + tc_windup(true, &bt); + critical_exit(); + mtx_unlock(&tc_setclock_mtx); if (timestepwarnings) { + nanotime(&taft); log(LOG_INFO, "Time stepped from %jd.%09ld to %jd.%09ld (%jd.%09ld)\n", (intmax_t)tbef.tv_sec, tbef.tv_nsec, (intmax_t)taft.tv_sec, taft.tv_nsec, (intmax_t)ts->tv_sec, ts->tv_nsec); } - cpu_tick_calibrate(1); +} + +static volatile int tc_windup_lock; +static void +tc_windup(bool top_call, struct bintime *new_boottimebin) +{ + + for (;;) { + if (atomic_cmpset_int(&tc_windup_lock, 0, 1)) { + atomic_thread_fence_acq(); + tc_windup_locked(new_boottimebin); + atomic_store_rel_int(&tc_windup_lock, 0); + break; + } else if (!top_call) { + break; + } + } } /* @@ -1265,7 +1340,7 @@ tc_setclock(struct timespec *ts) * timecounter and/or do seconds processing in NTP. Slightly magic. */ static void -tc_windup(void) +tc_windup_locked(struct bintime *new_boottimebin) { struct bintime bt; struct timehands *th, *tho; @@ -1289,6 +1364,8 @@ tc_windup(void) th->th_generation = 0; atomic_thread_fence_rel(); bcopy(tho, th, offsetof(struct timehands, th_generation)); + if (new_boottimebin != NULL) + th->th_boottime = *new_boottimebin; /* * Capture a timecounter delta on the current timecounter and if @@ -1338,7 +1415,7 @@ tc_windup(void) * case we missed a leap second. */ bt = th->th_offset; - bintime_add(&bt, &boottimebin); + bintime_add(&bt, &th->th_boottime); i = bt.sec - tho->th_microtime.tv_sec; if (i > LARGE_STEP) i = 2; @@ -1346,7 +1423,7 @@ tc_windup(void) t = bt.sec; ntp_update_second(&th->th_adjustment, &bt.sec); if (bt.sec != t) - boottimebin.sec += bt.sec - t; + th->th_boottime.sec += bt.sec - t; } /* Update the UTC timestamps used by the get*() functions. */ /* XXX shouldn't do this here. Should force non-`get' versions. */ @@ -1769,7 +1846,7 @@ pps_event(struct pps_state *pps, int event) tcount &= pps->capth->th_counter->tc_counter_mask; bt = pps->capth->th_offset; bintime_addx(&bt, pps->capth->th_scale * tcount); - bintime_add(&bt, &boottimebin); + bintime_add(&bt, &pps->capth->th_boottime); bintime2timespec(&bt, &ts); /* If the timecounter was wound up underneath us, bail out. */ @@ -1846,7 +1923,7 @@ tc_ticktock(int cnt) if (count < tc_tick) return; count = 0; - tc_windup(); + tc_windup(false, NULL); } static void __inline @@ -1921,7 +1998,7 @@ inittimecounter(void *dummy) /* warm up new timecounter (again) and get rolling. */ (void)timecounter->tc_get_timecount(timecounter); (void)timecounter->tc_get_timecount(timecounter); - tc_windup(); + tc_windup(true, NULL); } SYSINIT(timecounter, SI_SUB_CLOCKS, SI_ORDER_SECOND, inittimecounter, NULL); @@ -2095,7 +2172,7 @@ tc_fill_vdso_timehands(struct vdso_timehands *vdso_th) vdso_th->th_offset_count = th->th_offset_count; vdso_th->th_counter_mask = th->th_counter->tc_counter_mask; vdso_th->th_offset = th->th_offset; - vdso_th->th_boottime = boottimebin; + vdso_th->th_boottime = th->th_boottime; enabled = cpu_fill_vdso_timehands(vdso_th, th->th_counter); if (!vdso_th_enable) enabled = 0; @@ -2116,8 +2193,8 @@ tc_fill_vdso_timehands32(struct vdso_timehands32 *vdso_th32) vdso_th32->th_counter_mask = th->th_counter->tc_counter_mask; vdso_th32->th_offset.sec = th->th_offset.sec; *(uint64_t *)&vdso_th32->th_offset.frac[0] = th->th_offset.frac; - vdso_th32->th_boottime.sec = boottimebin.sec; - *(uint64_t *)&vdso_th32->th_boottime.frac[0] = boottimebin.frac; + vdso_th32->th_boottime.sec = th->th_boottime.sec; + *(uint64_t *)&vdso_th32->th_boottime.frac[0] = th->th_boottime.frac; enabled = cpu_fill_vdso_timehands32(vdso_th32, th->th_counter); if (!vdso_th_enable) enabled = 0; diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index 148da2b..82710f7 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -115,9 +115,7 @@ settime(struct thread *td, struct timeval *tv) struct timeval delta, tv1, tv2; static struct timeval maxtime, laststep; struct timespec ts; - int s; - s = splclock(); microtime(&tv1); delta = *tv; timevalsub(&delta, &tv1); @@ -147,10 +145,8 @@ settime(struct thread *td, struct timeval *tv) printf("Time adjustment clamped to -1 second\n"); } } else { - if (tv1.tv_sec == laststep.tv_sec) { - splx(s); + if (tv1.tv_sec == laststep.tv_sec) return (EPERM); - } if (delta.tv_sec > 1) { tv->tv_sec = tv1.tv_sec + 1; printf("Time adjustment clamped to +1 second\n"); @@ -161,10 +157,8 @@ settime(struct thread *td, struct timeval *tv) ts.tv_sec = tv->tv_sec; ts.tv_nsec = tv->tv_usec * 1000; - mtx_lock(&Giant); tc_setclock(&ts); resettodr(); - mtx_unlock(&Giant); return (0); } diff --git a/sys/kern/subr_rtc.c b/sys/kern/subr_rtc.c index dbad36d..4bac324 100644 --- a/sys/kern/subr_rtc.c +++ b/sys/kern/subr_rtc.c @@ -172,11 +172,11 @@ resettodr(void) if (disable_rtc_set || clock_dev == NULL) return; - mtx_lock(&resettodr_lock); getnanotime(&ts); timespecadd(&ts, &clock_adj); ts.tv_sec -= utc_offset(); /* XXX: We should really set all registered RTCs */ + mtx_lock(&resettodr_lock); error = CLOCK_SETTIME(clock_dev, &ts); mtx_unlock(&resettodr_lock); if (error != 0) diff --git a/sys/kern/sys_procdesc.c b/sys/kern/sys_procdesc.c index 37139c1..f47ae7c 100644 --- a/sys/kern/sys_procdesc.c +++ b/sys/kern/sys_procdesc.c @@ -517,7 +517,7 @@ procdesc_stat(struct file *fp, struct stat *sb, struct ucred *active_cred, struct thread *td) { struct procdesc *pd; - struct timeval pstart; + struct timeval pstart, boottime; /* * XXXRW: Perhaps we should cache some more information from the @@ -532,6 +532,7 @@ procdesc_stat(struct file *fp, struct stat *sb, struct ucred *active_cred, /* Set birth and [acm] times to process start time. */ pstart = pd->pd_proc->p_stats->p_start; + getboottime(&boottime); timevaladd(&pstart, &boottime); TIMEVAL_TO_TIMESPEC(&pstart, &sb->st_birthtim); sb->st_atim = sb->st_birthtim; diff --git a/sys/net/bpf.c b/sys/net/bpf.c index 3b12cf4..4251f71 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -2328,12 +2328,13 @@ bpf_hdrlen(struct bpf_d *d) static void bpf_bintime2ts(struct bintime *bt, struct bpf_ts *ts, int tstype) { - struct bintime bt2; + struct bintime bt2, boottimebin; struct timeval tsm; struct timespec tsn; if ((tstype & BPF_T_MONOTONIC) == 0) { bt2 = *bt; + getboottimebin(&boottimebin); bintime_add(&bt2, &boottimebin); bt = &bt2; } diff --git a/sys/netpfil/ipfw/ip_fw_sockopt.c b/sys/netpfil/ipfw/ip_fw_sockopt.c index d186ba5..7faf99f 100644 --- a/sys/netpfil/ipfw/ip_fw_sockopt.c +++ b/sys/netpfil/ipfw/ip_fw_sockopt.c @@ -395,6 +395,7 @@ swap_map(struct ip_fw_chain *chain, struct ip_fw **new_map, int new_len) static void export_cntr1_base(struct ip_fw *krule, struct ip_fw_bcounter *cntr) { + struct timeval boottime; cntr->size = sizeof(*cntr); @@ -403,21 +404,26 @@ export_cntr1_base(struct ip_fw *krule, struct ip_fw_bcounter *cntr) cntr->bcnt = counter_u64_fetch(krule->cntr + 1); cntr->timestamp = krule->timestamp; } - if (cntr->timestamp > 0) + if (cntr->timestamp > 0) { + getboottime(&boottime); cntr->timestamp += boottime.tv_sec; + } } static void export_cntr0_base(struct ip_fw *krule, struct ip_fw_bcounter0 *cntr) { + struct timeval boottime; if (krule->cntr != NULL) { cntr->pcnt = counter_u64_fetch(krule->cntr); cntr->bcnt = counter_u64_fetch(krule->cntr + 1); cntr->timestamp = krule->timestamp; } - if (cntr->timestamp > 0) + if (cntr->timestamp > 0) { + getboottime(&boottime); cntr->timestamp += boottime.tv_sec; + } } /* @@ -2048,11 +2054,13 @@ ipfw_getrules(struct ip_fw_chain *chain, void *buf, size_t space) char *ep = bp + space; struct ip_fw *rule; struct ip_fw_rule0 *dst; + struct timeval boottime; int error, i, l, warnflag; time_t boot_seconds; warnflag = 0; + getboottime(&boottime); boot_seconds = boottime.tv_sec; for (i = 0; i < chain->n_rules; i++) { rule = chain->map[i]; diff --git a/sys/nfs/nfs_lock.c b/sys/nfs/nfs_lock.c index 7d11672..c84413e 100644 --- a/sys/nfs/nfs_lock.c +++ b/sys/nfs/nfs_lock.c @@ -241,6 +241,7 @@ nfs_dolock(struct vop_advlock_args *ap) struct flock *fl; struct proc *p; struct nfsmount *nmp; + struct timeval boottime; td = curthread; p = td->td_proc; @@ -284,6 +285,7 @@ nfs_dolock(struct vop_advlock_args *ap) p->p_nlminfo = malloc(sizeof(struct nlminfo), M_NLMINFO, M_WAITOK | M_ZERO); p->p_nlminfo->pid_start = p->p_stats->p_start; + getboottime(&boottime); timevaladd(&p->p_nlminfo->pid_start, &boottime); } msg.lm_msg_ident.pid_start = p->p_nlminfo->pid_start; diff --git a/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c b/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c index 1d07943..0879299 100644 --- a/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c +++ b/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c @@ -504,11 +504,13 @@ svc_rpc_gss_find_client(struct svc_rpc_gss_clientid *id) { struct svc_rpc_gss_client *client; struct svc_rpc_gss_client_list *list; + struct timeval boottime; unsigned long hostid; rpc_gss_log_debug("in svc_rpc_gss_find_client(%d)", id->ci_id); getcredhostid(curthread->td_ucred, &hostid); + getboottime(&boottime); if (id->ci_hostid != hostid || id->ci_boottime != boottime.tv_sec) return (NULL); @@ -537,6 +539,7 @@ svc_rpc_gss_create_client(void) { struct svc_rpc_gss_client *client; struct svc_rpc_gss_client_list *list; + struct timeval boottime; unsigned long hostid; rpc_gss_log_debug("in svc_rpc_gss_create_client()"); @@ -547,6 +550,7 @@ svc_rpc_gss_create_client(void) sx_init(&client->cl_lock, "GSS-client"); getcredhostid(curthread->td_ucred, &hostid); client->cl_id.ci_hostid = hostid; + getboottime(&boottime); client->cl_id.ci_boottime = boottime.tv_sec; client->cl_id.ci_id = svc_rpc_gss_next_clientid++; list = &svc_rpc_gss_client_hash[client->cl_id.ci_id % CLIENT_HASH_SIZE]; diff --git a/sys/sys/time.h b/sys/sys/time.h index 395e888..659f8e0 100644 --- a/sys/sys/time.h +++ b/sys/sys/time.h @@ -372,8 +372,6 @@ void resettodr(void); extern volatile time_t time_second; extern volatile time_t time_uptime; -extern struct bintime boottimebin; -extern struct timeval boottime; extern struct bintime tc_tick_bt; extern sbintime_t tc_tick_sbt; extern struct bintime tick_bt; @@ -440,6 +438,9 @@ void getbintime(struct bintime *bt); void getnanotime(struct timespec *tsp); void getmicrotime(struct timeval *tvp); +void getboottime(struct timeval *boottime); +void getboottimebin(struct bintime *boottimebin); + /* Other functions */ int itimerdecr(struct itimerval *itp, int usec); int itimerfix(struct timeval *tv); From owner-svn-src-head@freebsd.org Fri Jul 1 04:57:25 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C3FD7B882A0; Fri, 1 Jul 2016 04:57:25 +0000 (UTC) (envelope-from loos.br@gmail.com) Received: from mail-io0-x234.google.com (mail-io0-x234.google.com [IPv6:2607:f8b0:4001:c06::234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 901732E2A; Fri, 1 Jul 2016 04:57:25 +0000 (UTC) (envelope-from loos.br@gmail.com) Received: by mail-io0-x234.google.com with SMTP id g13so90516520ioj.1; Thu, 30 Jun 2016 21:57:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=efwvS/T7tApG37h5iYiIkvR9hnMV6a9eAnQPqTktOI4=; b=WVxCffz9Y1I6bUIS0Ucb6+OJ9NWIL/Kxx+YwVvb+ThDGMVmyy2P6OBXM2L5011kgm4 MJo+SONV7fTTIVNQY9eoWX252Wn6Uk2CyWLeMrrzkV1jTlMt1oNkoCjl/9b6ccha/SR/ UgxXhImFcREd3A+KmiHIrYt7J7UzJlQNXqIRmKtTL3SikAnc2HUW3j3VE6SfW5WVsKqM MU4hGYx2IrvYyJ5xfhQwC66VZPhA8j6RSBDaarruMz4TlAeZgQ1IWWDG/XPsEaOra/Pj 9AG6/XxpIPA0yXPkzj2Ucu2kiSbW4qHyxA7neU2+KUZkdOPEMp3JnNL17UHJ+MQHUXz2 vouA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=efwvS/T7tApG37h5iYiIkvR9hnMV6a9eAnQPqTktOI4=; b=Yee6mL2CzwTR7p4JVcw9c5yV8jUIPV0kU+QpsPuqloBnGm5X7Pq4rllswYwAHBIwat hXGBj/ODOYN0SFB75rXKWBJUCNZzgaEEn0FfT2emnde0kgW9dLmtQADBS5BS+gT72AKX vzUOp5cEg45Q94uJisu3pGN4O5NCikl2uf3ybmCi8iqRWmr/hKKNxsr6DiGqS7as8FO4 ksEF6pSDDMcMJoatM8RbYPpMhEx/zE7id8IycItkZ9gFzsqm0XvLv/xvSPKQiZYStQ5P fr3xlMIgK9gynY6JD14PhM9DkymBkOG1eanU6g4sR/wm1ius3MANPo9hz0i16oJ3u0Zd wsjQ== X-Gm-Message-State: ALyK8tLCMlaPzdaSVByDFXaxROA1vlNqrRFFGLQ34Vpu6AdaVobzUxPlCH6OqASxLOtPMj+HwR1EcHm+jJc01w== X-Received: by 10.107.138.6 with SMTP id m6mr17198942iod.181.1467349044873; Thu, 30 Jun 2016 21:57:24 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.33.132 with HTTP; Thu, 30 Jun 2016 21:57:24 -0700 (PDT) In-Reply-To: <201606171821.u5HILudm021649@repo.freebsd.org> References: <201606171821.u5HILudm021649@repo.freebsd.org> From: Luiz Otavio O Souza Date: Fri, 1 Jul 2016 01:57:24 -0300 Message-ID: Subject: Re: svn commit: r301998 - in head: sbin/pfctl share/man/man5 sys/net sys/netpfil/pf To: Kristof Provost Cc: src-committers , svn-src-all , svn-src-head Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Fri, 01 Jul 2016 04:57:25 -0000 On Fri, Jun 17, 2016 at 3:21 PM, Kristof Provost wrote: > Author: kp > Date: Fri Jun 17 18:21:55 2016 > New Revision: 301998 > URL: https://svnweb.freebsd.org/changeset/base/301998 > > Log: > pf: Filter on and set vlan PCP values > > Adopt the OpenBSD syntax for setting and filtering on VLAN PCP values. This > introduces two new keywords: 'set prio' to set the PCP value, and 'prio' to > filter on it. > > Reviewed by: allanjude, araujo > Approved by: re (gjb) > Obtained from: OpenBSD (mostly) > Differential Revision: https://reviews.freebsd.org/D6786 Thanks Kristof! Luiz From owner-svn-src-head@freebsd.org Fri Jul 1 05:48:47 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 59F83B8C899; Fri, 1 Jul 2016 05:48:47 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1E74B2C5F; Fri, 1 Jul 2016 05:48:47 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u615mkqZ023149; Fri, 1 Jul 2016 05:48:46 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u615mjSU023139; Fri, 1 Jul 2016 05:48:45 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201607010548.u615mjSU023139@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Fri, 1 Jul 2016 05:48:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302305 - in head/contrib/expat: . doc examples lib tests tests/benchmark xmlwf X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Fri, 01 Jul 2016 05:48:47 -0000 Author: delphij Date: Fri Jul 1 05:48:45 2016 New Revision: 302305 URL: https://svnweb.freebsd.org/changeset/base/302305 Log: MFV r302260: expat 2.2.0 Approved by: re (kib) Added: head/contrib/expat/configure.ac - copied unchanged from r302260, vendor/expat/dist/configure.ac head/contrib/expat/doc/xmlwf.xml - copied unchanged from r302260, vendor/expat/dist/doc/xmlwf.xml Deleted: head/contrib/expat/configure.in head/contrib/expat/doc/xmlwf.sgml Modified: head/contrib/expat/COPYING head/contrib/expat/Changes head/contrib/expat/MANIFEST head/contrib/expat/Makefile.in head/contrib/expat/README head/contrib/expat/doc/expat.png (contents, props changed) head/contrib/expat/doc/reference.html head/contrib/expat/doc/xmlwf.1 head/contrib/expat/examples/elements.c head/contrib/expat/examples/outline.c head/contrib/expat/expat_config.h.in head/contrib/expat/lib/expat.h head/contrib/expat/lib/expat_external.h head/contrib/expat/lib/internal.h head/contrib/expat/lib/xmlparse.c head/contrib/expat/lib/xmlrole.c head/contrib/expat/lib/xmltok.c head/contrib/expat/lib/xmltok.h head/contrib/expat/lib/xmltok_impl.c head/contrib/expat/tests/benchmark/README.txt head/contrib/expat/tests/chardata.c head/contrib/expat/tests/minicheck.c head/contrib/expat/tests/minicheck.h head/contrib/expat/tests/runtests.c head/contrib/expat/tests/xmltest.sh head/contrib/expat/xmlwf/codepage.c head/contrib/expat/xmlwf/readfilemap.c head/contrib/expat/xmlwf/unixfilemap.c head/contrib/expat/xmlwf/xmlfile.c head/contrib/expat/xmlwf/xmlwf.c Directory Properties: head/contrib/expat/ (props changed) Modified: head/contrib/expat/COPYING ============================================================================== --- head/contrib/expat/COPYING Fri Jul 1 03:21:51 2016 (r302304) +++ head/contrib/expat/COPYING Fri Jul 1 05:48:45 2016 (r302305) @@ -1,6 +1,5 @@ -Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd - and Clark Cooper -Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers. +Copyright (c) 1998-2000 Thai Open Source Software Center Ltd and Clark Cooper +Copyright (c) 2001-2016 Expat maintainers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Modified: head/contrib/expat/Changes ============================================================================== --- head/contrib/expat/Changes Fri Jul 1 03:21:51 2016 (r302304) +++ head/contrib/expat/Changes Fri Jul 1 05:48:45 2016 (r302305) @@ -1,3 +1,67 @@ +Release 2.2.0 Tue June 21 2016 + Security fixes: + #537 CVE-2016-0718 -- Fix crash on malformed input + CVE-2016-4472 -- Improve insufficient fix to CVE-2015-1283 / + CVE-2015-2716 introduced with Expat 2.1.1 + #499 CVE-2016-5300 -- Use more entropy for hash initialization + than the original fix to CVE-2012-0876 + #519 CVE-2012-6702 -- Resolve troublesome internal call to srand + that was introduced with Expat 2.1.0 + when addressing CVE-2012-0876 (issue #496) + + Bug fixes: + Fix uninitialized reads of size 1 + (e.g. in little2_updatePosition) + Fix detection of UTF-8 character boundaries + + Other changes: + #532 Fix compilation for Visual Studio 2010 (keyword "C99") + Autotools: Resolve use of "$<" to better support bmake + Autotools: Add QA script "qa.sh" (and make target "qa") + Autotools: Respect CXXFLAGS if given + Autotools: Fix "make run-xmltest" + Autotools: Have "make run-xmltest" check for expected output + p90 CMake: Fix static build (BUILD_shared=OFF) on Windows + #536 CMake: Add soversion, support -DNO_SONAME=yes to bypass + #323 CMake: Add suffix "d" to differentiate debug from release + CMake: Define WIN32 with CMake on Windows + Annotate memory allocators for GCC + Address all currently known compile warnings + Make sure that API symbols remain visible despite + -fvisibility=hidden + Remove executable flag from source files + Resolve COMPILED_FROM_DSP in favor of WIN32 + + Special thanks to: + Björn Lindahl + Christian Heimes + Cristian Rodríguez + Daniel Krügler + Gustavo Grieco + Karl Waclawek + László Böszörményi + Marco Grassi + Pascal Cuoq + Sergei Nikulov + Thomas Beutlich + Warren Young + Yann Droneaud + +Release 2.1.1 Sat March 12 2016 + Security fixes: + #582: CVE-2015-1283 - Multiple integer overflows in XML_GetBuffer + + Bug fixes: + #502: Fix potential null pointer dereference + #520: Symbol XML_SetHashSalt was not exported + Output of "xmlwf -h" was incomplete + + Other changes: + #503: Document behavior of calling XML_SetHashSalt with salt 0 + Minor improvements to man page xmlwf(1) + Improvements to the experimental CMake build system + libtool now invoked with --verbose + Release 2.1.0 Sat March 24 2012 - Bug Fixes: #1742315: Harmful XML_ParserCreateNS suggestion. @@ -23,7 +87,7 @@ Release 2.1.0 Sat March 24 2012 #3312568: CMake support. #3446384: Report byte offsets for attr names and values. - New Features / API changes: - Added new API member XML_SetHashSalt() that allows setting an intial + Added new API member XML_SetHashSalt() that allows setting an initial value (salt) for hash calculations. This is part of the fix for bug #3496608 to randomize hash parameters. When compiled with XML_ATTR_INFO defined, adds new API member Modified: head/contrib/expat/MANIFEST ============================================================================== --- head/contrib/expat/MANIFEST Fri Jul 1 03:21:51 2016 (r302304) +++ head/contrib/expat/MANIFEST Fri Jul 1 05:48:45 2016 (r302305) @@ -44,7 +44,7 @@ doc/reference.html doc/style.css doc/valid-xhtml10.png doc/xmlwf.1 -doc/xmlwf.sgml +doc/xmlwf.xml CMakeLists.txt CMake.README COPYING @@ -54,7 +54,7 @@ MANIFEST Makefile.in README configure -configure.in +configure.ac expat_config.h.in expat_config.h.cmake expat.pc.in Modified: head/contrib/expat/Makefile.in ============================================================================== --- head/contrib/expat/Makefile.in Fri Jul 1 03:21:51 2016 (r302304) +++ head/contrib/expat/Makefile.in Fri Jul 1 05:48:45 2016 (r302305) @@ -42,7 +42,7 @@ INSTALL_DATA = @INSTALL_DATA@ mkinstalldirs = $(SHELL) $(top_srcdir)/conftools/mkinstalldirs MANFILE = $(srcdir)/doc/xmlwf.1 -APIHEADER = $(srcdir)/lib/expat.h $(srcdir)/lib/expat_external.h +APIHEADER = $(srcdir)/lib/expat.h $(srcdir)/lib/expat_external.h expat_config.h LIBRARY = libexpat.la DESTDIR = $(INSTALL_ROOT) @@ -51,7 +51,7 @@ default: buildlib xmlwf/xmlwf@EXEEXT@ buildlib: $(LIBRARY) expat.pc -all: $(LIBRARY) expat.pc xmlwf/xmlwf@EXEEXT@ examples/elements examples/outline +all: $(LIBRARY) expat.pc xmlwf/xmlwf@EXEEXT@ examples/elements examples/outline $(MANFILE) clean: cd lib && rm -f $(LIBRARY) *.@OBJEXT@ *.lo && rm -rf .libs _libs @@ -77,7 +77,10 @@ check: tests/runtests tests/runtestspp tests/runtests tests/runtestspp -install: xmlwf/xmlwf@EXEEXT@ installlib +$(MANFILE): + $(MAKE) -C doc xmlwf.1 + +install: xmlwf/xmlwf@EXEEXT@ installlib $(MANFILE) $(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(man1dir) $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) xmlwf/xmlwf@EXEEXT@ $(DESTDIR)$(bindir)/xmlwf $(INSTALL_DATA) $(MANFILE) $(DESTDIR)$(man1dir) @@ -116,7 +119,7 @@ CXXFLAGS = @CXXFLAGS@ VSNFLAG = -version-info @LIBCURRENT@:@LIBREVISION@:@LIBAGE@ ### autoconf this? -LTFLAGS = --silent +LTFLAGS = --verbose COMPILE = $(CC) $(INCLUDES) $(CFLAGS) $(DEFS) $(CPPFLAGS) CXXCOMPILE = $(CXX) $(INCLUDES) $(CXXFLAGS) $(DEFS) $(CPPFLAGS) @@ -154,11 +157,11 @@ xmlwf/xmlwf@EXEEXT@: $(XMLWF_OBJS) $(LIB examples/elements.@OBJEXT@: examples/elements.c examples/elements: examples/elements.@OBJEXT@ $(LIBRARY) - $(LINK_EXE) $< $(LIBRARY) + $(LINK_EXE) examples/elements.@OBJEXT@ $(LIBRARY) examples/outline.@OBJEXT@: examples/outline.c examples/outline: examples/outline.@OBJEXT@ $(LIBRARY) - $(LINK_EXE) $< $(LIBRARY) + $(LINK_EXE) examples/outline.@OBJEXT@ $(LIBRARY) tests/chardata.@OBJEXT@: tests/chardata.c tests/chardata.h tests/minicheck.@OBJEXT@: tests/minicheck.c tests/minicheck.h @@ -180,11 +183,19 @@ tests/xmlts.zip: wget --output-document=tests/xmlts.zip \ http://www.w3.org/XML/Test/xmlts20080827.zip -tests/XML-Test-Suite: tests/xmlts.zip +tests/xmlconf: tests/xmlts.zip cd tests && unzip -q xmlts.zip -run-xmltest: xmlwf/xmlwf@EXEEXT@ tests/XML-Test-Suite - tests/xmltest.sh +run-xmltest: xmlwf/xmlwf@EXEEXT@ tests/xmlconf + tests/xmltest.sh 2>&1 | tee tests/xmltest.log + diff -u tests/xmltest.log.expected tests/xmltest.log + +.PHONY: qa +qa: + ./qa.sh address + ./qa.sh memory + ./qa.sh undefined + ./qa.sh coverage .SUFFIXES: .c .cpp .lo .@OBJEXT@ Modified: head/contrib/expat/README ============================================================================== --- head/contrib/expat/README Fri Jul 1 03:21:51 2016 (r302304) +++ head/contrib/expat/README Fri Jul 1 05:48:45 2016 (r302305) @@ -1,5 +1,5 @@ - Expat, Release 2.1.0 + Expat, Release 2.2.0 This is Expat, a C library for parsing XML, written by James Clark. Expat is a stream-oriented XML parser. This means that you register @@ -114,7 +114,7 @@ Note for Solaris users: The "ar" comman "/usr/ccs/bin", which is not in the default PATH. You will need to add this to your path for the "make" command, and probably also switch to GNU make (the "make" found in /usr/ccs/bin does not seem to work -properly -- appearantly it does not understand .PHONY directives). If +properly -- apparently it does not understand .PHONY directives). If you're using ksh or bash, use this command to build: PATH=/usr/ccs/bin:$PATH make Copied: head/contrib/expat/configure.ac (from r302260, vendor/expat/dist/configure.ac) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/contrib/expat/configure.ac Fri Jul 1 05:48:45 2016 (r302305, copy of r302260, vendor/expat/dist/configure.ac) @@ -0,0 +1,157 @@ +dnl configuration script for expat +dnl Process this file with autoconf to produce a configure script. +dnl +dnl Copyright 2000 Clark Cooper +dnl +dnl This file is part of EXPAT. +dnl +dnl EXPAT is free software; you can redistribute it and/or modify it +dnl under the terms of the License (based on the MIT/X license) contained +dnl in the file COPYING that comes with this distribution. +dnl + +dnl Ensure that Expat is configured with autoconf 2.58 or newer +AC_PREREQ(2.58) + +dnl Get the version number of Expat, using m4's esyscmd() command to run +dnl the command at m4-generation time. This allows us to create an m4 +dnl symbol holding the correct version number. AC_INIT() requires the +dnl version number at m4-time, rather than when ./configure is run, so +dnl all this must happen as part of m4, not as part of the shell code +dnl contained in ./configure. +dnl +dnl NOTE: esyscmd() is a GNU M4 extension. Thus, we wrap it in an appropriate +dnl test. I believe this test will work, but I don't have a place with non- +dnl GNU M4 to test it right now. +define([expat_version], ifdef([__gnu__], + [esyscmd(conftools/get-version.sh lib/expat.h)], + [2.2.x])) +AC_INIT(expat, expat_version, expat-bugs@libexpat.org) +undefine([expat_version]) + +AC_CONFIG_SRCDIR(Makefile.in) +AC_CONFIG_AUX_DIR(conftools) +AC_CONFIG_MACRO_DIR([m4]) + + +dnl +dnl Increment LIBREVISION if source code has changed at all +dnl +dnl If the API has changed, increment LIBCURRENT and set LIBREVISION to 0 +dnl +dnl If the API changes compatibly (i.e. simply adding a new function +dnl without changing or removing earlier interfaces), then increment LIBAGE. +dnl +dnl If the API changes incompatibly set LIBAGE back to 0 +dnl + +LIBCURRENT=7 # sync +LIBREVISION=2 # with +LIBAGE=6 # CMakeLists.txt! + +AC_CONFIG_HEADER(expat_config.h) + +sinclude(conftools/ac_c_bigendian_cross.m4) + +AC_LIBTOOL_WIN32_DLL +AC_PROG_LIBTOOL + +AC_SUBST(LIBCURRENT) +AC_SUBST(LIBREVISION) +AC_SUBST(LIBAGE) + +dnl Checks for programs. +AC_PROG_CC +AC_PROG_CXX +AC_PROG_INSTALL + +if test "$GCC" = yes ; then + dnl + dnl Be careful about adding the -fexceptions option; some versions of + dnl GCC don't support it and it causes extra warnings that are only + dnl distracting; avoid. + dnl + OLDCFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wstrict-prototypes" + CFLAGS="$OLDCFLAGS -fexceptions" + AC_MSG_CHECKING(whether $CC accepts -fexceptions) + AC_TRY_LINK( , , + AC_MSG_RESULT(yes), + AC_MSG_RESULT(no); CFLAGS="$OLDCFLAGS") + if test "x$CXXFLAGS" = x ; then + CXXFLAGS=`echo "$CFLAGS" | sed 's/ -Wmissing-prototypes -Wstrict-prototypes//'` + fi +fi + +dnl Checks for header files. +AC_HEADER_STDC + +dnl Checks for typedefs, structures, and compiler characteristics. + +dnl Note: Avoid using AC_C_BIGENDIAN because it does not +dnl work in a cross compile. +AC_C_BIGENDIAN_CROSS + +AC_C_CONST +AC_TYPE_SIZE_T +AC_CHECK_FUNCS(memmove bcopy) + +dnl Only needed for xmlwf: +AC_CHECK_HEADERS(fcntl.h unistd.h) +AC_TYPE_OFF_T +AC_FUNC_MMAP + +if test "$ac_cv_func_mmap_fixed_mapped" = "yes"; then + FILEMAP=unixfilemap +else + FILEMAP=readfilemap +fi +AC_SUBST(FILEMAP) + +dnl Needed for the test support code; this was found at +dnl http://lists.gnu.org/archive/html/bug-autoconf/2002-07/msg00028.html + +# AC_CPP_FUNC +# ------------------ # +# Checks to see if ANSI C99 CPP variable __func__ works. +# If not, perhaps __FUNCTION__ works instead. +# If not, we'll just define __func__ to "". +AC_DEFUN([AC_CPP_FUNC], +[AC_REQUIRE([AC_PROG_CC_STDC])dnl +AC_CACHE_CHECK([for an ANSI C99-conforming __func__], ac_cv_cpp_func, +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], +[[char *foo = __func__;]])], + [ac_cv_cpp_func=yes], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], +[[char *foo = __FUNCTION__;]])], + [ac_cv_cpp_func=__FUNCTION__], + [ac_cv_cpp_func=no])])]) +if test $ac_cv_cpp_func = __FUNCTION__; then + AC_DEFINE(__func__,__FUNCTION__, + [Define to __FUNCTION__ or "" if `__func__' does not conform to +ANSI C.]) +elif test $ac_cv_cpp_func = no; then + AC_DEFINE(__func__,"", + [Define to __FUNCTION__ or "" if `__func__' does not conform to +ANSI C.]) +fi +])# AC_CPP_FUNC + +AC_CPP_FUNC + + +dnl Some basic configuration: +AC_DEFINE([XML_NS], 1, + [Define to make XML Namespaces functionality available.]) +AC_DEFINE([XML_DTD], 1, + [Define to make parameter entity parsing functionality available.]) +AC_DEFINE([XML_CONTEXT_BYTES], 1024, + [Define to specify how much context to retain around the current parse point.]) + +AC_CONFIG_FILES([Makefile expat.pc]) +AC_OUTPUT + +abs_srcdir="`cd $srcdir && pwd`" +abs_builddir="`pwd`" +if test "$abs_srcdir" != "$abs_builddir"; then + make mkdir-init +fi Modified: head/contrib/expat/doc/expat.png ============================================================================== Binary file (source and/or target). No diff available. Modified: head/contrib/expat/doc/reference.html ============================================================================== --- head/contrib/expat/doc/reference.html Fri Jul 1 03:21:51 2016 (r302304) +++ head/contrib/expat/doc/reference.html Fri Jul 1 05:48:45 2016 (r302305) @@ -2151,8 +2151,12 @@ Helps in preventing DoS attacks based on function behavior. In order to have an effect this must be called before parsing has started. Returns 1 if successful, 0 when called after XML_Parse or XML_ParseBuffer. -

Note: This call is optional, as the parser will auto-generate a new -random salt value if no value has been set at the start of parsing.

+

Note:This call is optional, as the parser will auto-generate +a new random salt value if no value has been set at the start of parsing. +

Note:One should not call XML_SetHashSalt with a +hash salt value of 0, as this value is used as sentinel value to indicate +that XML_SetHashSalt has not been called. Consequently +such a call will have no effect, even if it returns 1.


Modified: head/contrib/expat/doc/xmlwf.1
==============================================================================
--- head/contrib/expat/doc/xmlwf.1	Fri Jul  1 03:21:51 2016	(r302304)
+++ head/contrib/expat/doc/xmlwf.1	Fri Jul  1 05:48:45 2016	(r302305)
@@ -1,33 +1,40 @@
-.\" This manpage has been automatically generated by docbook2man 
-.\" from a DocBook document.  This tool can be found at:
-.\"  
-.\" Please send any bug reports, improvements, comments, patches, 
-.\" etc. to Steve Cheng .
-.TH "XMLWF" "1" "24 January 2003" "" ""
+'\" -*- coding: us-ascii -*-
+.if \n(.g .ds T< \\FC
+.if \n(.g .ds T> \\F[\n[.fam]]
+.de URL
+\\$2 \(la\\$1\(ra\\$3
+..
+.if \n(.g .mso www.tmac
+.TH XMLWF 1 "March 11, 2016" "" ""
 .SH NAME
 xmlwf \- Determines if an XML document is well-formed
 .SH SYNOPSIS
-
-\fBxmlwf\fR [ \fB-s\fR]  [ \fB-n\fR]  [ \fB-p\fR]  [ \fB-x\fR]  [ \fB-e \fIencoding\fB\fR]  [ \fB-w\fR]  [ \fB-d \fIoutput-dir\fB\fR]  [ \fB-c\fR]  [ \fB-m\fR]  [ \fB-r\fR]  [ \fB-t\fR]  [ \fB-v\fR]  [ \fBfile ...\fR] 
-
-.SH "DESCRIPTION"
-.PP
+'nh
+.fi
+.ad l
+\fBxmlwf\fR \kx
+.if (\nx>(\n(.l/2)) .nr x (\n(.l/5)
+'in \n(.iu+\nxu
+[\fB-s\fR] [\fB-n\fR] [\fB-p\fR] [\fB-x\fR] [\fB-e \fIencoding\fB\fR] [\fB-w\fR] [\fB-d \fIoutput-dir\fB\fR] [\fB-c\fR] [\fB-m\fR] [\fB-r\fR] [\fB-t\fR] [\fB-v\fR] [file ...]
+'in \n(.iu-\nxu
+.ad b
+'hy
+.SH DESCRIPTION
 \fBxmlwf\fR uses the Expat library to
-determine if an XML document is well-formed.  It is
+determine if an XML document is well-formed. It is
 non-validating.
 .PP
 If you do not specify any files on the command-line, and you
 have a recent version of \fBxmlwf\fR, the
 input file will be read from standard input.
 .SH "WELL-FORMED DOCUMENTS"
-.PP
 A well-formed document must adhere to the
 following rules:
 .TP 0.2i
 \(bu
-The file begins with an XML declaration.  For instance,
-.
-\fBNOTE:\fR
+The file begins with an XML declaration. For instance,
+\*(T<\*(T>.
+\fINOTE:\fR
 \fBxmlwf\fR does not currently
 check for a valid XML declaration.
 .TP 0.2i
@@ -36,8 +43,8 @@ Every start tag is either empty ()
 or has a corresponding end tag.
 .TP 0.2i
 \(bu
-There is exactly one root element.  This element must contain
-all other elements in the document.  Only comments, white
+There is exactly one root element. This element must contain
+all other elements in the document. Only comments, white
 space, and processing instructions may come after the close
 of the root element.
 .TP 0.2i
@@ -49,39 +56,38 @@ All attribute values are enclosed in quo
 or double).
 .PP
 If the document has a DTD, and it strictly complies with that
-DTD, then the document is also considered \fBvalid\fR.
+DTD, then the document is also considered \fIvalid\fR.
 \fBxmlwf\fR is a non-validating parser --
-it does not check the DTD.  However, it does support
-external entities (see the \fB-x\fR option).
-.SH "OPTIONS"
-.PP
+it does not check the DTD. However, it does support
+external entities (see the \*(T<\fB\-x\fR\*(T> option).
+.SH OPTIONS
 When an option includes an argument, you may specify the argument either
-separately ("\fB-d\fR output") or concatenated with the
-option ("\fB-d\fRoutput").  \fBxmlwf\fR
+separately ("\*(T<\fB\-d\fR\*(T> output") or concatenated with the
+option ("\*(T<\fB\-d\fR\*(T>output"). \fBxmlwf\fR
 supports both.
-.TP
-\fB-c\fR
+.TP 
+\*(T<\fB\-c\fR\*(T>
 If the input file is well-formed and \fBxmlwf\fR
 doesn't encounter any errors, the input file is simply copied to
 the output directory unchanged.
-This implies no namespaces (turns off \fB-n\fR) and
-requires \fB-d\fR to specify an output file.
-.TP
-\fB-d output-dir\fR
+This implies no namespaces (turns off \*(T<\fB\-n\fR\*(T>) and
+requires \*(T<\fB\-d\fR\*(T> to specify an output file.
+.TP 
+\*(T<\fB\-d output\-dir\fR\*(T>
 Specifies a directory to contain transformed
 representations of the input files.
-By default, \fB-d\fR outputs a canonical representation
+By default, \*(T<\fB\-d\fR\*(T> outputs a canonical representation
 (described below).
-You can select different output formats using \fB-c\fR
-and \fB-m\fR.
+You can select different output formats using \*(T<\fB\-c\fR\*(T>
+and \*(T<\fB\-m\fR\*(T>.
 
 The output filenames will
 be exactly the same as the input filenames or "STDIN" if the input is
-coming from standard input.  Therefore, you must be careful that the
+coming from standard input. Therefore, you must be careful that the
 output file does not go into the same directory as the input
-file.  Otherwise, \fBxmlwf\fR will delete the
+file. Otherwise, \fBxmlwf\fR will delete the
 input file before it generates the output file (just like running
-cat < file > file in most shells).
+\*(T file\*(T> in most shells).
 
 Two structurally equivalent XML documents have a byte-for-byte
 identical canonical XML representation.
@@ -89,39 +95,39 @@ Note that ignorable white space is consi
 is treated equivalently to data.
 More on canonical XML can be found at
 http://www.jclark.com/xml/canonxml.html .
-.TP
-\fB-e encoding\fR
+.TP 
+\*(T<\fB\-e encoding\fR\*(T>
 Specifies the character encoding for the document, overriding
-any document encoding declaration.  \fBxmlwf\fR
+any document encoding declaration. \fBxmlwf\fR
 supports four built-in encodings:
-US-ASCII,
-UTF-8,
-UTF-16, and
-ISO-8859-1.
-Also see the \fB-w\fR option.
-.TP
-\fB-m\fR
+\*(T,
+\*(T,
+\*(T, and
+\*(T.
+Also see the \*(T<\fB\-w\fR\*(T> option.
+.TP 
+\*(T<\fB\-m\fR\*(T>
 Outputs some strange sort of XML file that completely
 describes the input file, including character positions.
-Requires \fB-d\fR to specify an output file.
-.TP
-\fB-n\fR
-Turns on namespace processing.  (describe namespaces)
-\fB-c\fR disables namespaces.
-.TP
-\fB-p\fR
+Requires \*(T<\fB\-d\fR\*(T> to specify an output file.
+.TP 
+\*(T<\fB\-n\fR\*(T>
+Turns on namespace processing. (describe namespaces)
+\*(T<\fB\-c\fR\*(T> disables namespaces.
+.TP 
+\*(T<\fB\-p\fR\*(T>
 Tells xmlwf to process external DTDs and parameter
 entities.
 
 Normally \fBxmlwf\fR never parses parameter
-entities.  \fB-p\fR tells it to always parse them.
-\fB-p\fR implies \fB-x\fR.
-.TP
-\fB-r\fR
+entities. \*(T<\fB\-p\fR\*(T> tells it to always parse them.
+\*(T<\fB\-p\fR\*(T> implies \*(T<\fB\-x\fR\*(T>.
+.TP 
+\*(T<\fB\-r\fR\*(T>
 Normally \fBxmlwf\fR memory-maps the XML file
 before parsing; this can result in faster parsing on many
 platforms.
-\fB-r\fR turns off memory-mapping and uses normal file
+\*(T<\fB\-r\fR\*(T> turns off memory-mapping and uses normal file
 IO calls instead.
 Of course, memory-mapping is automatically turned off
 when reading from standard input.
@@ -131,34 +137,33 @@ substantially higher memory usage for
 \fBxmlwf\fR, but this appears to be a matter of
 the operating system reporting memory in a strange way; there is
 not a leak in \fBxmlwf\fR.
-.TP
-\fB-s\fR
+.TP 
+\*(T<\fB\-s\fR\*(T>
 Prints an error if the document is not standalone. 
 A document is standalone if it has no external subset and no
 references to parameter entities.
-.TP
-\fB-t\fR
-Turns on timings.  This tells Expat to parse the entire file,
+.TP 
+\*(T<\fB\-t\fR\*(T>
+Turns on timings. This tells Expat to parse the entire file,
 but not perform any processing.
 This gives a fairly accurate idea of the raw speed of Expat itself
 without client overhead.
-\fB-t\fR turns off most of the output options
-(\fB-d\fR, \fB-m\fR, \fB-c\fR,
-\&...).
-.TP
-\fB-v\fR
+\*(T<\fB\-t\fR\*(T> turns off most of the output options
+(\*(T<\fB\-d\fR\*(T>, \*(T<\fB\-m\fR\*(T>, \*(T<\fB\-c\fR\*(T>, ...).
+.TP 
+\*(T<\fB\-v\fR\*(T>
 Prints the version of the Expat library being used, including some
 information on the compile-time configuration of the library, and
 then exits.
-.TP
-\fB-w\fR
+.TP 
+\*(T<\fB\-w\fR\*(T>
 Enables support for Windows code pages.
 Normally, \fBxmlwf\fR will throw an error if it
-runs across an encoding that it is not equipped to handle itself.  With
-\fB-w\fR, xmlwf will try to use a Windows code
-page.  See also \fB-e\fR.
-.TP
-\fB-x\fR
+runs across an encoding that it is not equipped to handle itself. With
+\*(T<\fB\-w\fR\*(T>, xmlwf will try to use a Windows code
+page. See also \*(T<\fB\-e\fR\*(T>.
+.TP 
+\*(T<\fB\-x\fR\*(T>
 Turns on parsing external entities.
 
 Non-validating parsers are not required to resolve external
@@ -172,80 +177,75 @@ data from outside the XML file currently
 This is an example of an internal entity:
 
 .nf
+
 
 .fi
 
 And here are some examples of external entities:
 
 .nf
-  (parsed)
+
+  (parsed)
          (unparsed)
 .fi
-.TP
-\fB--\fR
+.TP 
+\*(T<\fB\-\-\fR\*(T>
 (Two hyphens.)
-Terminates the list of options.  This is only needed if a filename
-starts with a hyphen.  For example:
+Terminates the list of options. This is only needed if a filename
+starts with a hyphen. For example:
 
 .nf
-xmlwf -- -myfile.xml
+
+xmlwf \-\- \-myfile.xml
 .fi
 
 will run \fBxmlwf\fR on the file
-\fI-myfile.xml\fR.
+\*(T<\fI\-myfile.xml\fR\*(T>.
 .PP
 Older versions of \fBxmlwf\fR do not support
 reading from standard input.
-.SH "OUTPUT"
-.PP
+.SH OUTPUT
 If an input file is not well-formed,
 \fBxmlwf\fR prints a single line describing
-the problem to standard output.  If a file is well formed,
+the problem to standard output. If a file is well formed,
 \fBxmlwf\fR outputs nothing.
-Note that the result code is \fBnot\fR set.
-.SH "BUGS"
-.PP
-According to the W3C standard, an XML file without a
-declaration at the beginning is not considered well-formed.
-However, \fBxmlwf\fR allows this to pass.
-.PP
+Note that the result code is \fInot\fR set.
+.SH BUGS
 \fBxmlwf\fR returns a 0 - noerr result,
-even if the file is not well-formed.  There is no good way for
+even if the file is not well-formed. There is no good way for
 a program to use \fBxmlwf\fR to quickly
 check a file -- it must parse \fBxmlwf\fR's
 standard output.
 .PP
 The errors should go to standard error, not standard output.
 .PP
-There should be a way to get \fB-d\fR to send its
+There should be a way to get \*(T<\fB\-d\fR\*(T> to send its
 output to standard output rather than forcing the user to send
 it to a file.
 .PP
 I have no idea why anyone would want to use the
-\fB-d\fR, \fB-c\fR, and
-\fB-m\fR options.  If someone could explain it to
+\*(T<\fB\-d\fR\*(T>, \*(T<\fB\-c\fR\*(T>, and
+\*(T<\fB\-m\fR\*(T> options. If someone could explain it to
 me, I'd like to add this information to this manpage.
-.SH "ALTERNATIVES"
-.PP
+.SH ALTERNATIVES
 Here are some XML validators on the web:
 
 .nf
-http://www.hcrc.ed.ac.uk/~richard/xml-check.html
+
+http://www.hcrc.ed.ac.uk/~richard/xml\-check.html
 http://www.stg.brown.edu/service/xmlvalid/
 http://www.scripting.com/frontier5/xml/code/xmlValidator.html
 http://www.xml.com/pub/a/tools/ruwf/check.html
 .fi
 .SH "SEE ALSO"
-.PP
-
 .nf
+
 The Expat home page:        http://www.libexpat.org/
-The W3 XML specification:   http://www.w3.org/TR/REC-xml
+The W3 XML specification:   http://www.w3.org/TR/REC\-xml
 .fi
-.SH "AUTHOR"
-.PP
-This manual page was written by Scott Bronson  for
-the Debian GNU/Linux system (but may be used by others).  Permission is
+.SH AUTHOR
+This manual page was written by Scott Bronson <\*(T> for
+the Debian GNU/Linux system (but may be used by others). Permission is
 granted to copy, distribute and/or modify this document under
 the terms of the GNU Free Documentation
 License, Version 1.1.

Copied: head/contrib/expat/doc/xmlwf.xml (from r302260, vendor/expat/dist/doc/xmlwf.xml)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/contrib/expat/doc/xmlwf.xml	Fri Jul  1 05:48:45 2016	(r302305, copy of r302260, vendor/expat/dist/doc/xmlwf.xml)
@@ -0,0 +1,440 @@
+
+  Scott">
+  Bronson">
+  
+  March 11, 2016">
+  
+  1">
+  bronson@rinspin.com">
+  
+  XMLWF">
+  
+
+  Debian GNU/Linux">
+  GNU">
+]>
+
+
+  
+    
+ &dhemail; +
+ + &dhfirstname; + &dhsurname; + + + 2001 + &dhusername; + + &dhdate; +
+ + &dhucpackage; + + &dhsection; + + + &dhpackage; + + Determines if an XML document is well-formed + + + + &dhpackage; + + + + + + + + + + + + + + + + + + file ... + + + + + DESCRIPTION + + + &dhpackage; uses the Expat library to + determine if an XML document is well-formed. It is + non-validating. + + + + If you do not specify any files on the command-line, and you + have a recent version of &dhpackage;, the + input file will be read from standard input. + + + + + + WELL-FORMED DOCUMENTS + + + A well-formed document must adhere to the + following rules: + + + + + The file begins with an XML declaration. For instance, + <?xml version="1.0" standalone="yes"?>. + NOTE: + &dhpackage; does not currently + check for a valid XML declaration. + + + Every start tag is either empty (<tag/>) + or has a corresponding end tag. + + + There is exactly one root element. This element must contain + all other elements in the document. Only comments, white + space, and processing instructions may come after the close + of the root element. + + + All elements nest properly. + + + All attribute values are enclosed in quotes (either single + or double). + + + + + If the document has a DTD, and it strictly complies with that + DTD, then the document is also considered valid. + &dhpackage; is a non-validating parser -- + it does not check the DTD. However, it does support + external entities (see the option). + + + + + OPTIONS + + +When an option includes an argument, you may specify the argument either +separately (" output") or concatenated with the +option ("output"). &dhpackage; +supports both. + + + + + + + + + If the input file is well-formed and &dhpackage; + doesn't encounter any errors, the input file is simply copied to + the output directory unchanged. + This implies no namespaces (turns off ) and + requires to specify an output file. + + + + + + + + + Specifies a directory to contain transformed + representations of the input files. + By default, outputs a canonical representation + (described below). + You can select different output formats using + and . + + + The output filenames will + be exactly the same as the input filenames or "STDIN" if the input is + coming from standard input. Therefore, you must be careful that the + output file does not go into the same directory as the input + file. Otherwise, &dhpackage; will delete the + input file before it generates the output file (just like running + cat < file > file in most shells). + + + Two structurally equivalent XML documents have a byte-for-byte + identical canonical XML representation. + Note that ignorable white space is considered significant and + is treated equivalently to data. + More on canonical XML can be found at + http://www.jclark.com/xml/canonxml.html . + + + + + + + + + Specifies the character encoding for the document, overriding + any document encoding declaration. &dhpackage; + supports four built-in encodings: + US-ASCII, + UTF-8, + UTF-16, and + ISO-8859-1. + Also see the option. + + + + + + + + + Outputs some strange sort of XML file that completely + describes the input file, including character positions. + Requires to specify an output file. + + + + + + + + + Turns on namespace processing. (describe namespaces) + disables namespaces. + + + + + + + + + Tells xmlwf to process external DTDs and parameter + entities. + + + Normally &dhpackage; never parses parameter + entities. tells it to always parse them. + implies . + + + + + + + + + Normally &dhpackage; memory-maps the XML file + before parsing; this can result in faster parsing on many + platforms. + turns off memory-mapping and uses normal file + IO calls instead. + Of course, memory-mapping is automatically turned off + when reading from standard input. + + + Use of memory-mapping can cause some platforms to report + substantially higher memory usage for + &dhpackage;, but this appears to be a matter of + the operating system reporting memory in a strange way; there is + not a leak in &dhpackage;. + + + + + + + + + Prints an error if the document is not standalone. + A document is standalone if it has no external subset and no + references to parameter entities. + *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@freebsd.org Fri Jul 1 07:27:34 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2EACDB8E4D7; Fri, 1 Jul 2016 07:27:34 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 00E732609; Fri, 1 Jul 2016 07:27:33 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u617RXUt059934; Fri, 1 Jul 2016 07:27:33 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u617RXbN059933; Fri, 1 Jul 2016 07:27:33 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201607010727.u617RXbN059933@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Fri, 1 Jul 2016 07:27:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302306 - head/sys/dev/usb/controller X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Fri, 01 Jul 2016 07:27:34 -0000 Author: hselasky Date: Fri Jul 1 07:27:33 2016 New Revision: 302306 URL: https://svnweb.freebsd.org/changeset/base/302306 Log: Fix detection of USB device disconnects in USB host mode when the USB device is connected directly to the USB port of the DWC OTG, in this case a RPI-zero. PR: 210695 Approved by: re (gjb) MFC after: 1 week Modified: head/sys/dev/usb/controller/dwc_otg.c Modified: head/sys/dev/usb/controller/dwc_otg.c ============================================================================== --- head/sys/dev/usb/controller/dwc_otg.c Fri Jul 1 05:48:45 2016 (r302305) +++ head/sys/dev/usb/controller/dwc_otg.c Fri Jul 1 07:27:33 2016 (r302306) @@ -2985,7 +2985,8 @@ dwc_otg_interrupt(void *arg) else sc->sc_flags.status_bus_reset = 0; - if (hprt & HPRT_PRTENCHNG) + if ((hprt & HPRT_PRTENCHNG) && + (hprt & HPRT_PRTENA) == 0) sc->sc_flags.change_enabled = 1; if (hprt & HPRT_PRTENA) @@ -4745,6 +4746,8 @@ tr_handle_get_port_status: value = 0; + if (sc->sc_flags.change_enabled) + value |= UPS_C_PORT_ENABLED; if (sc->sc_flags.change_connect) value |= UPS_C_CONNECT_STATUS; if (sc->sc_flags.change_suspend) From owner-svn-src-head@freebsd.org Fri Jul 1 08:54:57 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E9CBDB87CB2; Fri, 1 Jul 2016 08:54:57 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail105.syd.optusnet.com.au (mail105.syd.optusnet.com.au [211.29.132.249]) by mx1.freebsd.org (Postfix) with ESMTP id 915422AB1; Fri, 1 Jul 2016 08:54:57 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from besplex.bde.org (c110-21-100-149.carlnfd1.nsw.optusnet.com.au [110.21.100.149]) by mail105.syd.optusnet.com.au (Postfix) with ESMTPS id 371A01045278; Fri, 1 Jul 2016 18:54:48 +1000 (AEST) Date: Fri, 1 Jul 2016 18:54:47 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Konstantin Belousov cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r302252 - head/sys/kern In-Reply-To: <20160630180106.GU38613@kib.kiev.ua> Message-ID: <20160701160438.U1233@besplex.bde.org> References: <201606281643.u5SGhNsi061606@repo.freebsd.org> <20160629175917.O968@besplex.bde.org> <20160629145443.GG38613@kib.kiev.ua> <20160629153233.GI38613@kib.kiev.ua> <20160630040123.F791@besplex.bde.org> <20160629211953.GK38613@kib.kiev.ua> <20160701005401.Q1084@besplex.bde.org> <20160630180106.GU38613@kib.kiev.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=EfU1O6SC c=1 sm=1 tr=0 a=XDAe9YG+7EcdVXYrgT+/UQ==:117 a=XDAe9YG+7EcdVXYrgT+/UQ==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=zejX9Yh8_zp2-627HP4A:9 a=sE8r4AzeOeev_3Q_:21 a=1KXmKgoS2apXmfzf:21 a=CjuIK1q_8ugA:10 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Fri, 01 Jul 2016 08:54:58 -0000 On Thu, 30 Jun 2016, Konstantin Belousov wrote: > On Fri, Jul 01, 2016 at 03:30:41AM +1000, Bruce Evans wrote: >> On Thu, 30 Jun 2016, Konstantin Belousov wrote: >> >>> On Thu, Jun 30, 2016 at 05:47:39AM +1000, Bruce Evans wrote: >>>> On Wed, 29 Jun 2016, Konstantin Belousov wrote: >>>> >>>>> On Wed, Jun 29, 2016 at 05:54:43PM +0300, Konstantin Belousov wrote: >>>>>> As an additional, but probably excessive measure, invocation of >>>>>> tc_windup() from hardclock could ask the setclock() to re-execute >>>>>> tc_windup() after its call is done. >>>> >>>> I don't quite understand this. hardclock -> tc_windup() normally doesn't >>>> have interference from tc_setclock(). >>> In what sense it does not have interference ? tc_windup() may be executed >>> from hardclock/hardclock_cnt (low half) and concurrently from setclock() >>> (top half). And this is exactly what we want to avoid, isn't it ? >> >> Ues, but you seemed to be saying that hardclock should schedule or call >> tc_setclock(). That makes no sense. So I thought that you meant >> tc_setclock() calling or scheduling tc_windup() in a different way than >> it does now (it just calls it now). > More precisely, I mean that hardclock, when not able to execute tc_windup() > due to the top-half currently executing tc_windup(), may ask top-half to > re-execute tc_windup() (and not tc_setclock()) once the current invocation > finishes. I see. I think that is unnecessary. tc_windup() from from the quasi-periodic hardclock() just needs to be called often enough to keep the timecounters from overflowing, but not so often as to expose races or inefficiencies by cycling through the timehands too rapidly. So if there are problems with the extra calls from tc_setclock(), then it is the case where the lock is contended that is least harmful! In that case, the call from tc_setclock() replaces a call from hardclock() with the same timing to within a few nanoseconds. We might have problems in other cases: - malicous/stress-testing calls to settime() cause rapid cycling of the timehands. Hopefully we fixed the races exposed by this last year. You are now reducing the number of timehands to 2. This runs the races more often. But if the fixes work, then even 1 timehands should work. The multiple timehands are just an optimization that works by increasing the chance that biuptime() and friends don't have to wait for a usable timehands. - on idle systems, tickless kernels are close to not calling tc_windup() enough to keep the timecounters from overflowing. I use HZ = 100 and this gives only 20-30 timer interrupts/second. The TSC timecounter at 4 GHz would overflow after 1 second, and the bogus TSC-low timecounter at 2 GHz overflows after 2 seconds. Other timecounters might have overflow in less than 1 second, or tickless kernels might get closer to actually tickless and give only 1 timer interrupt every few seconds on idle systems. Suspended systems give no timer interrupts, and the resume code for restarting the timecounter isn't quite right. - on idle systems, after coming out of idle, IIRC the timer code delivers virtual ticks to the timercounter and other subsystems. This also isn't quite right. It risks rapidly cycling through the timehands. It is better than for restarting for resume. In both cases, whenever the sleep interval is so long that timecounter state is lost by stopping or wrapping, the timecounter should be reset. The length of the sleep interval must be determined using another timer if the timecounter stops or wraps. >>> *... >>>>> + for (;;) { >>>>> + if (atomic_cmpset_int(&tc_windup_lock, 0, 1)) { >>>>> + atomic_thread_fence_acq(); >>>>> + tc_windup_locked(); >>>>> + atomic_store_rel_int(&tc_windup_lock, 0); >>>>> + break; >>>>> + } else if (!top_call) { >>>>> + break; >>>>> + } >>>>> + } >>>>> } >>>> >>>> I like to write optimized locking like that, but don't see why you >>>> want it here. >>> Because I do not want the fast clock interrupt handler to wait on lock, >>> which neccessary becomes spinlock. The ntp_lock is bad enough already. >>> What I coded above is not real lock. In contention case it bails out, >>> so there is no blocking. In particular, witness is not relevant to it. >> >> I think this is too complicated. Spinlocks aren't very expensive, and >> hardclock() already has some. I think it has several. It has at least >> one silly one -- in hardclock_cpu(), a thread locking to lock a single >> flags update. hardclock() and tc_windup() just aren't called enough >> for the locking overhead or contention to matter, even at too-large hz. > Spinlocks are quite expensive. They delay interrupt delivery. > I do not want the fast interrupt handler to be delayed due to the top-half > of the kernel executing settimeofday(2) in loop. I still think it is too complicated. Malicious/stress-testing users can easily find many other denial of service attacks involving mutexes, without needing root privilege like settimeofday(). Just using time syscalls, there is a thread_lock() (not on curthread(?)) in get_thread_cputme(). Thread locking doesn't have much contention but it does use spinlocks so it delays fast interrupts much the same as a general spinlock, especially in the UP case. I counted spinlocks and instructions in the "fast" clock interrupt handler. There aren't many spinlocks, but there are too many instructions to be fast: -current my-5.2 Xtimerint 10k-50k - clkintr - 896 hardclock 1091 842 (later counts are included in callers) tc_windup 987 693 __udivdi3 498 422 timehands_update 163 - -current is on i386 with an SMP kernel but on a 4x2 core system reduced to 1x1 since tracing is too broken to work with multiple cores (the multiple core are hard to control, and bugs cause crashes). my-5.2 is on i386 with a UP kernel on a 1x1 core system. Xtimerint is a "fast" interrupt handler. clkintr is a normal interrupt handler scheduled by a fast interrupt handler since the locking for a fast timer interrupt handler is too hard to get right. So the times for all the timer interrupt handling that is now done by Xtimerint are unavailable in ~5.2. They are even larger -- much more for context switches. tc_windup takes 30% more instructions in -current for not completely obvious reasons. 50-60% of the overhead is for a pessimized division, and somehow the compiler pessimizes this even better in -current than in 5.2 (using old gcc instead of older gcc). The division is 64/64 -> 64 bits. On amd64, this would be a single instruction, but on i386 the libcall is used. The pessimizations are: - the divisor (tc_frequency) is 64 bits, but for all supported timecounters it only needs 32 bits. My CPU can be overclocked to need 33 bits for the TSC timecounter, but the only the bogus TSC-low timecounter is available, partly to avoid needing the 33rd bit - i386 has a 64/32 -> 32 bit division instruction which can handle all the 32-bit divisors that can occur, but no one ever bother to optimize __udivdi3 to use this, so the full 64-bit division is always done. __udivdi3 shows up in other instruction traces. This is annoying but doesn't really matter since it is not called very often. >>> cpu_tick_calibrate(1); >>> nanotime(&tbef); >>> timespec2bintime(ts, &bt); >>> @@ -1247,8 +1252,10 @@ tc_setclock(struct timespec *ts) >>> bintime2timeval(&bt, &boottime); >> >> The leap second update to boottimebin in tc_windup() races with the >> update to boottimebin here. This can be fixed partially by using the >> same locking there. Then the locking would have to be a spin mutex >> (or special). This still doesn't fix non-atomic accesses to boottimebin >> in nanotime() and friends. Putting it in timehands seems to be best for >> fixing that. > Yes, timehands for bootimebin should be the solution, but > not in the scope of this patch. I will work on this right after the > current changeset lands in svn. You wrote the patch faster than I can reply :-). >> boottime is easier to fix (and doesn't need to be in timehands). It >> is only used to copy it out in a historical sysctl. The locking for >> that is buggy. We convert boottimebin to boottime here (now with locking) >> but in the sysctl we copy out boottime non-atomically. > Do we need boottime at all ? Can't it be calculated from boottimebin > on the sysctl invocation ? Later calculation is cleaner and probably easier with correct locking. boottime should be invariant after initialization. The invariant copy doesn't need any locking, except to initialize it. With our fuzzy/broken boottime, boottime has an error of about 1 seconds initially and later. Errors from races in not locking it are at most 1 second (except with 32-bit time they are 2**32 during a 1-second race in 2038). So null locking is good enough. The first write to the RTC in the ntp callout is a good place to freeze boottime so that it is invariant. I think that only applications doing buggy calculations of the current real time like 'now = boottime + CLOCK_UPTIME_time' would be broken further by fixing boottime. uptime(1) used to do the reverse of this calculation. It now uses CLOCK_UPTIME_time directly. This would work if CLOCK_UPTIME worked. Both CLOCK_UPTIME and CLOCK_MONOTONIC fail to count the time while the system is suspended, and have relatively minor errors for some clock drifts. Bruce From owner-svn-src-head@freebsd.org Fri Jul 1 10:39:58 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BFADCB89F04; Fri, 1 Jul 2016 10:39:58 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail107.syd.optusnet.com.au (mail107.syd.optusnet.com.au [211.29.132.53]) by mx1.freebsd.org (Postfix) with ESMTP id 71686288D; Fri, 1 Jul 2016 10:39:58 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from besplex.bde.org (c110-21-100-149.carlnfd1.nsw.optusnet.com.au [110.21.100.149]) by mail107.syd.optusnet.com.au (Postfix) with ESMTPS id 1ED07D48CAF; Fri, 1 Jul 2016 20:39:49 +1000 (AEST) Date: Fri, 1 Jul 2016 20:39:48 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Konstantin Belousov cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r302252 - head/sys/kern In-Reply-To: <20160701031549.GV38613@kib.kiev.ua> Message-ID: <20160701185743.Q1600@besplex.bde.org> References: <201606281643.u5SGhNsi061606@repo.freebsd.org> <20160629175917.O968@besplex.bde.org> <20160629145443.GG38613@kib.kiev.ua> <20160629153233.GI38613@kib.kiev.ua> <20160630040123.F791@besplex.bde.org> <20160629211953.GK38613@kib.kiev.ua> <20160701005401.Q1084@besplex.bde.org> <20160630180106.GU38613@kib.kiev.ua> <20160701031549.GV38613@kib.kiev.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=EfU1O6SC c=1 sm=1 tr=0 a=XDAe9YG+7EcdVXYrgT+/UQ==:117 a=XDAe9YG+7EcdVXYrgT+/UQ==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=pR1UwPydhmiD0_zUYnMA:9 a=x9fn74RsOB4bHPEa:21 a=fkw4OJNAAa02I7wV:21 a=CjuIK1q_8ugA:10 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Fri, 01 Jul 2016 10:39:58 -0000 On Fri, 1 Jul 2016, Konstantin Belousov wrote: > On Thu, Jun 30, 2016 at 09:01:06PM +0300, Konstantin Belousov wrote: >> Yes, timehands for bootimebin should be the solution, but >> not in the scope of this patch. I will work on this right after the >> current changeset lands in svn. > > Well, there is the move of boottimebin into timehands. I also reduced > the number of timehands to two, this was discussed many times before. > The feed-forward code is probably broken right now, I did not even > compile it. That was fast. It seems simple and clean enough, but is too much during a re freeze. I will only make some minor comments about style. > diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c > index 56b2ade..a0dce47 100644 > --- a/sys/compat/linprocfs/linprocfs.c > +++ b/sys/compat/linprocfs/linprocfs.c > @@ -447,9 +447,11 @@ linprocfs_dostat(PFS_FILL_ARGS) > struct pcpu *pcpu; > long cp_time[CPUSTATES]; > long *cp; > + struct timeval boottime; > int i; > > read_cpu_time(cp_time); > + getboottime(&boottime); This is used surprisingly often by too many subsystems. With the value still broken so that locking it doesn't help much, I would leave it as a global. > diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c > index 0f015b3..1c2d562 100644 > --- a/sys/kern/kern_tc.c > +++ b/sys/kern/kern_tc.c > @@ -70,31 +70,36 @@ struct timehands { > ... > -static struct timehands th9 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th0}; > ... > +static struct timehands th1 = { > + .th_counter = NULL, > + .th_adjustment = 0, > + .th_scale = 0, > + .th_offset_count = 0, > + .th_offset = {0, 0}, > + .th_microtime = {0, 0}, > + .th_nanotime = {0, 0}, > + .th_boottime = {0, 0}, > + .th_generation = 0, > + .th_next = &th0 > +}; This shouldn't spell out all the 0 initializers. That was only needed to reach the non-0 initializer at the end of the initializer. > static struct timehands th0 = { > - &dummy_timecounter, > - 0, > - (uint64_t)-1 / 1000000, > - 0, > - {1, 0}, > - {0, 0}, > - {0, 0}, > - 1, > - &th1 > + .th_counter = &dummy_timecounter, > + .th_adjustment = 0, > + .th_scale = (uint64_t)-1 / 1000000, > + .th_offset_count = 0, > + .th_offset = {1, 0}, > + .th_microtime = {0, 0}, > + .th_nanotime = {0, 0}, > + .th_boottime = {0, 0}, > + .th_generation = 1, > + .th_next = &th1 > }; > @@ -135,14 +138,22 @@ SYSCTL_PROC(_kern_timecounter, OID_AUTO, alloweddeviation, > ... > static int > sysctl_kern_boottime(SYSCTL_HANDLER_ARGS) > { > + struct bintime boottimebin; > + struct timeval boottime; > + > + binuptime1(NULL, &boottimebin); > + bintime2timeval(&boottimebin, &boottime); Use the wrapper function getboottime() if you keep it. > @@ -342,8 +365,8 @@ fbclock_getmicrotime(struct timeval *tvp) > } while (gen == 0 || gen != th->th_generation); > } > #else /* !FFCLOCK */ > -void > -binuptime(struct bintime *bt) > +static void > +binuptime1(struct bintime *bt, struct bintime *boottimebin) > { > struct timehands *th; > u_int gen; > @@ -351,13 +374,24 @@ binuptime(struct bintime *bt) > do { > th = timehands; > gen = atomic_load_acq_int(&th->th_generation); > - *bt = th->th_offset; > - bintime_addx(bt, th->th_scale * tc_delta(th)); > + if (bt != NULL) { > + *bt = th->th_offset; > + bintime_addx(bt, th->th_scale * tc_delta(th)); > + } > + if (boottimebin != NULL) > + *boottimebin = th->th_boottime; > atomic_thread_fence_acq(); > } while (gen == 0 || gen != th->th_generation); > } > > void > +binuptime(struct bintime *bt) > +{ > + > + binuptime1(bt, NULL); > +} Uptime functions don't use boottimebin, so it is ugly for the general binuptime1() function to return it. This is also pessimal. Maybe the compiler can optimize away the boottimebin == NULL case for the uptime functions, but none of the functions is explicitly inlined. I like functions not being inlined when this is not explicit. gcc only inlines ones that are static and called once. I don't like this, and turn it off using -fno-inline-functions-called-once. clang is too broken to support this flag. So maybe use a new general function that returns boottimebin for the non-uptime functions only. Possibly it can add the offset directly. > @@ -1116,8 +1170,10 @@ sysclock_snap2bintime(struct sysclock_snap *cs, struct bintime *bt, > if (cs->delta > 0) > bintime_addx(bt, cs->fb_info.th_scale * cs->delta); > > - if ((flags & FBCLOCK_UPTIME) == 0) > + if ((flags & FBCLOCK_UPTIME) == 0) { > + binuptime1(NULL, &boottimebin); Perhaps use a more direct way to get boottimebin(). binuptime1() is pessimized by null pointer checks for both its args. Use the new function getboottimebin() even if is not direct. > ... > diff --git a/sys/net/bpf.c b/sys/net/bpf.c > index 3b12cf4..4251f71 100644 > --- a/sys/net/bpf.c > +++ b/sys/net/bpf.c > @@ -2328,12 +2328,13 @@ bpf_hdrlen(struct bpf_d *d) > static void > bpf_bintime2ts(struct bintime *bt, struct bpf_ts *ts, int tstype) > { > - struct bintime bt2; > + struct bintime bt2, boottimebin; > struct timeval tsm; > struct timespec tsn; > > if ((tstype & BPF_T_MONOTONIC) == 0) { > bt2 = *bt; > + getboottimebin(&boottimebin); > bintime_add(&bt2, &boottimebin); > bt = &bt2; > } This is still too chummy with the (mis)implementation. I think it is to convert a relative CLOCK_MONOTONIC time to an absolute CLOCK_REALTIME time. That should be done in the time subsystem. It is unclear if we care about strict real time with leap seconds adjustments. BPF_T_MONOTONIC is not documented in any man page or used in any library or applicatiion in /usr/src. BPF_T_BINTIME is documented bpf(4) but not used in any library or application in /usr/src. Similarly for all of BPF_T_*. contrib/libpcap has 47 lines matching timeval, 2 matching timespec and 0 matching bintime. > diff --git a/sys/netpfil/ipfw/ip_fw_sockopt.c b/sys/netpfil/ipfw/ip_fw_sockopt.c > index d186ba5..7faf99f 100644 > --- a/sys/netpfil/ipfw/ip_fw_sockopt.c > +++ b/sys/netpfil/ipfw/ip_fw_sockopt.c > @@ -395,6 +395,7 @@ swap_map(struct ip_fw_chain *chain, struct ip_fw **new_map, int new_len) > static void > export_cntr1_base(struct ip_fw *krule, struct ip_fw_bcounter *cntr) > { > + struct timeval boottime; > > cntr->size = sizeof(*cntr); > > @@ -403,21 +404,26 @@ export_cntr1_base(struct ip_fw *krule, struct ip_fw_bcounter *cntr) > cntr->bcnt = counter_u64_fetch(krule->cntr + 1); > cntr->timestamp = krule->timestamp; > } > - if (cntr->timestamp > 0) > + if (cntr->timestamp > 0) { > + getboottime(&boottime); > cntr->timestamp += boottime.tv_sec; > + } > } Looks like another home made conversion from CLOCK_MONOTONIC to CLOCK_REALTIME. Easier to understand since it is actually used. ipfw seems to use only getmicrouptime() for timestamping. There are good reasons for using monotonic time for everything except presenting the time to the user and the conversion for that should be more careful than the above. > diff --git a/sys/nfs/nfs_lock.c b/sys/nfs/nfs_lock.c > index 7d11672..c84413e 100644 > --- a/sys/nfs/nfs_lock.c > +++ b/sys/nfs/nfs_lock.c > @@ -241,6 +241,7 @@ nfs_dolock(struct vop_advlock_args *ap) > struct flock *fl; > struct proc *p; > struct nfsmount *nmp; > + struct timeval boottime; > > td = curthread; > p = td->td_proc; > @@ -284,6 +285,7 @@ nfs_dolock(struct vop_advlock_args *ap) > p->p_nlminfo = malloc(sizeof(struct nlminfo), > M_NLMINFO, M_WAITOK | M_ZERO); > p->p_nlminfo->pid_start = p->p_stats->p_start; > + getboottime(&boottime); > timevaladd(&p->p_nlminfo->pid_start, &boottime); > } > msg.lm_msg_ident.pid_start = p->p_nlminfo->pid_start; Looks like most uses of boottime are for this buggy addition. I would only trust it for telling the user the boot time, though it is broken for that too. > diff --git a/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c b/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c > index 1d07943..0879299 100644 > --- a/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c > +++ b/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c > @@ -504,11 +504,13 @@ svc_rpc_gss_find_client(struct svc_rpc_gss_clientid *id) > { > struct svc_rpc_gss_client *client; > struct svc_rpc_gss_client_list *list; > + struct timeval boottime; > unsigned long hostid; > > rpc_gss_log_debug("in svc_rpc_gss_find_client(%d)", id->ci_id); > > getcredhostid(curthread->td_ucred, &hostid); > + getboottime(&boottime); > if (id->ci_hostid != hostid || id->ci_boottime != boottime.tv_sec) > return (NULL); Here it is hopefully just a magic id, with the user being a remote system. Any time that doesn't go backwards or forwards so far that it is in the lieftime of an old or new boot instance works well for identifying the boot instance. Bruce From owner-svn-src-head@freebsd.org Fri Jul 1 14:25:31 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 82232B88F31; Fri, 1 Jul 2016 14:25:31 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 02EB720A9; Fri, 1 Jul 2016 14:25:30 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u61EPHxW089967 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Fri, 1 Jul 2016 17:25:17 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u61EPHxW089967 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id u61EPGgK089963; Fri, 1 Jul 2016 17:25:16 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 1 Jul 2016 17:25:16 +0300 From: Konstantin Belousov To: Bruce Evans Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r302252 - head/sys/kern Message-ID: <20160701142516.GW38613@kib.kiev.ua> References: <201606281643.u5SGhNsi061606@repo.freebsd.org> <20160629175917.O968@besplex.bde.org> <20160629145443.GG38613@kib.kiev.ua> <20160629153233.GI38613@kib.kiev.ua> <20160630040123.F791@besplex.bde.org> <20160629211953.GK38613@kib.kiev.ua> <20160701005401.Q1084@besplex.bde.org> <20160630180106.GU38613@kib.kiev.ua> <20160701031549.GV38613@kib.kiev.ua> <20160701185743.Q1600@besplex.bde.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160701185743.Q1600@besplex.bde.org> User-Agent: Mutt/1.6.1 (2016-04-27) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Fri, 01 Jul 2016 14:25:31 -0000 On Fri, Jul 01, 2016 at 08:39:48PM +1000, Bruce Evans wrote: > It seems simple and clean enough, but is too much during a re freeze. > > I will only make some minor comments about style. Well, it is not only about style. If you have no more comments, I will ask for testing. The patch is about fixing bugs, although in somewhat extended scope, so I think it is still fine as the things do not explode. I added the stats to the patch, it is not that intrusive actually. I still do not see why/do not want to use spinlock for the tc_windup() exclusion. Patch is at the end of the message. > > > diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c > > index 56b2ade..a0dce47 100644 > > --- a/sys/compat/linprocfs/linprocfs.c > > +++ b/sys/compat/linprocfs/linprocfs.c > > @@ -447,9 +447,11 @@ linprocfs_dostat(PFS_FILL_ARGS) > > struct pcpu *pcpu; > > long cp_time[CPUSTATES]; > > long *cp; > > + struct timeval boottime; > > int i; > > > > read_cpu_time(cp_time); > > + getboottime(&boottime); > > This is used surprisingly often by too many subsystems. With the value still > broken so that locking it doesn't help much, I would leave it as a global. I prefer to keep the KPI consistent. > > + .th_generation = 0, > > + .th_next = &th0 > > +}; > > This shouldn't spell out all the 0 initializers. That was only needed to > reach the non-0 initializer at the end of the initializer. I thought about it, but initially did not liked the implicit initialization. Changed. > > static int > > sysctl_kern_boottime(SYSCTL_HANDLER_ARGS) > > { > > + struct bintime boottimebin; > > + struct timeval boottime; > > + > > + binuptime1(NULL, &boottimebin); > > + bintime2timeval(&boottimebin, &boottime); > > Use the wrapper function getboottime() if you keep it. Yes, I wrote this before I added the helper. > So maybe use a new general function that returns boottimebin for the > non-uptime functions only. Possibly it can add the offset directly. I changed getbintime() and getboottimebin() to use the fenced magic and fetch boottime inside the loop. This removed the need for binuptime1(). > > > @@ -1116,8 +1170,10 @@ sysclock_snap2bintime(struct sysclock_snap *cs, struct bintime *bt, > > if (cs->delta > 0) > > bintime_addx(bt, cs->fb_info.th_scale * cs->delta); > > > > - if ((flags & FBCLOCK_UPTIME) == 0) > > + if ((flags & FBCLOCK_UPTIME) == 0) { > > + binuptime1(NULL, &boottimebin); > > Perhaps use a more direct way to get boottimebin(). binuptime1() is > pessimized by null pointer checks for both its args. Use the new > function getboottimebin() even if is not direct. Used it, and now it is a direct interface into timehands as well. > > > ... > > diff --git a/sys/net/bpf.c b/sys/net/bpf.c > > index 3b12cf4..4251f71 100644 > > --- a/sys/net/bpf.c > > +++ b/sys/net/bpf.c > > @@ -2328,12 +2328,13 @@ bpf_hdrlen(struct bpf_d *d) > > static void > > bpf_bintime2ts(struct bintime *bt, struct bpf_ts *ts, int tstype) > > { > > - struct bintime bt2; > > + struct bintime bt2, boottimebin; > > struct timeval tsm; > > struct timespec tsn; > > > > if ((tstype & BPF_T_MONOTONIC) == 0) { > > bt2 = *bt; > > + getboottimebin(&boottimebin); > > bintime_add(&bt2, &boottimebin); > > bt = &bt2; > > } > > This is still too chummy with the (mis)implementation. I think it is to > convert a relative CLOCK_MONOTONIC time to an absolute CLOCK_REALTIME > time. That should be done in the time subsystem. It is unclear if > we care about strict real time with leap seconds adjustments. > > BPF_T_MONOTONIC is not documented in any man page or used in any library > or applicatiion in /usr/src. BPF_T_BINTIME is documented bpf(4) but not > used in any library or application in /usr/src. Similarly for all of > BPF_T_*. contrib/libpcap has 47 lines matching timeval, 2 matching > timespec and 0 matching bintime. I will leave this to bpf maintainers. > > > diff --git a/sys/netpfil/ipfw/ip_fw_sockopt.c b/sys/netpfil/ipfw/ip_fw_sockopt.c > > index d186ba5..7faf99f 100644 > > --- a/sys/netpfil/ipfw/ip_fw_sockopt.c > > +++ b/sys/netpfil/ipfw/ip_fw_sockopt.c > > @@ -395,6 +395,7 @@ swap_map(struct ip_fw_chain *chain, struct ip_fw **new_map, int new_len) > > static void > > export_cntr1_base(struct ip_fw *krule, struct ip_fw_bcounter *cntr) > > { > > + struct timeval boottime; > > > > cntr->size = sizeof(*cntr); > > > > @@ -403,21 +404,26 @@ export_cntr1_base(struct ip_fw *krule, struct ip_fw_bcounter *cntr) > > cntr->bcnt = counter_u64_fetch(krule->cntr + 1); > > cntr->timestamp = krule->timestamp; > > } > > - if (cntr->timestamp > 0) > > + if (cntr->timestamp > 0) { > > + getboottime(&boottime); > > cntr->timestamp += boottime.tv_sec; > > + } > > } > > Looks like another home made conversion from CLOCK_MONOTONIC to > CLOCK_REALTIME. Easier to understand since it is actually used. > ipfw seems to use only getmicrouptime() for timestamping. There are > good reasons for using monotonic time for everything except presenting > the time to the user and the conversion for that should be more careful > than the above. I leave this one to net- people as well. > > diff --git a/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c b/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c > > index 1d07943..0879299 100644 > > --- a/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c > > +++ b/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c > > @@ -504,11 +504,13 @@ svc_rpc_gss_find_client(struct svc_rpc_gss_clientid *id) > > { > > struct svc_rpc_gss_client *client; > > struct svc_rpc_gss_client_list *list; > > + struct timeval boottime; > > unsigned long hostid; > > > > rpc_gss_log_debug("in svc_rpc_gss_find_client(%d)", id->ci_id); > > > > getcredhostid(curthread->td_ucred, &hostid); > > + getboottime(&boottime); > > if (id->ci_hostid != hostid || id->ci_boottime != boottime.tv_sec) > > return (NULL); > > Here it is hopefully just a magic id, with the user being a remote system. > Any time that doesn't go backwards or forwards so far that it is in the > lieftime of an old or new boot instance works well for identifying the > boot instance. It does not work for leap seconds in the same way as is does not work after setclock(). So I just leave this conversion as is. sys/compat/linprocfs/linprocfs.c | 4 + sys/fs/devfs/devfs_vnops.c | 4 +- sys/fs/fdescfs/fdesc_vnops.c | 2 + sys/fs/nfs/nfsport.h | 2 +- sys/fs/procfs/procfs_status.c | 2 + sys/kern/kern_acct.c | 2 +- sys/kern/kern_ntptime.c | 55 +++++------- sys/kern/kern_proc.c | 2 + sys/kern/kern_tc.c | 161 +++++++++++++++++++++++++----------- sys/kern/kern_time.c | 8 +- sys/kern/subr_rtc.c | 2 +- sys/kern/sys_procdesc.c | 3 +- sys/net/bpf.c | 3 +- sys/netpfil/ipfw/ip_fw_sockopt.c | 12 ++- sys/nfs/nfs_lock.c | 2 + sys/rpc/rpcsec_gss/svc_rpcsec_gss.c | 4 + sys/sys/time.h | 5 +- 17 files changed, 174 insertions(+), 99 deletions(-) diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c index 56b2ade..a0dce47 100644 --- a/sys/compat/linprocfs/linprocfs.c +++ b/sys/compat/linprocfs/linprocfs.c @@ -447,9 +447,11 @@ linprocfs_dostat(PFS_FILL_ARGS) struct pcpu *pcpu; long cp_time[CPUSTATES]; long *cp; + struct timeval boottime; int i; read_cpu_time(cp_time); + getboottime(&boottime); sbuf_printf(sb, "cpu %ld %ld %ld %ld\n", T2J(cp_time[CP_USER]), T2J(cp_time[CP_NICE]), @@ -624,10 +626,12 @@ static int linprocfs_doprocstat(PFS_FILL_ARGS) { struct kinfo_proc kp; + struct timeval boottime; char state; static int ratelimit = 0; vm_offset_t startcode, startdata; + getboottime(&boottime); sx_slock(&proctree_lock); PROC_LOCK(p); fill_kinfo_proc(p, &kp); diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c index 7cc0f9e..afa3da4 100644 --- a/sys/fs/devfs/devfs_vnops.c +++ b/sys/fs/devfs/devfs_vnops.c @@ -707,10 +707,11 @@ devfs_getattr(struct vop_getattr_args *ap) { struct vnode *vp = ap->a_vp; struct vattr *vap = ap->a_vap; - int error; struct devfs_dirent *de; struct devfs_mount *dmp; struct cdev *dev; + struct timeval boottime; + int error; error = devfs_populate_vp(vp); if (error != 0) @@ -740,6 +741,7 @@ devfs_getattr(struct vop_getattr_args *ap) vap->va_blocksize = DEV_BSIZE; vap->va_type = vp->v_type; + getboottime(&boottime); #define fix(aa) \ do { \ if ((aa).tv_sec <= 3600) { \ diff --git a/sys/fs/fdescfs/fdesc_vnops.c b/sys/fs/fdescfs/fdesc_vnops.c index 4f6e1b9..65b8a54 100644 --- a/sys/fs/fdescfs/fdesc_vnops.c +++ b/sys/fs/fdescfs/fdesc_vnops.c @@ -394,7 +394,9 @@ fdesc_getattr(struct vop_getattr_args *ap) { struct vnode *vp = ap->a_vp; struct vattr *vap = ap->a_vap; + struct timeval boottime; + getboottime(&boottime); vap->va_mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH; vap->va_fileid = VTOFDESC(vp)->fd_ix; vap->va_uid = 0; diff --git a/sys/fs/nfs/nfsport.h b/sys/fs/nfs/nfsport.h index 921df2d..6b41e2f 100644 --- a/sys/fs/nfs/nfsport.h +++ b/sys/fs/nfs/nfsport.h @@ -872,7 +872,7 @@ int newnfs_realign(struct mbuf **, int); /* * Set boottime. */ -#define NFSSETBOOTTIME(b) ((b) = boottime) +#define NFSSETBOOTTIME(b) (getboottime(&b)) /* * The size of directory blocks in the buffer cache. diff --git a/sys/fs/procfs/procfs_status.c b/sys/fs/procfs/procfs_status.c index 5a00ee1..defdec3 100644 --- a/sys/fs/procfs/procfs_status.c +++ b/sys/fs/procfs/procfs_status.c @@ -70,6 +70,7 @@ procfs_doprocstatus(PFS_FILL_ARGS) const char *wmesg; char *pc; char *sep; + struct timeval boottime; int pid, ppid, pgid, sid; int i; @@ -129,6 +130,7 @@ procfs_doprocstatus(PFS_FILL_ARGS) calcru(p, &ut, &st); PROC_STATUNLOCK(p); start = p->p_stats->p_start; + getboottime(&boottime); timevaladd(&start, &boottime); sbuf_printf(sb, " %jd,%ld %jd,%ld %jd,%ld", (intmax_t)start.tv_sec, start.tv_usec, diff --git a/sys/kern/kern_acct.c b/sys/kern/kern_acct.c index ef3fd2e..46e6d9b 100644 --- a/sys/kern/kern_acct.c +++ b/sys/kern/kern_acct.c @@ -389,7 +389,7 @@ acct_process(struct thread *td) acct.ac_stime = encode_timeval(st); /* (4) The elapsed time the command ran (and its starting time) */ - tmp = boottime; + getboottime(&tmp); timevaladd(&tmp, &p->p_stats->p_start); acct.ac_btime = tmp.tv_sec; microuptime(&tmp); diff --git a/sys/kern/kern_ntptime.c b/sys/kern/kern_ntptime.c index d352ee7..efc3713 100644 --- a/sys/kern/kern_ntptime.c +++ b/sys/kern/kern_ntptime.c @@ -162,29 +162,12 @@ static l_fp time_adj; /* tick adjust (ns/s) */ static int64_t time_adjtime; /* correction from adjtime(2) (usec) */ -static struct mtx ntpadj_lock; -MTX_SYSINIT(ntpadj, &ntpadj_lock, "ntpadj", -#ifdef PPS_SYNC - MTX_SPIN -#else - MTX_DEF -#endif -); +static struct mtx ntp_lock; +MTX_SYSINIT(ntp, &ntp_lock, "ntp", MTX_SPIN); -/* - * When PPS_SYNC is defined, hardpps() function is provided which can - * be legitimately called from interrupt filters. Due to this, use - * spinlock for ntptime state protection, otherwise sleepable mutex is - * adequate. - */ -#ifdef PPS_SYNC -#define NTPADJ_LOCK() mtx_lock_spin(&ntpadj_lock) -#define NTPADJ_UNLOCK() mtx_unlock_spin(&ntpadj_lock) -#else -#define NTPADJ_LOCK() mtx_lock(&ntpadj_lock) -#define NTPADJ_UNLOCK() mtx_unlock(&ntpadj_lock) -#endif -#define NTPADJ_ASSERT_LOCKED() mtx_assert(&ntpadj_lock, MA_OWNED) +#define NTP_LOCK() mtx_lock_spin(&ntp_lock) +#define NTP_UNLOCK() mtx_unlock_spin(&ntp_lock) +#define NTP_ASSERT_LOCKED() mtx_assert(&ntp_lock, MA_OWNED) #ifdef PPS_SYNC /* @@ -271,7 +254,7 @@ ntp_gettime1(struct ntptimeval *ntvp) { struct timespec atv; /* nanosecond time */ - NTPADJ_ASSERT_LOCKED(); + NTP_ASSERT_LOCKED(); nanotime(&atv); ntvp->time.tv_sec = atv.tv_sec; @@ -302,9 +285,9 @@ sys_ntp_gettime(struct thread *td, struct ntp_gettime_args *uap) { struct ntptimeval ntv; - NTPADJ_LOCK(); + NTP_LOCK(); ntp_gettime1(&ntv); - NTPADJ_UNLOCK(); + NTP_UNLOCK(); td->td_retval[0] = ntv.time_state; return (copyout(&ntv, uap->ntvp, sizeof(ntv))); @@ -315,9 +298,9 @@ ntp_sysctl(SYSCTL_HANDLER_ARGS) { struct ntptimeval ntv; /* temporary structure */ - NTPADJ_LOCK(); + NTP_LOCK(); ntp_gettime1(&ntv); - NTPADJ_UNLOCK(); + NTP_UNLOCK(); return (sysctl_handle_opaque(oidp, &ntv, sizeof(ntv), req)); } @@ -382,7 +365,7 @@ sys_ntp_adjtime(struct thread *td, struct ntp_adjtime_args *uap) error = priv_check(td, PRIV_NTP_ADJTIME); if (error != 0) return (error); - NTPADJ_LOCK(); + NTP_LOCK(); if (modes & MOD_MAXERROR) time_maxerror = ntv.maxerror; if (modes & MOD_ESTERROR) @@ -484,7 +467,7 @@ sys_ntp_adjtime(struct thread *td, struct ntp_adjtime_args *uap) ntv.stbcnt = pps_stbcnt; #endif /* PPS_SYNC */ retval = ntp_is_time_error(time_status) ? TIME_ERROR : time_state; - NTPADJ_UNLOCK(); + NTP_UNLOCK(); error = copyout((caddr_t)&ntv, (caddr_t)uap->tp, sizeof(ntv)); if (error == 0) @@ -506,6 +489,8 @@ ntp_update_second(int64_t *adjustment, time_t *newsec) int tickrate; l_fp ftemp; /* 32/64-bit temporary */ + NTP_LOCK(); + /* * On rollover of the second both the nanosecond and microsecond * clocks are updated and the state machine cranked as @@ -627,6 +612,8 @@ ntp_update_second(int64_t *adjustment, time_t *newsec) else time_status &= ~STA_PPSSIGNAL; #endif /* PPS_SYNC */ + + NTP_UNLOCK(); } /* @@ -690,7 +677,7 @@ hardupdate(offset) long mtemp; l_fp ftemp; - NTPADJ_ASSERT_LOCKED(); + NTP_ASSERT_LOCKED(); /* * Select how the phase is to be controlled and from which @@ -772,7 +759,7 @@ hardpps(tsp, nsec) long u_sec, u_nsec, v_nsec; /* temps */ l_fp ftemp; - NTPADJ_LOCK(); + NTP_LOCK(); /* * The signal is first processed by a range gate and frequency @@ -956,7 +943,7 @@ hardpps(tsp, nsec) time_freq = pps_freq; out: - NTPADJ_UNLOCK(); + NTP_UNLOCK(); } #endif /* PPS_SYNC */ @@ -999,11 +986,11 @@ kern_adjtime(struct thread *td, struct timeval *delta, struct timeval *olddelta) return (error); ltw = (int64_t)delta->tv_sec * 1000000 + delta->tv_usec; } - NTPADJ_LOCK(); + NTP_LOCK(); ltr = time_adjtime; if (delta != NULL) time_adjtime = ltw; - NTPADJ_UNLOCK(); + NTP_UNLOCK(); if (olddelta != NULL) { atv.tv_sec = ltr / 1000000; atv.tv_usec = ltr % 1000000; diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index 2f1f620..892b23a 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -872,6 +872,7 @@ fill_kinfo_proc_only(struct proc *p, struct kinfo_proc *kp) struct session *sp; struct ucred *cred; struct sigacts *ps; + struct timeval boottime; /* For proc_realparent. */ sx_assert(&proctree_lock, SX_LOCKED); @@ -953,6 +954,7 @@ fill_kinfo_proc_only(struct proc *p, struct kinfo_proc *kp) kp->ki_nice = p->p_nice; kp->ki_fibnum = p->p_fibnum; kp->ki_start = p->p_stats->p_start; + getboottime(&boottime); timevaladd(&kp->ki_start, &boottime); PROC_STATLOCK(p); rufetch(p, &kp->ki_rusage); diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index 0f015b3..c9676fc 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -70,31 +70,22 @@ struct timehands { struct bintime th_offset; struct timeval th_microtime; struct timespec th_nanotime; + struct bintime th_boottime; /* Fields not to be copied in tc_windup start with th_generation. */ u_int th_generation; struct timehands *th_next; }; static struct timehands th0; -static struct timehands th9 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th0}; -static struct timehands th8 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th9}; -static struct timehands th7 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th8}; -static struct timehands th6 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th7}; -static struct timehands th5 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th6}; -static struct timehands th4 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th5}; -static struct timehands th3 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th4}; -static struct timehands th2 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th3}; -static struct timehands th1 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th2}; +static struct timehands th1 = { + .th_next = &th0 +}; static struct timehands th0 = { - &dummy_timecounter, - 0, - (uint64_t)-1 / 1000000, - 0, - {1, 0}, - {0, 0}, - {0, 0}, - 1, - &th1 + .th_counter = &dummy_timecounter, + .th_scale = (uint64_t)-1 / 1000000, + .th_offset = {1, 0}, + .th_generation = 1, + .th_next = &th1 }; static struct timehands *volatile timehands = &th0; @@ -106,8 +97,6 @@ int tc_min_ticktock_freq = 1; volatile time_t time_second = 1; volatile time_t time_uptime = 1; -struct bintime boottimebin; -struct timeval boottime; static int sysctl_kern_boottime(SYSCTL_HANDLER_ARGS); SYSCTL_PROC(_kern, KERN_BOOTTIME, boottime, CTLTYPE_STRUCT|CTLFLAG_RD, NULL, 0, sysctl_kern_boottime, "S,timeval", "System boottime"); @@ -135,7 +124,8 @@ SYSCTL_PROC(_kern_timecounter, OID_AUTO, alloweddeviation, static int tc_chosen; /* Non-zero if a specific tc was chosen via sysctl. */ -static void tc_windup(void); +static void tc_windup(bool top_call, struct bintime *new_boottimebin); +static void tc_windup_locked(struct bintime *new_boottimebin); static void cpu_tick_calibrate(int); void dtrace_getnanotime(struct timespec *tsp); @@ -143,6 +133,10 @@ void dtrace_getnanotime(struct timespec *tsp); static int sysctl_kern_boottime(SYSCTL_HANDLER_ARGS) { + struct timeval boottime; + + getboottime(&boottime); + #ifndef __mips__ #ifdef SCTL_MASK32 int tv[2]; @@ -150,11 +144,11 @@ sysctl_kern_boottime(SYSCTL_HANDLER_ARGS) if (req->flags & SCTL_MASK32) { tv[0] = boottime.tv_sec; tv[1] = boottime.tv_usec; - return SYSCTL_OUT(req, tv, sizeof(tv)); - } else + return (SYSCTL_OUT(req, tv, sizeof(tv))); + } #endif #endif - return SYSCTL_OUT(req, &boottime, sizeof(boottime)); + return (SYSCTL_OUT(req, &boottime, sizeof(boottime))); } static int @@ -164,7 +158,7 @@ sysctl_kern_timecounter_get(SYSCTL_HANDLER_ARGS) struct timecounter *tc = arg1; ncount = tc->tc_get_timecount(tc); - return sysctl_handle_int(oidp, &ncount, 0, req); + return (sysctl_handle_int(oidp, &ncount, 0, req)); } static int @@ -174,7 +168,7 @@ sysctl_kern_timecounter_freq(SYSCTL_HANDLER_ARGS) struct timecounter *tc = arg1; freq = tc->tc_frequency; - return sysctl_handle_64(oidp, &freq, 0, req); + return (sysctl_handle_64(oidp, &freq, 0, req)); } /* @@ -198,7 +192,7 @@ tc_delta(struct timehands *th) */ #ifdef FFCLOCK -void +static void fbclock_binuptime(struct bintime *bt) { struct timehands *th; @@ -234,8 +228,18 @@ fbclock_microuptime(struct timeval *tvp) void fbclock_bintime(struct bintime *bt) { + struct bintime boottimebin; + struct timehands *th; + unsigned int gen; - fbclock_binuptime(bt); + do { + th = timehands; + gen = atomic_load_acq_int(&th->th_generation); + *bt = th->th_offset; + bintime_addx(bt, th->th_scale * tc_delta(th)); + boottimebin = th->th_boottime; + atomic_thread_fence_acq(); + } while (gen == 0 || gen != th->th_generation); bintime_add(bt, &boottimebin); } @@ -303,12 +307,14 @@ void fbclock_getbintime(struct bintime *bt) { struct timehands *th; + struct bintime boottimebin; unsigned int gen; do { th = timehands; gen = atomic_load_acq_int(&th->th_generation); *bt = th->th_offset; + boottimebin = th->th_boottime; atomic_thread_fence_acq(); } while (gen == 0 || gen != th->th_generation); bintime_add(bt, &boottimebin); @@ -378,8 +384,18 @@ microuptime(struct timeval *tvp) void bintime(struct bintime *bt) { + struct bintime boottimebin; + struct timehands *th; + u_int gen; - binuptime(bt); + do { + th = timehands; + gen = atomic_load_acq_int(&th->th_generation); + *bt = th->th_offset; + bintime_addx(bt, th->th_scale * tc_delta(th)); + boottimebin = th->th_boottime; + atomic_thread_fence_acq(); + } while (gen == 0 || gen != th->th_generation); bintime_add(bt, &boottimebin); } @@ -447,12 +463,14 @@ void getbintime(struct bintime *bt) { struct timehands *th; + struct bintime boottimebin; u_int gen; do { th = timehands; gen = atomic_load_acq_int(&th->th_generation); *bt = th->th_offset; + boottimebin = th->th_boottime; atomic_thread_fence_acq(); } while (gen == 0 || gen != th->th_generation); bintime_add(bt, &boottimebin); @@ -487,6 +505,29 @@ getmicrotime(struct timeval *tvp) } #endif /* FFCLOCK */ +void +getboottime(struct timeval *boottime) +{ + struct bintime boottimebin; + + getboottimebin(&boottimebin); + bintime2timeval(&boottimebin, boottime); +} + +void +getboottimebin(struct bintime *boottimebin) +{ + struct timehands *th; + u_int gen; + + do { + th = timehands; + gen = atomic_load_acq_int(&th->th_generation); + *boottimebin = th->th_boottime; + atomic_thread_fence_acq(); + } while (gen == 0 || gen != th->th_generation); +} + #ifdef FFCLOCK /* * Support for feed-forward synchronization algorithms. This is heavily inspired @@ -1103,6 +1144,7 @@ int sysclock_snap2bintime(struct sysclock_snap *cs, struct bintime *bt, int whichclock, uint32_t flags) { + struct bintime boottimebin; #ifdef FFCLOCK struct bintime bt2; uint64_t period; @@ -1116,8 +1158,10 @@ sysclock_snap2bintime(struct sysclock_snap *cs, struct bintime *bt, if (cs->delta > 0) bintime_addx(bt, cs->fb_info.th_scale * cs->delta); - if ((flags & FBCLOCK_UPTIME) == 0) + if ((flags & FBCLOCK_UPTIME) == 0) { + getboottimebin(&boottimebin); bintime_add(bt, &boottimebin); + } break; #ifdef FFCLOCK case SYSCLOCK_FFWD: @@ -1226,10 +1270,12 @@ tc_getfrequency(void) return (timehands->th_counter->tc_frequency); } +static struct mtx tc_setclock_mtx; +MTX_SYSINIT(tc_setclock_init, &tc_setclock_mtx, "tcsetc", MTX_DEF); + /* * Step our concept of UTC. This is done by modifying our estimate of * when we booted. - * XXX: not locked. */ void tc_setclock(struct timespec *ts) @@ -1237,26 +1283,43 @@ tc_setclock(struct timespec *ts) struct timespec tbef, taft; struct bintime bt, bt2; - cpu_tick_calibrate(1); - nanotime(&tbef); timespec2bintime(ts, &bt); + nanotime(&tbef); + mtx_lock(&tc_setclock_mtx); + critical_enter(); + cpu_tick_calibrate(1); binuptime(&bt2); bintime_sub(&bt, &bt2); - bintime_add(&bt2, &boottimebin); - boottimebin = bt; - bintime2timeval(&bt, &boottime); /* XXX fiddle all the little crinkly bits around the fiords... */ - tc_windup(); - nanotime(&taft); + tc_windup(true, &bt); + critical_exit(); + mtx_unlock(&tc_setclock_mtx); if (timestepwarnings) { + nanotime(&taft); log(LOG_INFO, "Time stepped from %jd.%09ld to %jd.%09ld (%jd.%09ld)\n", (intmax_t)tbef.tv_sec, tbef.tv_nsec, (intmax_t)taft.tv_sec, taft.tv_nsec, (intmax_t)ts->tv_sec, ts->tv_nsec); } - cpu_tick_calibrate(1); +} + +static volatile int tc_windup_lock; +static void +tc_windup(bool top_call, struct bintime *new_boottimebin) +{ + + for (;;) { + if (atomic_cmpset_int(&tc_windup_lock, 0, 1)) { + atomic_thread_fence_acq(); + tc_windup_locked(new_boottimebin); + atomic_store_rel_int(&tc_windup_lock, 0); + break; + } else if (!top_call) { + break; + } + } } /* @@ -1265,7 +1328,7 @@ tc_setclock(struct timespec *ts) * timecounter and/or do seconds processing in NTP. Slightly magic. */ static void -tc_windup(void) +tc_windup_locked(struct bintime *new_boottimebin) { struct bintime bt; struct timehands *th, *tho; @@ -1289,6 +1352,8 @@ tc_windup(void) th->th_generation = 0; atomic_thread_fence_rel(); bcopy(tho, th, offsetof(struct timehands, th_generation)); + if (new_boottimebin != NULL) + th->th_boottime = *new_boottimebin; /* * Capture a timecounter delta on the current timecounter and if @@ -1338,7 +1403,7 @@ tc_windup(void) * case we missed a leap second. */ bt = th->th_offset; - bintime_add(&bt, &boottimebin); + bintime_add(&bt, &th->th_boottime); i = bt.sec - tho->th_microtime.tv_sec; if (i > LARGE_STEP) i = 2; @@ -1346,7 +1411,7 @@ tc_windup(void) t = bt.sec; ntp_update_second(&th->th_adjustment, &bt.sec); if (bt.sec != t) - boottimebin.sec += bt.sec - t; + th->th_boottime.sec += bt.sec - t; } /* Update the UTC timestamps used by the get*() functions. */ /* XXX shouldn't do this here. Should force non-`get' versions. */ @@ -1769,7 +1834,7 @@ pps_event(struct pps_state *pps, int event) tcount &= pps->capth->th_counter->tc_counter_mask; bt = pps->capth->th_offset; bintime_addx(&bt, pps->capth->th_scale * tcount); - bintime_add(&bt, &boottimebin); + bintime_add(&bt, &pps->capth->th_boottime); bintime2timespec(&bt, &ts); /* If the timecounter was wound up underneath us, bail out. */ @@ -1846,7 +1911,7 @@ tc_ticktock(int cnt) if (count < tc_tick) return; count = 0; - tc_windup(); + tc_windup(false, NULL); } static void __inline @@ -1921,7 +1986,7 @@ inittimecounter(void *dummy) /* warm up new timecounter (again) and get rolling. */ (void)timecounter->tc_get_timecount(timecounter); (void)timecounter->tc_get_timecount(timecounter); - tc_windup(); + tc_windup(true, NULL); } SYSINIT(timecounter, SI_SUB_CLOCKS, SI_ORDER_SECOND, inittimecounter, NULL); @@ -2095,7 +2160,7 @@ tc_fill_vdso_timehands(struct vdso_timehands *vdso_th) vdso_th->th_offset_count = th->th_offset_count; vdso_th->th_counter_mask = th->th_counter->tc_counter_mask; vdso_th->th_offset = th->th_offset; - vdso_th->th_boottime = boottimebin; + vdso_th->th_boottime = th->th_boottime; enabled = cpu_fill_vdso_timehands(vdso_th, th->th_counter); if (!vdso_th_enable) enabled = 0; @@ -2116,8 +2181,8 @@ tc_fill_vdso_timehands32(struct vdso_timehands32 *vdso_th32) vdso_th32->th_counter_mask = th->th_counter->tc_counter_mask; vdso_th32->th_offset.sec = th->th_offset.sec; *(uint64_t *)&vdso_th32->th_offset.frac[0] = th->th_offset.frac; - vdso_th32->th_boottime.sec = boottimebin.sec; - *(uint64_t *)&vdso_th32->th_boottime.frac[0] = boottimebin.frac; + vdso_th32->th_boottime.sec = th->th_boottime.sec; + *(uint64_t *)&vdso_th32->th_boottime.frac[0] = th->th_boottime.frac; enabled = cpu_fill_vdso_timehands32(vdso_th32, th->th_counter); if (!vdso_th_enable) enabled = 0; diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index 148da2b..82710f7 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -115,9 +115,7 @@ settime(struct thread *td, struct timeval *tv) struct timeval delta, tv1, tv2; static struct timeval maxtime, laststep; struct timespec ts; - int s; - s = splclock(); microtime(&tv1); delta = *tv; timevalsub(&delta, &tv1); @@ -147,10 +145,8 @@ settime(struct thread *td, struct timeval *tv) printf("Time adjustment clamped to -1 second\n"); } } else { - if (tv1.tv_sec == laststep.tv_sec) { - splx(s); + if (tv1.tv_sec == laststep.tv_sec) return (EPERM); - } if (delta.tv_sec > 1) { tv->tv_sec = tv1.tv_sec + 1; printf("Time adjustment clamped to +1 second\n"); @@ -161,10 +157,8 @@ settime(struct thread *td, struct timeval *tv) ts.tv_sec = tv->tv_sec; ts.tv_nsec = tv->tv_usec * 1000; - mtx_lock(&Giant); tc_setclock(&ts); resettodr(); - mtx_unlock(&Giant); return (0); } diff --git a/sys/kern/subr_rtc.c b/sys/kern/subr_rtc.c index dbad36d..4bac324 100644 --- a/sys/kern/subr_rtc.c +++ b/sys/kern/subr_rtc.c @@ -172,11 +172,11 @@ resettodr(void) if (disable_rtc_set || clock_dev == NULL) return; - mtx_lock(&resettodr_lock); getnanotime(&ts); timespecadd(&ts, &clock_adj); ts.tv_sec -= utc_offset(); /* XXX: We should really set all registered RTCs */ + mtx_lock(&resettodr_lock); error = CLOCK_SETTIME(clock_dev, &ts); mtx_unlock(&resettodr_lock); if (error != 0) diff --git a/sys/kern/sys_procdesc.c b/sys/kern/sys_procdesc.c index 37139c1..f47ae7c 100644 --- a/sys/kern/sys_procdesc.c +++ b/sys/kern/sys_procdesc.c @@ -517,7 +517,7 @@ procdesc_stat(struct file *fp, struct stat *sb, struct ucred *active_cred, struct thread *td) { struct procdesc *pd; - struct timeval pstart; + struct timeval pstart, boottime; /* * XXXRW: Perhaps we should cache some more information from the @@ -532,6 +532,7 @@ procdesc_stat(struct file *fp, struct stat *sb, struct ucred *active_cred, /* Set birth and [acm] times to process start time. */ pstart = pd->pd_proc->p_stats->p_start; + getboottime(&boottime); timevaladd(&pstart, &boottime); TIMEVAL_TO_TIMESPEC(&pstart, &sb->st_birthtim); sb->st_atim = sb->st_birthtim; diff --git a/sys/net/bpf.c b/sys/net/bpf.c index 3b12cf4..4251f71 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -2328,12 +2328,13 @@ bpf_hdrlen(struct bpf_d *d) static void bpf_bintime2ts(struct bintime *bt, struct bpf_ts *ts, int tstype) { - struct bintime bt2; + struct bintime bt2, boottimebin; struct timeval tsm; struct timespec tsn; if ((tstype & BPF_T_MONOTONIC) == 0) { bt2 = *bt; + getboottimebin(&boottimebin); bintime_add(&bt2, &boottimebin); bt = &bt2; } diff --git a/sys/netpfil/ipfw/ip_fw_sockopt.c b/sys/netpfil/ipfw/ip_fw_sockopt.c index d186ba5..7faf99f 100644 --- a/sys/netpfil/ipfw/ip_fw_sockopt.c +++ b/sys/netpfil/ipfw/ip_fw_sockopt.c @@ -395,6 +395,7 @@ swap_map(struct ip_fw_chain *chain, struct ip_fw **new_map, int new_len) static void export_cntr1_base(struct ip_fw *krule, struct ip_fw_bcounter *cntr) { + struct timeval boottime; cntr->size = sizeof(*cntr); @@ -403,21 +404,26 @@ export_cntr1_base(struct ip_fw *krule, struct ip_fw_bcounter *cntr) cntr->bcnt = counter_u64_fetch(krule->cntr + 1); cntr->timestamp = krule->timestamp; } - if (cntr->timestamp > 0) + if (cntr->timestamp > 0) { + getboottime(&boottime); cntr->timestamp += boottime.tv_sec; + } } static void export_cntr0_base(struct ip_fw *krule, struct ip_fw_bcounter0 *cntr) { + struct timeval boottime; if (krule->cntr != NULL) { cntr->pcnt = counter_u64_fetch(krule->cntr); cntr->bcnt = counter_u64_fetch(krule->cntr + 1); cntr->timestamp = krule->timestamp; } - if (cntr->timestamp > 0) + if (cntr->timestamp > 0) { + getboottime(&boottime); cntr->timestamp += boottime.tv_sec; + } } /* @@ -2048,11 +2054,13 @@ ipfw_getrules(struct ip_fw_chain *chain, void *buf, size_t space) char *ep = bp + space; struct ip_fw *rule; struct ip_fw_rule0 *dst; + struct timeval boottime; int error, i, l, warnflag; time_t boot_seconds; warnflag = 0; + getboottime(&boottime); boot_seconds = boottime.tv_sec; for (i = 0; i < chain->n_rules; i++) { rule = chain->map[i]; diff --git a/sys/nfs/nfs_lock.c b/sys/nfs/nfs_lock.c index 7d11672..c84413e 100644 --- a/sys/nfs/nfs_lock.c +++ b/sys/nfs/nfs_lock.c @@ -241,6 +241,7 @@ nfs_dolock(struct vop_advlock_args *ap) struct flock *fl; struct proc *p; struct nfsmount *nmp; + struct timeval boottime; td = curthread; p = td->td_proc; @@ -284,6 +285,7 @@ nfs_dolock(struct vop_advlock_args *ap) p->p_nlminfo = malloc(sizeof(struct nlminfo), M_NLMINFO, M_WAITOK | M_ZERO); p->p_nlminfo->pid_start = p->p_stats->p_start; + getboottime(&boottime); timevaladd(&p->p_nlminfo->pid_start, &boottime); } msg.lm_msg_ident.pid_start = p->p_nlminfo->pid_start; diff --git a/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c b/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c index 1d07943..0879299 100644 --- a/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c +++ b/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c @@ -504,11 +504,13 @@ svc_rpc_gss_find_client(struct svc_rpc_gss_clientid *id) { struct svc_rpc_gss_client *client; struct svc_rpc_gss_client_list *list; + struct timeval boottime; unsigned long hostid; rpc_gss_log_debug("in svc_rpc_gss_find_client(%d)", id->ci_id); getcredhostid(curthread->td_ucred, &hostid); + getboottime(&boottime); if (id->ci_hostid != hostid || id->ci_boottime != boottime.tv_sec) return (NULL); @@ -537,6 +539,7 @@ svc_rpc_gss_create_client(void) { struct svc_rpc_gss_client *client; struct svc_rpc_gss_client_list *list; + struct timeval boottime; unsigned long hostid; rpc_gss_log_debug("in svc_rpc_gss_create_client()"); @@ -547,6 +550,7 @@ svc_rpc_gss_create_client(void) sx_init(&client->cl_lock, "GSS-client"); getcredhostid(curthread->td_ucred, &hostid); client->cl_id.ci_hostid = hostid; + getboottime(&boottime); client->cl_id.ci_boottime = boottime.tv_sec; client->cl_id.ci_id = svc_rpc_gss_next_clientid++; list = &svc_rpc_gss_client_hash[client->cl_id.ci_id % CLIENT_HASH_SIZE]; diff --git a/sys/sys/time.h b/sys/sys/time.h index 395e888..659f8e0 100644 --- a/sys/sys/time.h +++ b/sys/sys/time.h @@ -372,8 +372,6 @@ void resettodr(void); extern volatile time_t time_second; extern volatile time_t time_uptime; -extern struct bintime boottimebin; -extern struct timeval boottime; extern struct bintime tc_tick_bt; extern sbintime_t tc_tick_sbt; extern struct bintime tick_bt; @@ -440,6 +438,9 @@ void getbintime(struct bintime *bt); void getnanotime(struct timespec *tsp); void getmicrotime(struct timeval *tvp); +void getboottime(struct timeval *boottime); +void getboottimebin(struct bintime *boottimebin); + /* Other functions */ int itimerdecr(struct itimerval *itp, int usec); int itimerfix(struct timeval *tv); From owner-svn-src-head@freebsd.org Fri Jul 1 19:58:14 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 968BDB8F77F; Fri, 1 Jul 2016 19:58:14 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4B4642F68; Fri, 1 Jul 2016 19:58:14 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u61JwDoc039801; Fri, 1 Jul 2016 19:58:13 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u61JwD6W039800; Fri, 1 Jul 2016 19:58:13 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201607011958.u61JwD6W039800@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Fri, 1 Jul 2016 19:58:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302307 - head/sys/net80211 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Fri, 01 Jul 2016 19:58:14 -0000 Author: adrian Date: Fri Jul 1 19:58:13 2016 New Revision: 302307 URL: https://svnweb.freebsd.org/changeset/base/302307 Log: [net80211] teach AMRR to log the initial MCS rate as "MCS X" Otheriwse it logs it as the rate value, which is 0x80 (MCS flag) + MCS, which isn't that helpful. Approved by: re (gjb) Modified: head/sys/net80211/ieee80211_amrr.c Modified: head/sys/net80211/ieee80211_amrr.c ============================================================================== --- head/sys/net80211/ieee80211_amrr.c Fri Jul 1 07:27:33 2016 (r302306) +++ head/sys/net80211/ieee80211_amrr.c Fri Jul 1 19:58:13 2016 (r302307) @@ -220,10 +220,13 @@ amrr_node_init(struct ieee80211_node *ni ni->ni_txrate = rate; amn->amn_ticks = ticks; + /* XXX TODO: we really need a rate-to-string method */ + /* XXX TODO: non-11n rate should be divided by two.. */ IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, - "AMRR: nrates=%d, initial rate %d", + "AMRR: nrates=%d, initial rate %s%d", rs->rs_nrates, - rate); + amrr_node_is_11n(ni) ? "MCS " : "", + rate & IEEE80211_RATE_VAL); } static void @@ -249,6 +252,8 @@ amrr_update(struct ieee80211_amrr *amrr, rs = &ni->ni_rates; } + /* XXX TODO: we really need a rate-to-string method */ + /* XXX TODO: non-11n rate should be divided by two.. */ IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, "AMRR: current rate %d, txcnt=%d, retrycnt=%d", rs->rs_rates[rix] & IEEE80211_RATE_VAL, @@ -270,6 +275,8 @@ amrr_update(struct ieee80211_amrr *amrr, amn->amn_recovery = 1; amn->amn_success = 0; rix++; + /* XXX TODO: we really need a rate-to-string method */ + /* XXX TODO: non-11n rate should be divided by two.. */ IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, "AMRR increasing rate %d (txcnt=%d retrycnt=%d)", rs->rs_rates[rix] & IEEE80211_RATE_VAL, @@ -291,6 +298,8 @@ amrr_update(struct ieee80211_amrr *amrr, amrr->amrr_min_success_threshold; } rix--; + /* XXX TODO: we really need a rate-to-string method */ + /* XXX TODO: non-11n rate should be divided by two.. */ IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, "AMRR decreasing rate %d (txcnt=%d retrycnt=%d)", rs->rs_rates[rix] & IEEE80211_RATE_VAL, From owner-svn-src-head@freebsd.org Fri Jul 1 20:11:30 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F2733B8F997; Fri, 1 Jul 2016 20:11:29 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BFD59270A; Fri, 1 Jul 2016 20:11:29 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u61KBSiV044548; Fri, 1 Jul 2016 20:11:28 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u61KBSEL044547; Fri, 1 Jul 2016 20:11:28 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201607012011.u61KBSEL044547@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 1 Jul 2016 20:11:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302308 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Fri, 01 Jul 2016 20:11:30 -0000 Author: kib Date: Fri Jul 1 20:11:28 2016 New Revision: 302308 URL: https://svnweb.freebsd.org/changeset/base/302308 Log: When a process knote was attached to the process which is already exiting, the knote is activated immediately. If the exit1() later activates knotes, such knote is attempted to be activated second time. Detect the condition by zeroed kn_ptr.p_proc pointer, and avoid excessive activation. Before r302235, such knotes were removed from the knlist immediately upon activation. Reported by: truckman Sponsored by: The FreeBSD Foundation Approved by: re (gjb) Modified: head/sys/kern/kern_event.c Modified: head/sys/kern/kern_event.c ============================================================================== --- head/sys/kern/kern_event.c Fri Jul 1 19:58:13 2016 (r302307) +++ head/sys/kern/kern_event.c Fri Jul 1 20:11:28 2016 (r302308) @@ -451,6 +451,9 @@ filt_proc(struct knote *kn, long hint) u_int event; p = kn->kn_ptr.p_proc; + if (p == NULL) /* already activated, from attach filter */ + return (0); + /* Mask off extra data. */ event = (u_int)hint & NOTE_PCTRLMASK; From owner-svn-src-head@freebsd.org Fri Jul 1 20:16:36 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5FCB5B8FB45; Fri, 1 Jul 2016 20:16:36 +0000 (UTC) (envelope-from skreuzer@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 31FF62A26; Fri, 1 Jul 2016 20:16:36 +0000 (UTC) (envelope-from skreuzer@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u61KGZsP047388; Fri, 1 Jul 2016 20:16:35 GMT (envelope-from skreuzer@FreeBSD.org) Received: (from skreuzer@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u61KGZxS047387; Fri, 1 Jul 2016 20:16:35 GMT (envelope-from skreuzer@FreeBSD.org) Message-Id: <201607012016.u61KGZxS047387@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: skreuzer set sender to skreuzer@FreeBSD.org using -f From: Steven Kreuzer Date: Fri, 1 Jul 2016 20:16:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302309 - head/release/doc/en_US.ISO8859-1/relnotes X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Fri, 01 Jul 2016 20:16:36 -0000 Author: skreuzer (doc,ports committer) Date: Fri Jul 1 20:16:35 2016 New Revision: 302309 URL: https://svnweb.freebsd.org/changeset/base/302309 Log: Document r263698, Add code for enabling second CPU core for A20 SoC. Approved by: re (gjb, implicit, relnotes) Modified: head/release/doc/en_US.ISO8859-1/relnotes/article.xml Modified: head/release/doc/en_US.ISO8859-1/relnotes/article.xml ============================================================================== --- head/release/doc/en_US.ISO8859-1/relnotes/article.xml Fri Jul 1 20:11:28 2016 (r302308) +++ head/release/doc/en_US.ISO8859-1/relnotes/article.xml Fri Jul 1 20:16:35 2016 (r302309) @@ -1509,6 +1509,10 @@ Support for the HiSilicon HI6220 SoC has been added. + + The second CPU core on + Allwinner A20 SoC have been enabled. + From owner-svn-src-head@freebsd.org Fri Jul 1 20:19:03 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5DE4BB8FBB0; Fri, 1 Jul 2016 20:19:03 +0000 (UTC) (envelope-from skreuzer@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2E2082BAC; Fri, 1 Jul 2016 20:19:03 +0000 (UTC) (envelope-from skreuzer@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u61KJ25M047504; Fri, 1 Jul 2016 20:19:02 GMT (envelope-from skreuzer@FreeBSD.org) Received: (from skreuzer@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u61KJ29e047503; Fri, 1 Jul 2016 20:19:02 GMT (envelope-from skreuzer@FreeBSD.org) Message-Id: <201607012019.u61KJ29e047503@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: skreuzer set sender to skreuzer@FreeBSD.org using -f From: Steven Kreuzer Date: Fri, 1 Jul 2016 20:19:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302310 - head/release/doc/en_US.ISO8859-1/relnotes X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Fri, 01 Jul 2016 20:19:03 -0000 Author: skreuzer (doc,ports committer) Date: Fri Jul 1 20:19:02 2016 New Revision: 302310 URL: https://svnweb.freebsd.org/changeset/base/302310 Log: Document r299688, Add support for H3 SoC Approved by: re (gjb, implicit, relnotes) Modified: head/release/doc/en_US.ISO8859-1/relnotes/article.xml Modified: head/release/doc/en_US.ISO8859-1/relnotes/article.xml ============================================================================== --- head/release/doc/en_US.ISO8859-1/relnotes/article.xml Fri Jul 1 20:16:35 2016 (r302309) +++ head/release/doc/en_US.ISO8859-1/relnotes/article.xml Fri Jul 1 20:19:02 2016 (r302310) @@ -1513,6 +1513,9 @@ The second CPU core on Allwinner A20 SoC have been enabled. + Support for the Allwinner H3 SoC + has been added. + From owner-svn-src-head@freebsd.org Fri Jul 1 20:26:01 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3C4A4B8FDB5; Fri, 1 Jul 2016 20:26:01 +0000 (UTC) (envelope-from skreuzer@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 08E222051; Fri, 1 Jul 2016 20:26:00 +0000 (UTC) (envelope-from skreuzer@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u61KQ0DM051141; Fri, 1 Jul 2016 20:26:00 GMT (envelope-from skreuzer@FreeBSD.org) Received: (from skreuzer@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u61KQ02r051140; Fri, 1 Jul 2016 20:26:00 GMT (envelope-from skreuzer@FreeBSD.org) Message-Id: <201607012026.u61KQ02r051140@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: skreuzer set sender to skreuzer@FreeBSD.org using -f From: Steven Kreuzer Date: Fri, 1 Jul 2016 20:26:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302311 - head/release/doc/en_US.ISO8859-1/relnotes X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Fri, 01 Jul 2016 20:26:01 -0000 Author: skreuzer (doc,ports committer) Date: Fri Jul 1 20:25:59 2016 New Revision: 302311 URL: https://svnweb.freebsd.org/changeset/base/302311 Log: Document 300777, Add support for GPIO, Sensors and interrupts on AXP209 PMIC Approved by: re (gjb, implicit, relnotes) Modified: head/release/doc/en_US.ISO8859-1/relnotes/article.xml Modified: head/release/doc/en_US.ISO8859-1/relnotes/article.xml ============================================================================== --- head/release/doc/en_US.ISO8859-1/relnotes/article.xml Fri Jul 1 20:19:02 2016 (r302310) +++ head/release/doc/en_US.ISO8859-1/relnotes/article.xml Fri Jul 1 20:25:59 2016 (r302311) @@ -1516,6 +1516,10 @@ Support for the Allwinner H3 SoC has been added. + Support for GPIO, Sensors and + interrupts on AXP209 power management integrated circuits have been + added. + From owner-svn-src-head@freebsd.org Fri Jul 1 21:09:31 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 77DCFB8F599; Fri, 1 Jul 2016 21:09:31 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 552432212; Fri, 1 Jul 2016 21:09:31 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u61L9U2M065960; Fri, 1 Jul 2016 21:09:30 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u61L9U13065958; Fri, 1 Jul 2016 21:09:30 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201607012109.u61L9U13065958@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Fri, 1 Jul 2016 21:09:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302312 - in head/sys/boot: fdt powerpc/ofw X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Fri, 01 Jul 2016 21:09:31 -0000 Author: nwhitehorn Date: Fri Jul 1 21:09:30 2016 New Revision: 302312 URL: https://svnweb.freebsd.org/changeset/base/302312 Log: Clean up some FDT-related code in the PowerPC bootloader, improving error checking and robustness. Prevents errors and crashes in FDT commands on PowerMac G5 systems. Approved by: re (gjb) Modified: head/sys/boot/fdt/fdt_loader_cmd.c head/sys/boot/powerpc/ofw/ofwfdt.c Modified: head/sys/boot/fdt/fdt_loader_cmd.c ============================================================================== --- head/sys/boot/fdt/fdt_loader_cmd.c Fri Jul 1 20:25:59 2016 (r302311) +++ head/sys/boot/fdt/fdt_loader_cmd.c Fri Jul 1 21:09:30 2016 (r302312) @@ -49,7 +49,7 @@ __FBSDID("$FreeBSD$"); #endif #define FDT_CWD_LEN 256 -#define FDT_MAX_DEPTH 6 +#define FDT_MAX_DEPTH 12 #define FDT_PROP_SEP " = " @@ -1029,7 +1029,7 @@ fdt_cmd_ls(int argc, char *argv[]) const char *prevname[FDT_MAX_DEPTH] = { NULL }; const char *name; char *path; - int i, o, depth, len; + int i, o, depth; path = (argc > 2) ? argv[2] : NULL; if (path == NULL) @@ -1045,7 +1045,7 @@ fdt_cmd_ls(int argc, char *argv[]) (o >= 0) && (depth >= 0); o = fdt_next_node(fdtp, o, &depth)) { - name = fdt_get_name(fdtp, o, &len); + name = fdt_get_name(fdtp, o, NULL); if (depth > FDT_MAX_DEPTH) { printf("max depth exceeded: %d\n", depth); Modified: head/sys/boot/powerpc/ofw/ofwfdt.c ============================================================================== --- head/sys/boot/powerpc/ofw/ofwfdt.c Fri Jul 1 20:25:59 2016 (r302311) +++ head/sys/boot/powerpc/ofw/ofwfdt.c Fri Jul 1 21:09:30 2016 (r302312) @@ -33,24 +33,37 @@ __FBSDID("$FreeBSD$"); #include #include "bootstrap.h" +extern int command_fdt_internal(int argc, char *argv[]); + static int OF_hasprop(phandle_t node, const char *prop) { - return (OF_getproplen(node, prop) > 0); + return (OF_getproplen(node, (char *)prop) > 0); } static void add_node_to_fdt(void *buffer, phandle_t node, int fdt_offset) { - int i, child_offset, error; - char name[2048], *lastprop, *subname; + int i, child_offset, error; + char name[255], *lastprop, *subname; void *propbuf; - size_t proplen; + ssize_t proplen; lastprop = NULL; while (OF_nextprop(node, lastprop, name) > 0) { proplen = OF_getproplen(node, name); + + /* Detect and correct for errors and strangeness */ + if (proplen < 0) + proplen = 0; + if (proplen > 1024) + proplen = 1024; + propbuf = malloc(proplen); + if (propbuf == NULL) { + printf("Cannot allocate memory for prop %s\n", name); + return; + } OF_getprop(node, name, propbuf, proplen); error = fdt_setprop(buffer, fdt_offset, name, propbuf, proplen); free(propbuf); @@ -64,7 +77,7 @@ add_node_to_fdt(void *buffer, phandle_t && !OF_hasprop(node, "ibm,phandle")) fdt_setprop(buffer, fdt_offset, "phandle", &node, sizeof(node)); - for (node = OF_child(node); node > 0; node = OF_peer(node)) { + for (node = OF_child(node); node > 0; node = OF_peer(node)) { OF_package_to_path(node, name, sizeof(name)); subname = strrchr(name, '/'); subname++; @@ -76,7 +89,7 @@ add_node_to_fdt(void *buffer, phandle_t } add_node_to_fdt(buffer, node, child_offset); - } + } } static void @@ -123,18 +136,16 @@ ofwfdt_fixups(void *fdtp) fdt_add_mem_rsv(fdtp, base, len); } else { /* - * Remove /memory/available properties, which reflect long-gone OF - * state. Note that this doesn't work if we need RTAS still, since - * that's part of the firmware. + * Remove /memory/available properties, which reflect long-gone + * OF state. Note that this doesn't work if we need RTAS still, + * since that's part of the firmware. */ - offset = fdt_path_offset(fdtp, "/memory@0"); if (offset > 0) fdt_delprop(fdtp, offset, "available"); } - - /* + /* * Convert stored ihandles under /chosen to xref phandles */ @@ -158,7 +169,8 @@ ofwfdt_fixups(void *fdtp) OF_getprop(node, "ibm,phandle", &node, sizeof(node)); node = cpu_to_fdt32(node); - fdt_setprop(fdtp, offset, chosenprops[i], &node, sizeof(node)); + fdt_setprop(fdtp, offset, chosenprops[i], &node, + sizeof(node)); } /* Refind node in case it moved */ From owner-svn-src-head@freebsd.org Fri Jul 1 23:18:50 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F1DA4B8F817; Fri, 1 Jul 2016 23:18:50 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C24BA2FF8; Fri, 1 Jul 2016 23:18:50 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u61NInOH014380; Fri, 1 Jul 2016 23:18:49 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u61NInK9014379; Fri, 1 Jul 2016 23:18:49 GMT (envelope-from np@FreeBSD.org) Message-Id: <201607012318.u61NInK9014379@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Fri, 1 Jul 2016 23:18:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302313 - head/sys/dev/cxgbe X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Fri, 01 Jul 2016 23:18:51 -0000 Author: np Date: Fri Jul 1 23:18:49 2016 New Revision: 302313 URL: https://svnweb.freebsd.org/changeset/base/302313 Log: cxgbe(4): Avoid a NULL dereference while dumping the L2 table. Entries used by switching filters that rewrite L2 information do not have any associated ifnet. Approved by: re@ (gjb@) Sponsored by: Chelsio Communications Modified: head/sys/dev/cxgbe/t4_l2t.c Modified: head/sys/dev/cxgbe/t4_l2t.c ============================================================================== --- head/sys/dev/cxgbe/t4_l2t.c Fri Jul 1 21:09:30 2016 (r302312) +++ head/sys/dev/cxgbe/t4_l2t.c Fri Jul 1 23:18:49 2016 (r302313) @@ -307,7 +307,6 @@ sysctl_l2t(SYSCTL_HANDLER_ARGS) } /* - * XXX: e->ifp may not be around. * XXX: IPv6 addresses may not align properly in the output. */ sbuf_printf(sb, "\n%4u %-15s %02x:%02x:%02x:%02x:%02x:%02x %4d" @@ -316,7 +315,7 @@ sysctl_l2t(SYSCTL_HANDLER_ARGS) e->dmac[3], e->dmac[4], e->dmac[5], e->vlan & 0xfff, vlan_prio(e), e->lport, l2e_state(e), atomic_load_acq_int(&e->refcnt), - e->ifp->if_xname); + e->ifp ? e->ifp->if_xname : "-"); skip: mtx_unlock(&e->lock); } From owner-svn-src-head@freebsd.org Sat Jul 2 08:04:48 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CFD75B8E87C; Sat, 2 Jul 2016 08:04:48 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail107.syd.optusnet.com.au (mail107.syd.optusnet.com.au [211.29.132.53]) by mx1.freebsd.org (Postfix) with ESMTP id 4AF652917; Sat, 2 Jul 2016 08:04:47 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from besplex.bde.org (c110-21-100-149.carlnfd1.nsw.optusnet.com.au [110.21.100.149]) by mail107.syd.optusnet.com.au (Postfix) with ESMTPS id 068ACD42CAC; Sat, 2 Jul 2016 18:04:43 +1000 (AEST) Date: Sat, 2 Jul 2016 18:04:43 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Konstantin Belousov cc: Bruce Evans , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r302252 - head/sys/kern In-Reply-To: <20160701142516.GW38613@kib.kiev.ua> Message-ID: <20160702153817.O1458@besplex.bde.org> References: <201606281643.u5SGhNsi061606@repo.freebsd.org> <20160629175917.O968@besplex.bde.org> <20160629145443.GG38613@kib.kiev.ua> <20160629153233.GI38613@kib.kiev.ua> <20160630040123.F791@besplex.bde.org> <20160629211953.GK38613@kib.kiev.ua> <20160701005401.Q1084@besplex.bde.org> <20160630180106.GU38613@kib.kiev.ua> <20160701031549.GV38613@kib.kiev.ua> <20160701185743.Q1600@besplex.bde.org> <20160701142516.GW38613@kib.kiev.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=M8SwUHEs c=1 sm=1 tr=0 a=XDAe9YG+7EcdVXYrgT+/UQ==:117 a=XDAe9YG+7EcdVXYrgT+/UQ==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=4ILv6jHNVIxmPAOTChkA:9 a=VCnQGyt-0XnCwhVq:21 a=62pVOZO2BG-M9G8m:21 a=CjuIK1q_8ugA:10 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Sat, 02 Jul 2016 08:04:48 -0000 On Fri, 1 Jul 2016, Konstantin Belousov wrote: > On Fri, Jul 01, 2016 at 08:39:48PM +1000, Bruce Evans wrote: >> It seems simple and clean enough, but is too much during a re freeze. >> >> I will only make some minor comments about style. > Well, it is not only about style. If you have no more comments, I will > ask for testing. The patch is about fixing bugs, although in somewhat > extended scope, so I think it is still fine as the things do not explode. What about FFCLOCK? That is hard to test. > I added the stats to the patch, it is not that intrusive actually. > > I still do not see why/do not want to use spinlock for the tc_windup() > exclusion. Patch is at the end of the message. It subverts the mutex/witness method for no good reason. You can use mtx_trylock() for the conditional locking. Not so good reasons for doing this are to micro-optimize and to avoid hard-disabling interrupts on the current CPU). But here optimization is not important and hard-disabling interrupts is a feature. Mutexes are only slightly slower, except with debugging options they are much slower but give more features. >>> diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c >>> index 56b2ade..a0dce47 100644 >>> --- a/sys/compat/linprocfs/linprocfs.c >>> +++ b/sys/compat/linprocfs/linprocfs.c >>> @@ -447,9 +447,11 @@ linprocfs_dostat(PFS_FILL_ARGS) >>> struct pcpu *pcpu; >>> long cp_time[CPUSTATES]; >>> long *cp; >>> + struct timeval boottime; >>> int i; >>> >>> read_cpu_time(cp_time); >>> + getboottime(&boottime); >> >> This is used surprisingly often by too many subsystems. With the value still >> broken so that locking it doesn't help much, I would leave it as a global. > I prefer to keep the KPI consistent. Not changing the KPI means keeping boottime as a global. getboottime() is a good KPI for accessing/converting a volatile implementation detail, but a correctly implemented boottime wouldn't be volatile and most uses of boottime are apparently wrong. Most uses are apparently to convert from monotic time to real time. For that, the KPI should be a conversion function. >... >> So maybe use a new general function that returns boottimebin for the >> non-uptime functions only. Possibly it can add the offset directly. > I changed getbintime() and getboottimebin() to use the fenced magic and > fetch boottime inside the loop. This removed the need for binuptime1(). Good. >>> diff --git a/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c b/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c >>> index 1d07943..0879299 100644 >>> --- a/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c >>> +++ b/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c >>> @@ -504,11 +504,13 @@ svc_rpc_gss_find_client(struct svc_rpc_gss_clientid *id) >>> { >>> struct svc_rpc_gss_client *client; >>> struct svc_rpc_gss_client_list *list; >>> + struct timeval boottime; >>> unsigned long hostid; >>> >>> rpc_gss_log_debug("in svc_rpc_gss_find_client(%d)", id->ci_id); >>> >>> getcredhostid(curthread->td_ucred, &hostid); >>> + getboottime(&boottime); >>> if (id->ci_hostid != hostid || id->ci_boottime != boottime.tv_sec) >>> return (NULL); >> >> Here it is hopefully just a magic id, with the user being a remote system. >> Any time that doesn't go backwards or forwards so far that it is in the >> lieftime of an old or new boot instance works well for identifying the >> boot instance. > It does not work for leap seconds in the same way as is does not work after > setclock(). So I just leave this conversion as is. We need to understand what such conversions are trying to do. Currently, adding boottime mostly does work for converting monotonic time to real time, since it is the same as what nanotime() and friends do (except with more races). E.g., the leap seconds adjustment normally subtracts 1 second from boottime so that when the monotonic time advances by 1 second the sum doesn't advance and thus gives the real time with POSIX's broken encoding. So the conversion is currently correct if the result is supposed to be the real time with POSIX's encoding. It is unclear what this is useful for. It is non-monotic, and you can't even depend on reversing the conversion by subtracting boottime since boottime isn't invariant. On Fri, 1 Jul 2016, Konstantin Belousov wrote: > On Fri, Jul 01, 2016 at 08:39:48PM +1000, Bruce Evans wrote: >> It seems simple and clean enough, but is too much during a re freeze. >> >> I will only make some minor comments about style. > Well, it is not only about style. If you have no more comments, I will > ask for testing. The patch is about fixing bugs, although in somewhat > extended scope, so I think it is still fine as the things do not explode. What about FFCLOCK? That is hard to test. > I added the stats to the patch, it is not that intrusive actually. > > I still do not see why/do not want to use spinlock for the tc_windup() > exclusion. Patch is at the end of the message. It subverts the mutex/witness method for no good reason. You can use mtx_trylock() for the conditional locking. Not so good reasons for doing this are to micro-optimize and to avoid hard-disabling interrupts on the current CPU). But here optimization is not important and hard-disabling interrupts is a feature. Mutexes are only slightly slower, except with debugging options they are much slower but give more features. >>> diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c >>> index 56b2ade..a0dce47 100644 >>> --- a/sys/compat/linprocfs/linprocfs.c >>> +++ b/sys/compat/linprocfs/linprocfs.c >>> @@ -447,9 +447,11 @@ linprocfs_dostat(PFS_FILL_ARGS) >>> struct pcpu *pcpu; >>> long cp_time[CPUSTATES]; >>> long *cp; >>> + struct timeval boottime; >>> int i; >>> >>> read_cpu_time(cp_time); >>> + getboottime(&boottime); >> >> This is used surprisingly often by too many subsystems. With the value still >> broken so that locking it doesn't help much, I would leave it as a global. > I prefer to keep the KPI consistent. Not changing the KPI means keeping boottime as a global. getboottime() is a good KPI for accessing/converting a volatile implementation detail, but a correctly implemented boottime wouldn't be volatile and most uses of boottime are apparently wrong. Most uses are apparently to convert from monotic time to real time. For that, the KPI should be a conversion function. >... >> So maybe use a new general function that returns boottimebin for the >> non-uptime functions only. Possibly it can add the offset directly. > I changed getbintime() and getboottimebin() to use the fenced magic and > fetch boottime inside the loop. This removed the need for binuptime1(). Good. >>> diff --git a/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c b/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c >>> index 1d07943..0879299 100644 >>> --- a/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c >>> +++ b/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c >>> @@ -504,11 +504,13 @@ svc_rpc_gss_find_client(struct svc_rpc_gss_clientid *id) >>> { >>> struct svc_rpc_gss_client *client; >>> struct svc_rpc_gss_client_list *list; >>> + struct timeval boottime; >>> unsigned long hostid; >>> >>> rpc_gss_log_debug("in svc_rpc_gss_find_client(%d)", id->ci_id); >>> >>> getcredhostid(curthread->td_ucred, &hostid); >>> + getboottime(&boottime); >>> if (id->ci_hostid != hostid || id->ci_boottime != boottime.tv_sec) >>> return (NULL); >> >> Here it is hopefully just a magic id, with the user being a remote system. >> Any time that doesn't go backwards or forwards so far that it is in the >> lieftime of an old or new boot instance works well for identifying the >> boot instance. > It does not work for leap seconds in the same way as is does not work after > setclock(). So I just leave this conversion as is. We need to understand what such conversions are trying to do. Currently, adding boottime mostly does work for converting monotonic time to real time, since it is the same as what nanotime() and friends do (except with more races). E.g., the leap seconds adjustment normally subtracts 1 second from boottime so that when the monotonic time advances by 1 second the sum doesn't advance and thus gives the real time with POSIX's broken encoding. So the conversion is currently correct if the result is supposed to be the real time with POSIX's encoding. It is unclear what this is useful for. It is non-monotic, and you can't even depend on reversing the conversion by subtracting boottime since boottime isn't invariant. > diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c > index 56b2ade..a0dce47 100644 > --- a/sys/compat/linprocfs/linprocfs.c > +++ b/sys/compat/linprocfs/linprocfs.c > @@ -447,9 +447,11 @@ linprocfs_dostat(PFS_FILL_ARGS) > struct pcpu *pcpu; > long cp_time[CPUSTATES]; > long *cp; > + struct timeval boottime; > int i; > > read_cpu_time(cp_time); > + getboottime(&boottime); > sbuf_printf(sb, "cpu %ld %ld %ld %ld\n", > T2J(cp_time[CP_USER]), > T2J(cp_time[CP_NICE]), linprocfs's use of boottime is easy to understand. One use is quite broken. linprocfs prints the boot time. This use is OK. linprocfs wants to print ki_start. ki_start is a real time. ps just prints it. But linprocfs subtracts the boot time from it before printing it. This make no sense. Kernel times are kept in p->p_stats->p_start. These are monotonic times. ki_start is this monotonic time misconverted by adding the current boottime. This would be correct if boottime were invariant. Currently it adds the current leap seconds adjustment and larger non-invariance. p_start is not used for much except to print it in ps and friends, so using monotonic time for it seems to be wrong. In FreeBSD-4, it was the real time. des changed it in 2003 to "This fixes a potential problem in the accounting code, which would compute the elapsed time incorrectly if the Unix time was stepped during the lifetime of the process." But it obviously causes much larger non-potential problems -- any step to fix drift or stopping (suspension) of the clock should not affect times in the past like the start time, but now does. Oops, there is a problem in acct_process(). This needs both a real time and a monotonic time for the start time. ac_btime is the real time of the start. This is calculated by adding boottime to p_start. ac_etime is the elapsed time. This is calculated by subtracing the current monotonic time from the monotonic p_start. des's change fixes this. Applications would still be confused if they add ac_btime to ac_etime and get a time in the future. des maintains linprocfs, and perhaps the difference is supposed to be the elapsed time there too, but its keyword is "starttime". > diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c > index 7cc0f9e..afa3da4 100644 > --- a/sys/fs/devfs/devfs_vnops.c > +++ b/sys/fs/devfs/devfs_vnops.c > @@ -707,10 +707,11 @@ devfs_getattr(struct vop_getattr_args *ap) > { > struct vnode *vp = ap->a_vp; > struct vattr *vap = ap->a_vap; > - int error; > struct devfs_dirent *de; > struct devfs_mount *dmp; > struct cdev *dev; > + struct timeval boottime; > + int error; > > error = devfs_populate_vp(vp); > if (error != 0) devfs's use of boottime is also easy to understand, and we (you :-) get to maintain devfs. devfs has problems initializing times because it creates device files before the current (real) time is fully initialized (I think before it is initialized at all). For early initialization, it is natural to set all times to the Epoch (0). This can be used as a flag for uninitialized. devfs actually uses the condition tv_sec <= 3600 as a condition for uninitialized. (3600 is a strange value. Why not 86400 so as to handle all possible timezone misadjustments?). When the todr is on wall time, this fixup only works East of Greenwich. It never works here. Device times here are initialized to a time 10-11 hours in the future if first access to the device is before adjkerntz runs to fix up the time. The future times are not considered to be uninitialized, so the fixup is not applied. same problem may affect other file systems, but mostly only affects ones with buggy setting of access times for read-only mounts. This bug was fixed in ffs a couple of years ago.) devfs doesn't support birth times, or the problem would be even more obvious. Later accesses tend to clobber the future times back to the current time, but the birth time would be invariant. This problem is much like the one of getting an invariant boot time. Real times are not really known until after adjkerntz adjusts for the timezone offset in the todr and ntp adjusts for the error in the todr. > diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c > index 0f015b3..c9676fc 100644 > --- a/sys/kern/kern_tc.c > +++ b/sys/kern/kern_tc.c > @@ -70,31 +70,22 @@ struct timehands { > ... > static struct timehands th0 = { > - &dummy_timecounter, > - 0, > - (uint64_t)-1 / 1000000, > - 0, > - {1, 0}, > - {0, 0}, > - {0, 0}, > - 1, > - &th1 > + .th_counter = &dummy_timecounter, > + .th_scale = (uint64_t)-1 / 1000000, > + .th_offset = {1, 0}, Is there a syntax for avoiding the explicit 0 in a nested initializer? Something like th_offset.tv_sec = 1. > @@ -378,8 +384,18 @@ microuptime(struct timeval *tvp) > void > bintime(struct bintime *bt) > { > + struct bintime boottimebin; > + struct timehands *th; > + u_int gen; > > - binuptime(bt); > + do { > + th = timehands; > + gen = atomic_load_acq_int(&th->th_generation); > + *bt = th->th_offset; > + bintime_addx(bt, th->th_scale * tc_delta(th)); > + boottimebin = th->th_boottime; > + atomic_thread_fence_acq(); > + } while (gen == 0 || gen != th->th_generation); > bintime_add(bt, &boottimebin); > } Better add th_boottime in the loop (and not use a local variable). This saves copying it in the usual case where the loop is only iterated once. Note that th_offset is already copied to the caller's variable and not to a local variable. This is not so good for adding the boot time to it. It might be better to go the other way and copy everything to local variables, but I fear that register pressure and memory clobbers will prevent generating best code then. Best code is to copy everything to registers, then check the generation count, then combine the registers outside the loop. > ... > diff --git a/sys/sys/time.h b/sys/sys/time.h > index 395e888..659f8e0 100644 > --- a/sys/sys/time.h > +++ b/sys/sys/time.h > @@ -372,8 +372,6 @@ void resettodr(void); > > extern volatile time_t time_second; > extern volatile time_t time_uptime; > -extern struct bintime boottimebin; > -extern struct timeval boottime; > extern struct bintime tc_tick_bt; > extern sbintime_t tc_tick_sbt; > extern struct bintime tick_bt; Can we fix more style bugs in this file? Here the variables were unsorted and misindented. > @@ -440,6 +438,9 @@ void getbintime(struct bintime *bt); > void getnanotime(struct timespec *tsp); > void getmicrotime(struct timeval *tvp); > > +void getboottime(struct timeval *boottime); > +void getboottimebin(struct bintime *boottimebin); > + > /* Other functions */ > int itimerdecr(struct itimerval *itp, int usec); > int itimerfix(struct timeval *tv); > The new functions probably belong in a new section, but they are only in a subsection of the previous section. They are "Other", not ones described in the comment for the previous section. The comment also doesn't describe the sbintime functions in the section. The placement of these functions also breaks the style of putting inline functions earlier. Other style bugs visible here are verbose variable names and missing 'p' in pointer names mostly for newer functions. The worse names were copied from the function implementations. Bruce From owner-svn-src-head@freebsd.org Sat Jul 2 11:54:22 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3ED77B86DF8; Sat, 2 Jul 2016 11:54:22 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0BEE82DB8; Sat, 2 Jul 2016 11:54:21 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u62BsLf2098726; Sat, 2 Jul 2016 11:54:21 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u62BsLI5098724; Sat, 2 Jul 2016 11:54:21 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201607021154.u62BsLI5098724@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Sat, 2 Jul 2016 11:54:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302316 - head/sbin/ipfw X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Sat, 02 Jul 2016 11:54:22 -0000 Author: ae Date: Sat Jul 2 11:54:20 2016 New Revision: 302316 URL: https://svnweb.freebsd.org/changeset/base/302316 Log: Hide warning about non-existent lookup tables and informational messages about modified table entry when quied mode enabled. Approved by: re (hrs) Obtained from: Yandex LLC Modified: head/sbin/ipfw/tables.c Modified: head/sbin/ipfw/tables.c ============================================================================== --- head/sbin/ipfw/tables.c Sat Jul 2 05:31:59 2016 (r302315) +++ head/sbin/ipfw/tables.c Sat Jul 2 11:54:20 2016 (r302316) @@ -914,9 +914,10 @@ table_modify_record(ipfw_obj_header *oh, xi.vmask = vmask; strlcpy(xi.tablename, oh->ntlv.name, sizeof(xi.tablename)); - fprintf(stderr, "DEPRECATED: inserting data into " - "non-existent table %s. (auto-created)\n", - xi.tablename); + if (quiet == 0) + warnx("DEPRECATED: inserting data into " + "non-existent table %s. (auto-created)", + xi.tablename); table_do_create(oh, &xi); } @@ -937,8 +938,6 @@ table_modify_record(ipfw_obj_header *oh, error = table_do_modify_record(cmd, oh, tent_buf, count, atomic); - quiet = 0; - /* * Compatibility stuff: do not yell on duplicate keys or * failed deletions. From owner-svn-src-head@freebsd.org Sat Jul 2 14:51:47 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 70FF0B8FB05; Sat, 2 Jul 2016 14:51:47 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BB5DE2D1B; Sat, 2 Jul 2016 14:51:46 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u62EpYHX037165 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Sat, 2 Jul 2016 17:51:35 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u62EpYHX037165 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id u62EpYla037164; Sat, 2 Jul 2016 17:51:34 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 2 Jul 2016 17:51:34 +0300 From: Konstantin Belousov To: Bruce Evans Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r302252 - head/sys/kern Message-ID: <20160702145134.GI38613@kib.kiev.ua> References: <20160629145443.GG38613@kib.kiev.ua> <20160629153233.GI38613@kib.kiev.ua> <20160630040123.F791@besplex.bde.org> <20160629211953.GK38613@kib.kiev.ua> <20160701005401.Q1084@besplex.bde.org> <20160630180106.GU38613@kib.kiev.ua> <20160701031549.GV38613@kib.kiev.ua> <20160701185743.Q1600@besplex.bde.org> <20160701142516.GW38613@kib.kiev.ua> <20160702153817.O1458@besplex.bde.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160702153817.O1458@besplex.bde.org> User-Agent: Mutt/1.6.1 (2016-04-27) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Sat, 02 Jul 2016 14:51:47 -0000 On Sat, Jul 02, 2016 at 06:04:43PM +1000, Bruce Evans wrote: > On Fri, 1 Jul 2016, Konstantin Belousov wrote: > > > On Fri, Jul 01, 2016 at 08:39:48PM +1000, Bruce Evans wrote: > >> It seems simple and clean enough, but is too much during a re freeze. > >> > >> I will only make some minor comments about style. > > Well, it is not only about style. If you have no more comments, I will > > ask for testing. The patch is about fixing bugs, although in somewhat > > extended scope, so I think it is still fine as the things do not explode. > > What about FFCLOCK? That is hard to test. I will only ensure that it compiles. > > > I added the stats to the patch, it is not that intrusive actually. > > > > I still do not see why/do not want to use spinlock for the tc_windup() > > exclusion. Patch is at the end of the message. > > It subverts the mutex/witness method for no good reason. You can use > mtx_trylock() for the conditional locking. Not so good reasons for > doing this are to micro-optimize and to avoid hard-disabling interrupts > on the current CPU). But here optimization is not important and > hard-disabling interrupts is a feature. Mutexes are only slightly > slower, except with debugging options they are much slower but give > more features. A reason not to use what you described is that our spinlocks lack try method. I implemented non-recursive trylock_spin. > > >>> diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c > >>> index 56b2ade..a0dce47 100644 > >>> --- a/sys/compat/linprocfs/linprocfs.c > >>> +++ b/sys/compat/linprocfs/linprocfs.c > >>> @@ -447,9 +447,11 @@ linprocfs_dostat(PFS_FILL_ARGS) > >>> struct pcpu *pcpu; > >>> long cp_time[CPUSTATES]; > >>> long *cp; > >>> + struct timeval boottime; > >>> int i; > >>> > >>> read_cpu_time(cp_time); > >>> + getboottime(&boottime); > >> > >> This is used surprisingly often by too many subsystems. With the value still > >> broken so that locking it doesn't help much, I would leave it as a global. > > I prefer to keep the KPI consistent. > > Not changing the KPI means keeping boottime as a global. getboottime() is > a good KPI for accessing/converting a volatile implementation detail, but > a correctly implemented boottime wouldn't be volatile and most uses of > boottime are apparently wrong. Most uses are apparently to convert from > monotic time to real time. For that, the KPI should be a conversion function. I have to stop somewhere with this patch. In particular, I decided to not do the sweeping pass over random subsystems doing bugfixes for what you described above. Current patch bug-to-bug compatible with the existing code, and I will not expand it. > We need to understand what such conversions are trying to do. ... some time later. > > diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c > > index 0f015b3..c9676fc 100644 > > --- a/sys/kern/kern_tc.c > > +++ b/sys/kern/kern_tc.c > > @@ -70,31 +70,22 @@ struct timehands { > > ... > > static struct timehands th0 = { > > - &dummy_timecounter, > > - 0, > > - (uint64_t)-1 / 1000000, > > - 0, > > - {1, 0}, > > - {0, 0}, > > - {0, 0}, > > - 1, > > - &th1 > > + .th_counter = &dummy_timecounter, > > + .th_scale = (uint64_t)-1 / 1000000, > > + .th_offset = {1, 0}, > > Is there a syntax for avoiding the explicit 0 in a nested initializer? > Something like th_offset.tv_sec = 1. .th_offset = { .sec = 1 }, > > > @@ -378,8 +384,18 @@ microuptime(struct timeval *tvp) > > void > > bintime(struct bintime *bt) > > { > > + struct bintime boottimebin; > > + struct timehands *th; > > + u_int gen; > > > > - binuptime(bt); > > + do { > > + th = timehands; > > + gen = atomic_load_acq_int(&th->th_generation); > > + *bt = th->th_offset; > > + bintime_addx(bt, th->th_scale * tc_delta(th)); > > + boottimebin = th->th_boottime; > > + atomic_thread_fence_acq(); > > + } while (gen == 0 || gen != th->th_generation); > > bintime_add(bt, &boottimebin); > > } > > Better add th_boottime in the loop (and not use a local variable). This > saves copying it in the usual case where the loop is only iterated once. Ok. > > Note that th_offset is already copied to the caller's variable and not > to a local variable. This is not so good for adding the boot time to > it. It might be better to go the other way and copy everything to > local variables, but I fear that register pressure and memory clobbers > will prevent generating best code then. Best code is to copy everything > to registers, then check the generation count, then combine the registers > outside the loop. Lets postpone this, the patch does already enough rototiling. > > > ... > > diff --git a/sys/sys/time.h b/sys/sys/time.h > > index 395e888..659f8e0 100644 > > --- a/sys/sys/time.h > > +++ b/sys/sys/time.h > > @@ -372,8 +372,6 @@ void resettodr(void); > > > > extern volatile time_t time_second; > > extern volatile time_t time_uptime; > > -extern struct bintime boottimebin; > > -extern struct timeval boottime; > > extern struct bintime tc_tick_bt; > > extern sbintime_t tc_tick_sbt; > > extern struct bintime tick_bt; > > Can we fix more style bugs in this file? Here the variables were unsorted > and misindented. And this. diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c index 56b2ade..a0dce47 100644 --- a/sys/compat/linprocfs/linprocfs.c +++ b/sys/compat/linprocfs/linprocfs.c @@ -447,9 +447,11 @@ linprocfs_dostat(PFS_FILL_ARGS) struct pcpu *pcpu; long cp_time[CPUSTATES]; long *cp; + struct timeval boottime; int i; read_cpu_time(cp_time); + getboottime(&boottime); sbuf_printf(sb, "cpu %ld %ld %ld %ld\n", T2J(cp_time[CP_USER]), T2J(cp_time[CP_NICE]), @@ -624,10 +626,12 @@ static int linprocfs_doprocstat(PFS_FILL_ARGS) { struct kinfo_proc kp; + struct timeval boottime; char state; static int ratelimit = 0; vm_offset_t startcode, startdata; + getboottime(&boottime); sx_slock(&proctree_lock); PROC_LOCK(p); fill_kinfo_proc(p, &kp); diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c index 7cc0f9e..afa3da4 100644 --- a/sys/fs/devfs/devfs_vnops.c +++ b/sys/fs/devfs/devfs_vnops.c @@ -707,10 +707,11 @@ devfs_getattr(struct vop_getattr_args *ap) { struct vnode *vp = ap->a_vp; struct vattr *vap = ap->a_vap; - int error; struct devfs_dirent *de; struct devfs_mount *dmp; struct cdev *dev; + struct timeval boottime; + int error; error = devfs_populate_vp(vp); if (error != 0) @@ -740,6 +741,7 @@ devfs_getattr(struct vop_getattr_args *ap) vap->va_blocksize = DEV_BSIZE; vap->va_type = vp->v_type; + getboottime(&boottime); #define fix(aa) \ do { \ if ((aa).tv_sec <= 3600) { \ diff --git a/sys/fs/fdescfs/fdesc_vnops.c b/sys/fs/fdescfs/fdesc_vnops.c index 4f6e1b9..65b8a54 100644 --- a/sys/fs/fdescfs/fdesc_vnops.c +++ b/sys/fs/fdescfs/fdesc_vnops.c @@ -394,7 +394,9 @@ fdesc_getattr(struct vop_getattr_args *ap) { struct vnode *vp = ap->a_vp; struct vattr *vap = ap->a_vap; + struct timeval boottime; + getboottime(&boottime); vap->va_mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH; vap->va_fileid = VTOFDESC(vp)->fd_ix; vap->va_uid = 0; diff --git a/sys/fs/nfs/nfsport.h b/sys/fs/nfs/nfsport.h index 921df2d..6b41e2f 100644 --- a/sys/fs/nfs/nfsport.h +++ b/sys/fs/nfs/nfsport.h @@ -872,7 +872,7 @@ int newnfs_realign(struct mbuf **, int); /* * Set boottime. */ -#define NFSSETBOOTTIME(b) ((b) = boottime) +#define NFSSETBOOTTIME(b) (getboottime(&b)) /* * The size of directory blocks in the buffer cache. diff --git a/sys/fs/procfs/procfs_status.c b/sys/fs/procfs/procfs_status.c index 5a00ee1..defdec3 100644 --- a/sys/fs/procfs/procfs_status.c +++ b/sys/fs/procfs/procfs_status.c @@ -70,6 +70,7 @@ procfs_doprocstatus(PFS_FILL_ARGS) const char *wmesg; char *pc; char *sep; + struct timeval boottime; int pid, ppid, pgid, sid; int i; @@ -129,6 +130,7 @@ procfs_doprocstatus(PFS_FILL_ARGS) calcru(p, &ut, &st); PROC_STATUNLOCK(p); start = p->p_stats->p_start; + getboottime(&boottime); timevaladd(&start, &boottime); sbuf_printf(sb, " %jd,%ld %jd,%ld %jd,%ld", (intmax_t)start.tv_sec, start.tv_usec, diff --git a/sys/kern/kern_acct.c b/sys/kern/kern_acct.c index ef3fd2e..46e6d9b 100644 --- a/sys/kern/kern_acct.c +++ b/sys/kern/kern_acct.c @@ -389,7 +389,7 @@ acct_process(struct thread *td) acct.ac_stime = encode_timeval(st); /* (4) The elapsed time the command ran (and its starting time) */ - tmp = boottime; + getboottime(&tmp); timevaladd(&tmp, &p->p_stats->p_start); acct.ac_btime = tmp.tv_sec; microuptime(&tmp); diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c index e7a7a99..39ffdb3 100644 --- a/sys/kern/kern_clock.c +++ b/sys/kern/kern_clock.c @@ -381,7 +381,9 @@ volatile int ticks; int psratio; static DPCPU_DEFINE(int, pcputicks); /* Per-CPU version of ticks. */ -static int global_hardclock_run = 0; +#ifdef DEVICE_POLLING +static int devpoll_run = 0; +#endif /* * Initialize clock frequencies and start both clocks running. @@ -584,15 +586,15 @@ hardclock_cnt(int cnt, int usermode) #endif /* We are in charge to handle this tick duty. */ if (newticks > 0) { - /* Dangerous and no need to call these things concurrently. */ - if (atomic_cmpset_acq_int(&global_hardclock_run, 0, 1)) { - tc_ticktock(newticks); + tc_ticktock(newticks); #ifdef DEVICE_POLLING + /* Dangerous and no need to call these things concurrently. */ + if (atomic_cmpset_acq_int(&devpoll_run, 0, 1)) { /* This is very short and quick. */ hardclock_device_poll(); -#endif /* DEVICE_POLLING */ - atomic_store_rel_int(&global_hardclock_run, 0); + atomic_store_rel_int(&devpoll_run, 0); } +#endif /* DEVICE_POLLING */ #ifdef SW_WATCHDOG if (watchdog_enabled > 0) { i = atomic_fetchadd_int(&watchdog_ticks, -newticks); diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c index d167205..ae236eb 100644 --- a/sys/kern/kern_mutex.c +++ b/sys/kern/kern_mutex.c @@ -281,6 +281,39 @@ __mtx_lock_spin_flags(volatile uintptr_t *c, int opts, const char *file, WITNESS_LOCK(&m->lock_object, opts | LOP_EXCLUSIVE, file, line); } +int +__mtx_trylock_spin_flags(volatile uintptr_t *c, int opts, const char *file, + int line) +{ + struct mtx *m; + + if (SCHEDULER_STOPPED()) + return (1); + + m = mtxlock2mtx(c); + + KASSERT(m->mtx_lock != MTX_DESTROYED, + ("mtx_lock_spin() of destroyed mutex @ %s:%d", file, line)); + KASSERT(LOCK_CLASS(&m->lock_object) == &lock_class_mtx_spin, + ("mtx_lock_spin() of sleep mutex %s @ %s:%d", + m->lock_object.lo_name, file, line)); + if (mtx_owned(m)) + KASSERT((m->lock_object.lo_flags & LO_RECURSABLE) != 0 || + (opts & MTX_RECURSE) != 0, + ("mtx_lock_spin: recursed on non-recursive mutex %s @ %s:%d\n", + m->lock_object.lo_name, file, line)); + opts &= ~MTX_RECURSE; + WITNESS_CHECKORDER(&m->lock_object, opts | LOP_NEWORDER | LOP_EXCLUSIVE, + file, line, NULL); + if (__mtx_trylock_spin(m, curthread, opts, file, line)) { + LOCK_LOG_TRY("LOCK", &m->lock_object, opts, 1, file, line); + WITNESS_LOCK(&m->lock_object, opts | LOP_EXCLUSIVE, file, line); + return (1); + } + LOCK_LOG_TRY("LOCK", &m->lock_object, opts, 0, file, line); + return (0); +} + void __mtx_unlock_spin_flags(volatile uintptr_t *c, int opts, const char *file, int line) diff --git a/sys/kern/kern_ntptime.c b/sys/kern/kern_ntptime.c index d352ee7..efc3713 100644 --- a/sys/kern/kern_ntptime.c +++ b/sys/kern/kern_ntptime.c @@ -162,29 +162,12 @@ static l_fp time_adj; /* tick adjust (ns/s) */ static int64_t time_adjtime; /* correction from adjtime(2) (usec) */ -static struct mtx ntpadj_lock; -MTX_SYSINIT(ntpadj, &ntpadj_lock, "ntpadj", -#ifdef PPS_SYNC - MTX_SPIN -#else - MTX_DEF -#endif -); +static struct mtx ntp_lock; +MTX_SYSINIT(ntp, &ntp_lock, "ntp", MTX_SPIN); -/* - * When PPS_SYNC is defined, hardpps() function is provided which can - * be legitimately called from interrupt filters. Due to this, use - * spinlock for ntptime state protection, otherwise sleepable mutex is - * adequate. - */ -#ifdef PPS_SYNC -#define NTPADJ_LOCK() mtx_lock_spin(&ntpadj_lock) -#define NTPADJ_UNLOCK() mtx_unlock_spin(&ntpadj_lock) -#else -#define NTPADJ_LOCK() mtx_lock(&ntpadj_lock) -#define NTPADJ_UNLOCK() mtx_unlock(&ntpadj_lock) -#endif -#define NTPADJ_ASSERT_LOCKED() mtx_assert(&ntpadj_lock, MA_OWNED) +#define NTP_LOCK() mtx_lock_spin(&ntp_lock) +#define NTP_UNLOCK() mtx_unlock_spin(&ntp_lock) +#define NTP_ASSERT_LOCKED() mtx_assert(&ntp_lock, MA_OWNED) #ifdef PPS_SYNC /* @@ -271,7 +254,7 @@ ntp_gettime1(struct ntptimeval *ntvp) { struct timespec atv; /* nanosecond time */ - NTPADJ_ASSERT_LOCKED(); + NTP_ASSERT_LOCKED(); nanotime(&atv); ntvp->time.tv_sec = atv.tv_sec; @@ -302,9 +285,9 @@ sys_ntp_gettime(struct thread *td, struct ntp_gettime_args *uap) { struct ntptimeval ntv; - NTPADJ_LOCK(); + NTP_LOCK(); ntp_gettime1(&ntv); - NTPADJ_UNLOCK(); + NTP_UNLOCK(); td->td_retval[0] = ntv.time_state; return (copyout(&ntv, uap->ntvp, sizeof(ntv))); @@ -315,9 +298,9 @@ ntp_sysctl(SYSCTL_HANDLER_ARGS) { struct ntptimeval ntv; /* temporary structure */ - NTPADJ_LOCK(); + NTP_LOCK(); ntp_gettime1(&ntv); - NTPADJ_UNLOCK(); + NTP_UNLOCK(); return (sysctl_handle_opaque(oidp, &ntv, sizeof(ntv), req)); } @@ -382,7 +365,7 @@ sys_ntp_adjtime(struct thread *td, struct ntp_adjtime_args *uap) error = priv_check(td, PRIV_NTP_ADJTIME); if (error != 0) return (error); - NTPADJ_LOCK(); + NTP_LOCK(); if (modes & MOD_MAXERROR) time_maxerror = ntv.maxerror; if (modes & MOD_ESTERROR) @@ -484,7 +467,7 @@ sys_ntp_adjtime(struct thread *td, struct ntp_adjtime_args *uap) ntv.stbcnt = pps_stbcnt; #endif /* PPS_SYNC */ retval = ntp_is_time_error(time_status) ? TIME_ERROR : time_state; - NTPADJ_UNLOCK(); + NTP_UNLOCK(); error = copyout((caddr_t)&ntv, (caddr_t)uap->tp, sizeof(ntv)); if (error == 0) @@ -506,6 +489,8 @@ ntp_update_second(int64_t *adjustment, time_t *newsec) int tickrate; l_fp ftemp; /* 32/64-bit temporary */ + NTP_LOCK(); + /* * On rollover of the second both the nanosecond and microsecond * clocks are updated and the state machine cranked as @@ -627,6 +612,8 @@ ntp_update_second(int64_t *adjustment, time_t *newsec) else time_status &= ~STA_PPSSIGNAL; #endif /* PPS_SYNC */ + + NTP_UNLOCK(); } /* @@ -690,7 +677,7 @@ hardupdate(offset) long mtemp; l_fp ftemp; - NTPADJ_ASSERT_LOCKED(); + NTP_ASSERT_LOCKED(); /* * Select how the phase is to be controlled and from which @@ -772,7 +759,7 @@ hardpps(tsp, nsec) long u_sec, u_nsec, v_nsec; /* temps */ l_fp ftemp; - NTPADJ_LOCK(); + NTP_LOCK(); /* * The signal is first processed by a range gate and frequency @@ -956,7 +943,7 @@ hardpps(tsp, nsec) time_freq = pps_freq; out: - NTPADJ_UNLOCK(); + NTP_UNLOCK(); } #endif /* PPS_SYNC */ @@ -999,11 +986,11 @@ kern_adjtime(struct thread *td, struct timeval *delta, struct timeval *olddelta) return (error); ltw = (int64_t)delta->tv_sec * 1000000 + delta->tv_usec; } - NTPADJ_LOCK(); + NTP_LOCK(); ltr = time_adjtime; if (delta != NULL) time_adjtime = ltw; - NTPADJ_UNLOCK(); + NTP_UNLOCK(); if (olddelta != NULL) { atv.tv_sec = ltr / 1000000; atv.tv_usec = ltr % 1000000; diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index 2f1f620..892b23a 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -872,6 +872,7 @@ fill_kinfo_proc_only(struct proc *p, struct kinfo_proc *kp) struct session *sp; struct ucred *cred; struct sigacts *ps; + struct timeval boottime; /* For proc_realparent. */ sx_assert(&proctree_lock, SX_LOCKED); @@ -953,6 +954,7 @@ fill_kinfo_proc_only(struct proc *p, struct kinfo_proc *kp) kp->ki_nice = p->p_nice; kp->ki_fibnum = p->p_fibnum; kp->ki_start = p->p_stats->p_start; + getboottime(&boottime); timevaladd(&kp->ki_start, &boottime); PROC_STATLOCK(p); rufetch(p, &kp->ki_rusage); diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index 0f015b3..e917b5a 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -70,31 +70,22 @@ struct timehands { struct bintime th_offset; struct timeval th_microtime; struct timespec th_nanotime; + struct bintime th_boottime; /* Fields not to be copied in tc_windup start with th_generation. */ u_int th_generation; struct timehands *th_next; }; static struct timehands th0; -static struct timehands th9 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th0}; -static struct timehands th8 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th9}; -static struct timehands th7 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th8}; -static struct timehands th6 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th7}; -static struct timehands th5 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th6}; -static struct timehands th4 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th5}; -static struct timehands th3 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th4}; -static struct timehands th2 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th3}; -static struct timehands th1 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th2}; +static struct timehands th1 = { + .th_next = &th0 +}; static struct timehands th0 = { - &dummy_timecounter, - 0, - (uint64_t)-1 / 1000000, - 0, - {1, 0}, - {0, 0}, - {0, 0}, - 1, - &th1 + .th_counter = &dummy_timecounter, + .th_scale = (uint64_t)-1 / 1000000, + .th_offset = { .sec = 1 }, + .th_generation = 1, + .th_next = &th1 }; static struct timehands *volatile timehands = &th0; @@ -106,8 +97,6 @@ int tc_min_ticktock_freq = 1; volatile time_t time_second = 1; volatile time_t time_uptime = 1; -struct bintime boottimebin; -struct timeval boottime; static int sysctl_kern_boottime(SYSCTL_HANDLER_ARGS); SYSCTL_PROC(_kern, KERN_BOOTTIME, boottime, CTLTYPE_STRUCT|CTLFLAG_RD, NULL, 0, sysctl_kern_boottime, "S,timeval", "System boottime"); @@ -135,7 +124,7 @@ SYSCTL_PROC(_kern_timecounter, OID_AUTO, alloweddeviation, static int tc_chosen; /* Non-zero if a specific tc was chosen via sysctl. */ -static void tc_windup(void); +static void tc_windup(struct bintime *new_boottimebin); static void cpu_tick_calibrate(int); void dtrace_getnanotime(struct timespec *tsp); @@ -143,6 +132,10 @@ void dtrace_getnanotime(struct timespec *tsp); static int sysctl_kern_boottime(SYSCTL_HANDLER_ARGS) { + struct timeval boottime; + + getboottime(&boottime); + #ifndef __mips__ #ifdef SCTL_MASK32 int tv[2]; @@ -150,11 +143,11 @@ sysctl_kern_boottime(SYSCTL_HANDLER_ARGS) if (req->flags & SCTL_MASK32) { tv[0] = boottime.tv_sec; tv[1] = boottime.tv_usec; - return SYSCTL_OUT(req, tv, sizeof(tv)); - } else + return (SYSCTL_OUT(req, tv, sizeof(tv))); + } #endif #endif - return SYSCTL_OUT(req, &boottime, sizeof(boottime)); + return (SYSCTL_OUT(req, &boottime, sizeof(boottime))); } static int @@ -164,7 +157,7 @@ sysctl_kern_timecounter_get(SYSCTL_HANDLER_ARGS) struct timecounter *tc = arg1; ncount = tc->tc_get_timecount(tc); - return sysctl_handle_int(oidp, &ncount, 0, req); + return (sysctl_handle_int(oidp, &ncount, 0, req)); } static int @@ -174,7 +167,7 @@ sysctl_kern_timecounter_freq(SYSCTL_HANDLER_ARGS) struct timecounter *tc = arg1; freq = tc->tc_frequency; - return sysctl_handle_64(oidp, &freq, 0, req); + return (sysctl_handle_64(oidp, &freq, 0, req)); } /* @@ -198,7 +191,7 @@ tc_delta(struct timehands *th) */ #ifdef FFCLOCK -void +static void fbclock_binuptime(struct bintime *bt) { struct timehands *th; @@ -234,9 +227,17 @@ fbclock_microuptime(struct timeval *tvp) void fbclock_bintime(struct bintime *bt) { + struct timehands *th; + unsigned int gen; - fbclock_binuptime(bt); - bintime_add(bt, &boottimebin); + do { + th = timehands; + gen = atomic_load_acq_int(&th->th_generation); + *bt = th->th_offset; + bintime_addx(bt, th->th_scale * tc_delta(th)); + bintime_add(bt, &th->th_boottime); + atomic_thread_fence_acq(); + } while (gen == 0 || gen != th->th_generation); } void @@ -309,9 +310,9 @@ fbclock_getbintime(struct bintime *bt) th = timehands; gen = atomic_load_acq_int(&th->th_generation); *bt = th->th_offset; + bintime_add(bt, &th->th_boottime); atomic_thread_fence_acq(); } while (gen == 0 || gen != th->th_generation); - bintime_add(bt, &boottimebin); } void @@ -378,9 +379,17 @@ microuptime(struct timeval *tvp) void bintime(struct bintime *bt) { + struct timehands *th; + u_int gen; - binuptime(bt); - bintime_add(bt, &boottimebin); + do { + th = timehands; + gen = atomic_load_acq_int(&th->th_generation); + *bt = th->th_offset; + bintime_addx(bt, th->th_scale * tc_delta(th)); + bintime_add(bt, &th->th_boottime); + atomic_thread_fence_acq(); + } while (gen == 0 || gen != th->th_generation); } void @@ -453,9 +462,9 @@ getbintime(struct bintime *bt) th = timehands; gen = atomic_load_acq_int(&th->th_generation); *bt = th->th_offset; + bintime_add(bt, &th->th_boottime); atomic_thread_fence_acq(); } while (gen == 0 || gen != th->th_generation); - bintime_add(bt, &boottimebin); } void @@ -487,6 +496,29 @@ getmicrotime(struct timeval *tvp) } #endif /* FFCLOCK */ +void +getboottime(struct timeval *boottime) +{ + struct bintime boottimebin; + + getboottimebin(&boottimebin); + bintime2timeval(&boottimebin, boottime); +} + +void +getboottimebin(struct bintime *boottimebin) +{ + struct timehands *th; + u_int gen; + + do { + th = timehands; + gen = atomic_load_acq_int(&th->th_generation); + *boottimebin = th->th_boottime; + atomic_thread_fence_acq(); + } while (gen == 0 || gen != th->th_generation); +} + #ifdef FFCLOCK /* * Support for feed-forward synchronization algorithms. This is heavily inspired @@ -1103,6 +1135,7 @@ int sysclock_snap2bintime(struct sysclock_snap *cs, struct bintime *bt, int whichclock, uint32_t flags) { + struct bintime boottimebin; #ifdef FFCLOCK struct bintime bt2; uint64_t period; @@ -1116,8 +1149,10 @@ sysclock_snap2bintime(struct sysclock_snap *cs, struct bintime *bt, if (cs->delta > 0) bintime_addx(bt, cs->fb_info.th_scale * cs->delta); - if ((flags & FBCLOCK_UPTIME) == 0) + if ((flags & FBCLOCK_UPTIME) == 0) { + getboottimebin(&boottimebin); bintime_add(bt, &boottimebin); + } break; #ifdef FFCLOCK case SYSCLOCK_FFWD: @@ -1226,10 +1261,12 @@ tc_getfrequency(void) return (timehands->th_counter->tc_frequency); } +static struct mtx tc_setclock_mtx; +MTX_SYSINIT(tc_setclock_init, &tc_setclock_mtx, "tcsetc", MTX_SPIN); + /* * Step our concept of UTC. This is done by modifying our estimate of * when we booted. - * XXX: not locked. */ void tc_setclock(struct timespec *ts) @@ -1237,26 +1274,24 @@ tc_setclock(struct timespec *ts) struct timespec tbef, taft; struct bintime bt, bt2; - cpu_tick_calibrate(1); - nanotime(&tbef); timespec2bintime(ts, &bt); + nanotime(&tbef); + mtx_lock_spin(&tc_setclock_mtx); + cpu_tick_calibrate(1); binuptime(&bt2); bintime_sub(&bt, &bt2); - bintime_add(&bt2, &boottimebin); - boottimebin = bt; - bintime2timeval(&bt, &boottime); /* XXX fiddle all the little crinkly bits around the fiords... */ - tc_windup(); - nanotime(&taft); + tc_windup(&bt); + mtx_unlock_spin(&tc_setclock_mtx); if (timestepwarnings) { + nanotime(&taft); log(LOG_INFO, "Time stepped from %jd.%09ld to %jd.%09ld (%jd.%09ld)\n", (intmax_t)tbef.tv_sec, tbef.tv_nsec, (intmax_t)taft.tv_sec, taft.tv_nsec, (intmax_t)ts->tv_sec, ts->tv_nsec); } - cpu_tick_calibrate(1); } /* @@ -1265,7 +1300,7 @@ tc_setclock(struct timespec *ts) * timecounter and/or do seconds processing in NTP. Slightly magic. */ static void -tc_windup(void) +tc_windup(struct bintime *new_boottimebin) { struct bintime bt; struct timehands *th, *tho; @@ -1289,6 +1324,8 @@ tc_windup(void) th->th_generation = 0; atomic_thread_fence_rel(); bcopy(tho, th, offsetof(struct timehands, th_generation)); + if (new_boottimebin != NULL) + th->th_boottime = *new_boottimebin; /* * Capture a timecounter delta on the current timecounter and if @@ -1338,7 +1375,7 @@ tc_windup(void) * case we missed a leap second. */ bt = th->th_offset; - bintime_add(&bt, &boottimebin); + bintime_add(&bt, &th->th_boottime); i = bt.sec - tho->th_microtime.tv_sec; if (i > LARGE_STEP) i = 2; @@ -1346,7 +1383,7 @@ tc_windup(void) t = bt.sec; ntp_update_second(&th->th_adjustment, &bt.sec); if (bt.sec != t) - boottimebin.sec += bt.sec - t; + th->th_boottime.sec += bt.sec - t; } /* Update the UTC timestamps used by the get*() functions. */ /* XXX shouldn't do this here. Should force non-`get' versions. */ @@ -1769,7 +1806,7 @@ pps_event(struct pps_state *pps, int event) tcount &= pps->capth->th_counter->tc_counter_mask; bt = pps->capth->th_offset; bintime_addx(&bt, pps->capth->th_scale * tcount); - bintime_add(&bt, &boottimebin); + bintime_add(&bt, &pps->capth->th_boottime); bintime2timespec(&bt, &ts); /* If the timecounter was wound up underneath us, bail out. */ @@ -1842,11 +1879,14 @@ tc_ticktock(int cnt) { static int count; - count += cnt; - if (count < tc_tick) - return; - count = 0; - tc_windup(); + if (mtx_trylock_spin(&tc_setclock_mtx)) { + count += cnt; + if (count >= tc_tick) { + count = 0; + tc_windup(NULL); + } + mtx_unlock_spin(&tc_setclock_mtx); + } } static void __inline @@ -1921,7 +1961,9 @@ inittimecounter(void *dummy) /* warm up new timecounter (again) and get rolling. */ (void)timecounter->tc_get_timecount(timecounter); (void)timecounter->tc_get_timecount(timecounter); - tc_windup(); + mtx_lock_spin(&tc_setclock_mtx); + tc_windup(NULL); + mtx_unlock_spin(&tc_setclock_mtx); } SYSINIT(timecounter, SI_SUB_CLOCKS, SI_ORDER_SECOND, inittimecounter, NULL); @@ -2095,7 +2137,7 @@ tc_fill_vdso_timehands(struct vdso_timehands *vdso_th) vdso_th->th_offset_count = th->th_offset_count; vdso_th->th_counter_mask = th->th_counter->tc_counter_mask; vdso_th->th_offset = th->th_offset; - vdso_th->th_boottime = boottimebin; + vdso_th->th_boottime = th->th_boottime; enabled = cpu_fill_vdso_timehands(vdso_th, th->th_counter); if (!vdso_th_enable) enabled = 0; @@ -2116,8 +2158,8 @@ tc_fill_vdso_timehands32(struct vdso_timehands32 *vdso_th32) vdso_th32->th_counter_mask = th->th_counter->tc_counter_mask; vdso_th32->th_offset.sec = th->th_offset.sec; *(uint64_t *)&vdso_th32->th_offset.frac[0] = th->th_offset.frac; - vdso_th32->th_boottime.sec = boottimebin.sec; - *(uint64_t *)&vdso_th32->th_boottime.frac[0] = boottimebin.frac; + vdso_th32->th_boottime.sec = th->th_boottime.sec; + *(uint64_t *)&vdso_th32->th_boottime.frac[0] = th->th_boottime.frac; enabled = cpu_fill_vdso_timehands32(vdso_th32, th->th_counter); if (!vdso_th_enable) enabled = 0; diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index 148da2b..82710f7 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -115,9 +115,7 @@ settime(struct thread *td, struct timeval *tv) struct timeval delta, tv1, tv2; static struct timeval maxtime, laststep; struct timespec ts; - int s; - s = splclock(); microtime(&tv1); delta = *tv; timevalsub(&delta, &tv1); @@ -147,10 +145,8 @@ settime(struct thread *td, struct timeval *tv) printf("Time adjustment clamped to -1 second\n"); } } else { - if (tv1.tv_sec == laststep.tv_sec) { - splx(s); + if (tv1.tv_sec == laststep.tv_sec) return (EPERM); - } if (delta.tv_sec > 1) { tv->tv_sec = tv1.tv_sec + 1; printf("Time adjustment clamped to +1 second\n"); @@ -161,10 +157,8 @@ settime(struct thread *td, struct timeval *tv) ts.tv_sec = tv->tv_sec; ts.tv_nsec = tv->tv_usec * 1000; - mtx_lock(&Giant); tc_setclock(&ts); resettodr(); - mtx_unlock(&Giant); return (0); } diff --git a/sys/kern/subr_rtc.c b/sys/kern/subr_rtc.c index dbad36d..4bac324 100644 --- a/sys/kern/subr_rtc.c +++ b/sys/kern/subr_rtc.c @@ -172,11 +172,11 @@ resettodr(void) if (disable_rtc_set || clock_dev == NULL) return; - mtx_lock(&resettodr_lock); getnanotime(&ts); timespecadd(&ts, &clock_adj); ts.tv_sec -= utc_offset(); /* XXX: We should really set all registered RTCs */ + mtx_lock(&resettodr_lock); error = CLOCK_SETTIME(clock_dev, &ts); mtx_unlock(&resettodr_lock); if (error != 0) diff --git a/sys/kern/sys_procdesc.c b/sys/kern/sys_procdesc.c index 37139c1..f47ae7c 100644 --- a/sys/kern/sys_procdesc.c +++ b/sys/kern/sys_procdesc.c @@ -517,7 +517,7 @@ procdesc_stat(struct file *fp, struct stat *sb, struct ucred *active_cred, struct thread *td) { struct procdesc *pd; - struct timeval pstart; + struct timeval pstart, boottime; /* * XXXRW: Perhaps we should cache some more information from the @@ -532,6 +532,7 @@ procdesc_stat(struct file *fp, struct stat *sb, struct ucred *active_cred, /* Set birth and [acm] times to process start time. */ pstart = pd->pd_proc->p_stats->p_start; + getboottime(&boottime); timevaladd(&pstart, &boottime); TIMEVAL_TO_TIMESPEC(&pstart, &sb->st_birthtim); sb->st_atim = sb->st_birthtim; diff --git a/sys/net/bpf.c b/sys/net/bpf.c index 3b12cf4..4251f71 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -2328,12 +2328,13 @@ bpf_hdrlen(struct bpf_d *d) static void bpf_bintime2ts(struct bintime *bt, struct bpf_ts *ts, int tstype) { - struct bintime bt2; + struct bintime bt2, boottimebin; struct timeval tsm; struct timespec tsn; if ((tstype & BPF_T_MONOTONIC) == 0) { bt2 = *bt; + getboottimebin(&boottimebin); bintime_add(&bt2, &boottimebin); bt = &bt2; } diff --git a/sys/netpfil/ipfw/ip_fw_sockopt.c b/sys/netpfil/ipfw/ip_fw_sockopt.c index d186ba5..7faf99f 100644 --- a/sys/netpfil/ipfw/ip_fw_sockopt.c +++ b/sys/netpfil/ipfw/ip_fw_sockopt.c @@ -395,6 +395,7 @@ swap_map(struct ip_fw_chain *chain, struct ip_fw **new_map, int new_len) static void export_cntr1_base(struct ip_fw *krule, struct ip_fw_bcounter *cntr) { + struct timeval boottime; cntr->size = sizeof(*cntr); @@ -403,21 +404,26 @@ export_cntr1_base(struct ip_fw *krule, struct ip_fw_bcounter *cntr) cntr->bcnt = counter_u64_fetch(krule->cntr + 1); cntr->timestamp = krule->timestamp; } - if (cntr->timestamp > 0) + if (cntr->timestamp > 0) { + getboottime(&boottime); cntr->timestamp += boottime.tv_sec; + } } static void export_cntr0_base(struct ip_fw *krule, struct ip_fw_bcounter0 *cntr) { + struct timeval boottime; if (krule->cntr != NULL) { cntr->pcnt = counter_u64_fetch(krule->cntr); cntr->bcnt = counter_u64_fetch(krule->cntr + 1); cntr->timestamp = krule->timestamp; } - if (cntr->timestamp > 0) + if (cntr->timestamp > 0) { + getboottime(&boottime); cntr->timestamp += boottime.tv_sec; + } } /* @@ -2048,11 +2054,13 @@ ipfw_getrules(struct ip_fw_chain *chain, void *buf, size_t space) char *ep = bp + space; struct ip_fw *rule; struct ip_fw_rule0 *dst; + struct timeval boottime; int error, i, l, warnflag; time_t boot_seconds; warnflag = 0; + getboottime(&boottime); boot_seconds = boottime.tv_sec; for (i = 0; i < chain->n_rules; i++) { rule = chain->map[i]; diff --git a/sys/nfs/nfs_lock.c b/sys/nfs/nfs_lock.c index 7d11672..c84413e 100644 --- a/sys/nfs/nfs_lock.c +++ b/sys/nfs/nfs_lock.c @@ -241,6 +241,7 @@ nfs_dolock(struct vop_advlock_args *ap) struct flock *fl; struct proc *p; struct nfsmount *nmp; + struct timeval boottime; td = curthread; p = td->td_proc; @@ -284,6 +285,7 @@ nfs_dolock(struct vop_advlock_args *ap) p->p_nlminfo = malloc(sizeof(struct nlminfo), M_NLMINFO, M_WAITOK | M_ZERO); p->p_nlminfo->pid_start = p->p_stats->p_start; + getboottime(&boottime); timevaladd(&p->p_nlminfo->pid_start, &boottime); } msg.lm_msg_ident.pid_start = p->p_nlminfo->pid_start; diff --git a/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c b/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c index 1d07943..0879299 100644 --- a/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c +++ b/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c @@ -504,11 +504,13 @@ svc_rpc_gss_find_client(struct svc_rpc_gss_clientid *id) { struct svc_rpc_gss_client *client; struct svc_rpc_gss_client_list *list; + struct timeval boottime; unsigned long hostid; rpc_gss_log_debug("in svc_rpc_gss_find_client(%d)", id->ci_id); getcredhostid(curthread->td_ucred, &hostid); + getboottime(&boottime); if (id->ci_hostid != hostid || id->ci_boottime != boottime.tv_sec) return (NULL); @@ -537,6 +539,7 @@ svc_rpc_gss_create_client(void) { struct svc_rpc_gss_client *client; struct svc_rpc_gss_client_list *list; + struct timeval boottime; unsigned long hostid; rpc_gss_log_debug("in svc_rpc_gss_create_client()"); @@ -547,6 +550,7 @@ svc_rpc_gss_create_client(void) sx_init(&client->cl_lock, "GSS-client"); getcredhostid(curthread->td_ucred, &hostid); client->cl_id.ci_hostid = hostid; + getboottime(&boottime); client->cl_id.ci_boottime = boottime.tv_sec; client->cl_id.ci_id = svc_rpc_gss_next_clientid++; list = &svc_rpc_gss_client_hash[client->cl_id.ci_id % CLIENT_HASH_SIZE]; diff --git a/sys/sys/mutex.h b/sys/sys/mutex.h index 0443922..db05fc9 100644 --- a/sys/sys/mutex.h +++ b/sys/sys/mutex.h @@ -112,6 +112,8 @@ void __mtx_unlock_flags(volatile uintptr_t *c, int opts, const char *file, int line); void __mtx_lock_spin_flags(volatile uintptr_t *c, int opts, const char *file, int line); +int __mtx_trylock_spin_flags(volatile uintptr_t *c, int opts, + const char *file, int line); void __mtx_unlock_spin_flags(volatile uintptr_t *c, int opts, const char *file, int line); #if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) @@ -152,6 +154,8 @@ void thread_lock_flags_(struct thread *, int, const char *, int); __mtx_unlock_flags(&(m)->mtx_lock, o, f, l) #define _mtx_lock_spin_flags(m, o, f, l) \ __mtx_lock_spin_flags(&(m)->mtx_lock, o, f, l) +#define _mtx_trylock_spin_flags(m, o, f, l) \ + __mtx_trylock_spin_flags(&(m)->mtx_lock, o, f, l) #define _mtx_unlock_spin_flags(m, o, f, l) \ __mtx_unlock_spin_flags(&(m)->mtx_lock, o, f, l) #if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) @@ -212,6 +216,21 @@ void thread_lock_flags_(struct thread *, int, const char *, int); LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(spin__acquire, \ mp, 0, 0, file, line); \ } while (0) +#define __mtx_trylock_spin(mp, tid, opts, file, line) __extension__ ({ \ + uintptr_t _tid = (uintptr_t)(tid); \ + int _ret; \ + \ + spinlock_enter(); \ + if (((mp)->mtx_lock != MTX_UNOWNED || !_mtx_obtain_lock((mp), _tid))) {\ + spinlock_exit(); \ + _ret = 0; \ + } else { \ + LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(spin__acquire, \ + mp, 0, 0, file, line); \ + _ret = 1; \ + } \ + _ret; \ +}) #else /* SMP */ #define __mtx_lock_spin(mp, tid, opts, file, line) do { \ uintptr_t _tid = (uintptr_t)(tid); \ @@ -224,6 +243,20 @@ void thread_lock_flags_(struct thread *, int, const char *, int); (mp)->mtx_lock = _tid; \ } \ } while (0) +#define __mtx_trylock_spin(mp, tid, opts, file, line) __extension__ ({ \ + uintptr_t _tid = (uintptr_t)(tid); \ + int _ret; \ + \ + spinlock_enter(); \ + if (((mp)->mtx_lock != MTX_UNOWNED) \ + spinlock_exit(); \ + _ret = 0; \ + } else { \ + (mp)->mtx_lock = _tid; \ + _ret = 1; \ + } \ + _ret; \ +}) #endif /* SMP */ /* Unlock a normal mutex. */ @@ -302,6 +335,7 @@ void thread_lock_flags_(struct thread *, int, const char *, int); #define mtx_lock(m) mtx_lock_flags((m), 0) #define mtx_lock_spin(m) mtx_lock_spin_flags((m), 0) #define mtx_trylock(m) mtx_trylock_flags((m), 0) +#define mtx_trylock_spin(m) mtx_trylock_spin_flags((m), 0) #define mtx_unlock(m) mtx_unlock_flags((m), 0) #define mtx_unlock_spin(m) mtx_unlock_spin_flags((m), 0) @@ -335,6 +369,8 @@ extern struct mtx_pool *mtxpool_sleep; _mtx_unlock_flags((m), (opts), (file), (line)) #define mtx_lock_spin_flags_(m, opts, file, line) \ _mtx_lock_spin_flags((m), (opts), (file), (line)) +#define mtx_trylock_spin_flags_(m, opts, file, line) \ + _mtx_trylock_spin_flags((m), (opts), (file), (line)) #define mtx_unlock_spin_flags_(m, opts, file, line) \ _mtx_unlock_spin_flags((m), (opts), (file), (line)) #else /* LOCK_DEBUG == 0 && !MUTEX_NOINLINE */ @@ -344,6 +380,8 @@ extern struct mtx_pool *mtxpool_sleep; __mtx_unlock((m), curthread, (opts), (file), (line)) #define mtx_lock_spin_flags_(m, opts, file, line) \ __mtx_lock_spin((m), curthread, (opts), (file), (line)) +#define mtx_trylock_spin_flags_(m, opts, file, line) \ + __mtx_trylock_spin((m), curthread, (opts), (file), (line)) #define mtx_unlock_spin_flags_(m, opts, file, line) \ __mtx_unlock_spin((m)) #endif /* LOCK_DEBUG > 0 || MUTEX_NOINLINE */ @@ -369,6 +407,8 @@ extern struct mtx_pool *mtxpool_sleep; mtx_unlock_spin_flags_((m), (opts), LOCK_FILE, LOCK_LINE) #define mtx_trylock_flags(m, opts) \ mtx_trylock_flags_((m), (opts), LOCK_FILE, LOCK_LINE) +#define mtx_trylock_spin_flags(m, opts) \ + mtx_trylock_spin_flags_((m), (opts), LOCK_FILE, LOCK_LINE) #define mtx_assert(m, what) \ mtx_assert_((m), (what), __FILE__, __LINE__) diff --git a/sys/sys/time.h b/sys/sys/time.h index 395e888..659f8e0 100644 --- a/sys/sys/time.h +++ b/sys/sys/time.h @@ -372,8 +372,6 @@ void resettodr(void); extern volatile time_t time_second; extern volatile time_t time_uptime; -extern struct bintime boottimebin; -extern struct timeval boottime; extern struct bintime tc_tick_bt; extern sbintime_t tc_tick_sbt; extern struct bintime tick_bt; @@ -440,6 +438,9 @@ void getbintime(struct bintime *bt); void getnanotime(struct timespec *tsp); void getmicrotime(struct timeval *tvp); +void getboottime(struct timeval *boottime); +void getboottimebin(struct bintime *boottimebin); + /* Other functions */ int itimerdecr(struct itimerval *itp, int usec); int itimerfix(struct timeval *tv); From owner-svn-src-head@freebsd.org Sat Jul 2 16:09:22 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 87A51B8FC48; Sat, 2 Jul 2016 16:09:22 +0000 (UTC) (envelope-from etnapierala@gmail.com) Received: from mail-wm0-x235.google.com (mail-wm0-x235.google.com [IPv6:2a00:1450:400c:c09::235]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1A2112EA8; Sat, 2 Jul 2016 16:09:22 +0000 (UTC) (envelope-from etnapierala@gmail.com) Received: by mail-wm0-x235.google.com with SMTP id a66so64632725wme.0; Sat, 02 Jul 2016 09:09:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=MH4cRgkbLTXWokF9jS0AJTH+mHR5T95Hz/NaZETFwZg=; b=K+uH4dgmpFNGe1TbNSJL/cJNZAzqvEgT3BIl79rqw0qgoOpjPgkVQHujIdn1Hunn2U dMg9pHTw8AFN/Wsz9Cl3tShKrS6fTplc4Ab+083qcO6FudS2NAzfXbkBfLEmFm9ixRVx Mi3xNSqiG1bsreT+Fsttf4EKSRDzgz7tBypwecKnMEnG2SeS1vF64jknYm6PHfOj73vV UqJBTfo9J+/nbSrytEABhrCtCVucnTTYXebcUlcm3CdqnOljL+AIRjhStrTaDXWHIYTz 6GO67mqE4eXCfAuXOIBbxvpkByWi0h0ptWwNz0RHJDVwElO5iOlS0UfOQ/D6nhR8LVfE nkjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=MH4cRgkbLTXWokF9jS0AJTH+mHR5T95Hz/NaZETFwZg=; b=I+0Lq3g88KciAZZDGhVIQ7gf6CfjL7/zLyJZHw76/QtregMBphdVl/uRi5MSBRbJI8 G238zuCuxvjmdtbuvlQ0T8R9H1TaSqYZsFdByMIxh3qhfa6Iw5lCovzKt3g9Uo1R4VTF j+HPASx1wKm9JquBHw+GmHpdpMjI6e1YU3wYQ7jWA6Sq76FKnyLX4W66kYc9oMm+WRBC S8Jn/suAOnUNVrm4yVzKgL5Op7Kn03EOmvT3cUr3aViqsZINrwRe5Oxg5jZl1D0hFHEJ DHbv/rz07LNU21HNhP0iBBVx0kDMeQhCsDjcr/Ki9tLuHF2qTQlFBvYUmu3Q/EZh11d0 Ut9w== X-Gm-Message-State: ALyK8tJq6Oh9yXGgiU6/4vZPWGkYZIHObYimKWzXBj5FjZJ4Af0yDh9yL4XCMS19Mdnd1A== X-Received: by 10.194.239.232 with SMTP id vv8mr3227618wjc.166.1467475760470; Sat, 02 Jul 2016 09:09:20 -0700 (PDT) Received: from brick (adeg137.neoplus.adsl.tpnet.pl. [79.184.84.137]) by smtp.gmail.com with ESMTPSA id r130sm3983531wmf.20.2016.07.02.09.09.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 02 Jul 2016 09:09:19 -0700 (PDT) Sender: =?UTF-8?Q?Edward_Tomasz_Napiera=C5=82a?= Date: Sat, 2 Jul 2016 18:09:16 +0200 From: Edward Tomasz =?utf-8?Q?Napiera=C5=82a?= To: Alexander Motin Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r302297 - in head/sys/cddl/contrib/opensolaris: common/acl uts/common/fs/zfs uts/common/sys Message-ID: <20160702160916.GA1985@brick> Mail-Followup-To: Alexander Motin , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201606301455.u5UEtnLs090648@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201606301455.u5UEtnLs090648@repo.freebsd.org> User-Agent: Mutt/1.6.1 (2016-04-27) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Sat, 02 Jul 2016 16:09:22 -0000 On 0630T1455, Alexander Motin wrote: > Author: mav > Date: Thu Jun 30 14:55:49 2016 > New Revision: 302297 > URL: https://svnweb.freebsd.org/changeset/base/302297 > > Log: > Revert r299454 and r299448. > > Those changes were found confusing FreeBSD libc ACL code, that doesn't > differentiate ACL for directories and files, and report ACLs for all > directories created after those patches as non-trivial. On the other > side these changes were considered wrong from POSIX and NFSv4 points of > view. Until further investigation done upstream, revert those changes > locally in preparation for FreeBSD 11.0 release. Thanks! But it still doesn't pass the regression tests, due to broken (or at least incompatible) interaction between inheritance and umask.