svn commit: r331418 - head/tools/tools/crypto

2018-03-22 Thread Conrad Meyer
Author: cem
Date: Fri Mar 23 05:37:18 2018
New Revision: 331418
URL: https://svnweb.freebsd.org/changeset/base/331418

Log:
  cryptocheck: Add support for Blake2{B,S} hashes
  
  Since they are not yet present in the version of openssl in base, this will
  require installing the ports openssl.
  
  Sponsored by: Dell EMC Isilon

Modified:
  head/tools/tools/crypto/Makefile
  head/tools/tools/crypto/cryptocheck.c

Modified: head/tools/tools/crypto/Makefile
==
--- head/tools/tools/crypto/MakefileFri Mar 23 04:31:19 2018
(r331417)
+++ head/tools/tools/crypto/MakefileFri Mar 23 05:37:18 2018
(r331418)
@@ -32,7 +32,10 @@ MAN=
 BINDIR?=   /usr/local/bin
 
 # cryptocheck: test symmetric crypto functions
-LIBADD.cryptocheck+=   crypto ssl util
+# Use openssl from ports for Blake2 algorithms
+CFLAGS.cryptocheck.c+= $$(pkg-config --cflags openssl)
+LDFLAGS.cryptocheck+=  $$(pkg-config --libs openssl)
+LIBADD.cryptocheck+=   util
 
 # cryptokeytest: test asymmetric crypto functions
 LIBADD.cryptokeytest+= crypto

Modified: head/tools/tools/crypto/cryptocheck.c
==
--- head/tools/tools/crypto/cryptocheck.c   Fri Mar 23 04:31:19 2018
(r331417)
+++ head/tools/tools/crypto/cryptocheck.c   Fri Mar 23 05:37:18 2018
(r331418)
@@ -59,6 +59,8 @@
  * sha256  256-bit sha2 hmac
  * sha384  384-bit sha2 hmac
  * sha512  512-bit sha2 hmac
+ * blake2b Blake2-B
+ * blake2s Blake2-S
  *
  * Block Ciphers:
  * aes-cbc 128-bit aes cbc
@@ -115,6 +117,10 @@ struct alg {
  .evp_md = EVP_sha384 },
{ .name = "sha512", .mac = CRYPTO_SHA2_512_HMAC, .type = T_HMAC,
  .evp_md = EVP_sha512 },
+   { .name = "blake2b", .mac = CRYPTO_BLAKE2B, .type = T_HMAC,
+ .evp_md = EVP_blake2b512 },
+   { .name = "blake2s", .mac = CRYPTO_BLAKE2S, .type = T_HMAC,
+ .evp_md = EVP_blake2s256 },
{ .name = "aes-cbc", .cipher = CRYPTO_AES_CBC, .type = T_BLKCIPHER,
  .evp_cipher = EVP_aes_128_cbc },
{ .name = "aes-cbc192", .cipher = CRYPTO_AES_CBC, .type = T_BLKCIPHER,
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r331369 - head/sys/vm

2018-03-22 Thread Bruce Evans

On Thu, 22 Mar 2018, Jeff Roberson wrote:


On Thu, 22 Mar 2018, Cy Schubert wrote:


It broke i386 too.


I just did
TARGET_ARCH=i386 make buildworld
TARGET_ARCH=i386 make buildkernel

This worked for me?


Index: sys/vm/vm_reserv.c
===
--- sys/vm/vm_reserv.c  (revision 331399)
+++ sys/vm/vm_reserv.c  (working copy)
@@ -45,8 +45,6 @@

#include 
#include 
-#include 
-#include 
#include 
#include 
#include 
@@ -55,6 +53,8 @@
#include 
#include 
#include 
+#include 
+#include 
#include 
#include 

This is because sys/i386/include/machine.h uses critical_enter() and
critical_exit() which are defined in sys/systm.h.


Wrong fix.  I see you committed this.  Now there are more bugs to fix.

 is a prerequisite for all kernel headers except
, since it defines and declares things like KASSERT() and
critical_enter() which might be used in other headers (except
sys/param.h and its standard pollution).  Sometimes sys/systm.h is
included as undocumented namespace pollution in headers that are
accidentally included before the (other) ones that use KASSERT(), etc.
The headers that have this bug have it to work around bugs in .c files
like the one above.  It is more usual to have this bug by not including
sys/systm.h at all than to have it by including it in a wrong order.
Sorting it alphabetically almost always gives a wrong order.  It must
be included after sys/param.h and that must be included first.

It is a related bug to include only sys/types.h and not sys/param.h.
This requires chumminess with the current implementation and all
future implementations.  sys/param.h provides certain undocumented
but standard namespace pollution which might vary with the implementation,
as necessary to satisfy some of the pollution requirements of all current
and future implementations of other headers.  (The pollution should be
monotonically decreasing but it was only that for a few years about 20
years ago when I worked on fixing it.)  .c files that include sys/types.h
instead of sys/param.h have do some subset of the includes in sys/param.h.
Since nothing is documented and the subset might depend on the arch and
user options, it is hard to know the minimal subset.

.c files that include sys/types.h tend to have lots of other #include
bugs like not including sys/systm.h.  Again it is hard to know the
minimal replacement for sys/systm.h and its undocumented but standard
pollution.  It is a style bug to include both sys/types.h and sys/param.h.
style(9) even explicitly forbids including both.  It is a larger style
bug to include the standard pollution in sys/systm.h direction.  This
includes especially  and .  These
should be considered as being implemented in sys/systm.h, with the
 headers for them only and implementation detail.  Similarly
for .


It built nicely on my amd64's though.


amd64 apparently has more namespace pollution which breaks detection
of the bug.  But I couldn't find where it is.  sys/systm.h isn't included
nested in any amd64 or x86 headers.  Apparently some amd64 option gives
it.

Bruce
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r331417 - head/tools/tools/crypto

2018-03-22 Thread Conrad Meyer
Author: cem
Date: Fri Mar 23 04:31:19 2018
New Revision: 331417
URL: https://svnweb.freebsd.org/changeset/base/331417

Log:
  Bring in JHB's cryptocheck tool
  
  It can be used to validate basic algorithm correctness on a variety of inputs,
  by comarison to openssl.
  
  While here, add some sanity to the crypto/Makefile.
  
  The tool may not be perfect, but getting it in tree where collaboration can
  happen is a nice first step.  The pace of development outside of svn seems
  to have slowed down mid-2017.
  
  Obtained from:github bsdjhb/freebsd:cryptocheck
  Sponsored by: Dell EMC Isilon

Added:
  head/tools/tools/crypto/cryptocheck.c   (contents, props changed)
Modified:
  head/tools/tools/crypto/Makefile

Modified: head/tools/tools/crypto/Makefile
==
--- head/tools/tools/crypto/MakefileFri Mar 23 03:48:45 2018
(r331416)
+++ head/tools/tools/crypto/MakefileFri Mar 23 04:31:19 2018
(r331417)
@@ -1,5 +1,6 @@
 #  $FreeBSD$
 #
+# Copyright (c) 2018   Conrad Meyer 
 # Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting
 # All rights reserved.
 #
@@ -25,40 +26,23 @@
 # SUCH DAMAGE.
 #
 
-ALL=   cryptotest cryptokeytest cryptostats \
+PROGS= cryptocheck cryptotest cryptokeytest cryptostats \
ubsecstats hifnstats ipsecstats safestats
-BINDIR=/usr/local/bin
+MAN=
+BINDIR?=   /usr/local/bin
 
-all:   ${ALL}
+# cryptocheck: test symmetric crypto functions
+LIBADD.cryptocheck+=   crypto ssl util
 
-# program to test asymmetric crypto functions
-cryptokeytest: cryptokeytest.c
-   ${CC} -o cryptokeytest cryptokeytest.c -lcrypto
+# cryptokeytest: test asymmetric crypto functions
+LIBADD.cryptokeytest+= crypto
 
-# program to dump statistics kept by the core crypto code
-cryptostats: cryptostats.c
-   ${CC} -o cryptostats cryptostats.c
+# cryptostats: dump statistics kept by the core crypto code
+# ubsecstats: print statistics kept by the Broadcom driver
+# hifnstats: print statistics kept by the HIFN driver
+# safestats: statistics kept by the SafeNet driver
+# ipsecstats: print statistics kept by fast ipsec
 
-# program to print statistics kept by the Broadcom driver
-ubsecstats: ubsecstats.c
-   ${CC} -o ubsecstats ubsecstats.c
+CLEANFILES+=   core a.out
 
-# program to print statistics kept by the HIFN driver
-hifnstats: hifnstats.c
-   ${CC} -o hifnstats hifnstats.c
-
-# program to print statistics kept by the SafeNet driver
-safestats: safestats.c
-   ${CC} -o safestats safestats.c
-
-# program to print statistics kept by fast ipsec
-ipsecstats: ipsecstats.c
-   ${CC} -o ipsecstats ipsecstats.c
-
-clean:
-   rm -f ${ALL} core a.out
-
-install: ${ALL}
-   for i in ${ALL}; do \
-   install $$i ${DESTDIR}${BINDIR}; \
-   done
+.include 

Added: head/tools/tools/crypto/cryptocheck.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/tools/crypto/cryptocheck.c   Fri Mar 23 04:31:19 2018
(r331417)
@@ -0,0 +1,1168 @@
+/*-
+ * Copyright (c) 2017 John Baldwin, 
+ * Copyright (c) 2004 Sam Leffler, Errno Consulting
+ * 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,
+ *without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
+ *redistribution must be conditioned upon including a substantially
+ *similar Disclaimer requirement for further binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *of any contributors may be used to endorse or promote products derived
+ *from this software without specific prior written permission.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
+ *
+ 

svn commit: r331416 - in head/stand: efi/libefi i386/libi386

2018-03-22 Thread Kyle Evans
Author: kevans
Date: Fri Mar 23 03:48:45 2018
New Revision: 331416
URL: https://svnweb.freebsd.org/changeset/base/331416

Log:
  Loader consoles: Implement SGR 22, reset intensity
  
  MFC after:3 days

Modified:
  head/stand/efi/libefi/efi_console.c
  head/stand/i386/libi386/vidconsole.c

Modified: head/stand/efi/libefi/efi_console.c
==
--- head/stand/efi/libefi/efi_console.c Fri Mar 23 03:22:30 2018
(r331415)
+++ head/stand/efi/libefi/efi_console.c Fri Mar 23 03:48:45 2018
(r331416)
@@ -383,6 +383,9 @@ efi_term_emu(int c)
fg_c = bg_c;
bg_c = t;
break;
+   case 22:/* normal intensity */
+   fg_c &= ~0x8;
+   break;
case 30: case 31: case 32: case 33:
case 34: case 35: case 36: case 37:
fg_c = ansi_col[args[i] - 30];

Modified: head/stand/i386/libi386/vidconsole.c
==
--- head/stand/i386/libi386/vidconsole.cFri Mar 23 03:22:30 2018
(r331415)
+++ head/stand/i386/libi386/vidconsole.cFri Mar 23 03:48:45 2018
(r331416)
@@ -449,6 +449,9 @@ vidc_term_emu(int c)
fg_c = bg_c;
bg_c = t;
break;
+case 22:   /* normal intensity */
+fg_c &= ~0x8;
+break;
case 30: case 31: case 32: case 33:
case 34: case 35: case 36: case 37:
fg_c = ansi_col[args[i] - 30];
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r331415 - head/sys/vm

2018-03-22 Thread Cy Schubert
Author: cy
Date: Fri Mar 23 03:22:30 2018
New Revision: 331415
URL: https://svnweb.freebsd.org/changeset/base/331415

Log:
  Fix build on i386 without INVARIANTS following r331369.
  
  --- vm_reserv.o ---
  In file included from /opt/src/svn-current/sys/vm/vm_reserv.c:48:
  In file included from /opt/src/svn-current/sys/sys/counter.h:37:
  ./machine/counter.h:174:3: error: implicit declaration of function
  'critical_enter' is invalid in C99 [-Werror,-Wimplicit-function-declarat
  ion]
  critical_enter();
  
  Reviewed by:  jeff@

Modified:
  head/sys/vm/vm_reserv.c

Modified: head/sys/vm/vm_reserv.c
==
--- head/sys/vm/vm_reserv.c Fri Mar 23 02:50:38 2018(r331414)
+++ head/sys/vm/vm_reserv.c Fri Mar 23 03:22:30 2018(r331415)
@@ -45,8 +45,6 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
-#include 
-#include 
 #include 
 #include 
 #include 
@@ -55,6 +53,8 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r331414 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys

2018-03-22 Thread Alexander Motin
Author: mav
Date: Fri Mar 23 02:50:38 2018
New Revision: 331414
URL: https://svnweb.freebsd.org/changeset/base/331414

Log:
  Reduce struct aggsum_bucket padding to fit into one cache line.
  
  Reported by:  mjg

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/aggsum.h

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/aggsum.h
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/aggsum.hFri Mar 
23 02:45:09 2018(r331413)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/aggsum.hFri Mar 
23 02:50:38 2018(r331414)
@@ -29,7 +29,7 @@ typedef struct aggsum_bucket {
kmutex_t asc_lock;
int64_t asc_delta;
uint64_t asc_borrowed;
-   uint64_t asc_pad[4]; /* pad out to cache line (64 bytes) */
+   uint64_t asc_pad[2]; /* pad out to cache line (64 bytes) */
 } aggsum_bucket_t __aligned(CACHE_LINE_SIZE);
 
 /*
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r331413 - head/sys/dev/efidev

2018-03-22 Thread Kyle Evans
Author: kevans
Date: Fri Mar 23 02:45:09 2018
New Revision: 331413
URL: https://svnweb.freebsd.org/changeset/base/331413

Log:
  efidev: Drop a quick note in about efi_cfgtbl/efi_runtime
  
  There's no real annotation for it, so it's not immediately obvious to the
  unfamiliar that these pointers are to locations in the EFI runtime map
  unlike the system table pointer immediately above them.

Modified:
  head/sys/dev/efidev/efirt.c

Modified: head/sys/dev/efidev/efirt.c
==
--- head/sys/dev/efidev/efirt.c Fri Mar 23 02:38:31 2018(r331412)
+++ head/sys/dev/efidev/efirt.c Fri Mar 23 02:45:09 2018(r331413)
@@ -57,6 +57,11 @@ __FBSDID("$FreeBSD$");
 #include 
 
 static struct efi_systbl *efi_systbl;
+/*
+ * The following pointers point to tables in the EFI runtime service data 
pages.
+ * Care should be taken to make sure that we've properly entered the EFI 
runtime
+ * environment (efi_enter()) before dereferencing them.
+ */
 static struct efi_cfgtbl *efi_cfgtbl;
 static struct efi_rt *efi_runtime;
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r331369 - head/sys/vm

2018-03-22 Thread Cy Schubert
In message , Jeff Roberson 
writes:
> On Thu, 22 Mar 2018, Cy Schubert wrote:
>
> > In message , Jeff Roberson
> > writes:
> >> On Thu, 22 Mar 2018, Cy Schubert wrote:
> >>
> >>> It broke i386 too.
> >>
> >> I just did
> >> TARGET_ARCH=i386 make buildworld
> >> TARGET_ARCH=i386 make buildkernel
> >>
> >> This worked for me?
> >>
> >> Jeff
> >
> > hmmm.
> >
> > make TARGET=i386 TARGET_ARCH=i386 buildkernel
>
> Do you have changes to GENERIC?

Not to GENERIC but I used a different kernel by default that removes 
most drivers (as I load them dynamically -- single kernel different 
modules on each machine).

Ahh but this particular i386 kernel I was building does not include 
INVARIANTS. sys/i386/include/counter.h at line 35 has:

#ifdef INVARIANTS
#include 
#endif

sys/proc.h includes sys/systm.h.

i386 without INVARIANTS will fail to build. With INVARIANTS i386 does 
build.

I'll commit the fix.

~cy


>
> Thanks,
> Jeff
> >
> > --- vm_reserv.o ---
> > In file included from /opt/src/svn-current/sys/vm/vm_reserv.c:48:
> > In file included from /opt/src/svn-current/sys/sys/counter.h:37:
> > ./machine/counter.h:174:3: error: implicit declaration of function
> > 'critical_enter' is invalid in C99 [-Werror,-Wimplicit-function-declarat
> > ion]
> >critical_enter();
> >^
> > ./machine/counter.h:174:3: error: this function declaration is not a
> > prototype [-Werror,-Wstrict-prototypes]
> > ./machine/counter.h:176:3: error: implicit declaration of function
> > 'critical_exit' is invalid in C99 [-Werror,-Wimplicit-function-declarati
> > on]
> >critical_exit();
> >^
> > ./machine/counter.h:176:3: note: did you mean 'critical_enter'?
> > ./machine/counter.h:174:3: note: 'critical_enter' declared here
> >critical_enter();
> >^
> > ./machine/counter.h:176:3: error: this function declaration is not a
> > prototype [-Werror,-Wstrict-prototypes]
> >critical_exit();
> >^
> > In file included from /opt/src/svn-current/sys/vm/vm_reserv.c:57:
> > /opt/src/svn-current/sys/sys/systm.h:217:6: error: conflicting types
> > for 'critical_enter'
> > voidcritical_enter(void);
> >^
> > ./machine/counter.h:174:3: note: previous implicit declaration is here
> >critical_enter();
> >^
> > In file included from /opt/src/svn-current/sys/vm/vm_reserv.c:57:
> > /opt/src/svn-current/sys/sys/systm.h:218:6: error: conflicting types
> > for 'critical_exit'
> > voidcritical_exit(void);
> >^
> > ./machine/counter.h:176:3: note: previous implicit declaration is here
> >critical_exit();
> >^
> > 6 errors generated.
> > *** [vm_reserv.o] Error code 1
> >
> > make[2]: stopped in /export/obj/opt/src/svn-current/i386.i386/sys/BREAK
> > --- modules-all ---
> > A failure has been detected in another branch of the parallel make
> >
> > make[3]: stopped in /opt/src/svn-current/sys/modules
> > *** [modules-all] Error code 2
> >
> > make[2]: stopped in /export/obj/opt/src/svn-current/i386.i386/sys/BREAK
> > 2 errors
> >
> > make[2]: stopped in /export/obj/opt/src/svn-current/i386.i386/sys/BREAK
> > *** [buildkernel] Error code 2
> >
> > make[1]: stopped in /opt/src/svn-current
> > 1 error
> >
> > make[1]: stopped in /opt/src/svn-current
> > *** [buildkernel] Error code 2
> >
> > make: stopped in /opt/src/svn-current
> > 1 error
> >
> > make: stopped in /opt/src/svn-current
> >
> > ~cy
> >
> >>
> >>>
> >>> Index: sys/vm/vm_reserv.c
> >>> ===
> >>> --- sys/vm/vm_reserv.c(revision 331399)
> >>> +++ sys/vm/vm_reserv.c(working copy)
> >>> @@ -45,8 +45,6 @@
> >>>
> >>> #include 
> >>> #include 
> >>> -#include 
> >>> -#include 
> >>> #include 
> >>> #include 
> >>> #include 
> >>> @@ -55,6 +53,8 @@
> >>> #include 
> >>> #include 
> >>> #include 
> >>> +#include 
> >>> +#include 
> >>> #include 
> >>> #include 
> >>>
> >>> This is because sys/i386/include/machine.h uses critical_enter() and
> >>> critical_exit() which are defined in sys/systm.h.
> >>>
> >>> It built nicely on my amd64's though.
> >>>
> >>> ~cy
> >>>
> >>> In message , Jeff Roberson
> >>> writes:
>  Thank you, working on it.  I had done a make universe before getting
>  review feedback.
> 
>  Jeff
> 
>  On Thu, 22 Mar 2018, Justin Hibbits wrote:
> 
> > This broke gcc builds.
> >
> > On Thu, Mar 22, 2018 at 2:21 PM, Jeff Roberson  wrote
> :
> >> Author: jeff
> >> Date: Thu Mar 22 19:21:11 2018
> >> New Revision: 331369
> >> URL: https://svnweb.freebsd.org/changeset/base/331369
> >>
> >> Log:
> >>   Lock reservations with a dedicated lock in each reservation.  Protec
> t
> >> th
>  e
> >>   

Re: svn commit: r331404 - in head: cddl/contrib/opensolaris/lib/libzpool/common/sys sys/cddl/contrib/opensolaris/uts/common sys/cddl/contrib/opensolaris/uts/common/fs/zfs sys/cddl/contrib/opensolaris/

2018-03-22 Thread Mateusz Guzik
On Fri, Mar 23, 2018 at 3:15 AM, Alexander Motin  wrote:

> Author: mav
> Date: Fri Mar 23 02:15:05 2018
> New Revision: 331404
> URL: https://svnweb.freebsd.org/changeset/base/331404
>
> Log:
>   MFV r331400: 8484 Implement aggregate sum and use for arc counters
>
>   In pursuit of improving performance on multi-core systems, we should
>   implements fanned out counters and use them to improve the performance of
>   some of the arc statistics. These stats are updated extremely frequently,
>   and can consume a significant amount of CPU time.
>
>
>
>
Due to seriously fat locks this struct:

typedef struct aggsum_bucket {
kmutex_t asc_lock;
int64_t asc_delta;
uint64_t asc_borrowed;
uint64_t asc_pad[4]; /* pad out to cache line (64 bytes) */
} aggsum_bucket_t __aligned(CACHE_LINE_SIZE);

ends up using *two* cache lines. Without asc_pad the size is 48 bytes.
asc_pad adds 4 * 8 = 32 which pushes it to the next line for no good reason.

That said, I suggest #ifndefing it the field.

-- 
Mateusz Guzik 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r331369 - head/sys/vm

2018-03-22 Thread Cy Schubert
In message , Jeff Roberson 
writes:
> On Thu, 22 Mar 2018, Cy Schubert wrote:
>
> > It broke i386 too.
>
> I believe I'm not able to reproduce this because it is a result of changes 
> in kernel config.  I can not reproduce it so I can't verify the fix. 
> Since you can, would you mind committing?  I see no problem with the diff 
> below.

I don't mind.

>
> Thanks,
> Jeff
>
> >
> > Index: sys/vm/vm_reserv.c
> > ===
> > --- sys/vm/vm_reserv.c  (revision 331399)
> > +++ sys/vm/vm_reserv.c  (working copy)
> > @@ -45,8 +45,6 @@
> >
> > #include 
> > #include 
> > -#include 
> > -#include 
> > #include 
> > #include 
> > #include 
> > @@ -55,6 +53,8 @@
> > #include 
> > #include 
> > #include 
> > +#include 
> > +#include 
> > #include 
> > #include 
> >
> > This is because sys/i386/include/machine.h uses critical_enter() and
> > critical_exit() which are defined in sys/systm.h.
> >
> > It built nicely on my amd64's though.
> >
> > ~cy
> >
> > In message , Jeff Roberson
> > writes:
> >> Thank you, working on it.  I had done a make universe before getting
> >> review feedback.
> >>
> >> Jeff
> >>
> >> On Thu, 22 Mar 2018, Justin Hibbits wrote:
> >>
> >>> This broke gcc builds.
> >>>
> >>> On Thu, Mar 22, 2018 at 2:21 PM, Jeff Roberson  wrote:
>  Author: jeff
>  Date: Thu Mar 22 19:21:11 2018
>  New Revision: 331369
>  URL: https://svnweb.freebsd.org/changeset/base/331369
> 
>  Log:
>    Lock reservations with a dedicated lock in each reservation.  Protect 
> th
> >> e
>    vmd_free_count with atomics.
> 
>    This allows us to allocate and free from reservations without the free
>  l
> >> ock
>    except where a superpage is allocated from the physical layer, which i
> s
>    roughly 1/512 of the operations on amd64.
> 
>    Use the counter api to eliminate cache conention on counters.
> 
>    Reviewed by:  markj
>    Tested by:pho
>    Sponsored by: Netflix, Dell/EMC Isilon
>    Differential Revision:https://reviews.freebsd.org/D14707
> 
>  Modified:
>    head/sys/vm/vm_page.c
>    head/sys/vm/vm_pagequeue.h
>    head/sys/vm/vm_reserv.c
>    head/sys/vm/vm_reserv.h
> 
>  Modified: head/sys/vm/vm_page.c
>  
> ==
> >> 
>  --- head/sys/vm/vm_page.c   Thu Mar 22 19:11:43 2018(r331368
> )
>  +++ head/sys/vm/vm_page.c   Thu Mar 22 19:21:11 2018(r331369
> )
>  @@ -177,7 +177,6 @@ static uma_zone_t fakepg_zone;
>   static void vm_page_alloc_check(vm_page_t m);
>   static void vm_page_clear_dirty_mask(vm_page_t m, vm_page_bits_t pagebi
> ts
> >> );
>   static void vm_page_enqueue(uint8_t queue, vm_page_t m);
>  -static void vm_page_free_phys(struct vm_domain *vmd, vm_page_t m);
>   static void vm_page_init(void *dummy);
>   static int vm_page_insert_after(vm_page_t m, vm_object_t object,
>   vm_pindex_t pindex, vm_page_t mpred);
>  @@ -1677,10 +1676,10 @@ vm_page_alloc_after(vm_object_t object, vm_pinde
> x_
> >> t pi
>    * for the request class and false otherwise.
>    */
>   int
>  -vm_domain_available(struct vm_domain *vmd, int req, int npages)
>  +vm_domain_allocate(struct vm_domain *vmd, int req, int npages)
>   {
>  +   u_int limit, old, new;
> 
>  -   vm_domain_free_assert_locked(vmd);
>  req = req & VM_ALLOC_CLASS_MASK;
> 
>  /*
>  @@ -1688,15 +1687,34 @@ vm_domain_available(struct vm_domain *vmd, int r
> eq
> >> , in
>   */
>  if (curproc == pageproc && req != VM_ALLOC_INTERRUPT)
>  req = VM_ALLOC_SYSTEM;
>  +   if (req == VM_ALLOC_INTERRUPT)
>  +   limit = 0;
>  +   else if (req == VM_ALLOC_SYSTEM)
>  +   limit = vmd->vmd_interrupt_free_min;
>  +   else
>  +   limit = vmd->vmd_free_reserved;
> 
>  -   if (vmd->vmd_free_count >= npages + vmd->vmd_free_reserved ||
>  -   (req == VM_ALLOC_SYSTEM &&
>  -   vmd->vmd_free_count >= npages + vmd->vmd_interrupt_free_min)
>  |
> >> |
>  -   (req == VM_ALLOC_INTERRUPT &&
>  -   vmd->vmd_free_count >= npages))
>  -   return (1);
>  +   /*
>  +* Attempt to reserve the pages.  Fail if we're below the limit.
>  +*/
>  +   limit += npages;
>  +   old = vmd->vmd_free_count;
>  +   do {
>  +   if (old < limit)
>  +   return (0);
>  +   new = old - npages;
>  +   } while (atomic_fcmpset_int(>vmd_free_count, , new) == 
> 0)
> >> ;
> 
>  -   

svn commit: r331408 - in head: cddl/contrib/opensolaris/cmd/zfs cddl/contrib/opensolaris/cmd/zpool sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2018-03-22 Thread Alexander Motin
Author: mav
Date: Fri Mar 23 02:30:29 2018
New Revision: 331408
URL: https://svnweb.freebsd.org/changeset/base/331408

Log:
  MFV r331407: 9213 zfs: sytem typo
  
  illumos/illumos-gate@edc8ef7d921c96b23969898aeb766cb24960bda7
  
  Reviewed by: C Fraire 
  Reviewed by: Andy Fiddaman 
  Approved by: Joshua M. Clulow 
  Author: Toomas Soome 

Modified:
  head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
  head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c
Directory Properties:
  head/cddl/contrib/opensolaris/   (props changed)
  head/cddl/contrib/opensolaris/cmd/zfs/   (props changed)
  head/sys/cddl/contrib/opensolaris/   (props changed)

Modified: head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
==
--- head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.cFri Mar 23 02:28:37 
2018(r331407)
+++ head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.cFri Mar 23 02:30:29 
2018(r331408)
@@ -2215,7 +2215,7 @@ zfs_do_upgrade(int argc, char **argv)
if (cb.cb_numfailed != 0)
ret = 1;
} else {
-   /* List old-version filesytems */
+   /* List old-version filesystems */
boolean_t found;
(void) printf(gettext("This system is currently running "
"ZFS filesystem version %llu.\n\n"), ZPL_VERSION);

Modified: head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
==
--- head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.cFri Mar 23 
02:28:37 2018(r331407)
+++ head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.cFri Mar 23 
02:30:29 2018(r331408)
@@ -1852,7 +1852,7 @@ show_import(nvlist_t *config)
 
case ZPOOL_STATUS_UNSUP_FEAT_READ:
(void) printf(gettext("status: The pool uses the following "
-   "feature(s) not supported on this sytem:\n"));
+   "feature(s) not supported on this system:\n"));
zpool_print_unsup_feat(config);
break;
 

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   Fri Mar 
23 02:28:37 2018(r331407)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c   Fri Mar 
23 02:30:29 2018(r331408)
@@ -2369,7 +2369,7 @@ slow:
 /*
  * Determine whether Access should be granted/denied.
  *
- * The least priv subsytem is always consulted as a basic privilege
+ * The least priv subsystem is always consulted as a basic privilege
  * can define any form of access.
  */
 int
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r331406 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2018-03-22 Thread Alexander Motin
Author: mav
Date: Fri Mar 23 02:24:52 2018
New Revision: 331406
URL: https://svnweb.freebsd.org/changeset/base/331406

Log:
  MFV r331405: 9084 spa_*_ashift must ignore spare devices
  
  illumos/illumos-gate@b037f3dbd69cef4a7ffd576ad33e07bfaf0b1e84
  
  Reviewed by: Prashanth Sreenivasa 
  Reviewed by: George Wilson 
  Approved by: Dan McDonald 
  Author: Prakash Surya 

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c
Directory Properties:
  head/sys/cddl/contrib/opensolaris/   (props changed)

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c  Fri Mar 23 
02:22:16 2018(r331405)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c  Fri Mar 23 
02:24:52 2018(r331406)
@@ -1589,14 +1589,6 @@ vdev_open(vdev_t *vd)
return (error);
}
 
-   if (vd->vdev_top == vd && vd->vdev_ashift != 0 &&
-   !vd->vdev_isl2cache && !vd->vdev_islog) {
-   if (vd->vdev_ashift > spa->spa_max_ashift)
-   spa->spa_max_ashift = vd->vdev_ashift;
-   if (vd->vdev_ashift < spa->spa_min_ashift)
-   spa->spa_min_ashift = vd->vdev_ashift;
-   }
-
/*
 * Track the min and max ashift values for normal data devices.
 */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r331404 - in head: cddl/contrib/opensolaris/lib/libzpool/common/sys sys/cddl/contrib/opensolaris/uts/common sys/cddl/contrib/opensolaris/uts/common/fs/zfs sys/cddl/contrib/opensolaris/u...

2018-03-22 Thread Alexander Motin
Author: mav
Date: Fri Mar 23 02:15:05 2018
New Revision: 331404
URL: https://svnweb.freebsd.org/changeset/base/331404

Log:
  MFV r331400: 8484 Implement aggregate sum and use for arc counters
  
  In pursuit of improving performance on multi-core systems, we should
  implements fanned out counters and use them to improve the performance of
  some of the arc statistics. These stats are updated extremely frequently,
  and can consume a significant amount of CPU time.
  
  Reviewed by: Pavel Zakharov 
  Reviewed by: Matthew Ahrens 
  Approved by: Dan McDonald 
  Author: Paul Dagnelie 

Added:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/THIRDPARTYLICENSE.cityhash
 - copied unchanged from r331400, 
vendor-sys/illumos/dist/uts/common/fs/zfs/THIRDPARTYLICENSE.cityhash
  
head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/THIRDPARTYLICENSE.cityhash.descrip
 - copied unchanged from r331400, 
vendor-sys/illumos/dist/uts/common/fs/zfs/THIRDPARTYLICENSE.cityhash.descrip
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/aggsum.c
 - copied unchanged from r331400, 
vendor-sys/illumos/dist/uts/common/fs/zfs/aggsum.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/cityhash.c
 - copied unchanged from r331400, 
vendor-sys/illumos/dist/uts/common/fs/zfs/cityhash.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/aggsum.h
 - copied, changed from r331400, 
vendor-sys/illumos/dist/uts/common/fs/zfs/sys/aggsum.h
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/cityhash.h
 - copied unchanged from r331400, 
vendor-sys/illumos/dist/uts/common/fs/zfs/sys/cityhash.h
Modified:
  head/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h
  head/sys/cddl/contrib/opensolaris/uts/common/Makefile.files
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_context.h
  head/sys/conf/files
Directory Properties:
  head/sys/cddl/contrib/opensolaris/   (props changed)

Modified: head/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h
==
--- head/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h Fri Mar 
23 01:43:27 2018(r331403)
+++ head/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h Fri Mar 
23 02:15:05 2018(r331404)
@@ -559,6 +559,7 @@ extern void delay(clock_t ticks);
} while (0);
 
 #definemax_ncpus   64
+#defineboot_ncpus  (sysconf(_SC_NPROCESSORS_ONLN))
 
 #defineminclsyspri 60
 #definemaxclsyspri 99

Modified: head/sys/cddl/contrib/opensolaris/uts/common/Makefile.files
==
--- head/sys/cddl/contrib/opensolaris/uts/common/Makefile.files Fri Mar 23 
01:43:27 2018(r331403)
+++ head/sys/cddl/contrib/opensolaris/uts/common/Makefile.files Fri Mar 23 
02:15:05 2018(r331404)
@@ -63,12 +63,14 @@ LUA_OBJS += \
 
 ZFS_COMMON_OBJS += \
abd.o   \
+   aggsum.o\
arc.o   \
bplist.o\
blkptr.o\
bpobj.o \
bptree.o\
bqueue.o\
+   cityhash.o  \
dbuf.o  \
ddt.o   \
ddt_zap.o   \

Copied: 
head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/THIRDPARTYLICENSE.cityhash 
(from r331400, 
vendor-sys/illumos/dist/uts/common/fs/zfs/THIRDPARTYLICENSE.cityhash)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ 
head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/THIRDPARTYLICENSE.cityhash  
Fri Mar 23 02:15:05 2018(r331404, copy of r331400, 
vendor-sys/illumos/dist/uts/common/fs/zfs/THIRDPARTYLICENSE.cityhash)
@@ -0,0 +1,19 @@
+Copyright (c) 2011 Google, Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND 

Re: svn commit: r331369 - head/sys/vm

2018-03-22 Thread Jeff Roberson

On Thu, 22 Mar 2018, Cy Schubert wrote:


In message , Jeff Roberson
writes:

On Thu, 22 Mar 2018, Cy Schubert wrote:


It broke i386 too.


I just did
TARGET_ARCH=i386 make buildworld
TARGET_ARCH=i386 make buildkernel

This worked for me?

Jeff


hmmm.

make TARGET=i386 TARGET_ARCH=i386 buildkernel


Do you have changes to GENERIC?

Thanks,
Jeff


--- vm_reserv.o ---
In file included from /opt/src/svn-current/sys/vm/vm_reserv.c:48:
In file included from /opt/src/svn-current/sys/sys/counter.h:37:
./machine/counter.h:174:3: error: implicit declaration of function
'critical_enter' is invalid in C99 [-Werror,-Wimplicit-function-declarat
ion]
   critical_enter();
   ^
./machine/counter.h:174:3: error: this function declaration is not a
prototype [-Werror,-Wstrict-prototypes]
./machine/counter.h:176:3: error: implicit declaration of function
'critical_exit' is invalid in C99 [-Werror,-Wimplicit-function-declarati
on]
   critical_exit();
   ^
./machine/counter.h:176:3: note: did you mean 'critical_enter'?
./machine/counter.h:174:3: note: 'critical_enter' declared here
   critical_enter();
   ^
./machine/counter.h:176:3: error: this function declaration is not a
prototype [-Werror,-Wstrict-prototypes]
   critical_exit();
   ^
In file included from /opt/src/svn-current/sys/vm/vm_reserv.c:57:
/opt/src/svn-current/sys/sys/systm.h:217:6: error: conflicting types
for 'critical_enter'
voidcritical_enter(void);
   ^
./machine/counter.h:174:3: note: previous implicit declaration is here
   critical_enter();
   ^
In file included from /opt/src/svn-current/sys/vm/vm_reserv.c:57:
/opt/src/svn-current/sys/sys/systm.h:218:6: error: conflicting types
for 'critical_exit'
voidcritical_exit(void);
   ^
./machine/counter.h:176:3: note: previous implicit declaration is here
   critical_exit();
   ^
6 errors generated.
*** [vm_reserv.o] Error code 1

make[2]: stopped in /export/obj/opt/src/svn-current/i386.i386/sys/BREAK
--- modules-all ---
A failure has been detected in another branch of the parallel make

make[3]: stopped in /opt/src/svn-current/sys/modules
*** [modules-all] Error code 2

make[2]: stopped in /export/obj/opt/src/svn-current/i386.i386/sys/BREAK
2 errors

make[2]: stopped in /export/obj/opt/src/svn-current/i386.i386/sys/BREAK
*** [buildkernel] Error code 2

make[1]: stopped in /opt/src/svn-current
1 error

make[1]: stopped in /opt/src/svn-current
*** [buildkernel] Error code 2

make: stopped in /opt/src/svn-current
1 error

make: stopped in /opt/src/svn-current

~cy





Index: sys/vm/vm_reserv.c
===
--- sys/vm/vm_reserv.c  (revision 331399)
+++ sys/vm/vm_reserv.c  (working copy)
@@ -45,8 +45,6 @@

#include 
#include 
-#include 
-#include 
#include 
#include 
#include 
@@ -55,6 +53,8 @@
#include 
#include 
#include 
+#include 
+#include 
#include 
#include 

This is because sys/i386/include/machine.h uses critical_enter() and
critical_exit() which are defined in sys/systm.h.

It built nicely on my amd64's though.

~cy

In message , Jeff Roberson
writes:

Thank you, working on it.  I had done a make universe before getting
review feedback.

Jeff

On Thu, 22 Mar 2018, Justin Hibbits wrote:


This broke gcc builds.

On Thu, Mar 22, 2018 at 2:21 PM, Jeff Roberson  wrote:

Author: jeff
Date: Thu Mar 22 19:21:11 2018
New Revision: 331369
URL: https://svnweb.freebsd.org/changeset/base/331369

Log:
  Lock reservations with a dedicated lock in each reservation.  Protect

th

e

  vmd_free_count with atomics.

  This allows us to allocate and free from reservations without the free

 l

ock

  except where a superpage is allocated from the physical layer, which i

s

  roughly 1/512 of the operations on amd64.

  Use the counter api to eliminate cache conention on counters.

  Reviewed by:  markj
  Tested by:pho
  Sponsored by: Netflix, Dell/EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D14707

Modified:
  head/sys/vm/vm_page.c
  head/sys/vm/vm_pagequeue.h
  head/sys/vm/vm_reserv.c
  head/sys/vm/vm_reserv.h

Modified: head/sys/vm/vm_page.c


==



--- head/sys/vm/vm_page.c   Thu Mar 22 19:11:43 2018(r331368

)

+++ head/sys/vm/vm_page.c   Thu Mar 22 19:21:11 2018(r331369

)

@@ -177,7 +177,6 @@ static uma_zone_t fakepg_zone;
 static void vm_page_alloc_check(vm_page_t m);
 static void vm_page_clear_dirty_mask(vm_page_t m, vm_page_bits_t pagebi

ts

);

 static void vm_page_enqueue(uint8_t queue, vm_page_t m);
-static void vm_page_free_phys(struct vm_domain *vmd, vm_page_t m);
 static void vm_page_init(void *dummy);
 static int vm_page_insert_after(vm_page_t m, vm_object_t 

Re: svn commit: r331369 - head/sys/vm

2018-03-22 Thread Cy Schubert
In message , Jeff Roberson 
writes:
> On Thu, 22 Mar 2018, Cy Schubert wrote:
>
> > It broke i386 too.
>
> I just did
> TARGET_ARCH=i386 make buildworld
> TARGET_ARCH=i386 make buildkernel
>
> This worked for me?
>
> Jeff

hmmm.

make TARGET=i386 TARGET_ARCH=i386 buildkernel

--- vm_reserv.o ---
In file included from /opt/src/svn-current/sys/vm/vm_reserv.c:48:
In file included from /opt/src/svn-current/sys/sys/counter.h:37:
./machine/counter.h:174:3: error: implicit declaration of function 
'critical_enter' is invalid in C99 [-Werror,-Wimplicit-function-declarat
ion]
critical_enter();
^
./machine/counter.h:174:3: error: this function declaration is not a 
prototype [-Werror,-Wstrict-prototypes]
./machine/counter.h:176:3: error: implicit declaration of function 
'critical_exit' is invalid in C99 [-Werror,-Wimplicit-function-declarati
on]
critical_exit();
^
./machine/counter.h:176:3: note: did you mean 'critical_enter'?
./machine/counter.h:174:3: note: 'critical_enter' declared here
critical_enter();
^
./machine/counter.h:176:3: error: this function declaration is not a 
prototype [-Werror,-Wstrict-prototypes]
critical_exit();
^
In file included from /opt/src/svn-current/sys/vm/vm_reserv.c:57:
/opt/src/svn-current/sys/sys/systm.h:217:6: error: conflicting types 
for 'critical_enter'
voidcritical_enter(void);
^
./machine/counter.h:174:3: note: previous implicit declaration is here
critical_enter();
^
In file included from /opt/src/svn-current/sys/vm/vm_reserv.c:57:
/opt/src/svn-current/sys/sys/systm.h:218:6: error: conflicting types 
for 'critical_exit'
voidcritical_exit(void);
^
./machine/counter.h:176:3: note: previous implicit declaration is here
critical_exit();
^
6 errors generated.
*** [vm_reserv.o] Error code 1

make[2]: stopped in /export/obj/opt/src/svn-current/i386.i386/sys/BREAK
--- modules-all ---
A failure has been detected in another branch of the parallel make

make[3]: stopped in /opt/src/svn-current/sys/modules
*** [modules-all] Error code 2

make[2]: stopped in /export/obj/opt/src/svn-current/i386.i386/sys/BREAK
2 errors

make[2]: stopped in /export/obj/opt/src/svn-current/i386.i386/sys/BREAK
*** [buildkernel] Error code 2

make[1]: stopped in /opt/src/svn-current
1 error

make[1]: stopped in /opt/src/svn-current
*** [buildkernel] Error code 2

make: stopped in /opt/src/svn-current
1 error

make: stopped in /opt/src/svn-current

~cy

>
> >
> > Index: sys/vm/vm_reserv.c
> > ===
> > --- sys/vm/vm_reserv.c  (revision 331399)
> > +++ sys/vm/vm_reserv.c  (working copy)
> > @@ -45,8 +45,6 @@
> >
> > #include 
> > #include 
> > -#include 
> > -#include 
> > #include 
> > #include 
> > #include 
> > @@ -55,6 +53,8 @@
> > #include 
> > #include 
> > #include 
> > +#include 
> > +#include 
> > #include 
> > #include 
> >
> > This is because sys/i386/include/machine.h uses critical_enter() and
> > critical_exit() which are defined in sys/systm.h.
> >
> > It built nicely on my amd64's though.
> >
> > ~cy
> >
> > In message , Jeff Roberson
> > writes:
> >> Thank you, working on it.  I had done a make universe before getting
> >> review feedback.
> >>
> >> Jeff
> >>
> >> On Thu, 22 Mar 2018, Justin Hibbits wrote:
> >>
> >>> This broke gcc builds.
> >>>
> >>> On Thu, Mar 22, 2018 at 2:21 PM, Jeff Roberson  wrote:
>  Author: jeff
>  Date: Thu Mar 22 19:21:11 2018
>  New Revision: 331369
>  URL: https://svnweb.freebsd.org/changeset/base/331369
> 
>  Log:
>    Lock reservations with a dedicated lock in each reservation.  Protect 
> th
> >> e
>    vmd_free_count with atomics.
> 
>    This allows us to allocate and free from reservations without the free
>  l
> >> ock
>    except where a superpage is allocated from the physical layer, which i
> s
>    roughly 1/512 of the operations on amd64.
> 
>    Use the counter api to eliminate cache conention on counters.
> 
>    Reviewed by:  markj
>    Tested by:pho
>    Sponsored by: Netflix, Dell/EMC Isilon
>    Differential Revision:https://reviews.freebsd.org/D14707
> 
>  Modified:
>    head/sys/vm/vm_page.c
>    head/sys/vm/vm_pagequeue.h
>    head/sys/vm/vm_reserv.c
>    head/sys/vm/vm_reserv.h
> 
>  Modified: head/sys/vm/vm_page.c
>  
> ==
> >> 
>  --- head/sys/vm/vm_page.c   Thu Mar 22 19:11:43 2018(r331368
> )
>  +++ head/sys/vm/vm_page.c   Thu Mar 22 19:21:11 2018(r331369
> )
>  @@ -177,7 +177,6 @@ static uma_zone_t fakepg_zone;
>   

Re: svn commit: r331369 - head/sys/vm

2018-03-22 Thread Jeff Roberson

On Thu, 22 Mar 2018, Cy Schubert wrote:


It broke i386 too.


I believe I'm not able to reproduce this because it is a result of changes 
in kernel config.  I can not reproduce it so I can't verify the fix. 
Since you can, would you mind committing?  I see no problem with the diff 
below.


Thanks,
Jeff



Index: sys/vm/vm_reserv.c
===
--- sys/vm/vm_reserv.c  (revision 331399)
+++ sys/vm/vm_reserv.c  (working copy)
@@ -45,8 +45,6 @@

#include 
#include 
-#include 
-#include 
#include 
#include 
#include 
@@ -55,6 +53,8 @@
#include 
#include 
#include 
+#include 
+#include 
#include 
#include 

This is because sys/i386/include/machine.h uses critical_enter() and
critical_exit() which are defined in sys/systm.h.

It built nicely on my amd64's though.

~cy

In message , Jeff Roberson
writes:

Thank you, working on it.  I had done a make universe before getting
review feedback.

Jeff

On Thu, 22 Mar 2018, Justin Hibbits wrote:


This broke gcc builds.

On Thu, Mar 22, 2018 at 2:21 PM, Jeff Roberson  wrote:

Author: jeff
Date: Thu Mar 22 19:21:11 2018
New Revision: 331369
URL: https://svnweb.freebsd.org/changeset/base/331369

Log:
  Lock reservations with a dedicated lock in each reservation.  Protect th

e

  vmd_free_count with atomics.

  This allows us to allocate and free from reservations without the free l

ock

  except where a superpage is allocated from the physical layer, which is
  roughly 1/512 of the operations on amd64.

  Use the counter api to eliminate cache conention on counters.

  Reviewed by:  markj
  Tested by:pho
  Sponsored by: Netflix, Dell/EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D14707

Modified:
  head/sys/vm/vm_page.c
  head/sys/vm/vm_pagequeue.h
  head/sys/vm/vm_reserv.c
  head/sys/vm/vm_reserv.h

Modified: head/sys/vm/vm_page.c
==



--- head/sys/vm/vm_page.c   Thu Mar 22 19:11:43 2018(r331368)
+++ head/sys/vm/vm_page.c   Thu Mar 22 19:21:11 2018(r331369)
@@ -177,7 +177,6 @@ static uma_zone_t fakepg_zone;
 static void vm_page_alloc_check(vm_page_t m);
 static void vm_page_clear_dirty_mask(vm_page_t m, vm_page_bits_t pagebits

);

 static void vm_page_enqueue(uint8_t queue, vm_page_t m);
-static void vm_page_free_phys(struct vm_domain *vmd, vm_page_t m);
 static void vm_page_init(void *dummy);
 static int vm_page_insert_after(vm_page_t m, vm_object_t object,
 vm_pindex_t pindex, vm_page_t mpred);
@@ -1677,10 +1676,10 @@ vm_page_alloc_after(vm_object_t object, vm_pindex_

t pi

  * for the request class and false otherwise.
  */
 int
-vm_domain_available(struct vm_domain *vmd, int req, int npages)
+vm_domain_allocate(struct vm_domain *vmd, int req, int npages)
 {
+   u_int limit, old, new;

-   vm_domain_free_assert_locked(vmd);
req = req & VM_ALLOC_CLASS_MASK;

/*
@@ -1688,15 +1687,34 @@ vm_domain_available(struct vm_domain *vmd, int req

, in

 */
if (curproc == pageproc && req != VM_ALLOC_INTERRUPT)
req = VM_ALLOC_SYSTEM;
+   if (req == VM_ALLOC_INTERRUPT)
+   limit = 0;
+   else if (req == VM_ALLOC_SYSTEM)
+   limit = vmd->vmd_interrupt_free_min;
+   else
+   limit = vmd->vmd_free_reserved;

-   if (vmd->vmd_free_count >= npages + vmd->vmd_free_reserved ||
-   (req == VM_ALLOC_SYSTEM &&
-   vmd->vmd_free_count >= npages + vmd->vmd_interrupt_free_min) |

|

-   (req == VM_ALLOC_INTERRUPT &&
-   vmd->vmd_free_count >= npages))
-   return (1);
+   /*
+* Attempt to reserve the pages.  Fail if we're below the limit.
+*/
+   limit += npages;
+   old = vmd->vmd_free_count;
+   do {
+   if (old < limit)
+   return (0);
+   new = old - npages;
+   } while (atomic_fcmpset_int(>vmd_free_count, , new) == 0)

;


-   return (0);
+   /* Wake the page daemon if we've crossed the threshold. */
+   if (vm_paging_needed(vmd, new) && !vm_paging_needed(vmd, old))
+   pagedaemon_wakeup(vmd->vmd_domain);
+
+   /* Only update bitsets on transitions. */
+   if ((old >= vmd->vmd_free_min && new < vmd->vmd_free_min) ||
+   (old >= vmd->vmd_free_severe && new < vmd->vmd_free_severe))
+   vm_domain_set(vmd);
+
+   return (1);
 }

 vm_page_t
@@ -1723,44 +1741,34 @@ vm_page_alloc_domain_after(vm_object_t object, vm_

pind

 again:
m = NULL;
 #if VM_NRESERVLEVEL > 0
+   /*
+* Can we allocate the page from a reservation?
+*/
if (vm_object_reserv(object) &&
-   (m = vm_reserv_extend(req, object, pindex, domain, mpred))
-   != NULL) {
+   ((m = vm_reserv_extend(req, object, pindex, domain, mpred)) !=

 NULL 

Re: svn commit: r331369 - head/sys/vm

2018-03-22 Thread Jeff Roberson

On Thu, 22 Mar 2018, Cy Schubert wrote:


It broke i386 too.


I just did
TARGET_ARCH=i386 make buildworld
TARGET_ARCH=i386 make buildkernel

This worked for me?

Jeff



Index: sys/vm/vm_reserv.c
===
--- sys/vm/vm_reserv.c  (revision 331399)
+++ sys/vm/vm_reserv.c  (working copy)
@@ -45,8 +45,6 @@

#include 
#include 
-#include 
-#include 
#include 
#include 
#include 
@@ -55,6 +53,8 @@
#include 
#include 
#include 
+#include 
+#include 
#include 
#include 

This is because sys/i386/include/machine.h uses critical_enter() and
critical_exit() which are defined in sys/systm.h.

It built nicely on my amd64's though.

~cy

In message , Jeff Roberson
writes:

Thank you, working on it.  I had done a make universe before getting
review feedback.

Jeff

On Thu, 22 Mar 2018, Justin Hibbits wrote:


This broke gcc builds.

On Thu, Mar 22, 2018 at 2:21 PM, Jeff Roberson  wrote:

Author: jeff
Date: Thu Mar 22 19:21:11 2018
New Revision: 331369
URL: https://svnweb.freebsd.org/changeset/base/331369

Log:
  Lock reservations with a dedicated lock in each reservation.  Protect th

e

  vmd_free_count with atomics.

  This allows us to allocate and free from reservations without the free l

ock

  except where a superpage is allocated from the physical layer, which is
  roughly 1/512 of the operations on amd64.

  Use the counter api to eliminate cache conention on counters.

  Reviewed by:  markj
  Tested by:pho
  Sponsored by: Netflix, Dell/EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D14707

Modified:
  head/sys/vm/vm_page.c
  head/sys/vm/vm_pagequeue.h
  head/sys/vm/vm_reserv.c
  head/sys/vm/vm_reserv.h

Modified: head/sys/vm/vm_page.c
==



--- head/sys/vm/vm_page.c   Thu Mar 22 19:11:43 2018(r331368)
+++ head/sys/vm/vm_page.c   Thu Mar 22 19:21:11 2018(r331369)
@@ -177,7 +177,6 @@ static uma_zone_t fakepg_zone;
 static void vm_page_alloc_check(vm_page_t m);
 static void vm_page_clear_dirty_mask(vm_page_t m, vm_page_bits_t pagebits

);

 static void vm_page_enqueue(uint8_t queue, vm_page_t m);
-static void vm_page_free_phys(struct vm_domain *vmd, vm_page_t m);
 static void vm_page_init(void *dummy);
 static int vm_page_insert_after(vm_page_t m, vm_object_t object,
 vm_pindex_t pindex, vm_page_t mpred);
@@ -1677,10 +1676,10 @@ vm_page_alloc_after(vm_object_t object, vm_pindex_

t pi

  * for the request class and false otherwise.
  */
 int
-vm_domain_available(struct vm_domain *vmd, int req, int npages)
+vm_domain_allocate(struct vm_domain *vmd, int req, int npages)
 {
+   u_int limit, old, new;

-   vm_domain_free_assert_locked(vmd);
req = req & VM_ALLOC_CLASS_MASK;

/*
@@ -1688,15 +1687,34 @@ vm_domain_available(struct vm_domain *vmd, int req

, in

 */
if (curproc == pageproc && req != VM_ALLOC_INTERRUPT)
req = VM_ALLOC_SYSTEM;
+   if (req == VM_ALLOC_INTERRUPT)
+   limit = 0;
+   else if (req == VM_ALLOC_SYSTEM)
+   limit = vmd->vmd_interrupt_free_min;
+   else
+   limit = vmd->vmd_free_reserved;

-   if (vmd->vmd_free_count >= npages + vmd->vmd_free_reserved ||
-   (req == VM_ALLOC_SYSTEM &&
-   vmd->vmd_free_count >= npages + vmd->vmd_interrupt_free_min) |

|

-   (req == VM_ALLOC_INTERRUPT &&
-   vmd->vmd_free_count >= npages))
-   return (1);
+   /*
+* Attempt to reserve the pages.  Fail if we're below the limit.
+*/
+   limit += npages;
+   old = vmd->vmd_free_count;
+   do {
+   if (old < limit)
+   return (0);
+   new = old - npages;
+   } while (atomic_fcmpset_int(>vmd_free_count, , new) == 0)

;


-   return (0);
+   /* Wake the page daemon if we've crossed the threshold. */
+   if (vm_paging_needed(vmd, new) && !vm_paging_needed(vmd, old))
+   pagedaemon_wakeup(vmd->vmd_domain);
+
+   /* Only update bitsets on transitions. */
+   if ((old >= vmd->vmd_free_min && new < vmd->vmd_free_min) ||
+   (old >= vmd->vmd_free_severe && new < vmd->vmd_free_severe))
+   vm_domain_set(vmd);
+
+   return (1);
 }

 vm_page_t
@@ -1723,44 +1741,34 @@ vm_page_alloc_domain_after(vm_object_t object, vm_

pind

 again:
m = NULL;
 #if VM_NRESERVLEVEL > 0
+   /*
+* Can we allocate the page from a reservation?
+*/
if (vm_object_reserv(object) &&
-   (m = vm_reserv_extend(req, object, pindex, domain, mpred))
-   != NULL) {
+   ((m = vm_reserv_extend(req, object, pindex, domain, mpred)) !=

 NULL ||

+   (m = vm_reserv_alloc_page(req, object, pindex, domain, mpred))

 != NULL)) {

domain = vm_phys_domain(m);
 

Re: svn commit: r331369 - head/sys/vm

2018-03-22 Thread Cy Schubert
It broke i386 too.

Index: sys/vm/vm_reserv.c
===
--- sys/vm/vm_reserv.c  (revision 331399)
+++ sys/vm/vm_reserv.c  (working copy)
@@ -45,8 +45,6 @@
 
 #include 
 #include 
-#include 
-#include 
 #include 
 #include 
 #include 
@@ -55,6 +53,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 
This is because sys/i386/include/machine.h uses critical_enter() and 
critical_exit() which are defined in sys/systm.h.

It built nicely on my amd64's though.

~cy

In message , Jeff Roberson 
writes:
> Thank you, working on it.  I had done a make universe before getting 
> review feedback.
>
> Jeff
>
> On Thu, 22 Mar 2018, Justin Hibbits wrote:
>
> > This broke gcc builds.
> >
> > On Thu, Mar 22, 2018 at 2:21 PM, Jeff Roberson  wrote:
> >> Author: jeff
> >> Date: Thu Mar 22 19:21:11 2018
> >> New Revision: 331369
> >> URL: https://svnweb.freebsd.org/changeset/base/331369
> >>
> >> Log:
> >>   Lock reservations with a dedicated lock in each reservation.  Protect th
> e
> >>   vmd_free_count with atomics.
> >>
> >>   This allows us to allocate and free from reservations without the free l
> ock
> >>   except where a superpage is allocated from the physical layer, which is
> >>   roughly 1/512 of the operations on amd64.
> >>
> >>   Use the counter api to eliminate cache conention on counters.
> >>
> >>   Reviewed by:  markj
> >>   Tested by:pho
> >>   Sponsored by: Netflix, Dell/EMC Isilon
> >>   Differential Revision:https://reviews.freebsd.org/D14707
> >>
> >> Modified:
> >>   head/sys/vm/vm_page.c
> >>   head/sys/vm/vm_pagequeue.h
> >>   head/sys/vm/vm_reserv.c
> >>   head/sys/vm/vm_reserv.h
> >>
> >> Modified: head/sys/vm/vm_page.c
> >> ==
> 
> >> --- head/sys/vm/vm_page.c   Thu Mar 22 19:11:43 2018(r331368)
> >> +++ head/sys/vm/vm_page.c   Thu Mar 22 19:21:11 2018(r331369)
> >> @@ -177,7 +177,6 @@ static uma_zone_t fakepg_zone;
> >>  static void vm_page_alloc_check(vm_page_t m);
> >>  static void vm_page_clear_dirty_mask(vm_page_t m, vm_page_bits_t pagebits
> );
> >>  static void vm_page_enqueue(uint8_t queue, vm_page_t m);
> >> -static void vm_page_free_phys(struct vm_domain *vmd, vm_page_t m);
> >>  static void vm_page_init(void *dummy);
> >>  static int vm_page_insert_after(vm_page_t m, vm_object_t object,
> >>  vm_pindex_t pindex, vm_page_t mpred);
> >> @@ -1677,10 +1676,10 @@ vm_page_alloc_after(vm_object_t object, vm_pindex_
> t pi
> >>   * for the request class and false otherwise.
> >>   */
> >>  int
> >> -vm_domain_available(struct vm_domain *vmd, int req, int npages)
> >> +vm_domain_allocate(struct vm_domain *vmd, int req, int npages)
> >>  {
> >> +   u_int limit, old, new;
> >>
> >> -   vm_domain_free_assert_locked(vmd);
> >> req = req & VM_ALLOC_CLASS_MASK;
> >>
> >> /*
> >> @@ -1688,15 +1687,34 @@ vm_domain_available(struct vm_domain *vmd, int req
> , in
> >>  */
> >> if (curproc == pageproc && req != VM_ALLOC_INTERRUPT)
> >> req = VM_ALLOC_SYSTEM;
> >> +   if (req == VM_ALLOC_INTERRUPT)
> >> +   limit = 0;
> >> +   else if (req == VM_ALLOC_SYSTEM)
> >> +   limit = vmd->vmd_interrupt_free_min;
> >> +   else
> >> +   limit = vmd->vmd_free_reserved;
> >>
> >> -   if (vmd->vmd_free_count >= npages + vmd->vmd_free_reserved ||
> >> -   (req == VM_ALLOC_SYSTEM &&
> >> -   vmd->vmd_free_count >= npages + vmd->vmd_interrupt_free_min) |
> |
> >> -   (req == VM_ALLOC_INTERRUPT &&
> >> -   vmd->vmd_free_count >= npages))
> >> -   return (1);
> >> +   /*
> >> +* Attempt to reserve the pages.  Fail if we're below the limit.
> >> +*/
> >> +   limit += npages;
> >> +   old = vmd->vmd_free_count;
> >> +   do {
> >> +   if (old < limit)
> >> +   return (0);
> >> +   new = old - npages;
> >> +   } while (atomic_fcmpset_int(>vmd_free_count, , new) == 0)
> ;
> >>
> >> -   return (0);
> >> +   /* Wake the page daemon if we've crossed the threshold. */
> >> +   if (vm_paging_needed(vmd, new) && !vm_paging_needed(vmd, old))
> >> +   pagedaemon_wakeup(vmd->vmd_domain);
> >> +
> >> +   /* Only update bitsets on transitions. */
> >> +   if ((old >= vmd->vmd_free_min && new < vmd->vmd_free_min) ||
> >> +   (old >= vmd->vmd_free_severe && new < vmd->vmd_free_severe))
> >> +   vm_domain_set(vmd);
> >> +
> >> +   return (1);
> >>  }
> >>
> >>  vm_page_t
> >> @@ -1723,44 +1741,34 @@ vm_page_alloc_domain_after(vm_object_t object, vm_
> pind
> >>  again:
> >> m = NULL;
> >>  #if VM_NRESERVLEVEL > 0
> >> +   /*
> >> +* Can we allocate the page from a reservation?

Re: svn commit: r331369 - head/sys/vm

2018-03-22 Thread Jeff Roberson
Thank you, working on it.  I had done a make universe before getting 
review feedback.


Jeff

On Thu, 22 Mar 2018, Justin Hibbits wrote:


This broke gcc builds.

On Thu, Mar 22, 2018 at 2:21 PM, Jeff Roberson  wrote:

Author: jeff
Date: Thu Mar 22 19:21:11 2018
New Revision: 331369
URL: https://svnweb.freebsd.org/changeset/base/331369

Log:
  Lock reservations with a dedicated lock in each reservation.  Protect the
  vmd_free_count with atomics.

  This allows us to allocate and free from reservations without the free lock
  except where a superpage is allocated from the physical layer, which is
  roughly 1/512 of the operations on amd64.

  Use the counter api to eliminate cache conention on counters.

  Reviewed by:  markj
  Tested by:pho
  Sponsored by: Netflix, Dell/EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D14707

Modified:
  head/sys/vm/vm_page.c
  head/sys/vm/vm_pagequeue.h
  head/sys/vm/vm_reserv.c
  head/sys/vm/vm_reserv.h

Modified: head/sys/vm/vm_page.c
==
--- head/sys/vm/vm_page.c   Thu Mar 22 19:11:43 2018(r331368)
+++ head/sys/vm/vm_page.c   Thu Mar 22 19:21:11 2018(r331369)
@@ -177,7 +177,6 @@ static uma_zone_t fakepg_zone;
 static void vm_page_alloc_check(vm_page_t m);
 static void vm_page_clear_dirty_mask(vm_page_t m, vm_page_bits_t pagebits);
 static void vm_page_enqueue(uint8_t queue, vm_page_t m);
-static void vm_page_free_phys(struct vm_domain *vmd, vm_page_t m);
 static void vm_page_init(void *dummy);
 static int vm_page_insert_after(vm_page_t m, vm_object_t object,
 vm_pindex_t pindex, vm_page_t mpred);
@@ -1677,10 +1676,10 @@ vm_page_alloc_after(vm_object_t object, vm_pindex_t pi
  * for the request class and false otherwise.
  */
 int
-vm_domain_available(struct vm_domain *vmd, int req, int npages)
+vm_domain_allocate(struct vm_domain *vmd, int req, int npages)
 {
+   u_int limit, old, new;

-   vm_domain_free_assert_locked(vmd);
req = req & VM_ALLOC_CLASS_MASK;

/*
@@ -1688,15 +1687,34 @@ vm_domain_available(struct vm_domain *vmd, int req, in
 */
if (curproc == pageproc && req != VM_ALLOC_INTERRUPT)
req = VM_ALLOC_SYSTEM;
+   if (req == VM_ALLOC_INTERRUPT)
+   limit = 0;
+   else if (req == VM_ALLOC_SYSTEM)
+   limit = vmd->vmd_interrupt_free_min;
+   else
+   limit = vmd->vmd_free_reserved;

-   if (vmd->vmd_free_count >= npages + vmd->vmd_free_reserved ||
-   (req == VM_ALLOC_SYSTEM &&
-   vmd->vmd_free_count >= npages + vmd->vmd_interrupt_free_min) ||
-   (req == VM_ALLOC_INTERRUPT &&
-   vmd->vmd_free_count >= npages))
-   return (1);
+   /*
+* Attempt to reserve the pages.  Fail if we're below the limit.
+*/
+   limit += npages;
+   old = vmd->vmd_free_count;
+   do {
+   if (old < limit)
+   return (0);
+   new = old - npages;
+   } while (atomic_fcmpset_int(>vmd_free_count, , new) == 0);

-   return (0);
+   /* Wake the page daemon if we've crossed the threshold. */
+   if (vm_paging_needed(vmd, new) && !vm_paging_needed(vmd, old))
+   pagedaemon_wakeup(vmd->vmd_domain);
+
+   /* Only update bitsets on transitions. */
+   if ((old >= vmd->vmd_free_min && new < vmd->vmd_free_min) ||
+   (old >= vmd->vmd_free_severe && new < vmd->vmd_free_severe))
+   vm_domain_set(vmd);
+
+   return (1);
 }

 vm_page_t
@@ -1723,44 +1741,34 @@ vm_page_alloc_domain_after(vm_object_t object, vm_pind
 again:
m = NULL;
 #if VM_NRESERVLEVEL > 0
+   /*
+* Can we allocate the page from a reservation?
+*/
if (vm_object_reserv(object) &&
-   (m = vm_reserv_extend(req, object, pindex, domain, mpred))
-   != NULL) {
+   ((m = vm_reserv_extend(req, object, pindex, domain, mpred)) != NULL 
||
+   (m = vm_reserv_alloc_page(req, object, pindex, domain, mpred)) != 
NULL)) {
domain = vm_phys_domain(m);
vmd = VM_DOMAIN(domain);
goto found;
}
 #endif
vmd = VM_DOMAIN(domain);
-   vm_domain_free_lock(vmd);
-   if (vm_domain_available(vmd, req, 1)) {
+   if (vm_domain_allocate(vmd, req, 1)) {
/*
-* Can we allocate the page from a reservation?
+* If not, allocate it from the free page queues.
 */
+   vm_domain_free_lock(vmd);
+   m = vm_phys_alloc_pages(domain, object != NULL ?
+   VM_FREEPOOL_DEFAULT : VM_FREEPOOL_DIRECT, 0);
+   vm_domain_free_unlock(vmd);
+   if (m == NULL) {
+   vm_domain_freecnt_inc(vmd, 1);
 #if VM_NRESERVLEVEL > 0
-   if (!vm_object_reserv(object) ||
- 

svn commit: r331401 - head/sys/powerpc/powerpc

2018-03-22 Thread Justin Hibbits
Author: jhibbits
Date: Fri Mar 23 00:40:08 2018
New Revision: 331401
URL: https://svnweb.freebsd.org/changeset/base/331401

Log:
  Debug interrupts aren't instruction traps
  
  The EXC_DEBUG type is akin to the MPC74xx "Instruction Breakpoint" trap.
  Don't treat it as a trap instruction.

Modified:
  head/sys/powerpc/powerpc/trap.c

Modified: head/sys/powerpc/powerpc/trap.c
==
--- head/sys/powerpc/powerpc/trap.c Fri Mar 23 00:20:42 2018
(r331400)
+++ head/sys/powerpc/powerpc/trap.c Fri Mar 23 00:40:08 2018
(r331401)
@@ -189,7 +189,7 @@ frame_is_trap_inst(struct trapframe *frame)
 #ifdef AIM
return (frame->exc == EXC_PGM && frame->srr1 & EXC_PGM_TRAP);
 #else
-   return (frame->exc == EXC_DEBUG || frame->cpu.booke.esr & ESR_PTR);
+   return ((frame->cpu.booke.esr & ESR_PTR) != 0);
 #endif
 }
 
@@ -895,6 +895,7 @@ db_trap_glue(struct trapframe *frame)
&& (frame->exc == EXC_TRC || frame->exc == EXC_RUNMODETRC
|| frame_is_trap_inst(frame)
|| frame->exc == EXC_BPT
+   || frame->exc == EXC_DEBUG
|| frame->exc == EXC_DSI)) {
int type = frame->exc;
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r331380 - head/sys/netinet6

2018-03-22 Thread Sean Bruno
Author: sbruno
Date: Thu Mar 22 23:34:48 2018
New Revision: 331380
URL: https://svnweb.freebsd.org/changeset/base/331380

Log:
  Refactor ip6_getpcbopt() for better locking and memory management
  
  Created GET_PKTOPT_EXT_HDR() and GET_PKTOPT_SOCKADDR() macros to
  handle safely fetching options from in6p_outputopts, including
  properly dealing with in6p locking and preparing memory for
  sooptcopyout().
  
  Changed the function signature of ip6_getpcbopt() to allow the
  function to acquire and release locks on in6p as needed.
  
  Submitted by: Jason Eggleston 
  Sponsored by: Limelight Networks
  Differential Revision:https://reviews.freebsd.org/D14619

Modified:
  head/sys/netinet6/ip6_output.c

Modified: head/sys/netinet6/ip6_output.c
==
--- head/sys/netinet6/ip6_output.c  Thu Mar 22 22:29:32 2018
(r331379)
+++ head/sys/netinet6/ip6_output.c  Thu Mar 22 23:34:48 2018
(r331380)
@@ -135,7 +135,7 @@ static int ip6_pcbopt(int, u_char *, int, struct ip6_p
   struct ucred *, int);
 static int ip6_pcbopts(struct ip6_pktopts **, struct mbuf *,
struct socket *, struct sockopt *);
-static int ip6_getpcbopt(struct ip6_pktopts *, int, struct sockopt *);
+static int ip6_getpcbopt(struct inpcb *, int, struct sockopt *);
 static int ip6_setpktopt(int, u_char *, int, struct ip6_pktopts *,
struct ucred *, int, int, int);
 
@@ -2132,8 +2132,7 @@ do {  
\
case IPV6_DONTFRAG:
case IPV6_USE_MIN_MTU:
case IPV6_PREFER_TEMPADDR:
-   error = ip6_getpcbopt(in6p->in6p_outputopts,
-   optname, sopt);
+   error = ip6_getpcbopt(in6p, optname, sopt);
break;
 
case IPV6_MULTICAST_IF:
@@ -2310,18 +2309,51 @@ ip6_pcbopt(int optname, u_char *buf, int len, struct i
return (ip6_setpktopt(optname, buf, len, opt, cred, 1, 0, uproto));
 }
 
+#define GET_PKTOPT_VAR(field, lenexpr) do {
\
+   if (pktopt && pktopt->field) {  
\
+   INP_RUNLOCK(in6p);  
\
+   optdata = malloc(sopt->sopt_valsize, M_TEMP, M_WAITOK); 
\
+   malloc_optdata = true;  
\
+   INP_RLOCK(in6p);
\
+   if (in6p->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) {   
\
+   INP_RUNLOCK(in6p);  
\
+   free(optdata, M_TEMP);  
\
+   return (ECONNRESET);
\
+   }   
\
+   pktopt = in6p->in6p_outputopts; 
\
+   if (pktopt && pktopt->field) {  
\
+   optdatalen = min(lenexpr, sopt->sopt_valsize);  
\
+   bcopy(>field, optdata, optdatalen); 
\
+   } else {
\
+   free(optdata, M_TEMP);  
\
+   optdata = NULL; 
\
+   malloc_optdata = false; 
\
+   }   
\
+   }   
\
+} while(0)
+
+#define GET_PKTOPT_EXT_HDR(field) GET_PKTOPT_VAR(field,
\
+   (((struct ip6_ext *)pktopt->field)->ip6e_len + 1) << 3)
+
+#define GET_PKTOPT_SOCKADDR(field) GET_PKTOPT_VAR(field,   
\
+   pktopt->field->sa_len)
+
 static int
-ip6_getpcbopt(struct ip6_pktopts *pktopt, int optname, struct sockopt *sopt)
+ip6_getpcbopt(struct inpcb *in6p, int optname, struct sockopt *sopt)
 {
void *optdata = NULL;
+   bool malloc_optdata = false;
int optdatalen = 0;
-   struct ip6_ext *ip6e;
int error = 0;
struct in6_pktinfo null_pktinfo;
int deftclass = 0, on;
int defminmtu = IP6PO_MINMTU_MCASTONLY;
int defpreftemp = IP6PO_TEMPADDR_SYSTEM;
+   struct ip6_pktopts *pktopt;
 
+   INP_RLOCK(in6p);
+   pktopt = in6p->in6p_outputopts;
+
switch (optname) {
case IPV6_PKTINFO:
optdata = (void *)_pktinfo;
@@ -2337,50 +2369,29 @@ ip6_getpcbopt(struct ip6_pktopts *pktopt, int optname,

svn commit: r331379 - in head/sys: netinet netinet6

2018-03-22 Thread Sean Bruno
Author: sbruno
Date: Thu Mar 22 22:29:32 2018
New Revision: 331379
URL: https://svnweb.freebsd.org/changeset/base/331379

Log:
  Simple locking fixes in ip_ctloutput, ip6_ctloutput, rip_ctloutput.
  
  Submitted by: Jason Eggleston 
  Sponsored by: Limelight Networks
  Differential Revision:https://reviews.freebsd.org/D14624

Modified:
  head/sys/netinet/ip_output.c
  head/sys/netinet/raw_ip.c
  head/sys/netinet6/ip6_output.c

Modified: head/sys/netinet/ip_output.c
==
--- head/sys/netinet/ip_output.cThu Mar 22 22:13:46 2018
(r331378)
+++ head/sys/netinet/ip_output.cThu Mar 22 22:29:32 2018
(r331379)
@@ -1314,12 +1314,14 @@ ip_ctloutput(struct socket *so, struct sockopt *sopt)
break;
 
case IP_PORTRANGE:
+   INP_RLOCK(inp);
if (inp->inp_flags & INP_HIGHPORT)
optval = IP_PORTRANGE_HIGH;
else if (inp->inp_flags & INP_LOWPORT)
optval = IP_PORTRANGE_LOW;
else
optval = 0;
+   INP_RUNLOCK(inp);
break;
 
case IP_ONESBCAST:
@@ -1345,9 +1347,11 @@ ip_ctloutput(struct socket *so, struct sockopt *sopt)
break;
 #ifdef RSS
case IP_RSSBUCKETID:
+   INP_RLOCK(inp);
retval = rss_hash2bucket(inp->inp_flowid,
inp->inp_flowtype,
_bucket);
+   INP_RUNLOCK(inp);
if (retval == 0)
optval = rss_bucket;
else

Modified: head/sys/netinet/raw_ip.c
==
--- head/sys/netinet/raw_ip.c   Thu Mar 22 22:13:46 2018(r331378)
+++ head/sys/netinet/raw_ip.c   Thu Mar 22 22:29:32 2018(r331379)
@@ -639,10 +639,12 @@ rip_ctloutput(struct socket *so, struct sockopt *sopt)
sizeof optval);
if (error)
break;
+   INP_WLOCK(inp);
if (optval)
inp->inp_flags |= INP_HDRINCL;
else
inp->inp_flags &= ~INP_HDRINCL;
+   INP_WUNLOCK(inp);
break;
 
case IP_FW3:/* generic ipfw v.3 functions */

Modified: head/sys/netinet6/ip6_output.c
==
--- head/sys/netinet6/ip6_output.c  Thu Mar 22 22:13:46 2018
(r331378)
+++ head/sys/netinet6/ip6_output.c  Thu Mar 22 22:29:32 2018
(r331379)
@@ -1498,8 +1498,10 @@ ip6_ctloutput(struct socket *so, struct sockopt *sopt)
error = soopt_mcopyin(sopt, m); /* XXX */
if (error != 0)
break;
+   INP_WLOCK(in6p);
error = ip6_pcbopts(>in6p_outputopts,
m, so, sopt);
+   INP_WUNLOCK(in6p);
m_freem(m); /* XXX */
break;
}
@@ -1635,11 +1637,13 @@ do {
\
error = EINVAL;
break;
}
+   INP_WLOCK(in6p);
optp = >in6p_outputopts;
error = ip6_pcbopt(IPV6_HOPLIMIT,
(u_char *), sizeof(optval),
optp, (td != NULL) ? td->td_ucred :
NULL, uproto);
+   INP_WUNLOCK(in6p);
break;
}
 
@@ -1690,8 +1694,10 @@ do { 
\
 * available only prior to bind(2).
 * see ipng mailing list, Jun 22 2001.
 */
+   INP_WLOCK(in6p);
if 

svn commit: r331378 - head/sys/dev/bhnd/nvram

2018-03-22 Thread Landon J. Fuller
Author: landonf
Date: Thu Mar 22 22:13:46 2018
New Revision: 331378
URL: https://svnweb.freebsd.org/changeset/base/331378

Log:
  Add missing NULL checks when calling malloc(M_NOWAIT) in
  bhnd_nv_strdup/bhnd_nv_strndup.
  
  If malloc(9) failed during initial bhnd(4) attach, while allocating the root
  NVRAM path string ("/"), the returned NULL pointer would be passed as the
  destination to memcpy().
  
  Reported by:  Ilja Van Sprundel 

Modified:
  head/sys/dev/bhnd/nvram/bhnd_nvram_private.h

Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_private.h
==
--- head/sys/dev/bhnd/nvram/bhnd_nvram_private.hThu Mar 22 21:57:10 
2018(r331377)
+++ head/sys/dev/bhnd/nvram/bhnd_nvram_private.hThu Mar 22 22:13:46 
2018(r331378)
@@ -91,6 +91,9 @@ bhnd_nv_strdup(const char *str)
 
len = strlen(str);
dest = malloc(len + 1, M_BHND_NVRAM, M_NOWAIT);
+   if (dest == NULL)
+   return (NULL);
+
memcpy(dest, str, len);
dest[len] = '\0';
 
@@ -105,6 +108,9 @@ bhnd_nv_strndup(const char *str, size_t len)
 
len = strnlen(str, len);
dest = malloc(len + 1, M_BHND_NVRAM, M_NOWAIT);
+   if (dest == NULL)
+   return (NULL);
+
memcpy(dest, str, len);
dest[len] = '\0';
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r331369 - head/sys/vm

2018-03-22 Thread Justin Hibbits
This broke gcc builds.

On Thu, Mar 22, 2018 at 2:21 PM, Jeff Roberson  wrote:
> Author: jeff
> Date: Thu Mar 22 19:21:11 2018
> New Revision: 331369
> URL: https://svnweb.freebsd.org/changeset/base/331369
>
> Log:
>   Lock reservations with a dedicated lock in each reservation.  Protect the
>   vmd_free_count with atomics.
>
>   This allows us to allocate and free from reservations without the free lock
>   except where a superpage is allocated from the physical layer, which is
>   roughly 1/512 of the operations on amd64.
>
>   Use the counter api to eliminate cache conention on counters.
>
>   Reviewed by:  markj
>   Tested by:pho
>   Sponsored by: Netflix, Dell/EMC Isilon
>   Differential Revision:https://reviews.freebsd.org/D14707
>
> Modified:
>   head/sys/vm/vm_page.c
>   head/sys/vm/vm_pagequeue.h
>   head/sys/vm/vm_reserv.c
>   head/sys/vm/vm_reserv.h
>
> Modified: head/sys/vm/vm_page.c
> ==
> --- head/sys/vm/vm_page.c   Thu Mar 22 19:11:43 2018(r331368)
> +++ head/sys/vm/vm_page.c   Thu Mar 22 19:21:11 2018(r331369)
> @@ -177,7 +177,6 @@ static uma_zone_t fakepg_zone;
>  static void vm_page_alloc_check(vm_page_t m);
>  static void vm_page_clear_dirty_mask(vm_page_t m, vm_page_bits_t pagebits);
>  static void vm_page_enqueue(uint8_t queue, vm_page_t m);
> -static void vm_page_free_phys(struct vm_domain *vmd, vm_page_t m);
>  static void vm_page_init(void *dummy);
>  static int vm_page_insert_after(vm_page_t m, vm_object_t object,
>  vm_pindex_t pindex, vm_page_t mpred);
> @@ -1677,10 +1676,10 @@ vm_page_alloc_after(vm_object_t object, vm_pindex_t pi
>   * for the request class and false otherwise.
>   */
>  int
> -vm_domain_available(struct vm_domain *vmd, int req, int npages)
> +vm_domain_allocate(struct vm_domain *vmd, int req, int npages)
>  {
> +   u_int limit, old, new;
>
> -   vm_domain_free_assert_locked(vmd);
> req = req & VM_ALLOC_CLASS_MASK;
>
> /*
> @@ -1688,15 +1687,34 @@ vm_domain_available(struct vm_domain *vmd, int req, in
>  */
> if (curproc == pageproc && req != VM_ALLOC_INTERRUPT)
> req = VM_ALLOC_SYSTEM;
> +   if (req == VM_ALLOC_INTERRUPT)
> +   limit = 0;
> +   else if (req == VM_ALLOC_SYSTEM)
> +   limit = vmd->vmd_interrupt_free_min;
> +   else
> +   limit = vmd->vmd_free_reserved;
>
> -   if (vmd->vmd_free_count >= npages + vmd->vmd_free_reserved ||
> -   (req == VM_ALLOC_SYSTEM &&
> -   vmd->vmd_free_count >= npages + vmd->vmd_interrupt_free_min) ||
> -   (req == VM_ALLOC_INTERRUPT &&
> -   vmd->vmd_free_count >= npages))
> -   return (1);
> +   /*
> +* Attempt to reserve the pages.  Fail if we're below the limit.
> +*/
> +   limit += npages;
> +   old = vmd->vmd_free_count;
> +   do {
> +   if (old < limit)
> +   return (0);
> +   new = old - npages;
> +   } while (atomic_fcmpset_int(>vmd_free_count, , new) == 0);
>
> -   return (0);
> +   /* Wake the page daemon if we've crossed the threshold. */
> +   if (vm_paging_needed(vmd, new) && !vm_paging_needed(vmd, old))
> +   pagedaemon_wakeup(vmd->vmd_domain);
> +
> +   /* Only update bitsets on transitions. */
> +   if ((old >= vmd->vmd_free_min && new < vmd->vmd_free_min) ||
> +   (old >= vmd->vmd_free_severe && new < vmd->vmd_free_severe))
> +   vm_domain_set(vmd);
> +
> +   return (1);
>  }
>
>  vm_page_t
> @@ -1723,44 +1741,34 @@ vm_page_alloc_domain_after(vm_object_t object, vm_pind
>  again:
> m = NULL;
>  #if VM_NRESERVLEVEL > 0
> +   /*
> +* Can we allocate the page from a reservation?
> +*/
> if (vm_object_reserv(object) &&
> -   (m = vm_reserv_extend(req, object, pindex, domain, mpred))
> -   != NULL) {
> +   ((m = vm_reserv_extend(req, object, pindex, domain, mpred)) != 
> NULL ||
> +   (m = vm_reserv_alloc_page(req, object, pindex, domain, mpred)) != 
> NULL)) {
> domain = vm_phys_domain(m);
> vmd = VM_DOMAIN(domain);
> goto found;
> }
>  #endif
> vmd = VM_DOMAIN(domain);
> -   vm_domain_free_lock(vmd);
> -   if (vm_domain_available(vmd, req, 1)) {
> +   if (vm_domain_allocate(vmd, req, 1)) {
> /*
> -* Can we allocate the page from a reservation?
> +* If not, allocate it from the free page queues.
>  */
> +   vm_domain_free_lock(vmd);
> +   m = vm_phys_alloc_pages(domain, object != NULL ?
> +   VM_FREEPOOL_DEFAULT : VM_FREEPOOL_DIRECT, 0);
> +   vm_domain_free_unlock(vmd);
> +   if (m == NULL) {
> +   

svn commit: r331376 - head/sys/netinet6

2018-03-22 Thread Sean Bruno
Author: sbruno
Date: Thu Mar 22 21:18:34 2018
New Revision: 331376
URL: https://svnweb.freebsd.org/changeset/base/331376

Log:
  Handle locking and memory safety for IPV6_PATHMTU in ip6_ctloutput().
  
  Submitted by: Jason Eggleston 
  Reviewed by:  ae
  Sponsored by: Limelight Networks
  Differential Revision:https://reviews.freebsd.org/D14622

Modified:
  head/sys/netinet6/ip6_output.c

Modified: head/sys/netinet6/ip6_output.c
==
--- head/sys/netinet6/ip6_output.c  Thu Mar 22 20:47:25 2018
(r331375)
+++ head/sys/netinet6/ip6_output.c  Thu Mar 22 21:18:34 2018
(r331376)
@@ -2053,6 +2053,7 @@ do {  
\
{
u_long pmtu = 0;
struct ip6_mtuinfo mtuinfo;
+   struct in6_addr addr;
 
if (!(so->so_state & SS_ISCONNECTED))
return (ENOTCONN);
@@ -2060,9 +2061,14 @@ do { 
\
 * XXX: we dot not consider the case of source
 * routing, or optional information to specify
 * the outgoing interface.
+* Copy faddr out of in6p to avoid holding lock
+* on inp during route lookup.
 */
+   INP_RLOCK(in6p);
+   bcopy(>in6p_faddr, , sizeof(addr));
+   INP_RUNLOCK(in6p);
error = ip6_getpmtu_ctl(so->so_fibnum,
-   >in6p_faddr, );
+   , );
if (error)
break;
if (pmtu > IPV6_MAXPACKET)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r331347 - in head: etc/mtree include sys/conf sys/dev/tcp_log sys/kern sys/netinet usr.bin/netstat

2018-03-22 Thread Justin Hibbits
On Thu, Mar 22, 2018 at 3:44 PM, Andriy Gapon  wrote:
> On 22/03/2018 17:39, Jonathan Looney wrote:
>> A tinderbox build didn't complain about atomic_fetchadd_64, so I assume it 
>> is OK.
>>
>> Yes, this can be made optional, if there is a need for that.
>>
>
> FWWI, TARGET=powerpc TARGET_ARCH=powerpc build failed for me.
>
> cc1: warnings being treated as errors
> /usr/devel/svn/head/sys/netinet/tcp_log_buf.c: In function 
> 'tcp_log_selectauto':
> /usr/devel/svn/head/sys/netinet/tcp_log_buf.c:286: warning: implicit 
> declaration
> of function 'atomic_fetchadd_64'
> /usr/devel/svn/head/sys/netinet/tcp_log_buf.c:286: warning: nested extern
> declaration of 'atomic_fetchadd_64' [-Wnested-externs]
>
> --
> Andriy Gapon
>

mips complains, too.  Check out https://ci.freebsd.org/tinderbox .

- Justin
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r331375 - head/sys/kern

2018-03-22 Thread Konstantin Belousov
Author: kib
Date: Thu Mar 22 20:47:25 2018
New Revision: 331375
URL: https://svnweb.freebsd.org/changeset/base/331375

Log:
  Do not send signals to init directly from shutdown_nice(9), do it from
  the task context.
  
  shutdown_nice() is used from the fast interrupt handlers, mostly for
  console drivers, where we cannot lock blockable locks.  Schedule the
  task in the fast queue to send the signal from the proper context.
  
  Reviewed by:  imp
  Discussed with:   bde
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week

Modified:
  head/sys/kern/kern_shutdown.c

Modified: head/sys/kern/kern_shutdown.c
==
--- head/sys/kern/kern_shutdown.c   Thu Mar 22 20:44:27 2018
(r331374)
+++ head/sys/kern/kern_shutdown.c   Thu Mar 22 20:47:25 2018
(r331375)
@@ -72,6 +72,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -276,6 +277,28 @@ sys_reboot(struct thread *td, struct reboot_args *uap)
return (error);
 }
 
+static void
+shutdown_nice_task_fn(void *arg, int pending __unused)
+{
+   int howto;
+
+   howto = (uintptr_t)arg;
+   /* Send a signal to init(8) and have it shutdown the world. */
+   PROC_LOCK(initproc);
+   if (howto & RB_POWEROFF)
+   kern_psignal(initproc, SIGUSR2);
+   else if (howto & RB_POWERCYCLE)
+   kern_psignal(initproc, SIGWINCH);
+   else if (howto & RB_HALT)
+   kern_psignal(initproc, SIGUSR1);
+   else
+   kern_psignal(initproc, SIGINT);
+   PROC_UNLOCK(initproc);
+}
+
+static struct task shutdown_nice_task = TASK_INITIALIZER(0,
+_nice_task_fn, NULL);
+
 /*
  * Called by events that want to shut down.. e.g   on a PC
  */
@@ -283,20 +306,14 @@ void
 shutdown_nice(int howto)
 {
 
-   if (initproc != NULL) {
-   /* Send a signal to init(8) and have it shutdown the world. */
-   PROC_LOCK(initproc);
-   if (howto & RB_POWEROFF)
-   kern_psignal(initproc, SIGUSR2);
-   else if (howto & RB_POWERCYCLE)
-   kern_psignal(initproc, SIGWINCH);
-   else if (howto & RB_HALT)
-   kern_psignal(initproc, SIGUSR1);
-   else
-   kern_psignal(initproc, SIGINT);
-   PROC_UNLOCK(initproc);
+   if (initproc != NULL && !SCHEDULER_STOPPED()) {
+   shutdown_nice_task.ta_context = (void *)(uintptr_t)howto;
+   taskqueue_enqueue(taskqueue_fast, _nice_task);
} else {
-   /* No init(8) running, so simply reboot. */
+   /*
+* No init(8) running, or scheduler would not allow it
+* to run, so simply reboot.
+*/
kern_reboot(howto | RB_NOSYNC);
}
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r331374 - head/sys/amd64/amd64

2018-03-22 Thread Konstantin Belousov
Author: kib
Date: Thu Mar 22 20:44:27 2018
New Revision: 331374
URL: https://svnweb.freebsd.org/changeset/base/331374

Log:
  Fixes for ptrace(PT_GETXSTATE_INFO) related to the padding in struct
  ptrace_xstate_info).
  
  struct ptrace_xstate_info has 64bit member but ends up with 32bit
  one. As result, on amd64 there is a 32bit padding at the end, but not
  on i386.
  
  We must clear the padding before doing the copyout. For compat32 case,
  we must copyout the structure which does not have the padding at the
  end.  The later fixes 32bit gdb display of the YMM registers when
  running on amd64 kernel.
  
  Reported by:  Vlad Tsyrklevich
  Reviewed by:  brooks (previous version)
  Sponsored by: The FreeBSD Foundation
  admbugs:  765
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D14794

Modified:
  head/sys/amd64/amd64/ptrace_machdep.c

Modified: head/sys/amd64/amd64/ptrace_machdep.c
==
--- head/sys/amd64/amd64/ptrace_machdep.c   Thu Mar 22 20:21:05 2018
(r331373)
+++ head/sys/amd64/amd64/ptrace_machdep.c   Thu Mar 22 20:44:27 2018
(r331374)
@@ -45,10 +45,20 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#ifdef COMPAT_FREEBSD32
+struct ptrace_xstate_info32 {
+   uint32_txsave_mask1, xsave_mask2;
+   uint32_txsave_len;
+};
+#endif
+
 static int
 cpu_ptrace_xstate(struct thread *td, int req, void *addr, int data)
 {
struct ptrace_xstate_info info;
+#ifdef COMPAT_FREEBSD32
+   struct ptrace_xstate_info32 info32;
+#endif
char *savefpu;
int error;
 
@@ -78,13 +88,28 @@ cpu_ptrace_xstate(struct thread *td, int req, void *ad
break;
 
case PT_GETXSTATE_INFO:
-   if (data != sizeof(info)) {
-   error  = EINVAL;
-   break;
+#ifdef COMPAT_FREEBSD32
+   if (SV_CURPROC_FLAG(SV_ILP32)) {
+   if (data != sizeof(info32)) {
+   error = EINVAL;
+   } else {
+   info32.xsave_len = cpu_max_ext_state_size;
+   info32.xsave_mask1 = xsave_mask;
+   info32.xsave_mask2 = xsave_mask >> 32;
+   error = copyout(, addr, data);
+   }
+   } else
+#endif
+   {
+   if (data != sizeof(info)) {
+   error  = EINVAL;
+   } else {
+   bzero(, sizeof(info));
+   info.xsave_len = cpu_max_ext_state_size;
+   info.xsave_mask = xsave_mask;
+   error = copyout(, addr, data);
+   }
}
-   info.xsave_len = cpu_max_ext_state_size;
-   info.xsave_mask = xsave_mask;
-   error = copyout(, addr, data);
break;
 
case PT_GETXSTATE:
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r331347 - in head: etc/mtree include sys/conf sys/dev/tcp_log sys/kern sys/netinet usr.bin/netstat

2018-03-22 Thread Andriy Gapon
On 22/03/2018 17:39, Jonathan Looney wrote:
> A tinderbox build didn't complain about atomic_fetchadd_64, so I assume it is 
> OK.
> 
> Yes, this can be made optional, if there is a need for that.
> 

FWWI, TARGET=powerpc TARGET_ARCH=powerpc build failed for me.

cc1: warnings being treated as errors
/usr/devel/svn/head/sys/netinet/tcp_log_buf.c: In function 'tcp_log_selectauto':
/usr/devel/svn/head/sys/netinet/tcp_log_buf.c:286: warning: implicit declaration
of function 'atomic_fetchadd_64'
/usr/devel/svn/head/sys/netinet/tcp_log_buf.c:286: warning: nested extern
declaration of 'atomic_fetchadd_64' [-Wnested-externs]

-- 
Andriy Gapon
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r331373 - head/sys/netinet6

2018-03-22 Thread Sean Bruno
Author: sbruno
Date: Thu Mar 22 20:21:05 2018
New Revision: 331373
URL: https://svnweb.freebsd.org/changeset/base/331373

Log:
  Improve write locking in ip6_ctloutput() with macros.
  
  Submitted by: Jason Eggleston 
  Sponsored by: Limelight Networks
  Differential Revision:https://reviews.freebsd.org/D14620

Modified:
  head/sys/netinet6/ip6_output.c

Modified: head/sys/netinet6/ip6_output.c
==
--- head/sys/netinet6/ip6_output.c  Thu Mar 22 19:49:37 2018
(r331372)
+++ head/sys/netinet6/ip6_output.c  Thu Mar 22 20:21:05 2018
(r331373)
@@ -1596,23 +1596,34 @@ do { \
 } while (/*CONSTCOND*/ 0)
 #define OPTBIT(bit) (in6p->inp_flags & (bit) ? 1 : 0)
 
-#define OPTSET2(bit, val) do { \
-   INP_WLOCK(in6p);\
+#define OPTSET2_N(bit, val) do {   \
if (val)\
in6p->inp_flags2 |= bit;\
else\
in6p->inp_flags2 &= ~bit;   \
+} while (0)
+#define OPTSET2(bit, val) do { \
+   INP_WLOCK(in6p);\
+   OPTSET2_N(bit, val);\
INP_WUNLOCK(in6p);  \
 } while (0)
 #define OPTBIT2(bit) (in6p->inp_flags2 & (bit) ? 1 : 0)
+#define OPTSET2292_EXCLUSIVE(bit)  \
+do {   \
+   INP_WLOCK(in6p);\
+   if (OPTBIT(IN6P_RFC2292)) { \
+   error = EINVAL; \
+   } else {\
+   if (optval) \
+   in6p->inp_flags |= (bit);   \
+   else\
+   in6p->inp_flags &= ~(bit);  \
+   }   \
+   INP_WUNLOCK(in6p);  \
+} while (/*CONSTCOND*/ 0)
 
case IPV6_RECVPKTINFO:
-   /* cannot mix with RFC2292 */
-   if (OPTBIT(IN6P_RFC2292)) {
-   error = EINVAL;
-   break;
-   }
-   OPTSET(IN6P_PKTINFO);
+   OPTSET2292_EXCLUSIVE(IN6P_PKTINFO);
break;
 
case IPV6_HOPLIMIT:
@@ -1633,48 +1644,23 @@ do { \
}
 
case IPV6_RECVHOPLIMIT:
-   /* cannot mix with RFC2292 */
-   if (OPTBIT(IN6P_RFC2292)) {
-   error = EINVAL;
-   break;
-   }
-   OPTSET(IN6P_HOPLIMIT);
+   OPTSET2292_EXCLUSIVE(IN6P_HOPLIMIT);
break;
 
case IPV6_RECVHOPOPTS:
-   /* cannot mix with RFC2292 */
-   if (OPTBIT(IN6P_RFC2292)) {
-   error = EINVAL;
-   break;
-   }
-   OPTSET(IN6P_HOPOPTS);
+   OPTSET2292_EXCLUSIVE(IN6P_HOPOPTS);
break;
 
case IPV6_RECVDSTOPTS:
-   /* cannot mix with RFC2292 */
-   if (OPTBIT(IN6P_RFC2292)) {
-   error = EINVAL;
-   break;
-   }
-   OPTSET(IN6P_DSTOPTS);
+   OPTSET2292_EXCLUSIVE(IN6P_DSTOPTS);
break;
 
case IPV6_RECVRTHDRDSTOPTS:
-   /* cannot mix 

svn commit: r331369 - head/sys/vm

2018-03-22 Thread Jeff Roberson
Author: jeff
Date: Thu Mar 22 19:21:11 2018
New Revision: 331369
URL: https://svnweb.freebsd.org/changeset/base/331369

Log:
  Lock reservations with a dedicated lock in each reservation.  Protect the
  vmd_free_count with atomics.
  
  This allows us to allocate and free from reservations without the free lock
  except where a superpage is allocated from the physical layer, which is
  roughly 1/512 of the operations on amd64.
  
  Use the counter api to eliminate cache conention on counters.
  
  Reviewed by:  markj
  Tested by:pho
  Sponsored by: Netflix, Dell/EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D14707

Modified:
  head/sys/vm/vm_page.c
  head/sys/vm/vm_pagequeue.h
  head/sys/vm/vm_reserv.c
  head/sys/vm/vm_reserv.h

Modified: head/sys/vm/vm_page.c
==
--- head/sys/vm/vm_page.c   Thu Mar 22 19:11:43 2018(r331368)
+++ head/sys/vm/vm_page.c   Thu Mar 22 19:21:11 2018(r331369)
@@ -177,7 +177,6 @@ static uma_zone_t fakepg_zone;
 static void vm_page_alloc_check(vm_page_t m);
 static void vm_page_clear_dirty_mask(vm_page_t m, vm_page_bits_t pagebits);
 static void vm_page_enqueue(uint8_t queue, vm_page_t m);
-static void vm_page_free_phys(struct vm_domain *vmd, vm_page_t m);
 static void vm_page_init(void *dummy);
 static int vm_page_insert_after(vm_page_t m, vm_object_t object,
 vm_pindex_t pindex, vm_page_t mpred);
@@ -1677,10 +1676,10 @@ vm_page_alloc_after(vm_object_t object, vm_pindex_t pi
  * for the request class and false otherwise.
  */
 int
-vm_domain_available(struct vm_domain *vmd, int req, int npages)
+vm_domain_allocate(struct vm_domain *vmd, int req, int npages)
 {
+   u_int limit, old, new;
 
-   vm_domain_free_assert_locked(vmd);
req = req & VM_ALLOC_CLASS_MASK;
 
/*
@@ -1688,15 +1687,34 @@ vm_domain_available(struct vm_domain *vmd, int req, in
 */
if (curproc == pageproc && req != VM_ALLOC_INTERRUPT)
req = VM_ALLOC_SYSTEM;
+   if (req == VM_ALLOC_INTERRUPT)
+   limit = 0;
+   else if (req == VM_ALLOC_SYSTEM)
+   limit = vmd->vmd_interrupt_free_min;
+   else
+   limit = vmd->vmd_free_reserved;
 
-   if (vmd->vmd_free_count >= npages + vmd->vmd_free_reserved ||
-   (req == VM_ALLOC_SYSTEM &&
-   vmd->vmd_free_count >= npages + vmd->vmd_interrupt_free_min) ||
-   (req == VM_ALLOC_INTERRUPT &&
-   vmd->vmd_free_count >= npages))
-   return (1);
+   /*
+* Attempt to reserve the pages.  Fail if we're below the limit.
+*/
+   limit += npages;
+   old = vmd->vmd_free_count;
+   do {
+   if (old < limit)
+   return (0);
+   new = old - npages;
+   } while (atomic_fcmpset_int(>vmd_free_count, , new) == 0);
 
-   return (0);
+   /* Wake the page daemon if we've crossed the threshold. */
+   if (vm_paging_needed(vmd, new) && !vm_paging_needed(vmd, old))
+   pagedaemon_wakeup(vmd->vmd_domain);
+
+   /* Only update bitsets on transitions. */
+   if ((old >= vmd->vmd_free_min && new < vmd->vmd_free_min) ||
+   (old >= vmd->vmd_free_severe && new < vmd->vmd_free_severe))
+   vm_domain_set(vmd);
+
+   return (1);
 }
 
 vm_page_t
@@ -1723,44 +1741,34 @@ vm_page_alloc_domain_after(vm_object_t object, vm_pind
 again:
m = NULL;
 #if VM_NRESERVLEVEL > 0
+   /*
+* Can we allocate the page from a reservation?
+*/
if (vm_object_reserv(object) &&
-   (m = vm_reserv_extend(req, object, pindex, domain, mpred))
-   != NULL) {
+   ((m = vm_reserv_extend(req, object, pindex, domain, mpred)) != NULL 
||
+   (m = vm_reserv_alloc_page(req, object, pindex, domain, mpred)) != 
NULL)) {
domain = vm_phys_domain(m);
vmd = VM_DOMAIN(domain);
goto found;
}
 #endif
vmd = VM_DOMAIN(domain);
-   vm_domain_free_lock(vmd);
-   if (vm_domain_available(vmd, req, 1)) {
+   if (vm_domain_allocate(vmd, req, 1)) {
/*
-* Can we allocate the page from a reservation?
+* If not, allocate it from the free page queues.
 */
+   vm_domain_free_lock(vmd);
+   m = vm_phys_alloc_pages(domain, object != NULL ?
+   VM_FREEPOOL_DEFAULT : VM_FREEPOOL_DIRECT, 0);
+   vm_domain_free_unlock(vmd);
+   if (m == NULL) {
+   vm_domain_freecnt_inc(vmd, 1);
 #if VM_NRESERVLEVEL > 0
-   if (!vm_object_reserv(object) ||
-   (m = vm_reserv_alloc_page(object, pindex,
-   domain, mpred)) == NULL)
+   if (vm_reserv_reclaim_inactive(domain))
+   goto again;
 #endif
- 

svn commit: r331368 - in head/sys: kern sys vm

2018-03-22 Thread Jeff Roberson
Author: jeff
Date: Thu Mar 22 19:11:43 2018
New Revision: 331368
URL: https://svnweb.freebsd.org/changeset/base/331368

Log:
  Start witness much earlier in boot so that we can shrink the pend list and
  make it more immune to further change.
  
  Reviewed by:  markj, imp (Part of D14707)
  Sponsored by: Netflix, Dell/EMC Isilon

Modified:
  head/sys/kern/subr_witness.c
  head/sys/sys/lock.h
  head/sys/vm/vm_page.c

Modified: head/sys/kern/subr_witness.c
==
--- head/sys/kern/subr_witness.cThu Mar 22 19:06:50 2018
(r331367)
+++ head/sys/kern/subr_witness.cThu Mar 22 19:11:43 2018
(r331368)
@@ -139,7 +139,7 @@ __FBSDID("$FreeBSD$");
 #defineWITNESS_COUNT   1536
 #endif
 #defineWITNESS_HASH_SIZE   251 /* Prime, gives load factor < 2 
*/
-#defineWITNESS_PENDLIST(2048 + (MAXCPU * 4))
+#defineWITNESS_PENDLIST(512 + (MAXCPU * 4))
 
 /* Allocate 256 KB of stack data space */
 #defineWITNESS_LO_DATA_COUNT   2048
@@ -752,27 +752,45 @@ fixup_filename(const char *file)
 }
 
 /*
+ * Calculate the size of early witness structures.
+ */
+int
+witness_startup_count(void)
+{
+   int sz;
+
+   sz = sizeof(struct witness) * witness_count;
+   sz += sizeof(*w_rmatrix) * (witness_count + 1);
+   sz += sizeof(*w_rmatrix[0]) * (witness_count + 1) *
+   (witness_count + 1);
+
+   return (sz);
+}
+
+/*
  * The WITNESS-enabled diagnostic code.  Note that the witness code does
  * assume that the early boot is single-threaded at least until after this
  * routine is completed.
  */
-static void
-witness_initialize(void *dummy __unused)
+void
+witness_startup(void *mem)
 {
struct lock_object *lock;
struct witness_order_list_entry *order;
struct witness *w, *w1;
+   uintptr_t p;
int i;
 
-   w_data = malloc(sizeof (struct witness) * witness_count, M_WITNESS,
-   M_WAITOK | M_ZERO);
+   p = (uintptr_t)mem;
+   w_data = (void *)p;
+   p += sizeof(struct witness) * witness_count;
 
-   w_rmatrix = malloc(sizeof(*w_rmatrix) * (witness_count + 1),
-   M_WITNESS, M_WAITOK | M_ZERO);
+   w_rmatrix = (void *)p;
+   p += sizeof(*w_rmatrix) * (witness_count + 1);
 
for (i = 0; i < witness_count + 1; i++) {
-   w_rmatrix[i] = malloc(sizeof(*w_rmatrix[i]) *
-   (witness_count + 1), M_WITNESS, M_WAITOK | M_ZERO);
+   w_rmatrix[i] = (void *)p;
+   p += sizeof(*w_rmatrix[i]) * (witness_count + 1);
}
badstack_sbuf_size = witness_count * 256;
 
@@ -840,8 +858,6 @@ witness_initialize(void *dummy __unused)
 
mtx_lock();
 }
-SYSINIT(witness_init, SI_SUB_WITNESS, SI_ORDER_FIRST, witness_initialize,
-NULL);
 
 void
 witness_init(struct lock_object *lock, const char *type)

Modified: head/sys/sys/lock.h
==
--- head/sys/sys/lock.h Thu Mar 22 19:06:50 2018(r331367)
+++ head/sys/sys/lock.h Thu Mar 22 19:11:43 2018(r331368)
@@ -277,6 +277,8 @@ const char *witness_file(struct lock_object *);
 void   witness_thread_exit(struct thread *);
 
 #ifdef WITNESS
+intwitness_startup_count(void);
+void   witness_startup(void *);
 
 /* Flags for witness_warn(). */
 #defineWARN_GIANTOK0x01/* Giant is exempt from this check. */

Modified: head/sys/vm/vm_page.c
==
--- head/sys/vm/vm_page.c   Thu Mar 22 19:06:50 2018(r331367)
+++ head/sys/vm/vm_page.c   Thu Mar 22 19:11:43 2018(r331368)
@@ -539,6 +539,15 @@ vm_page_startup(vm_offset_t vaddr)
bzero((void *)mapped, end - new_end);
uma_startup((void *)mapped, boot_pages);
 
+#ifdef WITNESS
+   end = new_end;
+   new_end = end - round_page(witness_startup_count());
+   mapped = pmap_map(, new_end, end,
+   VM_PROT_READ | VM_PROT_WRITE);
+   bzero((void *)mapped, end - new_end);
+   witness_startup((void *)mapped);
+#endif
+
 #if defined(__aarch64__) || defined(__amd64__) || defined(__arm__) || \
 defined(__i386__) || defined(__mips__)
/*
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r331367 - head/sys/vm

2018-03-22 Thread Jeff Roberson
Author: jeff
Date: Thu Mar 22 19:06:50 2018
New Revision: 331367
URL: https://svnweb.freebsd.org/changeset/base/331367

Log:
  Use read_mostly and alignment tags to eliminate or limit false sharing.
  
  Reviewed by:  markj (Part of D14707)
  Sponsored by: Netflix, Dell/EMC Isilon

Modified:
  head/sys/vm/vm_phys.c

Modified: head/sys/vm/vm_phys.c
==
--- head/sys/vm/vm_phys.c   Thu Mar 22 18:58:34 2018(r331366)
+++ head/sys/vm/vm_phys.c   Thu Mar 22 19:06:50 2018(r331367)
@@ -73,14 +73,14 @@ _Static_assert(sizeof(long) * NBBY >= VM_PHYSSEG_MAX,
 "Too many physsegs.");
 
 #ifdef NUMA
-struct mem_affinity *mem_affinity;
-int *mem_locality;
+struct mem_affinity __read_mostly *mem_affinity;
+int __read_mostly *mem_locality;
 #endif
 
-int vm_ndomains = 1;
+int __read_mostly vm_ndomains = 1;
 
-struct vm_phys_seg vm_phys_segs[VM_PHYSSEG_MAX];
-int vm_phys_nsegs;
+struct vm_phys_seg __read_mostly vm_phys_segs[VM_PHYSSEG_MAX];
+int __read_mostly vm_phys_nsegs;
 
 struct vm_phys_fictitious_seg;
 static int vm_phys_fictitious_cmp(struct vm_phys_fictitious_seg *,
@@ -100,18 +100,18 @@ struct vm_phys_fictitious_seg {
 RB_GENERATE_STATIC(fict_tree, vm_phys_fictitious_seg, node,
 vm_phys_fictitious_cmp);
 
-static struct rwlock vm_phys_fictitious_reg_lock;
+static struct rwlock_padalign vm_phys_fictitious_reg_lock;
 MALLOC_DEFINE(M_FICT_PAGES, "vm_fictitious", "Fictitious VM pages");
 
-static struct vm_freelist
+static struct vm_freelist __aligned(CACHE_LINE_SIZE)
 vm_phys_free_queues[MAXMEMDOM][VM_NFREELIST][VM_NFREEPOOL][VM_NFREEORDER];
 
-static int vm_nfreelists;
+static int __read_mostly vm_nfreelists;
 
 /*
  * Provides the mapping from VM_FREELIST_* to free list indices (flind).
  */
-static int vm_freelist_to_flind[VM_NFREELIST];
+static int __read_mostly vm_freelist_to_flind[VM_NFREELIST];
 
 CTASSERT(VM_FREELIST_DEFAULT == 0);
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r331366 - in head/contrib/llvm: include/llvm/MC lib/MC lib/MC/MCParser lib/Object

2018-03-22 Thread Dimitry Andric
Author: dim
Date: Thu Mar 22 18:58:34 2018
New Revision: 331366
URL: https://svnweb.freebsd.org/changeset/base/331366

Log:
  Pull in r327101 from upstream llvm trunk (by Rafael Espindola):
  
Don't treat .symver as a regular alias definition.
  
This patch starts simplifying the handling of .symver.
  
For now it just moves the responsibility for creating an alias down to
the streamer. With that the asm streamer can pass a .symver unchanged,
which is nice since gas cannot parse "foo@bar = zed".
  
In a followup I hope to move the handling down to the writer so that
we don't need special hacks for avoiding breaking names with @@@ on
windows.
  
  Pull in r327160 from upstream llvm trunk (by Rafael Espindola):
  
Delay creating an alias for @@@.
  
With this we only create an alias for @@@ once we know if it should
use @ or @@. This avoids last minutes renames and hacks to handle MS
names.
  
This only handles the ELF writer. LTO still has issues with @@@
aliases.
  
  Pull in r327928 from upstream llvm trunk (by Vitaly Buka):
  
Object: Move attribute calculation into RecordStreamer. NFC
  
Summary: Preparation for D44274
  
Reviewers: pcc, espindola
  
Subscribers: hiraditya
  
Differential Revision: https://reviews.llvm.org/D44276
  
  Pull in r327930 from upstream llvm trunk (by Vitaly Buka):
  
Object: Fix handling of @@@ in .symver directive
  
Summary:
name@@@nodename is going to be replaced with name@@nodename if symbols is
defined in the assembled file, or name@nodename if undefined.
https://sourceware.org/binutils/docs/as/Symver.html
  
Fixes PR36623
  
Reviewers: pcc, espindola
  
Subscribers: mehdi_amini, hiraditya
  
Differential Revision: https://reviews.llvm.org/D44274
  
  Together, these changes fix handling of @@@ in .symver directives when
  doing Link Time Optimization.
  
  Reported by:  Shawn Webb 
  MFC after:3 months
  X-MFC-With:   r327952

Modified:
  head/contrib/llvm/include/llvm/MC/MCAssembler.h
  head/contrib/llvm/include/llvm/MC/MCELFStreamer.h
  head/contrib/llvm/include/llvm/MC/MCStreamer.h
  head/contrib/llvm/lib/MC/ELFObjectWriter.cpp
  head/contrib/llvm/lib/MC/MCAsmStreamer.cpp
  head/contrib/llvm/lib/MC/MCELFStreamer.cpp
  head/contrib/llvm/lib/MC/MCParser/ELFAsmParser.cpp
  head/contrib/llvm/lib/MC/MCStreamer.cpp
  head/contrib/llvm/lib/Object/ModuleSymbolTable.cpp
  head/contrib/llvm/lib/Object/RecordStreamer.cpp
  head/contrib/llvm/lib/Object/RecordStreamer.h

Modified: head/contrib/llvm/include/llvm/MC/MCAssembler.h
==
--- head/contrib/llvm/include/llvm/MC/MCAssembler.h Thu Mar 22 18:24:00 
2018(r331365)
+++ head/contrib/llvm/include/llvm/MC/MCAssembler.h Thu Mar 22 18:58:34 
2018(r331366)
@@ -206,6 +206,8 @@ class MCAssembler { (private)
   handleFixup(const MCAsmLayout , MCFragment , const MCFixup );
 
 public:
+  std::vector> Symvers;
+
   /// Construct a new assembler instance.
   //
   // FIXME: How are we going to parameterize this? Two obvious options are stay

Modified: head/contrib/llvm/include/llvm/MC/MCELFStreamer.h
==
--- head/contrib/llvm/include/llvm/MC/MCELFStreamer.h   Thu Mar 22 18:24:00 
2018(r331365)
+++ head/contrib/llvm/include/llvm/MC/MCELFStreamer.h   Thu Mar 22 18:58:34 
2018(r331366)
@@ -51,6 +51,8 @@ class MCELFStreamer : public MCObjectStreamer { (publi
 unsigned ByteAlignment) override;
 
   void emitELFSize(MCSymbol *Symbol, const MCExpr *Value) override;
+  void emitELFSymverDirective(StringRef AliasName,
+  const MCSymbol *Aliasee) override;
 
   void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
  unsigned ByteAlignment) override;

Modified: head/contrib/llvm/include/llvm/MC/MCStreamer.h
==
--- head/contrib/llvm/include/llvm/MC/MCStreamer.h  Thu Mar 22 18:24:00 
2018(r331365)
+++ head/contrib/llvm/include/llvm/MC/MCStreamer.h  Thu Mar 22 18:58:34 
2018(r331366)
@@ -519,9 +519,10 @@ class MCStreamer { (public)
   ///
   /// This corresponds to an assembler statement such as:
   ///  .symver _start, foo@@SOME_VERSION
-  /// \param Alias - The versioned alias (i.e. "foo@@SOME_VERSION")
+  /// \param AliasName - The versioned alias (i.e. "foo@@SOME_VERSION")
   /// \param Aliasee - The aliased symbol (i.e. "_start")
-  virtual void emitELFSymverDirective(MCSymbol *Alias, const MCSymbol 
*Aliasee);
+  virtual void emitELFSymverDirective(StringRef AliasName,
+  const MCSymbol *Aliasee);
 
   /// \brief Emit a Linker Optimization Hint (LOH) directive.
  

Re: svn commit: r331347 - in head: etc/mtree include sys/conf sys/dev/tcp_log sys/kern sys/netinet usr.bin/netstat

2018-03-22 Thread Ruslan Bukin
On Thu, Mar 22, 2018 at 03:39:23PM +, Jonathan Looney wrote:
>Yes, this can be made optional, if there is a need for that.

It may be good to have kernel option for that I think. As we target embedded 
market it is good to have things pluggable.

Example: I able to fit freebsd kernel and minimalistic world to 2MB flash 
device (compressed).
But I think if some code added I unable to fit anymore. 
But I agree that ROM memory is almost free, however some ASICs has this memory 
only and you may have no space for external chips on PCB.

Ruslan
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r331365 - in head/sys: amd64/amd64 dev/efidev

2018-03-22 Thread Kyle Evans
Author: kevans
Date: Thu Mar 22 18:24:00 2018
New Revision: 331365
URL: https://svnweb.freebsd.org/changeset/base/331365

Log:
  Re-work efidev ordering to fix efirt preloaded by loader on amd64
  
  On amd64, efi_enter calls fpu_kern_enter(). This may not be called until
  fpuinitstate has been invoked, resulting in a kernel panic with
  efirt_load="YES" in loader.conf(5).
  
  Move fpuinitstate a little earlier in SI_SUB_DRIVERS so that we can squeeze
  efirt between it and efirtc at SI_SUB_DRIVERS, SI_ORDER_ANY. efidev must be
  after efirt and doesn't really need to be at SI_SUB_DEVFS, so drop it at
  SI_SUB_DRIVER, SI_ORDER_ANY.
  
  The not immediately obvious dependency of fpuinitstate by efirt has been
  noted in both places.
  
  Discussed with:   kib, andrew
  Reported by:  Jakob Alvermark 
  X-MFC-With:   r330868

Modified:
  head/sys/amd64/amd64/fpu.c
  head/sys/dev/efidev/efidev.c
  head/sys/dev/efidev/efirt.c

Modified: head/sys/amd64/amd64/fpu.c
==
--- head/sys/amd64/amd64/fpu.c  Thu Mar 22 17:49:27 2018(r331364)
+++ head/sys/amd64/amd64/fpu.c  Thu Mar 22 18:24:00 2018(r331365)
@@ -366,7 +366,8 @@ fpuinitstate(void *arg __unused)
start_emulating();
intr_restore(saveintr);
 }
-SYSINIT(fpuinitstate, SI_SUB_DRIVERS, SI_ORDER_ANY, fpuinitstate, NULL);
+/* EFIRT needs this to be initialized before we can enter our EFI environment 
*/
+SYSINIT(fpuinitstate, SI_SUB_DRIVERS, SI_ORDER_FIRST, fpuinitstate, NULL);
 
 /*
  * Free coprocessor (if we have it).

Modified: head/sys/dev/efidev/efidev.c
==
--- head/sys/dev/efidev/efidev.cThu Mar 22 17:49:27 2018
(r331364)
+++ head/sys/dev/efidev/efidev.cThu Mar 22 18:24:00 2018
(r331365)
@@ -216,6 +216,6 @@ static moduledata_t efidev_moddata = {
.priv = NULL,
 };
 
-DECLARE_MODULE(efidev, efidev_moddata, SI_SUB_DEVFS, SI_ORDER_ANY);
+DECLARE_MODULE(efidev, efidev_moddata, SI_SUB_DRIVERS, SI_ORDER_ANY);
 MODULE_VERSION(efidev, 1);
 MODULE_DEPEND(efidev, efirt, 1, 1, 1);

Modified: head/sys/dev/efidev/efirt.c
==
--- head/sys/dev/efidev/efirt.c Thu Mar 22 17:49:27 2018(r331364)
+++ head/sys/dev/efidev/efirt.c Thu Mar 22 18:24:00 2018(r331365)
@@ -450,5 +450,6 @@ static moduledata_t efirt_moddata = {
.evhand = efirt_modevents,
.priv = NULL,
 };
-DECLARE_MODULE(efirt, efirt_moddata, SI_SUB_VM_CONF, SI_ORDER_ANY);
+/* After fpuinitstate, before efidev */
+DECLARE_MODULE(efirt, efirt_moddata, SI_SUB_DRIVERS, SI_ORDER_SECOND);
 MODULE_VERSION(efirt, 1);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r331347 - in head: etc/mtree include sys/conf sys/dev/tcp_log sys/kern sys/netinet usr.bin/netstat

2018-03-22 Thread Ruslan Bukin
Look at these
https://ci.freebsd.org/job/FreeBSD-head-mips-build/lastBuild/console
https://ci.freebsd.org/job/FreeBSD-head-powerpc-build/lastBuild/console

Example
make -j5 TARGET=mips TARGET_ARCH=mipsel kernel-toolchain
make -j5 TARGET=mips TARGET_ARCH=mipsel KERNCONF=CANNA buildkernel

Ruslan

On Thu, Mar 22, 2018 at 03:39:23PM +, Jonathan Looney wrote:
>A tinderbox build didn't complain about atomic_fetchadd_64, so I assume it
>is OK.
>Yes, this can be made optional, if there is a need for that.
>Jonathan
>On Thu, Mar 22, 2018 at 2:22 PM, Ruslan Bukin
><[1]ruslan.bu...@cl.cam.ac.uk> wrote:
> 
>  Also can this be pluggable ?
>  It looks like it is optional device which means it can free up some
>  space in embedded environment when unused
>  Ruslan
>  On Thu, Mar 22, 2018 at 02:16:06PM +, Ruslan Bukin wrote:
>  > We don't have atomic_fetchadd_64 for mips32 I think
>  >
>  > Ruslan
>  >
>  > On Thu, Mar 22, 2018 at 09:40:08AM +, Jonathan T. Looney wrote:
>  > > Author: jtl
>  > > Date: Thu Mar 22 09:40:08 2018
>  > > New Revision: 331347
>  > > URL: [2]https://svnweb.freebsd.org/changeset/base/331347
>  > >
>  > > Log:
>  > >   Add the "TCP Blackbox Recorder" which we discussed at the
>  developer
>  > >   summits at BSDCan and BSDCam in 2017.
>  > >
>  > >   The TCP Blackbox Recorder allows you to capture events on a TCP
>  connection
>  > >   in a ring buffer. It stores metadata with the event. It
>  optionally stores
>  > >   the TCP header associated with an event (if the event is
>  associated with a
>  > >   packet) and also optionally stores information on the sockets.
>  > >
>  > >   It supports setting a log ID on a TCP connection and using this
>  to correlate
>  > >   multiple connections that share a common log ID.
>  > >
>  > >   You can log connections in different modes. If you are doing a
>  coordinated
>  > >   test with a particular connection, you may tell the system to
>  put it in
>  > >   mode 4 (continuous dump). Or, if you just want to monitor for
>  errors, you
>  > >   can put it in mode 1 (ring buffer) and dump all the ring buffers
>  associated
>  > >   with the connection ID when we receive an error signal for that
>  connection
>  > >   ID. You can set a default mode that will be applied to a
>  particular ratio
>  > >   of incoming connections. You can also manually set a mode using
>  a socket
>  > >   option.
>  > >
>  > >   This commit includes only basic probes. rrs@ has added quite an
>  abundance
>  > >   of probes in his TCP development work. He plans to commit those
>  soon.
>  > >
>  > >   There are user-space programs which we plan to commit as ports.
>  These read
>  > >   the data from the log device and output pcapng files, and then
>  let you
>  > >   analyze the data (and metadata) in the pcapng files.
>  > >
>  > >   Reviewed by:      gnn (previous version)
>  > >   Obtained from:    Netflix, Inc.
>  > >   Relnotes: yes
>  > >   Differential Revision:   
>  [3]https://reviews.freebsd.org/D11085
>  > >
>  > > Added:
>  > >   head/sys/dev/tcp_log/
>  > >   head/sys/dev/tcp_log/tcp_log_dev.c   (contents, props changed)
>  > >   head/sys/dev/tcp_log/tcp_log_dev.h   (contents, props changed)
>  > >   head/sys/netinet/tcp_log_buf.c   (contents, props changed)
>  > >   head/sys/netinet/tcp_log_buf.h   (contents, props changed)
>  > > Modified:
>  > >   head/etc/mtree/BSD.include.dist
>  > >   head/include/Makefile
>  > >   head/sys/conf/files
>  > >   head/sys/kern/subr_witness.c
>  > >   head/sys/netinet/tcp.h
>  > >   head/sys/netinet/tcp_input.c
>  > >   head/sys/netinet/tcp_output.c
>  > >   head/sys/netinet/tcp_subr.c
>  > >   head/sys/netinet/tcp_timer.c
>  > >   head/sys/netinet/tcp_usrreq.c
>  > >   head/sys/netinet/tcp_var.h
>  > >   head/usr.bin/netstat/inet.c
>  > >   head/usr.bin/netstat/main.c
>  > >   head/usr.bin/netstat/netstat.1
>  > >   head/usr.bin/netstat/netstat.h
>  > >
>  > > Modified: head/etc/mtree/BSD.include.dist
>  > >
>  
> ==
>  > > --- head/etc/mtree/BSD.include.dist Thu Mar 22 08:32:39 2018     
>    (r331346)
>  > > +++ head/etc/mtree/BSD.include.dist Thu Mar 22 09:40:08 2018     
>    (r331347)
>  > > @@ -158,6 +158,8 @@
>  > >          ..
>  > >          speaker
>  > >          ..
>  > > +        tcp_log
>  > > +        ..
>  > >          usb
>  > >          ..
>  > >          vkbd
>  > >
>  > > Modified: head/include/Makefile
>  > >
>  
> 

Re: svn commit: r331209 - head

2018-03-22 Thread Kyle Evans
On Thu, Mar 22, 2018 at 1:13 PM, Steven Hartland
 wrote:
> I think it would be worth specifically detailing the steps to achieve this,
> as its not immediately obvious how this would be done.
>

Hi,

A later commit clarified, but then an even later commit made these
instructions obsolete. =) The problem this entry was made for has been
eradicated, and the entry has since been removed.

Thanks,

Kyle Evans
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r331209 - head

2018-03-22 Thread Steven Hartland
I think it would be worth specifically detailing the steps to achieve 
this, as its not immediately obvious how this would be done.


On 19/03/2018 15:27, Kyle Evans wrote:

Author: kevans
Date: Mon Mar 19 15:27:53 2018
New Revision: 331209
URL: https://svnweb.freebsd.org/changeset/base/331209

Log:
   Add note to UPDATING about UEFI changes requiring loader(8) update
   
   These problems have only been observed with boards using U-Boot (e.g. ARM)

   where virtual addresses are already set in the memory map by the firmware
   and the firmware is expecting a call to SetVirtualAddressMap to be made.
   I refrain from mentioning this in the note because this could also be the
   case on some not-yet-tested firmware on amd64 and it's not a bad
   recommendation for the general case.

Modified:
   head/UPDATING

Modified: head/UPDATING
==
--- head/UPDATING   Mon Mar 19 15:11:10 2018(r331208)
+++ head/UPDATING   Mon Mar 19 15:27:53 2018(r331209)
@@ -51,6 +51,13 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 12.x IS SLOW:
  
  ** SPECIAL WARNING: **
  
+20180319:

+   For UEFI systems: the UEFI loader(8), loader.efi, should be updated in
+   conjunction with installing a new kernel after r330868. The kernel,
+   after this revision, will be more lenient when mapping addresses for
+   UEFI Runtime Services and this may result in a kernel panic without the
+   corresponding loader(8) update.
+
  20180212:
FreeBSD boot loader enhanced with Lua scripting. It's purely opt-in for
now by building WITH_LOADER_LUA and WITHOUT_FORTH in /etc/src.conf.



___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r331364 - head/release/tools

2018-03-22 Thread Glen Barber
Author: gjb
Date: Thu Mar 22 17:49:27 2018
New Revision: 331364
URL: https://svnweb.freebsd.org/changeset/base/331364

Log:
  Remove google_accounts_manager from VM_RC_LIST in the GCE configuration
  file, no longer needed.
  
  PR:   221714
  MFC after:3 days
  Sponsored by: The FreeBSD Foundation

Modified:
  head/release/tools/gce.conf

Modified: head/release/tools/gce.conf
==
--- head/release/tools/gce.conf Thu Mar 22 17:46:38 2018(r331363)
+++ head/release/tools/gce.conf Thu Mar 22 17:49:27 2018(r331364)
@@ -9,7 +9,7 @@ export VM_EXTRA_PACKAGES="firstboot-freebsd-update fir
sysutils/py-google-compute-engine"
 
 # Set to a list of third-party software to enable in rc.conf(5).
-export VM_RC_LIST="google_accounts_manager ntpd sshd firstboot_growfs \
+export VM_RC_LIST="ntpd sshd firstboot_growfs \
firstboot_pkgs firstboot_freebsd_update google_startup \
google_accounts_daemon google_clock_skew_daemon
google_instance_setup google_ip_forwarding_daemon
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r331347 - in head: etc/mtree include sys/conf sys/dev/tcp_log sys/kern sys/netinet usr.bin/netstat

2018-03-22 Thread Jonathan Looney
A tinderbox build didn't complain about atomic_fetchadd_64, so I assume it
is OK.

Yes, this can be made optional, if there is a need for that.

Jonathan

On Thu, Mar 22, 2018 at 2:22 PM, Ruslan Bukin 
wrote:

> Also can this be pluggable ?
> It looks like it is optional device which means it can free up some space
> in embedded environment when unused
>
> Ruslan
>
> On Thu, Mar 22, 2018 at 02:16:06PM +, Ruslan Bukin wrote:
> > We don't have atomic_fetchadd_64 for mips32 I think
> >
> > Ruslan
> >
> > On Thu, Mar 22, 2018 at 09:40:08AM +, Jonathan T. Looney wrote:
> > > Author: jtl
> > > Date: Thu Mar 22 09:40:08 2018
> > > New Revision: 331347
> > > URL: https://svnweb.freebsd.org/changeset/base/331347
> > >
> > > Log:
> > >   Add the "TCP Blackbox Recorder" which we discussed at the developer
> > >   summits at BSDCan and BSDCam in 2017.
> > >
> > >   The TCP Blackbox Recorder allows you to capture events on a TCP
> connection
> > >   in a ring buffer. It stores metadata with the event. It optionally
> stores
> > >   the TCP header associated with an event (if the event is associated
> with a
> > >   packet) and also optionally stores information on the sockets.
> > >
> > >   It supports setting a log ID on a TCP connection and using this to
> correlate
> > >   multiple connections that share a common log ID.
> > >
> > >   You can log connections in different modes. If you are doing a
> coordinated
> > >   test with a particular connection, you may tell the system to put it
> in
> > >   mode 4 (continuous dump). Or, if you just want to monitor for
> errors, you
> > >   can put it in mode 1 (ring buffer) and dump all the ring buffers
> associated
> > >   with the connection ID when we receive an error signal for that
> connection
> > >   ID. You can set a default mode that will be applied to a particular
> ratio
> > >   of incoming connections. You can also manually set a mode using a
> socket
> > >   option.
> > >
> > >   This commit includes only basic probes. rrs@ has added quite an
> abundance
> > >   of probes in his TCP development work. He plans to commit those soon.
> > >
> > >   There are user-space programs which we plan to commit as ports.
> These read
> > >   the data from the log device and output pcapng files, and then let
> you
> > >   analyze the data (and metadata) in the pcapng files.
> > >
> > >   Reviewed by:  gnn (previous version)
> > >   Obtained from:Netflix, Inc.
> > >   Relnotes: yes
> > >   Differential Revision:https://reviews.freebsd.org/D11085
> > >
> > > Added:
> > >   head/sys/dev/tcp_log/
> > >   head/sys/dev/tcp_log/tcp_log_dev.c   (contents, props changed)
> > >   head/sys/dev/tcp_log/tcp_log_dev.h   (contents, props changed)
> > >   head/sys/netinet/tcp_log_buf.c   (contents, props changed)
> > >   head/sys/netinet/tcp_log_buf.h   (contents, props changed)
> > > Modified:
> > >   head/etc/mtree/BSD.include.dist
> > >   head/include/Makefile
> > >   head/sys/conf/files
> > >   head/sys/kern/subr_witness.c
> > >   head/sys/netinet/tcp.h
> > >   head/sys/netinet/tcp_input.c
> > >   head/sys/netinet/tcp_output.c
> > >   head/sys/netinet/tcp_subr.c
> > >   head/sys/netinet/tcp_timer.c
> > >   head/sys/netinet/tcp_usrreq.c
> > >   head/sys/netinet/tcp_var.h
> > >   head/usr.bin/netstat/inet.c
> > >   head/usr.bin/netstat/main.c
> > >   head/usr.bin/netstat/netstat.1
> > >   head/usr.bin/netstat/netstat.h
> > >
> > > Modified: head/etc/mtree/BSD.include.dist
> > > 
> ==
> > > --- head/etc/mtree/BSD.include.dist Thu Mar 22 08:32:39 2018
> (r331346)
> > > +++ head/etc/mtree/BSD.include.dist Thu Mar 22 09:40:08 2018
> (r331347)
> > > @@ -158,6 +158,8 @@
> > >  ..
> > >  speaker
> > >  ..
> > > +tcp_log
> > > +..
> > >  usb
> > >  ..
> > >  vkbd
> > >
> > > Modified: head/include/Makefile
> > > 
> ==
> > > --- head/include/Makefile   Thu Mar 22 08:32:39 2018(r331346)
> > > +++ head/include/Makefile   Thu Mar 22 09:40:08 2018(r331347)
> > > @@ -47,7 +47,7 @@ LSUBDIRS= cam/ata cam/mmc cam/nvme cam/scsi \
> > > dev/hwpmc dev/hyperv \
> > > dev/ic dev/iicbus dev/io dev/lmc dev/mfi dev/mmc dev/nvme \
> > > dev/ofw dev/pbio dev/pci ${_dev_powermac_nvram} dev/ppbus
> dev/smbus \
> > > -   dev/speaker dev/vkbd dev/wi \
> > > +   dev/speaker dev/tcp_log dev/vkbd dev/wi \
> > > fs/devfs fs/fdescfs fs/msdosfs fs/nandfs fs/nfs fs/nullfs \
> > > fs/procfs fs/smbfs fs/udf fs/unionfs \
> > > geom/cache geom/concat geom/eli geom/gate geom/journal geom/label \
> > >
> > > Modified: head/sys/conf/files
> > > 
> ==
> > > --- head/sys/conf/files Thu Mar 22 08:32:39 2018(r331346)
> > > +++ head/sys/conf/files Thu 

svn commit: r331362 - head/sys/kern

2018-03-22 Thread Warner Losh
Author: imp
Date: Thu Mar 22 15:34:37 2018
New Revision: 331362
URL: https://svnweb.freebsd.org/changeset/base/331362

Log:
  Drop any recursed taking of Giant once and for all at the top of
  kern_reboot(). The shutdown path is now safe to run without Giant.
  
  Discussed with: kib@
  Sponsored by: Netflix

Modified:
  head/sys/kern/kern_shutdown.c

Modified: head/sys/kern/kern_shutdown.c
==
--- head/sys/kern/kern_shutdown.c   Thu Mar 22 15:32:57 2018
(r331361)
+++ head/sys/kern/kern_shutdown.c   Thu Mar 22 15:34:37 2018
(r331362)
@@ -366,6 +366,17 @@ kern_reboot(int howto)
 {
static int once = 0;
 
+   /*
+* Normal paths here don't hold Giant, but we can wind up here
+* unexpectedly with it held.  Drop it now so we don't have to
+* drop and pick it up elsewhere. The paths it is locking will
+* never be returned to, and it is preferable to preclude
+* deadlock than to lock against code that won't ever
+* continue.
+*/
+   while (mtx_owned())
+   mtx_unlock();
+
 #if defined(SMP)
/*
 * Bind us to the first CPU so that all shutdown code runs there.  Some
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r331361 - head/sys/dev/efidev

2018-03-22 Thread Andrew Turner
Author: andrew
Date: Thu Mar 22 15:32:57 2018
New Revision: 331361
URL: https://svnweb.freebsd.org/changeset/base/331361

Log:
  Enter into the EFI environment before dereferencing the runtime services
  pointer. This may be within the EFI address space and not the FreeBSD
  kernel address space.
  
  X-MFC-With:   r330868
  Sponsored by: DARPA, AFRL

Modified:
  head/sys/dev/efidev/efirt.c

Modified: head/sys/dev/efidev/efirt.c
==
--- head/sys/dev/efidev/efirt.c Thu Mar 22 15:24:26 2018(r331360)
+++ head/sys/dev/efidev/efirt.c Thu Mar 22 15:32:57 2018(r331361)
@@ -88,6 +88,9 @@ static int efi_status2err[25] = {
EPROTO  /* EFI_PROTOCOL_ERROR */
 };
 
+static int efi_enter(void);
+static void efi_leave(void);
+
 static int
 efi_status_to_errno(efi_status status)
 {
@@ -190,9 +193,14 @@ efi_init(void)
 * call RS->SetVirtualAddressMap. As this is not always the case, e.g.
 * with an old loader.efi, check if the RS->GetTime function is within
 * the EFI map, and fail to attach if not.
+*
+* We need to enter into the EFI environment as efi_runtime may point
+* to an EFI address.
 */
+   efi_enter();
if (!efi_is_in_map(map, efihdr->memory_size / efihdr->descriptor_size,
efihdr->descriptor_size, (vm_offset_t)efi_runtime->rt_gettime)) {
+   efi_leave();
if (bootverbose)
printf(
 "EFI runtime services table has an invalid pointer\n");
@@ -200,6 +208,7 @@ efi_init(void)
efi_destroy_1t1_map();
return (ENXIO);
}
+   efi_leave();
 
return (0);
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r331360 - head/sys/dev/usb/controller

2018-03-22 Thread Andrew Turner
Author: andrew
Date: Thu Mar 22 15:24:26 2018
New Revision: 331360
URL: https://svnweb.freebsd.org/changeset/base/331360

Log:
  Increase the size of the endpoint buffers. They are double buffered so
  need to be twice the size.
  
  Sponsored by: DARPA, AFRL

Modified:
  head/sys/dev/usb/controller/musb_otg.c

Modified: head/sys/dev/usb/controller/musb_otg.c
==
--- head/sys/dev/usb/controller/musb_otg.c  Thu Mar 22 15:11:53 2018
(r331359)
+++ head/sys/dev/usb/controller/musb_otg.c  Thu Mar 22 15:24:26 2018
(r331360)
@@ -157,7 +157,7 @@ static const struct musb_otg_ep_cfg musbotg_ep_default
},
{
.ep_end = 7,
-   .ep_fifosz_shift = 9,
+   .ep_fifosz_shift = 10,
.ep_fifosz_reg = MUSB2_VAL_FIFOSZ_512 | MUSB2_MASK_FIFODB,
},
{
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r331359 - head/sys/dev/syscons

2018-03-22 Thread Warner Losh
Author: imp
Date: Thu Mar 22 15:11:53 2018
New Revision: 331359
URL: https://svnweb.freebsd.org/changeset/base/331359

Log:
  Revert r331298
  
  Normally, shutdown_nice() just signals init. However, sometimes it
  calls kern_reboot directly. For that case, r331298 dropped the Giant
  lock before calling it. This turns out to be incorrect for the more
  common case where init exists and we just signal it. Restore the old
  behavior. The direct call to kern_reboot() doesn't sync buffers to the
  disk, so should work with Giant held, so we don't need to drop locks
  here for that.
  
  Noticed by: bde@
  Sponsored by: Netflix

Modified:
  head/sys/dev/syscons/syscons.c

Modified: head/sys/dev/syscons/syscons.c
==
--- head/sys/dev/syscons/syscons.c  Thu Mar 22 14:51:05 2018
(r331358)
+++ head/sys/dev/syscons/syscons.c  Thu Mar 22 15:11:53 2018
(r331359)
@@ -3858,28 +3858,22 @@ next_code:
 
case RBT:
 #ifndef SC_DISABLE_REBOOT
-   if (enable_reboot && !(flags & SCGETC_CN)) {
-   mtx_unlock();
+   if (enable_reboot && !(flags & SCGETC_CN))
shutdown_nice(0);
-   }
 #endif
break;
 
case HALT:
 #ifndef SC_DISABLE_REBOOT
-   if (enable_reboot && !(flags & SCGETC_CN)) {
-   mtx_unlock();
+   if (enable_reboot && !(flags & SCGETC_CN))
shutdown_nice(RB_HALT);
-   }
 #endif
break;
 
case PDWN:
 #ifndef SC_DISABLE_REBOOT
-   if (enable_reboot && !(flags & SCGETC_CN)) {
-   mtx_unlock();
+   if (enable_reboot && !(flags & SCGETC_CN))
shutdown_nice(RB_HALT|RB_POWEROFF);
-   }
 #endif
break;
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r331298 - head/sys/dev/syscons

2018-03-22 Thread Konstantin Belousov
On Fri, Mar 23, 2018 at 01:21:43AM +1100, Bruce Evans wrote:
> I don't like having a whole task for this.  The whole thing is just a
> hack to work around some the upper layers of the tty driver and some
> lower layers not having any input [escape] sequences to control the
> kernel.  Only the syscons and vt lower layers have such sequences
> (where they are actually key combinations that are converted to control
> operations instead of to input [escape] sequences).  To work around for
> hardware ttys, the filter for kdb sequences is abused to implement a
> non-kdb sequence for rebooting.
> 
> The tty input methods could check for kernel-control sequences and safely
> signal init.  This is a bit too complicated for syscons and vt since they
> can more easily check for key combinations, but wouldhave to convert these
> to standard sequences to get the tty layer to do the same thing.  (They
> have many more kernel-control key combinations and the non-kdb one for
> rebooting is just a bug for them.)  This is a bit complicated for hardware
> tty drivers too -- some use the tty bulk-input method and this shouldn't
> check for sequences, but should reduce to bcopy().  Hoever, to detect the
> kdb sequences, these drivers han to check at a low level anyway.  They
> can be clever about this and only check for the console device[s] which are
> usually only used for for input at a low rate.
This is both complicated and mostly pointless. The task mechanism
provides the easy solution, and more, the task mechanism was
specifically designed to allow to schedule activities in the more
allowing context, from a more restrictive context. I have no intent to
start the self-inflicting activity to code the attempt to modify a lot
of drivers to do what can be done in 10 lines of code.

> Calling kern_reboot() from fast interrupt handlers is still invalid.
> It is quite likely to deadlock.  In particular, it should deadlock in
> when kern_reboot() prints messages to the console.  Most console drivers
> have races instead of deadlocks by dropping their lock[s] in their
> fast interrupt handler before calling the buggy alt escape function.
I agree that it is mostly invalid. If SCHEDULER_STOPPED() evaluates to
true, then the clean shutdown is not possible at all on modern hardware.
Most drivers are asynchronous, and even the hardware reboot command
management is async.

Similarly, if initproc is not yet initialized, it is silly to expect
clean shutdown to occur. I just keep the existing behavior for these
corner cases, perhaps it was added for some reasons and might sometime
work.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r331298 - head/sys/dev/syscons

2018-03-22 Thread Warner Losh
On Thu, Mar 22, 2018 at 5:42 AM, Konstantin Belousov 
wrote:

> On Thu, Mar 22, 2018 at 05:50:57PM +1100, Bruce Evans wrote:
> > On Wed, 21 Mar 2018, Warner Losh wrote:
> >
> > > On Wed, Mar 21, 2018 at 2:27 PM, Konstantin Belousov <
> kostik...@gmail.com>
> > > wrote:
> > >> ...
> > >> Are you saying that fast interrupt handlers call shutdown_nice() ?
> This
> > >> is the quite serious bug on its own.  To fix it, shutdown_nice()
> should
> > >> use a fast taskqueue to schedule the task which would lock the process
> > >> and send the signal.
> > >
> > > Is there some way we know we're in a fast interrupt handler? If so, it
> > > should be simple to fix. If not, then there's an API change ahead of
> us...
> >
> > There is a td_intr_nesting_level flag that might work.  (I invented this,
> > but don't like its current use.)
> But why do we need to know this ?  We can always schedule a task in the
> fast taskqueue if init is present and can be scheduled.


Ah, good point. Seems like a poster child example of doing a fast task
queue deferment. That's always safe, except maybe in BDE's fast interrupt
world.

> > But bde is right: the system has to be in good enough shape to cope. I
> > > wonder if we should put that coping into kdb_reboot() instead. It's
> only an
> > > issue for  TILDE ^R, which is a fairly edge case.
> >
> > shutdown_nice() is also called directly from syscons and vt for the
> reboot,
> > halt and poweroff keys.  This happens in normal interrupt handler
> context,
> > so there is only a problem when init is not running.
>
> diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c
> index e5ea9644ad3..e7c6d4c92b2 100644
> --- a/sys/kern/kern_shutdown.c
> +++ b/sys/kern/kern_shutdown.c
> @@ -72,6 +72,7 @@ __FBSDID("$FreeBSD$");
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>
> @@ -276,6 +277,28 @@ sys_reboot(struct thread *td, struct reboot_args *uap)
> return (error);
>  }
>
> +static void
> +shutdown_nice_task_fn(void *arg, int pending __unused)
> +{
> +   int howto;
> +
> +   howto = (uintptr_t)arg;
> +   /* Send a signal to init(8) and have it shutdown the world. */
> +   PROC_LOCK(initproc);
> +   if (howto & RB_POWEROFF)
> +   kern_psignal(initproc, SIGUSR2);
> +   else if (howto & RB_POWERCYCLE)
> +   kern_psignal(initproc, SIGWINCH);
> +   else if (howto & RB_HALT)
> +   kern_psignal(initproc, SIGUSR1);
> +   else
> +   kern_psignal(initproc, SIGINT);
> +   PROC_UNLOCK(initproc);
> +}
> +
> +static struct task shutdown_nice_task = TASK_INITIALIZER(0,
> +_nice_task_fn, NULL);
> +
>  /*
>   * Called by events that want to shut down.. e.g   on a PC
>   */
> @@ -283,20 +306,14 @@ void
>  shutdown_nice(int howto)
>  {
>
> -   if (initproc != NULL) {
> -   /* Send a signal to init(8) and have it shutdown the
> world. */
> -   PROC_LOCK(initproc);
> -   if (howto & RB_POWEROFF)
> -   kern_psignal(initproc, SIGUSR2);
> -   else if (howto & RB_POWERCYCLE)
> -   kern_psignal(initproc, SIGWINCH);
> -   else if (howto & RB_HALT)
> -   kern_psignal(initproc, SIGUSR1);
> -   else
> -   kern_psignal(initproc, SIGINT);
> -   PROC_UNLOCK(initproc);
> +   if (initproc != NULL && !SCHEDULER_STOPPED()) {
> +   shutdown_nice_task.ta_context = (void *)(uintptr_t)howto;
> +   taskqueue_enqueue(taskqueue_fast, _nice_task);
> } else {
> -   /* No init(8) running, so simply reboot. */
> +   /*
> +* No init(8) running, or scheduler would not allow it
> +* to run, so simply reboot.
> +*/
> kern_reboot(howto | RB_NOSYNC);
> }
>  }
>

I like this elegance. I think we should commit this. While it would be nice
to support the super-fast interrupts that bde has done, we already don't
support it in a number of places. Conceptually, I like the notion of the
tilde escape machine in the tty layer, but I don't like the trade offs.
Here we only defer to reboot, which requires a fair amount of machinery
working to work right. it's not the dependencies I'd prefer, but usually it
doesn't matter. However, to do that, it would also mean that breaking to
the debugger would need to be done in the tty layer, which requires more of
the context switching mechanisms to be working, which would be a bigger
loss. So this is a good trade-off.

If kern_reboot() can't be called from a fast interrupt handler in bdeBSD,
it would be a simple matter to put a wrapper around it here so his kernel
can context switch. Though, if the scheduler isn't running, I'm not sure
what you can do in this situation. The system is already hung or in a
really bad way, so it would have to jump to somewhere late in 

svn commit: r331358 - head/libexec/tftpd/tests

2018-03-22 Thread Alan Somers
Author: asomers
Date: Thu Mar 22 14:51:05 2018
New Revision: 331358
URL: https://svnweb.freebsd.org/changeset/base/331358

Log:
  tftpd: misc Coverity cleanup in the tests
  
  A bunch of unchecked return values from open(2) and read(2)
  
  Reported by:  Coverity
  CID:  1386900, 1386911, 1386926, 1386928, 1386932, 1386942
  CID:  1386961, 1386979
  MFC after:8 days
  X-MFC-With:   330696

Modified:
  head/libexec/tftpd/tests/functional.c

Modified: head/libexec/tftpd/tests/functional.c
==
--- head/libexec/tftpd/tests/functional.c   Thu Mar 22 13:30:35 2018
(r331357)
+++ head/libexec/tftpd/tests/functional.c   Thu Mar 22 14:51:05 2018
(r331358)
@@ -224,19 +224,17 @@ do { \
 static void
 cleanup(void)
 {
-   int fd = -1;
-   char buffer[80] = {0};
+   FILE *f;
pid_t pid;
 
-   fd = open(pidfile, O_RDONLY);
-   if (fd < 0)
+   f = fopen(pidfile, "r");
+   if (f == NULL)
return;
-   if (read(fd, buffer, sizeof(buffer)) > 0) {
-   sscanf(buffer, "%d", );
+   if (fscanf(f, "%d", ) == 1) {
kill(pid, SIGTERM);
waitpid(pid, NULL, 0);
}
-   close(fd);
+   fclose(f);
unlink(pidfile);
 }
 
@@ -698,6 +696,7 @@ TFTPD_TC_DEFINE(w_flag,, w_flag = 1;)
recv_ack(1);
 
fd = open("small.txt", O_RDONLY);
+   ATF_REQUIRE(fd >= 0);
r = read(fd, buffer, sizeof(buffer));
close(fd);
require_bufeq(contents, contents_len, buffer, r);
@@ -734,6 +733,7 @@ TFTPD_TC_DEFINE(wrq_dropped_ack,)
recv_ack(2);
 
fd = open("medium.txt", O_RDONLY);
+   ATF_REQUIRE(fd >= 0);
r = read(fd, buffer, sizeof(buffer));
close(fd);
require_bufeq((const char*)contents, 768, buffer, r);
@@ -766,6 +766,7 @@ TFTPD_TC_DEFINE(wrq_dropped_data,)
recv_ack(1);
 
fd = open("small.txt", O_RDONLY);
+   ATF_REQUIRE(fd >= 0);
r = read(fd, buffer, sizeof(buffer));
close(fd);
require_bufeq(contents, contents_len, buffer, r);
@@ -799,6 +800,7 @@ TFTPD_TC_DEFINE(wrq_duped_data,)
recv_ack(2);
 
fd = open("medium.txt", O_RDONLY);
+   ATF_REQUIRE(fd >= 0);
r = read(fd, buffer, sizeof(buffer));
close(fd);
require_bufeq((const char*)contents, 768, buffer, r);
@@ -862,6 +864,7 @@ TFTPD_TC_DEFINE(wrq_medium,)
recv_ack(2);
 
fd = open("medium.txt", O_RDONLY);
+   ATF_REQUIRE(fd >= 0);
r = read(fd, buffer, sizeof(buffer));
close(fd);
require_bufeq((const char*)contents, 768, buffer, r);
@@ -894,6 +897,7 @@ TFTPD_TC_DEFINE(wrq_netascii,)
recv_ack(1);
 
fd = open("unix.txt", O_RDONLY);
+   ATF_REQUIRE(fd >= 0);
r = read(fd, buffer, sizeof(buffer));
close(fd);
require_bufeq(expected, sizeof(expected), buffer, r);
@@ -931,6 +935,7 @@ TFTPD_TC_DEFINE(wrq_small,)
recv_ack(1);
 
fd = open("small.txt", O_RDONLY);
+   ATF_REQUIRE(fd >= 0);
r = read(fd, buffer, sizeof(buffer));
close(fd);
require_bufeq(contents, contents_len, buffer, r);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r331347 - in head: etc/mtree include sys/conf sys/dev/tcp_log sys/kern sys/netinet usr.bin/netstat

2018-03-22 Thread Ruslan Bukin
Also can this be pluggable ?
It looks like it is optional device which means it can free up some space in 
embedded environment when unused

Ruslan

On Thu, Mar 22, 2018 at 02:16:06PM +, Ruslan Bukin wrote:
> We don't have atomic_fetchadd_64 for mips32 I think
> 
> Ruslan
> 
> On Thu, Mar 22, 2018 at 09:40:08AM +, Jonathan T. Looney wrote:
> > Author: jtl
> > Date: Thu Mar 22 09:40:08 2018
> > New Revision: 331347
> > URL: https://svnweb.freebsd.org/changeset/base/331347
> > 
> > Log:
> >   Add the "TCP Blackbox Recorder" which we discussed at the developer
> >   summits at BSDCan and BSDCam in 2017.
> >   
> >   The TCP Blackbox Recorder allows you to capture events on a TCP connection
> >   in a ring buffer. It stores metadata with the event. It optionally stores
> >   the TCP header associated with an event (if the event is associated with a
> >   packet) and also optionally stores information on the sockets.
> >   
> >   It supports setting a log ID on a TCP connection and using this to 
> > correlate
> >   multiple connections that share a common log ID.
> >   
> >   You can log connections in different modes. If you are doing a coordinated
> >   test with a particular connection, you may tell the system to put it in
> >   mode 4 (continuous dump). Or, if you just want to monitor for errors, you
> >   can put it in mode 1 (ring buffer) and dump all the ring buffers 
> > associated
> >   with the connection ID when we receive an error signal for that connection
> >   ID. You can set a default mode that will be applied to a particular ratio
> >   of incoming connections. You can also manually set a mode using a socket
> >   option.
> >   
> >   This commit includes only basic probes. rrs@ has added quite an abundance
> >   of probes in his TCP development work. He plans to commit those soon.
> >   
> >   There are user-space programs which we plan to commit as ports. These read
> >   the data from the log device and output pcapng files, and then let you
> >   analyze the data (and metadata) in the pcapng files.
> >   
> >   Reviewed by:  gnn (previous version)
> >   Obtained from:Netflix, Inc.
> >   Relnotes: yes
> >   Differential Revision:https://reviews.freebsd.org/D11085
> > 
> > Added:
> >   head/sys/dev/tcp_log/
> >   head/sys/dev/tcp_log/tcp_log_dev.c   (contents, props changed)
> >   head/sys/dev/tcp_log/tcp_log_dev.h   (contents, props changed)
> >   head/sys/netinet/tcp_log_buf.c   (contents, props changed)
> >   head/sys/netinet/tcp_log_buf.h   (contents, props changed)
> > Modified:
> >   head/etc/mtree/BSD.include.dist
> >   head/include/Makefile
> >   head/sys/conf/files
> >   head/sys/kern/subr_witness.c
> >   head/sys/netinet/tcp.h
> >   head/sys/netinet/tcp_input.c
> >   head/sys/netinet/tcp_output.c
> >   head/sys/netinet/tcp_subr.c
> >   head/sys/netinet/tcp_timer.c
> >   head/sys/netinet/tcp_usrreq.c
> >   head/sys/netinet/tcp_var.h
> >   head/usr.bin/netstat/inet.c
> >   head/usr.bin/netstat/main.c
> >   head/usr.bin/netstat/netstat.1
> >   head/usr.bin/netstat/netstat.h
> > 
> > Modified: head/etc/mtree/BSD.include.dist
> > ==
> > --- head/etc/mtree/BSD.include.dist Thu Mar 22 08:32:39 2018
> > (r331346)
> > +++ head/etc/mtree/BSD.include.dist Thu Mar 22 09:40:08 2018
> > (r331347)
> > @@ -158,6 +158,8 @@
> >  ..
> >  speaker
> >  ..
> > +tcp_log
> > +..
> >  usb
> >  ..
> >  vkbd
> > 
> > Modified: head/include/Makefile
> > ==
> > --- head/include/Makefile   Thu Mar 22 08:32:39 2018(r331346)
> > +++ head/include/Makefile   Thu Mar 22 09:40:08 2018(r331347)
> > @@ -47,7 +47,7 @@ LSUBDIRS= cam/ata cam/mmc cam/nvme cam/scsi \
> > dev/hwpmc dev/hyperv \
> > dev/ic dev/iicbus dev/io dev/lmc dev/mfi dev/mmc dev/nvme \
> > dev/ofw dev/pbio dev/pci ${_dev_powermac_nvram} dev/ppbus dev/smbus \
> > -   dev/speaker dev/vkbd dev/wi \
> > +   dev/speaker dev/tcp_log dev/vkbd dev/wi \
> > fs/devfs fs/fdescfs fs/msdosfs fs/nandfs fs/nfs fs/nullfs \
> > fs/procfs fs/smbfs fs/udf fs/unionfs \
> > geom/cache geom/concat geom/eli geom/gate geom/journal geom/label \
> > 
> > Modified: head/sys/conf/files
> > ==
> > --- head/sys/conf/files Thu Mar 22 08:32:39 2018(r331346)
> > +++ head/sys/conf/files Thu Mar 22 09:40:08 2018(r331347)
> > @@ -3161,6 +3161,7 @@ dev/syscons/star/star_saver.c optional star_saver
> >  dev/syscons/syscons.c  optional sc
> >  dev/syscons/sysmouse.c optional sc
> >  dev/syscons/warp/warp_saver.c  optional warp_saver
> > +dev/tcp_log/tcp_log_dev.c  optional inet | inet6
> >  dev/tdfx/tdfx_linux.c  optional tdfx_linux tdfx compat_linux
> >  

Re: svn commit: r331347 - in head: etc/mtree include sys/conf sys/dev/tcp_log sys/kern sys/netinet usr.bin/netstat

2018-03-22 Thread Ruslan Bukin
We don't have atomic_fetchadd_64 for mips32 I think

Ruslan

On Thu, Mar 22, 2018 at 09:40:08AM +, Jonathan T. Looney wrote:
> Author: jtl
> Date: Thu Mar 22 09:40:08 2018
> New Revision: 331347
> URL: https://svnweb.freebsd.org/changeset/base/331347
> 
> Log:
>   Add the "TCP Blackbox Recorder" which we discussed at the developer
>   summits at BSDCan and BSDCam in 2017.
>   
>   The TCP Blackbox Recorder allows you to capture events on a TCP connection
>   in a ring buffer. It stores metadata with the event. It optionally stores
>   the TCP header associated with an event (if the event is associated with a
>   packet) and also optionally stores information on the sockets.
>   
>   It supports setting a log ID on a TCP connection and using this to correlate
>   multiple connections that share a common log ID.
>   
>   You can log connections in different modes. If you are doing a coordinated
>   test with a particular connection, you may tell the system to put it in
>   mode 4 (continuous dump). Or, if you just want to monitor for errors, you
>   can put it in mode 1 (ring buffer) and dump all the ring buffers associated
>   with the connection ID when we receive an error signal for that connection
>   ID. You can set a default mode that will be applied to a particular ratio
>   of incoming connections. You can also manually set a mode using a socket
>   option.
>   
>   This commit includes only basic probes. rrs@ has added quite an abundance
>   of probes in his TCP development work. He plans to commit those soon.
>   
>   There are user-space programs which we plan to commit as ports. These read
>   the data from the log device and output pcapng files, and then let you
>   analyze the data (and metadata) in the pcapng files.
>   
>   Reviewed by:gnn (previous version)
>   Obtained from:  Netflix, Inc.
>   Relnotes:   yes
>   Differential Revision:  https://reviews.freebsd.org/D11085
> 
> Added:
>   head/sys/dev/tcp_log/
>   head/sys/dev/tcp_log/tcp_log_dev.c   (contents, props changed)
>   head/sys/dev/tcp_log/tcp_log_dev.h   (contents, props changed)
>   head/sys/netinet/tcp_log_buf.c   (contents, props changed)
>   head/sys/netinet/tcp_log_buf.h   (contents, props changed)
> Modified:
>   head/etc/mtree/BSD.include.dist
>   head/include/Makefile
>   head/sys/conf/files
>   head/sys/kern/subr_witness.c
>   head/sys/netinet/tcp.h
>   head/sys/netinet/tcp_input.c
>   head/sys/netinet/tcp_output.c
>   head/sys/netinet/tcp_subr.c
>   head/sys/netinet/tcp_timer.c
>   head/sys/netinet/tcp_usrreq.c
>   head/sys/netinet/tcp_var.h
>   head/usr.bin/netstat/inet.c
>   head/usr.bin/netstat/main.c
>   head/usr.bin/netstat/netstat.1
>   head/usr.bin/netstat/netstat.h
> 
> Modified: head/etc/mtree/BSD.include.dist
> ==
> --- head/etc/mtree/BSD.include.dist   Thu Mar 22 08:32:39 2018
> (r331346)
> +++ head/etc/mtree/BSD.include.dist   Thu Mar 22 09:40:08 2018
> (r331347)
> @@ -158,6 +158,8 @@
>  ..
>  speaker
>  ..
> +tcp_log
> +..
>  usb
>  ..
>  vkbd
> 
> Modified: head/include/Makefile
> ==
> --- head/include/Makefile Thu Mar 22 08:32:39 2018(r331346)
> +++ head/include/Makefile Thu Mar 22 09:40:08 2018(r331347)
> @@ -47,7 +47,7 @@ LSUBDIRS=   cam/ata cam/mmc cam/nvme cam/scsi \
>   dev/hwpmc dev/hyperv \
>   dev/ic dev/iicbus dev/io dev/lmc dev/mfi dev/mmc dev/nvme \
>   dev/ofw dev/pbio dev/pci ${_dev_powermac_nvram} dev/ppbus dev/smbus \
> - dev/speaker dev/vkbd dev/wi \
> + dev/speaker dev/tcp_log dev/vkbd dev/wi \
>   fs/devfs fs/fdescfs fs/msdosfs fs/nandfs fs/nfs fs/nullfs \
>   fs/procfs fs/smbfs fs/udf fs/unionfs \
>   geom/cache geom/concat geom/eli geom/gate geom/journal geom/label \
> 
> Modified: head/sys/conf/files
> ==
> --- head/sys/conf/files   Thu Mar 22 08:32:39 2018(r331346)
> +++ head/sys/conf/files   Thu Mar 22 09:40:08 2018(r331347)
> @@ -3161,6 +3161,7 @@ dev/syscons/star/star_saver.c   optional star_saver
>  dev/syscons/syscons.coptional sc
>  dev/syscons/sysmouse.c   optional sc
>  dev/syscons/warp/warp_saver.coptional warp_saver
> +dev/tcp_log/tcp_log_dev.coptional inet | inet6
>  dev/tdfx/tdfx_linux.coptional tdfx_linux tdfx compat_linux
>  dev/tdfx/tdfx_pci.c  optional tdfx pci
>  dev/ti/if_ti.c   optional ti pci
> @@ -4309,6 +4310,7 @@ netinet/tcp_debug.c optional tcpdebug
>  netinet/tcp_fastopen.c   optional inet tcp_rfc7413 | inet6 
> tcp_rfc7413
>  netinet/tcp_hostcache.c  optional inet | inet6
>  netinet/tcp_input.c  optional inet | inet6
> 

Re: svn commit: r331298 - head/sys/dev/syscons

2018-03-22 Thread Bruce Evans

On Thu, 22 Mar 2018, Konstantin Belousov wrote:


On Thu, Mar 22, 2018 at 05:50:57PM +1100, Bruce Evans wrote:

On Wed, 21 Mar 2018, Warner Losh wrote:


On Wed, Mar 21, 2018 at 2:27 PM, Konstantin Belousov 
wrote:

...
Are you saying that fast interrupt handlers call shutdown_nice() ?  This
is the quite serious bug on its own.  To fix it, shutdown_nice() should
use a fast taskqueue to schedule the task which would lock the process
and send the signal.


Is there some way we know we're in a fast interrupt handler? If so, it
should be simple to fix. If not, then there's an API change ahead of us...


There is a td_intr_nesting_level flag that might work.  (I invented this,
but don't like its current use.)

But why do we need to know this ?  We can always schedule a task in the
fast taskqueue if init is present and can be scheduled.


Not quite always.  In my version, fast interrupt handlers are actually
fast, so they can interrupt any spin mutex and cannot call any
scheduling function.  This is enforced by setting the pcpu pointer to
NULL.  Taskqueues and even SWIs are unavailable for fast interrupt
handlers.  Scheduling is done by setting a flag that is checked in
timeout handlers like it was in FreeBSD-1.


...

shutdown_nice() is also called directly from syscons and vt for the reboot,
halt and poweroff keys.  This happens in normal interrupt handler context,
so there is only a problem when init is not running.


diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c
index e5ea9644ad3..e7c6d4c92b2 100644
--- a/sys/kern/kern_shutdown.c
+++ b/sys/kern/kern_shutdown.c
@@ -72,6 +72,7 @@ __FBSDID("$FreeBSD$");
#include 
#include 
#include 
+#include 
#include 
#include 

@@ -276,6 +277,28 @@ sys_reboot(struct thread *td, struct reboot_args *uap)
return (error);
}

+static void
+shutdown_nice_task_fn(void *arg, int pending __unused)
+{
+   int howto;
+
+   howto = (uintptr_t)arg;
+   /* Send a signal to init(8) and have it shutdown the world. */
+   PROC_LOCK(initproc);
+   if (howto & RB_POWEROFF)
+   kern_psignal(initproc, SIGUSR2);
+   else if (howto & RB_POWERCYCLE)
+   kern_psignal(initproc, SIGWINCH);
+   else if (howto & RB_HALT)
+   kern_psignal(initproc, SIGUSR1);
+   else
+   kern_psignal(initproc, SIGINT);
+   PROC_UNLOCK(initproc);
+}
+
+static struct task shutdown_nice_task = TASK_INITIALIZER(0,
+_nice_task_fn, NULL);
+


I don't like having a whole task for this.  The whole thing is just a
hack to work around some the upper layers of the tty driver and some
lower layers not having any input [escape] sequences to control the
kernel.  Only the syscons and vt lower layers have such sequences
(where they are actually key combinations that are converted to control
operations instead of to input [escape] sequences).  To work around for
hardware ttys, the filter for kdb sequences is abused to implement a
non-kdb sequence for rebooting.

The tty input methods could check for kernel-control sequences and safely
signal init.  This is a bit too complicated for syscons and vt since they
can more easily check for key combinations, but wouldhave to convert these
to standard sequences to get the tty layer to do the same thing.  (They
have many more kernel-control key combinations and the non-kdb one for
rebooting is just a bug for them.)  This is a bit complicated for hardware
tty drivers too -- some use the tty bulk-input method and this shouldn't
check for sequences, but should reduce to bcopy().  Hoever, to detect the
kdb sequences, these drivers han to check at a low level anyway.  They
can be clever about this and only check for the console device[s] which are
usually only used for for input at a low rate.


/*
 * Called by events that want to shut down.. e.g   on a PC
 */
@@ -283,20 +306,14 @@ void
shutdown_nice(int howto)
{

-   if (initproc != NULL) {
-   /* Send a signal to init(8) and have it shutdown the world. */
-   PROC_LOCK(initproc);
-   if (howto & RB_POWEROFF)
-   kern_psignal(initproc, SIGUSR2);
-   else if (howto & RB_POWERCYCLE)
-   kern_psignal(initproc, SIGWINCH);
-   else if (howto & RB_HALT)
-   kern_psignal(initproc, SIGUSR1);
-   else
-   kern_psignal(initproc, SIGINT);
-   PROC_UNLOCK(initproc);
+   if (initproc != NULL && !SCHEDULER_STOPPED()) {
+   shutdown_nice_task.ta_context = (void *)(uintptr_t)howto;
+   taskqueue_enqueue(taskqueue_fast, _nice_task);
} else {
-   /* No init(8) running, so simply reboot. */
+   /*
+* No init(8) running, or scheduler would not allow it
+* to run, so simply reboot.
+*/
kern_reboot(howto | RB_NOSYNC);
}
}


Calling 

Re: svn commit: r331356 - in head: lib/libsysdecode sys/amd64/linux sys/amd64/linux32 sys/compat/linux sys/i386/linux sys/modules/linux_common

2018-03-22 Thread Ed Maste
On 22 March 2018 at 08:58, Ed Maste  wrote:
> Author: emaste
> Date: Thu Mar 22 12:58:49 2018
> New Revision: 331356
> URL: https://svnweb.freebsd.org/changeset/base/331356
>
> Log:
>   Share Linux errno table with libsysdecode

I had a question about using ".inc" vs ".h". I followed the ".inc"
convention from some examples in llvm and elsewhere, because
linux_errno.inc is unlike regular headers - it's not idempotent, and
the array has to be the first non-comment content in the file because
it's prefixed with "static" before one of the #includes.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r331357 - head/sys/compat/linuxkpi/common/include/linux

2018-03-22 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Mar 22 13:30:35 2018
New Revision: 331357
URL: https://svnweb.freebsd.org/changeset/base/331357

Log:
  The pci_disable_device() function is also expected to clear the PCI
  busmaster. This fixes LinuxKPI compliancy with Linux.
  
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/include/linux/pci.h

Modified: head/sys/compat/linuxkpi/common/include/linux/pci.h
==
--- head/sys/compat/linuxkpi/common/include/linux/pci.h Thu Mar 22 12:58:49 
2018(r331356)
+++ head/sys/compat/linuxkpi/common/include/linux/pci.h Thu Mar 22 13:30:35 
2018(r331357)
@@ -343,6 +343,7 @@ pci_disable_device(struct pci_dev *pdev)
 
pci_disable_io(pdev->dev.bsddev, SYS_RES_IOPORT);
pci_disable_io(pdev->dev.bsddev, SYS_RES_MEMORY);
+   pci_disable_busmaster(pdev->dev.bsddev);
 }
 
 static inline int
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r331356 - in head: lib/libsysdecode sys/amd64/linux sys/amd64/linux32 sys/compat/linux sys/i386/linux sys/modules/linux_common

2018-03-22 Thread Ed Maste
Author: emaste
Date: Thu Mar 22 12:58:49 2018
New Revision: 331356
URL: https://svnweb.freebsd.org/changeset/base/331356

Log:
  Share Linux errno table with libsysdecode
  
  Requested by: jhb
  Reviewed by:  jhb
  Sponsored by: Turing Robotic Industries Inc.

Added:
  head/sys/compat/linux/linux_errno.inc
 - copied, changed from r331355, head/sys/compat/linux/linux_errno.c
Modified:
  head/lib/libsysdecode/errno.c
  head/sys/amd64/linux/linux_sysvec.c
  head/sys/amd64/linux32/linux32_sysvec.c
  head/sys/compat/linux/linux_emul.h
  head/sys/compat/linux/linux_errno.c
  head/sys/i386/linux/linux_sysvec.c
  head/sys/modules/linux_common/Makefile

Modified: head/lib/libsysdecode/errno.c
==
--- head/lib/libsysdecode/errno.c   Thu Mar 22 12:26:27 2018
(r331355)
+++ head/lib/libsysdecode/errno.c   Thu Mar 22 12:58:49 2018
(r331356)
@@ -37,25 +37,8 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #if defined(__i386__) || defined(__amd64__)
-/*
- * Linux syscalls return negative errno's, we do positive and map them
- * Reference:
- *   FreeBSD: src/sys/sys/errno.h
- *   Linux:   include/uapi/asm-generic/errno-base.h
- *include/uapi/asm-generic/errno.h
- */
-static int bsd_to_linux_errno[ELAST + 1] = {
-   -0,  -1,  -2,  -3,  -4,  -5,  -6,  -7,  -8,  -9,
-   -10, -35, -12, -13, -14, -15, -16, -17, -18, -19,
-   -20, -21, -22, -23, -24, -25, -26, -27, -28, -29,
-   -30, -31, -32, -33, -34, -11,-115,-114, -88, -89,
-   -90, -91, -92, -93, -94, -95, -96, -97, -98, -99,
-   -100,-101,-102,-103,-104,-105,-106,-107,-108,-109,
-   -110,-111, -40, -36,-112,-113, -39, -11, -87,-122,
-   -116, -66,  -6,  -6,  -6,  -6,  -6, -37, -38,  -9,
- -6,  -6, -43, -42, -75,-125, -84, -61, -16, -74,
--72, -67, -71,  -1,  -1, -131, -130
-};
+static
+#include 
 #endif
 
 #include 
@@ -156,8 +139,8 @@ sysdecode_abi_to_freebsd_errno(enum sysdecode_abi abi,
 * This is imprecise since it returns the first
 * matching errno.
 */
-   for (i = 0; i < nitems(bsd_to_linux_errno); i++) {
-   if (error == bsd_to_linux_errno[i])
+   for (i = 0; i < nitems(linux_errtbl); i++) {
+   if (error == linux_errtbl[i])
return (i);
}
break;
@@ -187,7 +170,7 @@ sysdecode_freebsd_to_abi_errno(enum sysdecode_abi abi,
case SYSDECODE_ABI_LINUX:
case SYSDECODE_ABI_LINUX32:
if (error >= 0 && error <= ELAST)
-   return (bsd_to_linux_errno[error]);
+   return (linux_errtbl[error]);
break;
 #endif
case SYSDECODE_ABI_CLOUDABI32:

Modified: head/sys/amd64/linux/linux_sysvec.c
==
--- head/sys/amd64/linux/linux_sysvec.c Thu Mar 22 12:26:27 2018
(r331355)
+++ head/sys/amd64/linux/linux_sysvec.c Thu Mar 22 12:58:49 2018
(r331356)
@@ -752,7 +752,7 @@ struct sysentvec elf_linux_sysvec = {
.sv_table   = linux_sysent,
.sv_mask= 0,
.sv_errsize = ELAST + 1,
-   .sv_errtbl  = bsd_to_linux_errno_generic,
+   .sv_errtbl  = linux_errtbl,
.sv_transtrap   = linux_translate_traps,
.sv_fixup   = linux_fixup_elf,
.sv_sendsig = linux_rt_sendsig,

Modified: head/sys/amd64/linux32/linux32_sysvec.c
==
--- head/sys/amd64/linux32/linux32_sysvec.c Thu Mar 22 12:26:27 2018
(r331355)
+++ head/sys/amd64/linux32/linux32_sysvec.c Thu Mar 22 12:58:49 2018
(r331356)
@@ -952,7 +952,7 @@ struct sysentvec elf_linux_sysvec = {
.sv_table   = linux32_sysent,
.sv_mask= 0,
.sv_errsize = ELAST + 1,
-   .sv_errtbl  = bsd_to_linux_errno_generic,
+   .sv_errtbl  = linux_errtbl,
.sv_transtrap   = linux_translate_traps,
.sv_fixup   = linux_fixup_elf,
.sv_sendsig = linux_sendsig,

Modified: head/sys/compat/linux/linux_emul.h
==
--- head/sys/compat/linux/linux_emul.h  Thu Mar 22 12:26:27 2018
(r331355)
+++ head/sys/compat/linux/linux_emul.h  Thu Mar 22 12:58:49 2018
(r331356)
@@ -77,6 +77,6 @@ struct linux_pemuldata {
 
 struct linux_pemuldata *pem_find(struct proc *);
 
-extern const int bsd_to_linux_errno_generic[];
+extern const int linux_errtbl[];
 
 #endif /* !_LINUX_EMUL_H_ */

Modified: head/sys/compat/linux/linux_errno.c
==
--- head/sys/compat/linux/linux_errno.c Thu Mar 22 12:26:27 2018
(r331355)
+++ head/sys/compat/linux/linux_errno.c Thu Mar 22 12:58:49 

svn commit: r331355 - head/sys/compat/linuxkpi/common/include/linux

2018-03-22 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Mar 22 12:26:27 2018
New Revision: 331355
URL: https://svnweb.freebsd.org/changeset/base/331355

Log:
  Clear old MSIX IRQ numbers in the LinuxKPI.
  
  When disabling the MSIX IRQ vectors for a PCI device through the
  LinuxKPI, make sure any old MSIX IRQ numbers are no longer visible to
  the linux_pci_find_irq_dev() function else IRQs can be requested from
  the wrong PCI device.
  
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/include/linux/pci.h

Modified: head/sys/compat/linuxkpi/common/include/linux/pci.h
==
--- head/sys/compat/linuxkpi/common/include/linux/pci.h Thu Mar 22 12:01:30 
2018(r331354)
+++ head/sys/compat/linuxkpi/common/include/linux/pci.h Thu Mar 22 12:26:27 
2018(r331355)
@@ -425,6 +425,15 @@ pci_disable_msix(struct pci_dev *pdev)
 {
 
pci_release_msi(pdev->dev.bsddev);
+
+   /*
+* The MSIX IRQ numbers associated with this PCI device are no
+* longer valid and might be re-assigned. Make sure
+* linux_pci_find_irq_dev() does no longer see them by
+* resetting their references to zero:
+*/
+   pdev->dev.msix = 0;
+   pdev->dev.msix_max = 0;
 }
 
 static inline bus_addr_t
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r331306 - head/sys/dev/usb/controller

2018-03-22 Thread Hans Petter Selasky

On 03/22/18 13:02, Andrew Turner wrote:

On 21 Mar 2018, at 21:54, Hans Petter Selasky  wrote:

On 03/21/18 17:45, Andrew Turner wrote:

On 21 Mar 2018, at 15:37, Hans Petter Selasky  wrote:

On 03/21/18 16:24, Kyle Evans wrote:

+   {
+   .ep_end = 7,
+   .ep_fifosz_shift = 9,
+   .ep_fifosz_reg = MUSB2_VAL_FIFOSZ_512 | MUSB2_MASK_FIFODB,
+   },

I'm afraid I'm not familiar with this- why did .ep_fifosz_shift for
this case drop to 9? frx = 10 in the temp < 8 case in the removals of
the following hunks. Mostly curious because the others seemed to stay
the same.


Hi Andrew,

It might be an idea to keep the fifosz_shift at 10, else high-speed BULK 
traffic won't be double buffered, and this might affect performance.

Should the endpoint 1 size also be fixed? The register has it at 4k, but it 
wasn’t an 8k buffer.


No, because High-Speed BULK will only use 512 byte packets, and 4k is reserved 
for isochronous, which doesn't need double buffering at the moment.


Ok, in that case should we remove the double buffer flag on endpoint 1? The 
Linux driver seems to always use a 512 byte buffer there, and always doubles 
the offset increment when the double buffer flag is set.


Hi Andrew,

That's a good question. I think you should leave the double buffer flag 
on for this register. Double buffering is then later on re-programmed by:



static void
musbotg_clear_stall_sub(struct musbotg_softc *sc, uint16_t wMaxPacket,
uint8_t ep_no, uint8_t ep_type, uint8_t ep_dir)


If you look at the writes to MUSB2_REG_TXDBDIS and MUSB2_REG_RXDBDIS.

I think those registers override the "master" register. You might want 
to check the PRM to be absolutely sure.


--HPS
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r331306 - head/sys/dev/usb/controller

2018-03-22 Thread Andrew Turner
> On 21 Mar 2018, at 21:54, Hans Petter Selasky  wrote:
> 
> On 03/21/18 17:45, Andrew Turner wrote:
>>> On 21 Mar 2018, at 15:37, Hans Petter Selasky  wrote:
>>> 
>>> On 03/21/18 16:24, Kyle Evans wrote:
> +   {
> +   .ep_end = 7,
> +   .ep_fifosz_shift = 9,
> +   .ep_fifosz_reg = MUSB2_VAL_FIFOSZ_512 | MUSB2_MASK_FIFODB,
> +   },
 I'm afraid I'm not familiar with this- why did .ep_fifosz_shift for
 this case drop to 9? frx = 10 in the temp < 8 case in the removals of
 the following hunks. Mostly curious because the others seemed to stay
 the same.
>>> 
>>> Hi Andrew,
>>> 
>>> It might be an idea to keep the fifosz_shift at 10, else high-speed BULK 
>>> traffic won't be double buffered, and this might affect performance.
>> Should the endpoint 1 size also be fixed? The register has it at 4k, but it 
>> wasn’t an 8k buffer.
> 
> No, because High-Speed BULK will only use 512 byte packets, and 4k is 
> reserved for isochronous, which doesn't need double buffering at the moment.

Ok, in that case should we remove the double buffer flag on endpoint 1? The 
Linux driver seems to always use a 512 byte buffer there, and always doubles 
the offset increment when the double buffer flag is set.

Andrew

___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r331353 - head

2018-03-22 Thread Kyle Evans
Author: kevans
Date: Thu Mar 22 11:57:59 2018
New Revision: 331353
URL: https://svnweb.freebsd.org/changeset/base/331353

Log:
  Partially revert r328780
  
  efi.4th was added to ObsoleteFiles and disconnected from the build, but not
  removed from hte repo. We've since found a mild use for it that makes some
  amount of sense, so partially revert r328780 and bring it back to life.
  
  Reported by:  many
  X-MFC-With:   r331326

Modified:
  head/ObsoleteFiles.inc

Modified: head/ObsoleteFiles.inc
==
--- head/ObsoleteFiles.inc  Thu Mar 22 11:57:12 2018(r331352)
+++ head/ObsoleteFiles.inc  Thu Mar 22 11:57:59 2018(r331353)
@@ -59,7 +59,6 @@ OLD_FILES+=usr/share/openssl/man/man1/c_rehash.1.gz
 # 20180206: remove gdbtui
 OLD_FILES+=usr/bin/gdbtui
 # 20180201: Obsolete forth files
-OLD_FILES+=boot/efi.4th
 OLD_FILES+=boot/pcibios.4th
 # 20180114: new clang import which bumps version from 5.0.1 to 6.0.0.
 OLD_FILES+=usr/lib/clang/5.0.1/include/sanitizer/allocator_interface.h
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r331298 - head/sys/dev/syscons

2018-03-22 Thread Konstantin Belousov
On Thu, Mar 22, 2018 at 05:50:57PM +1100, Bruce Evans wrote:
> On Wed, 21 Mar 2018, Warner Losh wrote:
> 
> > On Wed, Mar 21, 2018 at 2:27 PM, Konstantin Belousov 
> > wrote:
> >> ...
> >> Are you saying that fast interrupt handlers call shutdown_nice() ?  This
> >> is the quite serious bug on its own.  To fix it, shutdown_nice() should
> >> use a fast taskqueue to schedule the task which would lock the process
> >> and send the signal.
> >
> > Is there some way we know we're in a fast interrupt handler? If so, it
> > should be simple to fix. If not, then there's an API change ahead of us...
> 
> There is a td_intr_nesting_level flag that might work.  (I invented this,
> but don't like its current use.)
But why do we need to know this ?  We can always schedule a task in the
fast taskqueue if init is present and can be scheduled.

> 
> > But bde is right: the system has to be in good enough shape to cope. I
> > wonder if we should put that coping into kdb_reboot() instead. It's only an
> > issue for  TILDE ^R, which is a fairly edge case.
> 
> shutdown_nice() is also called directly from syscons and vt for the reboot,
> halt and poweroff keys.  This happens in normal interrupt handler context,
> so there is only a problem when init is not running.

diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c
index e5ea9644ad3..e7c6d4c92b2 100644
--- a/sys/kern/kern_shutdown.c
+++ b/sys/kern/kern_shutdown.c
@@ -72,6 +72,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -276,6 +277,28 @@ sys_reboot(struct thread *td, struct reboot_args *uap)
return (error);
 }
 
+static void
+shutdown_nice_task_fn(void *arg, int pending __unused)
+{
+   int howto;
+
+   howto = (uintptr_t)arg;
+   /* Send a signal to init(8) and have it shutdown the world. */
+   PROC_LOCK(initproc);
+   if (howto & RB_POWEROFF)
+   kern_psignal(initproc, SIGUSR2);
+   else if (howto & RB_POWERCYCLE)
+   kern_psignal(initproc, SIGWINCH);
+   else if (howto & RB_HALT)
+   kern_psignal(initproc, SIGUSR1);
+   else
+   kern_psignal(initproc, SIGINT);
+   PROC_UNLOCK(initproc);
+}
+
+static struct task shutdown_nice_task = TASK_INITIALIZER(0,
+_nice_task_fn, NULL);
+
 /*
  * Called by events that want to shut down.. e.g   on a PC
  */
@@ -283,20 +306,14 @@ void
 shutdown_nice(int howto)
 {
 
-   if (initproc != NULL) {
-   /* Send a signal to init(8) and have it shutdown the world. */
-   PROC_LOCK(initproc);
-   if (howto & RB_POWEROFF)
-   kern_psignal(initproc, SIGUSR2);
-   else if (howto & RB_POWERCYCLE)
-   kern_psignal(initproc, SIGWINCH);
-   else if (howto & RB_HALT)
-   kern_psignal(initproc, SIGUSR1);
-   else
-   kern_psignal(initproc, SIGINT);
-   PROC_UNLOCK(initproc);
+   if (initproc != NULL && !SCHEDULER_STOPPED()) {
+   shutdown_nice_task.ta_context = (void *)(uintptr_t)howto;
+   taskqueue_enqueue(taskqueue_fast, _nice_task);
} else {
-   /* No init(8) running, so simply reboot. */
+   /*
+* No init(8) running, or scheduler would not allow it
+* to run, so simply reboot.
+*/
kern_reboot(howto | RB_NOSYNC);
}
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r331348 - head/usr.bin/netstat

2018-03-22 Thread Jonathan T. Looney
Author: jtl
Date: Thu Mar 22 09:43:15 2018
New Revision: 331348
URL: https://svnweb.freebsd.org/changeset/base/331348

Log:
  Bump netstat.1's .Dd after r331347.

Modified:
  head/usr.bin/netstat/netstat.1

Modified: head/usr.bin/netstat/netstat.1
==
--- head/usr.bin/netstat/netstat.1  Thu Mar 22 09:40:08 2018
(r331347)
+++ head/usr.bin/netstat/netstat.1  Thu Mar 22 09:43:15 2018
(r331348)
@@ -28,7 +28,7 @@
 .\"@(#)netstat.1   8.8 (Berkeley) 4/18/94
 .\" $FreeBSD$
 .\"
-.Dd September 9, 2017
+.Dd March 22, 2018
 .Dt NETSTAT 1
 .Os
 .Sh NAME
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r331347 - in head: etc/mtree include sys/conf sys/dev/tcp_log sys/kern sys/netinet usr.bin/netstat

2018-03-22 Thread Jonathan T. Looney
Author: jtl
Date: Thu Mar 22 09:40:08 2018
New Revision: 331347
URL: https://svnweb.freebsd.org/changeset/base/331347

Log:
  Add the "TCP Blackbox Recorder" which we discussed at the developer
  summits at BSDCan and BSDCam in 2017.
  
  The TCP Blackbox Recorder allows you to capture events on a TCP connection
  in a ring buffer. It stores metadata with the event. It optionally stores
  the TCP header associated with an event (if the event is associated with a
  packet) and also optionally stores information on the sockets.
  
  It supports setting a log ID on a TCP connection and using this to correlate
  multiple connections that share a common log ID.
  
  You can log connections in different modes. If you are doing a coordinated
  test with a particular connection, you may tell the system to put it in
  mode 4 (continuous dump). Or, if you just want to monitor for errors, you
  can put it in mode 1 (ring buffer) and dump all the ring buffers associated
  with the connection ID when we receive an error signal for that connection
  ID. You can set a default mode that will be applied to a particular ratio
  of incoming connections. You can also manually set a mode using a socket
  option.
  
  This commit includes only basic probes. rrs@ has added quite an abundance
  of probes in his TCP development work. He plans to commit those soon.
  
  There are user-space programs which we plan to commit as ports. These read
  the data from the log device and output pcapng files, and then let you
  analyze the data (and metadata) in the pcapng files.
  
  Reviewed by:  gnn (previous version)
  Obtained from:Netflix, Inc.
  Relnotes: yes
  Differential Revision:https://reviews.freebsd.org/D11085

Added:
  head/sys/dev/tcp_log/
  head/sys/dev/tcp_log/tcp_log_dev.c   (contents, props changed)
  head/sys/dev/tcp_log/tcp_log_dev.h   (contents, props changed)
  head/sys/netinet/tcp_log_buf.c   (contents, props changed)
  head/sys/netinet/tcp_log_buf.h   (contents, props changed)
Modified:
  head/etc/mtree/BSD.include.dist
  head/include/Makefile
  head/sys/conf/files
  head/sys/kern/subr_witness.c
  head/sys/netinet/tcp.h
  head/sys/netinet/tcp_input.c
  head/sys/netinet/tcp_output.c
  head/sys/netinet/tcp_subr.c
  head/sys/netinet/tcp_timer.c
  head/sys/netinet/tcp_usrreq.c
  head/sys/netinet/tcp_var.h
  head/usr.bin/netstat/inet.c
  head/usr.bin/netstat/main.c
  head/usr.bin/netstat/netstat.1
  head/usr.bin/netstat/netstat.h

Modified: head/etc/mtree/BSD.include.dist
==
--- head/etc/mtree/BSD.include.dist Thu Mar 22 08:32:39 2018
(r331346)
+++ head/etc/mtree/BSD.include.dist Thu Mar 22 09:40:08 2018
(r331347)
@@ -158,6 +158,8 @@
 ..
 speaker
 ..
+tcp_log
+..
 usb
 ..
 vkbd

Modified: head/include/Makefile
==
--- head/include/Makefile   Thu Mar 22 08:32:39 2018(r331346)
+++ head/include/Makefile   Thu Mar 22 09:40:08 2018(r331347)
@@ -47,7 +47,7 @@ LSUBDIRS= cam/ata cam/mmc cam/nvme cam/scsi \
dev/hwpmc dev/hyperv \
dev/ic dev/iicbus dev/io dev/lmc dev/mfi dev/mmc dev/nvme \
dev/ofw dev/pbio dev/pci ${_dev_powermac_nvram} dev/ppbus dev/smbus \
-   dev/speaker dev/vkbd dev/wi \
+   dev/speaker dev/tcp_log dev/vkbd dev/wi \
fs/devfs fs/fdescfs fs/msdosfs fs/nandfs fs/nfs fs/nullfs \
fs/procfs fs/smbfs fs/udf fs/unionfs \
geom/cache geom/concat geom/eli geom/gate geom/journal geom/label \

Modified: head/sys/conf/files
==
--- head/sys/conf/files Thu Mar 22 08:32:39 2018(r331346)
+++ head/sys/conf/files Thu Mar 22 09:40:08 2018(r331347)
@@ -3161,6 +3161,7 @@ dev/syscons/star/star_saver.c optional star_saver
 dev/syscons/syscons.c  optional sc
 dev/syscons/sysmouse.c optional sc
 dev/syscons/warp/warp_saver.c  optional warp_saver
+dev/tcp_log/tcp_log_dev.c  optional inet | inet6
 dev/tdfx/tdfx_linux.c  optional tdfx_linux tdfx compat_linux
 dev/tdfx/tdfx_pci.coptional tdfx pci
 dev/ti/if_ti.c optional ti pci
@@ -4309,6 +4310,7 @@ netinet/tcp_debug.c   optional tcpdebug
 netinet/tcp_fastopen.c optional inet tcp_rfc7413 | inet6 tcp_rfc7413
 netinet/tcp_hostcache.coptional inet | inet6
 netinet/tcp_input.coptional inet | inet6
+netinet/tcp_log_buf.c  optional inet | inet6
 netinet/tcp_lro.c  optional inet | inet6
 netinet/tcp_output.c   optional inet | inet6
 netinet/tcp_offload.c  optional tcp_offload inet | tcp_offload inet6

Added: head/sys/dev/tcp_log/tcp_log_dev.c
==
--- 

svn commit: r331346 - head/sys/modules/blake2

2018-03-22 Thread Li-Wen Hsu
Author: lwhsu (ports committer)
Date: Thu Mar 22 08:32:39 2018
New Revision: 331346
URL: https://svnweb.freebsd.org/changeset/base/331346

Log:
  Fix build.
  
  Reviewed by:  cem
  Differential Revision:https://reviews.freebsd.org/D14793

Modified:
  head/sys/modules/blake2/Makefile

Modified: head/sys/modules/blake2/Makefile
==
--- head/sys/modules/blake2/MakefileThu Mar 22 06:31:05 2018
(r331345)
+++ head/sys/modules/blake2/MakefileThu Mar 22 08:32:39 2018
(r331346)
@@ -80,7 +80,7 @@ SRCS  += string.h
 
 SRCS   += blake2_cryptodev.c
 
-SRCS   += opt_param.h cryptodev_if.h
+SRCS   += opt_param.h cryptodev_if.h bus_if.h device_if.h
 
 WARNS  ?= 6
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r331298 - head/sys/dev/syscons

2018-03-22 Thread Bruce Evans

On Wed, 21 Mar 2018, Warner Losh wrote:


On Wed, Mar 21, 2018 at 2:27 PM, Konstantin Belousov 
wrote:

...
Are you saying that fast interrupt handlers call shutdown_nice() ?  This
is the quite serious bug on its own.  To fix it, shutdown_nice() should
use a fast taskqueue to schedule the task which would lock the process
and send the signal.


Is there some way we know we're in a fast interrupt handler? If so, it
should be simple to fix. If not, then there's an API change ahead of us...


There is a td_intr_nesting_level flag that might work.  (I invented this,
but don't like its current use.)


But bde is right: the system has to be in good enough shape to cope. I
wonder if we should put that coping into kdb_reboot() instead. It's only an
issue for  TILDE ^R, which is a fairly edge case.


shutdown_nice() is also called directly from syscons and vt for the reboot,
halt and poweroff keys.  This happens in normal interrupt handler context,
so there is only a problem when init is not running.

Bruce
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r331298 - head/sys/dev/syscons

2018-03-22 Thread Bruce Evans

On Wed, 21 Mar 2018, Warner Losh wrote:


On Wed, Mar 21, 2018 at 11:53 AM, Bruce Evans  wrote:


On Wed, 21 Mar 2018, Warner Losh wrote:

Log:

 Unlock giant when calling shutdown_nice()


This breaks the driver.  Giant is syscons' driver lock, and also the
interrupt handler lock for at least the atkbd keyboard driver, so vt
sometimes holds the lock for.


OK. I got carried away. You're right. The proper fix is to unlock Giant at
the top of kern_reboot() instead. This handles the case where we call
shutdown_nice() with no init running and have to call kern_reboot directly.
Otherwise it's perfectly fine to just call shutdown_nice() with Giant held
since we just signal init from there. So I'll revert this change and make
that other change instead.
...
Good point. I think the following change is good for everything except
calling shutdown_nice() from a fast interrupt handler with noinit running:

diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c
index e5ea9644ad3f..564aecd811be 100644
--- a/sys/kern/kern_shutdown.c
+++ b/sys/kern/kern_shutdown.c
@@ -366,6 +366,12 @@ kern_reboot(int howto)
{
   static int once = 0;

+   /*
+* Drop Giant once and for all.
+*/
+   while (mtx_owned())
+   mtx_unlock();
+
#if defined(SMP)
   /*
* Bind us to the first CPU so that all shutdown code runs there.
Some

Comments?


Try putting this in vfs_mountroot_parse() and/or the second clause of
shutdown_nice() only.  The only other calls are from is from sys_reboot()
and vpanic().  sys_reboot() is either MPSAFE or not, and it should know
when it is safe to drop its Giant lock if at all.  vpanic() sets
SCHEDULER_STOPPED() to avoid seeing problems with Giant or any other
mutex.

Bruce
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r331326 - in head/stand: forth i386/loader

2018-03-22 Thread Cy Schubert
In message 
, Kyle Evans writes:
> On Wed, Mar 21, 2018 at 10:30 PM, Cy Schubert  wro
> te:
> > In message <201803212201.w2lm1pvl020...@repo.freebsd.org>, Kyle Evans
> > writes:
> >> Author: kevans
> >> Date: Wed Mar 21 22:01:51 2018
> >> New Revision: 331326
> >> URL: https://svnweb.freebsd.org/changeset/base/331326
> >>
> >> Log:
> >>   Forth version of EFI autoresizing
> >>
> >>   r331321 delegated autoresizing to an efi-autoresizecons command that
> >>   currently is expected to be done in forth/lua prior to drawing anything
> >>   useful.
> >>
> >>   Add the Forth version of the lua addition in r331321, hook efi.4th up to
>  be
> >>   installed.
> >>
> >>   efiboot? was written by dteske@; anything outside of that may be blamed 
> on
> >>   me.
> >>
> >> Modified:
> >>   head/stand/forth/Makefile
> >>   head/stand/forth/efi.4th
> >>   head/stand/forth/loader.rc
> >>   head/stand/i386/loader/loader.rc
> >>
> >> Modified: head/stand/forth/Makefile
> >> ==
> ===
> >> =
> >> --- head/stand/forth/Makefile Wed Mar 21 21:15:43 2018(r331325)
> >> +++ head/stand/forth/Makefile Wed Mar 21 22:01:51 2018(r331326)
> >> @@ -18,6 +18,7 @@ FILES+= brand-fbsd.4th
> >>  FILES+=  check-password.4th
> >>  FILES+=  color.4th
> >>  FILES+=  delay.4th
> >> +FILES+=  efi.4th
> >>  FILES+=  frames.4th
> >>  FILES+=  loader.4th
> >>  FILES+=  logo-beastie.4th
> >>
> >> Modified: head/stand/forth/efi.4th
> >> ==
> ===
> >> =
> >> --- head/stand/forth/efi.4th  Wed Mar 21 21:15:43 2018(r331325)
> >> +++ head/stand/forth/efi.4th  Wed Mar 21 22:01:51 2018(r331326)
> >> @@ -26,5 +26,16 @@
> >>
> >>  only forth definitions
> >>
> >> -\ Place holder for more functions
> >> +: efiboot? ( -- flag )
> >> + s" efi-version" getenv -1 <> dup if
> >> + swap drop ( c-addr flag -- flag )
> >> + then
> >> +;
> >> +
> >> +: maybe-efi-resizecons
> >> + efiboot? if
> >> + efi-autoresizecons
> >
> > This statement breaks boot on my BIOS machines. It cannot find
> > efi-autoresizecons, causing a bare kernel without modules to load or
> > kenv variables set.
> >
>
> Ugh, sorry about that. =( I've converted that to a runtime evaluation
> in r331341 and (hopefully) properly observed my failure to succeed.

No problem. That fixed it.

>
> On the plus side, today I learned about `boot-conf` to get back to the
> Forth-intercepted 'boot' behavior to workaround the breakage. =)

Yes. Good point. I'll remember that too.

Thanks again.
-- 
Cheers,
Cy Schubert 
FreeBSD UNIX:     Web:  http://www.FreeBSD.org

The need of the many outweighs the greed of the few.


___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r331345 - head/sys/dev/jedec_dimm

2018-03-22 Thread Ravi Pokala
Author: rpokala
Date: Thu Mar 22 06:31:05 2018
New Revision: 331345
URL: https://svnweb.freebsd.org/changeset/base/331345

Log:
  jedec_dimm: Use correct string length when populating sc->slotid_str
  
  Don't limit the copy to the size of the target string *pointer* (always
  4 on 32-bit / 8 on 64-bit). Instead, just use strdup().
  
  Reported by:  Coverity
  CID:  1386912
  Reviewed by:  cem, imp
  MFC after:1 week

Modified:
  head/sys/dev/jedec_dimm/jedec_dimm.c

Modified: head/sys/dev/jedec_dimm/jedec_dimm.c
==
--- head/sys/dev/jedec_dimm/jedec_dimm.cThu Mar 22 05:26:27 2018
(r331344)
+++ head/sys/dev/jedec_dimm/jedec_dimm.cThu Mar 22 06:31:05 2018
(r331345)
@@ -341,10 +341,7 @@ jedec_dimm_attach(device_t dev)
if (resource_string_value(device_get_name(dev), device_get_unit(dev),
"slotid", _str) == 0) {
if (slotid_str != NULL) {
-   sc->slotid_str = malloc(strlen(slotid_str) + 1,
-   M_DEVBUF, (M_WAITOK | M_ZERO));
-   strlcpy(sc->slotid_str, slotid_str,
-   sizeof(sc->slotid_str));
+   sc->slotid_str = strdup(slotid_str, M_DEVBUF);
SYSCTL_ADD_STRING(ctx, children, OID_AUTO, "slotid",
CTLFLAG_RD | CTLFLAG_MPSAFE, sc->slotid_str, 0,
"DIMM Slot Identifier");
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r331298 - head/sys/dev/syscons

2018-03-22 Thread Bruce Evans

On Wed, 21 Mar 2018, Konstantin Belousov wrote:


On Thu, Mar 22, 2018 at 04:53:22AM +1100, Bruce Evans wrote:

Serial console drivers with fast interrupt handlers have much more
broken locking for ddb special keys.  It is invalid to either drop locks
or call the "any" function from a fast interrupt handler, but buggy
serial console drivers calls kbd_alt_break(), and that now calls
shutdown_nice() and other functions that cannot be called from a fast
interrupt handler.  ddb keys supply most of the shutdown_nice()
functionality for serial consoles, and there are no escape sequence to
get this without ddb or maybe another debugger, so these bugs don't
affect most users.

Handling this correctly requires much the same fix as an unsafe signal
handler, and fixes have much the same problems -- not much more than
setting a flag is safe, and the flag might never be looked at if the
system is in a bad state.  However, if a nice shutdown is possible then
the sytem must be in a good enough state to poll for flags.


Are you saying that fast interrupt handlers call shutdown_nice() ?  This
is the quite serious bug on its own.  To fix it, shutdown_nice() should
use a fast taskqueue to schedule the task which would lock the process
and send the signal.


Yes.  See kdb_reboot().  This is called for an escape sequence from
kdb_alt_break_internal().  The other calls in kdb_alt_break_internal()
don't wander into a function that calls shutdown_nice() and are
relatively safe.  They have to be not completely safe to work in "any"
context.  kdb_reboot() is the opposite -- we want it to fail if the
context is not nice enough to reboot nicely.

BTW, I've often wanted to be able to send more general signals to init
using keystrokes, independent of being logged in.  Mainly SIGHUP to
shut down to single user mode.  This has some security problems,
especially for the "any" signal to the "any" process.  At least syscons
defaults to allowing Ctrl-Alt-Del to reboot.  I like that and miss it
on serial consoles and on some non-FreeBSD OS's (the alt-break sequence
to reach kdb_reboot() is not equivalent, since it is only available
if much more insecure sequences are also allowed).  Shutdown isn't as
fundamentally insecure as sending arbitrary signals and most systems
allow it without much more than a password for users that have physical
access to the system.

OTOH, I don't like the syscons key that suspends.  This is also allowed
by default.  I sometimes press it by mistake on a system that can suspend
but not resume.  Unlike the reboot key, there are no knobs for controlling
it.  There are 3 static configuration knobs, 2 sysctls and the keymap
which must be understood for securing the main reboot key in syscons, and a
slightly different set of controls in vt :-(.  For suspend, there is only
the keymap.  Syscons also has a standby key and more shutdown keys, but
these are in more obscure parts of keymaps and I've never noticed typing
them by mistake.

Bruce
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"