svn commit: r357853 - head/sys/cam/scsi

2020-02-12 Thread Warner Losh
Author: imp
Date: Thu Feb 13 03:37:11 2020
New Revision: 357853
URL: https://svnweb.freebsd.org/changeset/base/357853

Log:
  Use INT instead of string for the ints. Because the string "I" was right, the
  old code appeared to work. This was a cut and paste error.
  
  Noticed by: rpokala@

Modified:
  head/sys/cam/scsi/scsi_da.c

Modified: head/sys/cam/scsi/scsi_da.c
==
--- head/sys/cam/scsi/scsi_da.c Thu Feb 13 03:13:29 2020(r357852)
+++ head/sys/cam/scsi/scsi_da.c Thu Feb 13 03:37:11 2020(r357853)
@@ -2328,11 +2328,11 @@ dasysctlinit(void *context, int pending)
softc, 0, daflagssysctl, "A",
"Flags for drive");
SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
-   OID_AUTO, "rotating", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE,
+   OID_AUTO, "rotating", CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE,
&softc->flags, DA_FLAG_ROTATING, dabitsysctl, "I",
"Rotating media *DEPRECATED* gone in FreeBSD 14");
SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
-   OID_AUTO, "unmapped_io", CTLTYPE_STRING | CTLFLAG_RD | 
CTLFLAG_MPSAFE,
+   OID_AUTO, "unmapped_io", CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE,
&softc->flags, DA_FLAG_UNMAPPEDIO, dabitsysctl, "I",
"Unmapped I/O support *DEPRECATED* gone in FreeBSD 14");
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357852 - in stable: 11/include 11/lib/libc/stdio 12/include 12/lib/libc/stdio

2020-02-12 Thread Kyle Evans
Author: kevans
Date: Thu Feb 13 03:13:29 2020
New Revision: 357852
URL: https://svnweb.freebsd.org/changeset/base/357852

Log:
  MFC r357284, r357419: stdio unlocked
  
  r357284:
  stdio: provide _unlocked variants of fflush, fputc, fputs, fread, fwrite
  
  fflush_unlocked is currently desired in ports by sysutils/metalog, and
  redefined as the locked fflush.
  
  fputc_unlocked, fputs_unlocked, fread_unlocked, and fwrite_unlocked are
  currently desired in ports by devel/elfutils, and redefined as the locked
  fputs, fread, and fwrite respectively.
  
  r357419:
  libc: provide fputc_unlocked
  
  Among the same justification as the other stdio _unlocked; in addition to an
  inline version in , we must provide a function in libc as well for
  the functionality. This fixes the lang/gcc* builds, which want to use the
  symbol from libc.

Modified:
  stable/11/include/stdio.h
  stable/11/lib/libc/stdio/Makefile.inc
  stable/11/lib/libc/stdio/Symbol.map
  stable/11/lib/libc/stdio/fflush.3
  stable/11/lib/libc/stdio/fflush.c
  stable/11/lib/libc/stdio/fputc.c
  stable/11/lib/libc/stdio/fputs.3
  stable/11/lib/libc/stdio/fputs.c
  stable/11/lib/libc/stdio/fread.3
  stable/11/lib/libc/stdio/fread.c
  stable/11/lib/libc/stdio/fwrite.c
  stable/11/lib/libc/stdio/putc.3
Directory Properties:
  stable/11/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/12/include/stdio.h
  stable/12/lib/libc/stdio/Makefile.inc
  stable/12/lib/libc/stdio/Symbol.map
  stable/12/lib/libc/stdio/fflush.3
  stable/12/lib/libc/stdio/fflush.c
  stable/12/lib/libc/stdio/fputc.c
  stable/12/lib/libc/stdio/fputs.3
  stable/12/lib/libc/stdio/fputs.c
  stable/12/lib/libc/stdio/fread.3
  stable/12/lib/libc/stdio/fread.c
  stable/12/lib/libc/stdio/fwrite.c
  stable/12/lib/libc/stdio/putc.3
Directory Properties:
  stable/12/   (props changed)

Modified: stable/11/include/stdio.h
==
--- stable/11/include/stdio.h   Thu Feb 13 03:11:39 2020(r357851)
+++ stable/11/include/stdio.h   Thu Feb 13 03:13:29 2020(r357852)
@@ -345,7 +345,13 @@ int putchar_unlocked(int);
 voidclearerr_unlocked(FILE *);
 int feof_unlocked(FILE *);
 int ferror_unlocked(FILE *);
+int fflush_unlocked(FILE *);
 int fileno_unlocked(FILE *);
+int fputc_unlocked(int, FILE *);
+int fputs_unlocked(const char * __restrict, FILE * __restrict);
+size_t  fread_unlocked(void * __restrict, size_t, size_t, FILE * __restrict);
+size_t  fwrite_unlocked(const void * __restrict, size_t, size_t,
+FILE * __restrict);
 #endif
 
 #if __POSIX_VISIBLE >= 200112
@@ -541,10 +547,11 @@ extern int __isthreaded;
  * See ISO/IEC 9945-1 ANSI/IEEE Std 1003.1 Second Edition 1996-07-12
  * B.8.2.7 for the rationale behind the *_unlocked() macros.
  */
+#defineclearerr_unlocked(p)__sclearerr(p)
 #definefeof_unlocked(p)__sfeof(p)
 #defineferror_unlocked(p)  __sferror(p)
-#defineclearerr_unlocked(p)__sclearerr(p)
 #definefileno_unlocked(p)  __sfileno(p)
+#definefputc_unlocked(s, p)__sputc(s, p)
 #endif
 #if __POSIX_VISIBLE >= 199506
 #definegetc_unlocked(fp)   __sgetc(fp)

Modified: stable/11/lib/libc/stdio/Makefile.inc
==
--- stable/11/lib/libc/stdio/Makefile.inc   Thu Feb 13 03:11:39 2020
(r357851)
+++ stable/11/lib/libc/stdio/Makefile.inc   Thu Feb 13 03:13:29 2020
(r357852)
@@ -48,13 +48,17 @@ MLINKS+=ferror.3 ferror_unlocked.3 \
ferror.3 clearerr.3 ferror.3 clearerr_unlocked.3 \
ferror.3 feof.3 ferror.3 feof_unlocked.3 \
ferror.3 fileno.3 ferror.3 fileno_unlocked.3
-MLINKS+=fflush.3 fpurge.3
+MLINKS+=fflush.3 fflush_unlocked.3 \
+   fflush.3 fpurge.3
 MLINKS+=fgets.3 gets.3
 MLINKS+=fgets.3 gets_s.3
 MLINKS+=flockfile.3 ftrylockfile.3 flockfile.3 funlockfile.3
 MLINKS+=fopen.3 fdopen.3 fopen.3 freopen.3 fopen.3 fmemopen.3
-MLINKS+=fputs.3 puts.3
-MLINKS+=fread.3 fwrite.3
+MLINKS+=fputs.3 fputs_unlocked.3 \
+   fputs.3 puts.3
+MLINKS+=fread.3 fread_unlocked.3 \
+   fread.3 fwrite.3 \
+   fread.3 fwrite_unlocked.3
 MLINKS+=fseek.3 fgetpos.3 fseek.3 fseeko.3 fseek.3 fsetpos.3 fseek.3 ftell.3 \
fseek.3 ftello.3 fseek.3 rewind.3
 MLINKS+=funopen.3 fropen.3 funopen.3 fwopen.3

Modified: stable/11/lib/libc/stdio/Symbol.map
==
--- stable/11/lib/libc/stdio/Symbol.map Thu Feb 13 03:11:39 2020
(r357851)
+++ stable/11/lib/libc/stdio/Symbol.map Thu Feb 13 03:13:29 2020
(r357852)
@@ -171,6 +171,14 @@ FBSD_1.5 {
gets_s;
 };
 
+FBSD_1.6 {
+   fflush_unlocked;
+   fputc_unlocked;
+   fputs_unlocked;
+   fread_unlocked;
+   fwrite_unlocked;
+};
+
 FBSDprivate_1.0 {
_flockfile;
_flockfile_debug_stu

svn commit: r357852 - in stable: 11/include 11/lib/libc/stdio 12/include 12/lib/libc/stdio

2020-02-12 Thread Kyle Evans
Author: kevans
Date: Thu Feb 13 03:13:29 2020
New Revision: 357852
URL: https://svnweb.freebsd.org/changeset/base/357852

Log:
  MFC r357284, r357419: stdio unlocked
  
  r357284:
  stdio: provide _unlocked variants of fflush, fputc, fputs, fread, fwrite
  
  fflush_unlocked is currently desired in ports by sysutils/metalog, and
  redefined as the locked fflush.
  
  fputc_unlocked, fputs_unlocked, fread_unlocked, and fwrite_unlocked are
  currently desired in ports by devel/elfutils, and redefined as the locked
  fputs, fread, and fwrite respectively.
  
  r357419:
  libc: provide fputc_unlocked
  
  Among the same justification as the other stdio _unlocked; in addition to an
  inline version in , we must provide a function in libc as well for
  the functionality. This fixes the lang/gcc* builds, which want to use the
  symbol from libc.

Modified:
  stable/12/include/stdio.h
  stable/12/lib/libc/stdio/Makefile.inc
  stable/12/lib/libc/stdio/Symbol.map
  stable/12/lib/libc/stdio/fflush.3
  stable/12/lib/libc/stdio/fflush.c
  stable/12/lib/libc/stdio/fputc.c
  stable/12/lib/libc/stdio/fputs.3
  stable/12/lib/libc/stdio/fputs.c
  stable/12/lib/libc/stdio/fread.3
  stable/12/lib/libc/stdio/fread.c
  stable/12/lib/libc/stdio/fwrite.c
  stable/12/lib/libc/stdio/putc.3
Directory Properties:
  stable/12/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/11/include/stdio.h
  stable/11/lib/libc/stdio/Makefile.inc
  stable/11/lib/libc/stdio/Symbol.map
  stable/11/lib/libc/stdio/fflush.3
  stable/11/lib/libc/stdio/fflush.c
  stable/11/lib/libc/stdio/fputc.c
  stable/11/lib/libc/stdio/fputs.3
  stable/11/lib/libc/stdio/fputs.c
  stable/11/lib/libc/stdio/fread.3
  stable/11/lib/libc/stdio/fread.c
  stable/11/lib/libc/stdio/fwrite.c
  stable/11/lib/libc/stdio/putc.3
Directory Properties:
  stable/11/   (props changed)

Modified: stable/12/include/stdio.h
==
--- stable/12/include/stdio.h   Thu Feb 13 03:11:39 2020(r357851)
+++ stable/12/include/stdio.h   Thu Feb 13 03:13:29 2020(r357852)
@@ -347,7 +347,13 @@ int putchar_unlocked(int);
 voidclearerr_unlocked(FILE *);
 int feof_unlocked(FILE *);
 int ferror_unlocked(FILE *);
+int fflush_unlocked(FILE *);
 int fileno_unlocked(FILE *);
+int fputc_unlocked(int, FILE *);
+int fputs_unlocked(const char * __restrict, FILE * __restrict);
+size_t  fread_unlocked(void * __restrict, size_t, size_t, FILE * __restrict);
+size_t  fwrite_unlocked(const void * __restrict, size_t, size_t,
+FILE * __restrict);
 #endif
 
 #if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 500
@@ -508,10 +514,11 @@ extern int __isthreaded;
  * See ISO/IEC 9945-1 ANSI/IEEE Std 1003.1 Second Edition 1996-07-12
  * B.8.2.7 for the rationale behind the *_unlocked() macros.
  */
+#defineclearerr_unlocked(p)__sclearerr(p)
 #definefeof_unlocked(p)__sfeof(p)
 #defineferror_unlocked(p)  __sferror(p)
-#defineclearerr_unlocked(p)__sclearerr(p)
 #definefileno_unlocked(p)  __sfileno(p)
+#definefputc_unlocked(s, p)__sputc(s, p)
 #endif
 #if __POSIX_VISIBLE >= 199506
 #definegetc_unlocked(fp)   __sgetc(fp)

Modified: stable/12/lib/libc/stdio/Makefile.inc
==
--- stable/12/lib/libc/stdio/Makefile.inc   Thu Feb 13 03:11:39 2020
(r357851)
+++ stable/12/lib/libc/stdio/Makefile.inc   Thu Feb 13 03:13:29 2020
(r357852)
@@ -48,13 +48,17 @@ MLINKS+=ferror.3 ferror_unlocked.3 \
ferror.3 clearerr.3 ferror.3 clearerr_unlocked.3 \
ferror.3 feof.3 ferror.3 feof_unlocked.3 \
ferror.3 fileno.3 ferror.3 fileno_unlocked.3
-MLINKS+=fflush.3 fpurge.3
+MLINKS+=fflush.3 fflush_unlocked.3 \
+   fflush.3 fpurge.3
 MLINKS+=fgets.3 gets.3
 MLINKS+=fgets.3 gets_s.3
 MLINKS+=flockfile.3 ftrylockfile.3 flockfile.3 funlockfile.3
 MLINKS+=fopen.3 fdopen.3 fopen.3 freopen.3 fopen.3 fmemopen.3
-MLINKS+=fputs.3 puts.3
-MLINKS+=fread.3 fwrite.3
+MLINKS+=fputs.3 fputs_unlocked.3 \
+   fputs.3 puts.3
+MLINKS+=fread.3 fread_unlocked.3 \
+   fread.3 fwrite.3 \
+   fread.3 fwrite_unlocked.3
 MLINKS+=fseek.3 fgetpos.3 fseek.3 fseeko.3 fseek.3 fsetpos.3 fseek.3 ftell.3 \
fseek.3 ftello.3 fseek.3 rewind.3
 MLINKS+=funopen.3 fropen.3 funopen.3 fwopen.3

Modified: stable/12/lib/libc/stdio/Symbol.map
==
--- stable/12/lib/libc/stdio/Symbol.map Thu Feb 13 03:11:39 2020
(r357851)
+++ stable/12/lib/libc/stdio/Symbol.map Thu Feb 13 03:13:29 2020
(r357852)
@@ -171,6 +171,14 @@ FBSD_1.5 {
gets_s;
 };
 
+FBSD_1.6 {
+   fflush_unlocked;
+   fputc_unlocked;
+   fputs_unlocked;
+   fread_unlocked;
+   fwrite_unlocked;
+};
+
 FBSDprivate_1.0 {
_flockfile;

svn commit: r357851 - stable/11/lib/libc/stdio

2020-02-12 Thread Kyle Evans
Author: kevans
Date: Thu Feb 13 03:11:39 2020
New Revision: 357851
URL: https://svnweb.freebsd.org/changeset/base/357851

Log:
  MFC r327181: fsync(3): correctly document return values
  
  In r268924 the behavior of fflush was changed to return success
  on read only streams. Document this.

Modified:
  stable/11/lib/libc/stdio/fflush.3
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/lib/libc/stdio/fflush.3
==
--- stable/11/lib/libc/stdio/fflush.3   Thu Feb 13 01:42:13 2020
(r357850)
+++ stable/11/lib/libc/stdio/fflush.3   Thu Feb 13 03:11:39 2020
(r357851)
@@ -32,7 +32,7 @@
 .\" @(#)fflush.3   8.1 (Berkeley) 6/4/93
 .\" $FreeBSD$
 .\"
-.Dd June 4, 1993
+.Dd December 25, 2017
 .Dt FFLUSH 3
 .Os
 .Sh NAME
@@ -87,9 +87,7 @@ is set to indicate the error.
 The
 .Fa stream
 argument
-is not an open stream, or, in the case of
-.Fn fflush ,
-not a stream open for writing.
+is not an open stream.
 .El
 .Pp
 The function
@@ -97,7 +95,12 @@ The function
 may also fail and set
 .Va errno
 for any of the errors specified for the routine
-.Xr write 2 .
+.Xr write 2 ,
+except that in case of
+.Fa stream
+being a read-only descriptor,
+.Fn fflush
+returns 0.
 .Sh SEE ALSO
 .Xr write 2 ,
 .Xr fclose 3 ,
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357850 - head/share/misc

2020-02-12 Thread Ryan Moeller
Author: freqlabs
Date: Thu Feb 13 01:42:13 2020
New Revision: 357850
URL: https://svnweb.freebsd.org/changeset/base/357850

Log:
  Add myself (freqlabs) as a src committer
  
  Approved by:  mav (mentor)
  MFC after:3 days

Modified:
  head/share/misc/committers-src.dot

Modified: head/share/misc/committers-src.dot
==
--- head/share/misc/committers-src.dot  Thu Feb 13 01:23:44 2020
(r357849)
+++ head/share/misc/committers-src.dot  Thu Feb 13 01:42:13 2020
(r357850)
@@ -175,6 +175,7 @@ fabient [label="Fabien Thomas\nfabi...@freebsd.org\n20
 fanf [label="Tony Finch\nf...@freebsd.org\n2002/05/05"]
 fjoe [label="Max Khon\nf...@freebsd.org\n2001/08/06"]
 flz [label="Florent Thoumie\n...@freebsd.org\n2006/03/30"]
+freqlabs [label="Ryan Moeller\nfreql...@freebsd.org\n2020/02/10"]
 fsu [label="Fedor Uporov\n...@freebsd.org\n2017/08/28"]
 gabor [label="Gabor Kovesdan\nga...@freebsd.org\n2010/02/02"]
 gad [label="Garance A. Drosehn\n...@freebsd.org\n2000/10/27"]
@@ -716,6 +717,7 @@ markm -> sheldonh
 
 mav -> ae
 mav -> eugen
+mav -> freqlabs
 mav -> ram
 
 mdf -> gleb
@@ -730,6 +732,8 @@ mlaier -> benjsc
 mlaier -> dhartmei
 mlaier -> thompsa
 mlaier -> eri
+
+mmacy -> freqlabs
 
 msmith -> cokane
 msmith -> jasone
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357848 - head/sys/cam/scsi

2020-02-12 Thread Warner Losh
Author: imp
Date: Thu Feb 13 01:23:32 2020
New Revision: 357848
URL: https://svnweb.freebsd.org/changeset/base/357848

Log:
  Export the current da flags as bitfield
  
  Export the current flags. They can be useful to other programs wanting to do
  special thigns for removable or similar devices.
  
  Differential Revision: https://reviews.freebsd.org/D23417

Modified:
  head/sys/cam/scsi/scsi_da.c

Modified: head/sys/cam/scsi/scsi_da.c
==
--- head/sys/cam/scsi/scsi_da.c Wed Feb 12 23:54:38 2020(r357847)
+++ head/sys/cam/scsi/scsi_da.c Thu Feb 13 01:23:32 2020(r357848)
@@ -122,6 +122,28 @@ typedef enum {
DA_FLAG_CAN_ATA_ZONE= 0x04,
DA_FLAG_TUR_PENDING = 0x08
 } da_flags;
+#define DA_FLAG_STRING \
+   "\020"  \
+   "\001PACK_INVALID"  \
+   "\002NEW_PACK"  \
+   "\003PACK_LOCKED"   \
+   "\004PACK_REMOVABLE"\
+   "\005UNUSED"\
+   "\006NEED_OTAG" \
+   "\007WAS_OTAG"  \
+   "\010RETRY_UA"  \
+   "\011OPEN"  \
+   "\012SCTX_INIT" \
+   "\013CAN_RC16"  \
+   "\014PROBED"\
+   "\015DIRTY" \
+   "\016ANNOUCNED" \
+   "\017CAN_ATA_DMA"   \
+   "\020CAN_ATA_LOG"   \
+   "\021CAN_ATA_IDLOG" \
+   "\022CAN_ATA_SUPACP"\
+   "\023CAN_ATA_ZONE"  \
+   "\024TUR_PENDING"
 
 typedef enum {
DA_Q_NONE   = 0x00,
@@ -1442,6 +1464,7 @@ staticvoiddasysctlinit(void *context, int 
pending);
 static int dasysctlsofttimeout(SYSCTL_HANDLER_ARGS);
 static int dacmdsizesysctl(SYSCTL_HANDLER_ARGS);
 static int dadeletemethodsysctl(SYSCTL_HANDLER_ARGS);
+static int daflagssysctl(SYSCTL_HANDLER_ARGS);
 static int dazonemodesysctl(SYSCTL_HANDLER_ARGS);
 static int dazonesupsysctl(SYSCTL_HANDLER_ARGS);
 static int dadeletemaxsysctl(SYSCTL_HANDLER_ARGS);
@@ -2316,6 +2339,11 @@ dasysctlinit(void *context, int pending)
   0,
   "DIF protection type");
 
+   SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
+   OID_AUTO, "flags", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE,
+   softc, 0, daflagssysctl, "A",
+   "Flags for drive");
+
 #ifdef CAM_TEST_FAILURE
SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
OID_AUTO, "invalidate", CTLTYPE_U64 | CTLFLAG_RW | 
CTLFLAG_MPSAFE,
@@ -2588,6 +2616,24 @@ dadeletemethodchoose(struct da_softc *softc, da_delete
 
/* Fallback to default. */
dadeletemethodset(softc, default_method);
+}
+
+static int
+daflagssysctl(SYSCTL_HANDLER_ARGS)
+{
+   struct sbuf sbuf;
+   struct da_softc *softc = arg1;
+   int error;
+
+   sbuf_new_for_sysctl(&sbuf, NULL, 0, req);
+   if (softc->flags != 0)
+   sbuf_printf(&sbuf, "0x%b", softc->flags, DA_FLAG_STRING);
+   else
+   sbuf_printf(&sbuf, "0");
+   error = sbuf_finish(&sbuf);
+   sbuf_delete(&sbuf);
+
+   return (error);
 }
 
 static int
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357849 - head/sys/cam/scsi

2020-02-12 Thread Warner Losh
Author: imp
Date: Thu Feb 13 01:23:44 2020
New Revision: 357849
URL: https://svnweb.freebsd.org/changeset/base/357849

Log:
  Convert rotating and unmapped_io to a DA flag
  
  Rotating and unmapped_io are really da flags. Convert them to a flag so it 
will
  be reported with the other flags for the device. Deprecate the .rotating and
  .unmapped_io sysctls in FreeBSD 14 and remove the softc ints.
  
  Differential Revision: https://reviews.freebsd.org/D23417

Modified:
  head/sys/cam/scsi/scsi_da.c

Modified: head/sys/cam/scsi/scsi_da.c
==
--- head/sys/cam/scsi/scsi_da.c Thu Feb 13 01:23:32 2020(r357848)
+++ head/sys/cam/scsi/scsi_da.c Thu Feb 13 01:23:44 2020(r357849)
@@ -106,6 +106,7 @@ typedef enum {
DA_FLAG_NEW_PACK= 0x02,
DA_FLAG_PACK_LOCKED = 0x04,
DA_FLAG_PACK_REMOVABLE  = 0x08,
+   DA_FLAG_ROTATING= 0x10,
DA_FLAG_NEED_OTAG   = 0x20,
DA_FLAG_WAS_OTAG= 0x40,
DA_FLAG_RETRY_UA= 0x80,
@@ -120,7 +121,8 @@ typedef enum {
DA_FLAG_CAN_ATA_IDLOG   = 0x01,
DA_FLAG_CAN_ATA_SUPCAP  = 0x02,
DA_FLAG_CAN_ATA_ZONE= 0x04,
-   DA_FLAG_TUR_PENDING = 0x08
+   DA_FLAG_TUR_PENDING = 0x08,
+   DA_FLAG_UNMAPPEDIO  = 0x10
 } da_flags;
 #define DA_FLAG_STRING \
"\020"  \
@@ -128,7 +130,7 @@ typedef enum {
"\002NEW_PACK"  \
"\003PACK_LOCKED"   \
"\004PACK_REMOVABLE"\
-   "\005UNUSED"\
+   "\005ROTATING"  \
"\006NEED_OTAG" \
"\007WAS_OTAG"  \
"\010RETRY_UA"  \
@@ -143,7 +145,8 @@ typedef enum {
"\021CAN_ATA_IDLOG" \
"\022CAN_ATA_SUPACP"\
"\023CAN_ATA_ZONE"  \
-   "\024TUR_PENDING"
+   "\024TUR_PENDING"   \
+   "\025UNMAPPEDIO"
 
 typedef enum {
DA_Q_NONE   = 0x00,
@@ -367,8 +370,6 @@ struct da_softc {
da_delete_methods   delete_method_pref;
da_delete_methods   delete_method;
da_delete_func_t*delete_func;
-   int unmappedio;
-   int rotating;
int p_type;
struct   disk_params params;
struct   disk *disk;
@@ -1464,6 +1465,7 @@ staticvoiddasysctlinit(void *context, int 
pending);
 static int dasysctlsofttimeout(SYSCTL_HANDLER_ARGS);
 static int dacmdsizesysctl(SYSCTL_HANDLER_ARGS);
 static int dadeletemethodsysctl(SYSCTL_HANDLER_ARGS);
+static int dabitsysctl(SYSCTL_HANDLER_ARGS);
 static int daflagssysctl(SYSCTL_HANDLER_ARGS);
 static int dazonemodesysctl(SYSCTL_HANDLER_ARGS);
 static int dazonesupsysctl(SYSCTL_HANDLER_ARGS);
@@ -2315,24 +2317,6 @@ dasysctlinit(void *context, int pending)
SYSCTL_ADD_INT(&softc->sysctl_ctx,
   SYSCTL_CHILDREN(softc->sysctl_tree),
   OID_AUTO,
-  "unmapped_io",
-  CTLFLAG_RD,
-  &softc->unmappedio,
-  0,
-  "Unmapped I/O support");
-
-   SYSCTL_ADD_INT(&softc->sysctl_ctx,
-  SYSCTL_CHILDREN(softc->sysctl_tree),
-  OID_AUTO,
-  "rotating",
-  CTLFLAG_RD,
-  &softc->rotating,
-  0,
-  "Rotating media");
-
-   SYSCTL_ADD_INT(&softc->sysctl_ctx,
-  SYSCTL_CHILDREN(softc->sysctl_tree),
-  OID_AUTO,
   "p_type",
   CTLFLAG_RD,
   &softc->p_type,
@@ -2343,6 +2327,14 @@ dasysctlinit(void *context, int pending)
OID_AUTO, "flags", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE,
softc, 0, daflagssysctl, "A",
"Flags for drive");
+   SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
+   OID_AUTO, "rotating", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE,
+   &softc->flags, DA_FLAG_ROTATING, dabitsysctl, "I",
+   "Rotating media *DEPRECATED* gone in FreeBSD 14");
+   SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
+   OID_AUTO, "unmapped_io", CTLTYPE_STRING | CTLFLAG_RD | 
CTLFLAG_MPSAFE,
+   &softc->flags, DA_FLAG_UNMAPPEDIO, dabitsysctl, "I",
+   "Unmapped I/O support *DEPRECATED* gone in FreeBSD 14");
 
 #ifdef CAM_TEST_FAILURE
SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
@@ -2619,6 +2611,21 @@ dadeletemethodchoose(struct da_softc *softc, da_delete
 }
 
 static int
+dabitsysctl(SYSCTL_HANDLER_ARGS)
+{
+   int flags = (in

svn commit: r357847 - head

2020-02-12 Thread Dimitry Andric
Author: dim
Date: Wed Feb 12 23:54:38 2020
New Revision: 357847
URL: https://svnweb.freebsd.org/changeset/base/357847

Log:
  Fix typo introduced with r347534 (cap_sysctl additions).
  
  This ensures the old libcap_sysctl.so.1 gets cleaned up when running
  "make delete-old-libs".

Modified:
  head/ObsoleteFiles.inc

Modified: head/ObsoleteFiles.inc
==
--- head/ObsoleteFiles.inc  Wed Feb 12 22:44:18 2020(r357846)
+++ head/ObsoleteFiles.inc  Wed Feb 12 23:54:38 2020(r357847)
@@ -757,7 +757,7 @@ OLD_FILES+=usr/share/man/man4/wb.4.gz
 OLD_FILES+=usr/share/man/man4/xe.4.gz
 OLD_FILES+=usr/share/man/man4/if_xe.4.gz
 # 20190513: libcap_sysctl interface change
-OLD_FILES+=lib/casper/libcap_sysctl.1
+OLD_FILES+=lib/casper/libcap_sysctl.so.1
 # 20190509: tests/sys/opencrypto requires the net/py-dpkt package.
 OLD_FILES+=usr/tests/sys/opencrypto/dpkt.py
 OLD_FILES+=usr/tests/sys/opencrypto/dpkt.pyc
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357846 - head/usr.sbin/bhyve

2020-02-12 Thread Vincenzo Maffione
Author: vmaffione
Date: Wed Feb 12 22:44:18 2020
New Revision: 357846
URL: https://svnweb.freebsd.org/changeset/base/357846

Log:
  bhyve: move virtio-net header processing to pci_virtio_net
  
  This patch cleans up the API between the net frontends (e1000,
  virtio-net) and the net backends (tap and netmap).
  We move the virtio-net header stripping/prepending to the
  virtio-net code, where this functionality belongs.
  In this way, the netbe_send() and netbe_recv() signatures
  can have const struct iov * rather than struct iov *.
  
  Reviewed by:  grehan, bcr, aleksandr.fedo...@itglobal.com
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D23342

Modified:
  head/usr.sbin/bhyve/net_backends.c
  head/usr.sbin/bhyve/net_backends.h
  head/usr.sbin/bhyve/net_utils.c
  head/usr.sbin/bhyve/pci_e82545.c
  head/usr.sbin/bhyve/pci_virtio_net.c

Modified: head/usr.sbin/bhyve/net_backends.c
==
--- head/usr.sbin/bhyve/net_backends.c  Wed Feb 12 22:29:08 2020
(r357845)
+++ head/usr.sbin/bhyve/net_backends.c  Wed Feb 12 22:44:18 2020
(r357846)
@@ -99,7 +99,8 @@ struct net_backend {
 * vector provided by the caller has 'iovcnt' elements and contains
 * the packet to send.
 */
-   ssize_t (*send)(struct net_backend *be, struct iovec *iov, int iovcnt);
+   ssize_t (*send)(struct net_backend *be, const struct iovec *iov,
+   int iovcnt);
 
/*
 * Called to receive a packet from the backend. When the function
@@ -108,7 +109,8 @@ struct net_backend {
 * The function returns 0 if the backend doesn't have a new packet to
 * receive.
 */
-   ssize_t (*recv)(struct net_backend *be, struct iovec *iov, int iovcnt);
+   ssize_t (*recv)(struct net_backend *be, const struct iovec *iov,
+   int iovcnt);
 
/*
 * Ask the backend to enable or disable receive operation in the
@@ -238,13 +240,13 @@ error:
  * Called to send a buffer chain out to the tap device
  */
 static ssize_t
-tap_send(struct net_backend *be, struct iovec *iov, int iovcnt)
+tap_send(struct net_backend *be, const struct iovec *iov, int iovcnt)
 {
return (writev(be->fd, iov, iovcnt));
 }
 
 static ssize_t
-tap_recv(struct net_backend *be, struct iovec *iov, int iovcnt)
+tap_recv(struct net_backend *be, const struct iovec *iov, int iovcnt)
 {
ssize_t ret;
 
@@ -458,7 +460,7 @@ netmap_cleanup(struct net_backend *be)
 }
 
 static ssize_t
-netmap_send(struct net_backend *be, struct iovec *iov,
+netmap_send(struct net_backend *be, const struct iovec *iov,
int iovcnt)
 {
struct netmap_priv *priv = (struct netmap_priv *)be->opaque;
@@ -538,7 +540,7 @@ txsync:
 }
 
 static ssize_t
-netmap_recv(struct net_backend *be, struct iovec *iov, int iovcnt)
+netmap_recv(struct net_backend *be, const struct iovec *iov, int iovcnt)
 {
struct netmap_priv *priv = (struct netmap_priv *)be->opaque;
struct netmap_slot *slot = NULL;
@@ -749,42 +751,10 @@ netbe_set_cap(struct net_backend *be, uint64_t feature
return (ret);
 }
 
-static __inline struct iovec *
-iov_trim(struct iovec *iov, int *iovcnt, unsigned int tlen)
-{
-   struct iovec *riov;
-
-   /* XXX short-cut: assume first segment is >= tlen */
-   assert(iov[0].iov_len >= tlen);
-
-   iov[0].iov_len -= tlen;
-   if (iov[0].iov_len == 0) {
-   assert(*iovcnt > 1);
-   *iovcnt -= 1;
-   riov = &iov[1];
-   } else {
-   iov[0].iov_base = (void *)((uintptr_t)iov[0].iov_base + tlen);
-   riov = &iov[0];
-   }
-
-   return (riov);
-}
-
 ssize_t
-netbe_send(struct net_backend *be, struct iovec *iov, int iovcnt)
+netbe_send(struct net_backend *be, const struct iovec *iov, int iovcnt)
 {
 
-   assert(be != NULL);
-   if (be->be_vnet_hdr_len != be->fe_vnet_hdr_len) {
-   /*
-* The frontend uses a virtio-net header, but the backend
-* does not. We ignore it (as it must be all zeroes) and
-* strip it.
-*/
-   assert(be->be_vnet_hdr_len == 0);
-   iov = iov_trim(iov, &iovcnt, be->fe_vnet_hdr_len);
-   }
-
return (be->send(be, iov, iovcnt));
 }
 
@@ -794,46 +764,10 @@ netbe_send(struct net_backend *be, struct iovec *iov, 
  * the length of the packet just read. Return -1 in case of errors.
  */
 ssize_t
-netbe_recv(struct net_backend *be, struct iovec *iov, int iovcnt)
+netbe_recv(struct net_backend *be, const struct iovec *iov, int iovcnt)
 {
-   /* Length of prepended virtio-net header. */
-   unsigned int hlen = be->fe_vnet_hdr_len;
-   int ret;
 
-   assert(be != NULL);
-
-   if (hlen && hlen != be->be_vnet_hdr_len) {
-   /*
-* The frontend uses a virtio-net header, but the backend
-

svn commit: r357845 - head/stand/efi/loader

2020-02-12 Thread Kyle Evans
Author: kevans
Date: Wed Feb 12 22:29:08 2020
New Revision: 357845
URL: https://svnweb.freebsd.org/changeset/base/357845

Log:
  efiloader: don't execute hooks when setting currdev/loaddev
  
  We still need to set the hooks to prevent improper manipulations thereafter
  at the loader prompt, but as it is we're actively preventing loaddev from
  being set correctly in some circumstances (ZFS in particular) and doing more
  work than needed with currdev -- that hook in particular validates it as a
  correct device, which we can assume isn't needed in this context.
  
  Reviewed by:  imp, sig...@gmail.com
  Submitted/Diagnosed by:   sig...@gmail.com
  Differential Revision:https://reviews.freebsd.org/D23390

Modified:
  head/stand/efi/loader/main.c

Modified: head/stand/efi/loader/main.c
==
--- head/stand/efi/loader/main.cWed Feb 12 21:52:10 2020
(r357844)
+++ head/stand/efi/loader/main.cWed Feb 12 22:29:08 2020
(r357845)
@@ -180,8 +180,17 @@ static void
 set_currdev(const char *devname)
 {
 
-   env_setenv("currdev", EV_VOLATILE, devname, efi_setcurrdev, 
env_nounset);
-   env_setenv("loaddev", EV_VOLATILE, devname, env_noset, env_nounset);
+   /*
+* Don't execute hooks here; we may need to try setting these more than
+* once here if we're probing for the ZFS pool we're supposed to boot.
+* The currdev hook is intended to just validate user input anyways,
+* while the loaddev hook makes it immutable once we've determined what
+* the proper currdev is.
+*/
+   env_setenv("currdev", EV_VOLATILE | EV_NOHOOK, devname, efi_setcurrdev,
+   env_nounset);
+   env_setenv("loaddev", EV_VOLATILE | EV_NOHOOK, devname, env_noset,
+   env_nounset);
 }
 
 static void
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r357833 - head/tests/sys/pjdfstest/tests

2020-02-12 Thread Ed Maste
On Wed, 12 Feb 2020 at 15:34, Enji Cooper  wrote:
>
> On Wed, Feb 12, 2020 at 9:37 AM Ed Maste  wrote:
> >
> > Author: emaste
> > Date: Wed Feb 12 17:37:32 2020
> > New Revision: 357833
> > URL: https://svnweb.freebsd.org/changeset/base/357833
> >
> > Log:
> >   Tag pjdfstest symlink with pkgbase package
> >
> >   As with the rest of pjdfstest, tag the symlink with package=tests.
> >   The tests -> . symlink seems a little strange but that's independent
> >   of pkgbase.
>
> Sidenote: the reason for the symlink was to facilitate integrating the
> test suite without having to completely refactor the code.

Thanks for the note - this probably ought to be a comment by the
symlink; I'll add it at some point if you don't get to it first.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357844 - head/contrib/elftoolchain/addr2line

2020-02-12 Thread Ed Maste
Author: emaste
Date: Wed Feb 12 21:52:10 2020
New Revision: 357844
URL: https://svnweb.freebsd.org/changeset/base/357844

Log:
  addr2line: Handle DW_AT_ranges in compile units
  
  Based on original submission by Marat Radchenko in ELF Tool Chain
  ticket #545, rebased and updated by Tiger Gao.
  
  PR:   217736
  Submitted by: Marat Radchenko 
  Submitted by: Tiger Gao 
  Reviewed by:  markj
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D23501

Modified:
  head/contrib/elftoolchain/addr2line/addr2line.c

Modified: head/contrib/elftoolchain/addr2line/addr2line.c
==
--- head/contrib/elftoolchain/addr2line/addr2line.c Wed Feb 12 21:16:30 
2020(r357843)
+++ head/contrib/elftoolchain/addr2line/addr2line.c Wed Feb 12 21:52:10 
2020(r357844)
@@ -65,6 +65,7 @@ struct CU {
Dwarf_Signed nsrcfiles;
STAILQ_HEAD(, Func) funclist;
Dwarf_Die die;
+   Dwarf_Debug dbg;
 };
 
 static struct option longopts[] = {
@@ -345,7 +346,8 @@ cont_search:
collect_func(dbg, ret_die, parent, cu);
 
/* Cleanup */
-   dwarf_dealloc(dbg, die, DW_DLA_DIE);
+   if (die != cu->die)
+   dwarf_dealloc(dbg, die, DW_DLA_DIE);
 
if (abst_die != NULL)
dwarf_dealloc(dbg, abst_die, DW_DLA_DIE);
@@ -411,6 +413,102 @@ culookup(Dwarf_Unsigned addr)
return (NULL);
 }
 
+/*
+ * Check whether addr falls into range(s) of current CU, and save current CU
+ * to lookup tree if so.
+ */
+static int
+check_range(Dwarf_Debug dbg, Dwarf_Die die, Dwarf_Unsigned addr,
+struct CU **cu)
+{
+   Dwarf_Error de;
+   Dwarf_Unsigned addr_base, lopc, hipc;
+   Dwarf_Off ranges_off;
+   Dwarf_Signed ranges_cnt;
+   Dwarf_Ranges *ranges;
+   int i, ret;
+   bool in_range;
+
+   addr_base = 0;
+   ranges = NULL;
+   ranges_cnt = 0;
+   in_range = false;
+
+   ret = dwarf_attrval_unsigned(die, DW_AT_ranges, &ranges_off, &de);
+   if (ret == DW_DLV_NO_ENTRY) {
+   if (dwarf_attrval_unsigned(die, DW_AT_low_pc, &lopc, &de) ==
+   DW_DLV_OK) {
+   if (lopc == curlopc)
+   return (DW_DLV_ERROR);
+   if (dwarf_attrval_unsigned(die, DW_AT_high_pc, &hipc,
+   &de) == DW_DLV_OK) {
+   /*
+* Check if the address falls into the PC
+* range of this CU.
+*/
+   if (handle_high_pc(die, lopc, &hipc) !=
+   DW_DLV_OK)
+   return (DW_DLV_ERROR);
+   } else {
+   /* Assume ~0ULL if DW_AT_high_pc not present */
+   hipc = ~0ULL;
+   }
+
+   if (addr >= lopc && addr < hipc) {
+   in_range = true;
+   }
+   }
+   } else if (ret == DW_DLV_OK) {
+   ret = dwarf_get_ranges(dbg, ranges_off, &ranges,
+   &ranges_cnt, NULL, &de);
+   if (ret != DW_DLV_OK)
+   return (ret);
+
+   if (!ranges || ranges_cnt <= 0)
+   return (DW_DLV_ERROR);
+
+   for (i = 0; i < ranges_cnt; i++) {
+   if (ranges[i].dwr_type == DW_RANGES_END)
+   return (DW_DLV_NO_ENTRY);
+
+   if (ranges[i].dwr_type ==
+   DW_RANGES_ADDRESS_SELECTION) {
+   addr_base = ranges[i].dwr_addr2;
+   continue;
+   }
+
+   /* DW_RANGES_ENTRY */
+   lopc = ranges[i].dwr_addr1 + addr_base;
+   hipc = ranges[i].dwr_addr2 + addr_base;
+
+   if (lopc == curlopc)
+   return (DW_DLV_ERROR);
+
+   if (addr >= lopc && addr < hipc){
+   in_range = true;
+   break;
+   }
+   }
+   } else {
+   return (DW_DLV_ERROR);
+   }
+   
+   if (in_range) {
+   if ((*cu = calloc(1, sizeof(struct CU))) == NULL)
+   err(EXIT_FAILURE, "calloc");
+   (*cu)->lopc = lopc;
+   (*cu)->hipc = hipc;
+   (*cu)->die = die;
+   (*cu)->dbg = dbg;
+   STAILQ_INIT(&(*cu)->funclist);
+   RB_INSERT(cutree, &cuhead, *cu);
+   curlopc = lopc;
+   return (DW_DLV_OK);
+   } else {
+ 

svn commit: r357843 - head/tests/sys/net/routing

2020-02-12 Thread Alexander V. Chernikov
Author: melifaro
Date: Wed Feb 12 21:16:30 2020
New Revision: 357843
URL: https://svnweb.freebsd.org/changeset/base/357843

Log:
  * Fix flaking lle tests by filtering out non-relevant rtsock messages.
  * Consistently use RTM_DECLARE_ROOT_TEST() macro.
  * Temporarily remove iftype validation from IPv6 lle notifications.
  
  Reported by:  kp

Modified:
  head/tests/sys/net/routing/test_rtsock_lladdr.c

Modified: head/tests/sys/net/routing/test_rtsock_lladdr.c
==
--- head/tests/sys/net/routing/test_rtsock_lladdr.c Wed Feb 12 20:18:29 
2020(r357842)
+++ head/tests/sys/net/routing/test_rtsock_lladdr.c Wed Feb 12 21:16:30 
2020(r357843)
@@ -98,14 +98,18 @@ prepare_route_message(struct rt_msghdr *rtm, int cmd, 
 #defineDESCRIBE_ROOT_TEST(_msg)config_describe_root_test(tc, 
_msg)
 #defineCLEANUP_AFTER_TEST  config_generic_cleanup(config_setup(tc))
 
-
-ATF_TC_WITH_CLEANUP(rtm_add_v6_ll_lle_success);
-ATF_TC_HEAD(rtm_add_v6_ll_lle_success, tc)
-{
-
-   DESCRIBE_ROOT_TEST("Tests addition of link-local IPv6 ND entry");
+#defineRTM_DECLARE_ROOT_TEST(_name, _descr)\
+ATF_TC_WITH_CLEANUP(_name);\
+ATF_TC_HEAD(_name, tc) \
+{  \
+   DESCRIBE_ROOT_TEST(_descr); \
+}  \
+ATF_TC_CLEANUP(_name, tc)  \
+{  \
+   CLEANUP_AFTER_TEST; \
 }
 
+RTM_DECLARE_ROOT_TEST(rtm_add_v6_ll_lle_success, "Tests addition of link-local 
IPv6 ND entry");
 ATF_TC_BODY(rtm_add_v6_ll_lle_success, tc)
 {
DECLARE_TEST_VARS;
@@ -134,7 +138,7 @@ ATF_TC_BODY(rtm_add_v6_ll_lle_success, tc)
 *  af=link len=54 sdl_index=3 if_name=tap4242 addr=52:54:00:14:E3:10
 */
 
-   rtm = rtsock_read_rtm(c->rtsock_fd, buffer, sizeof(buffer));
+   rtm = rtsock_read_rtm_reply(c->rtsock_fd, buffer, sizeof(buffer), 
rtm->rtm_seq);
 
sa = rtsock_find_rtm_sa(rtm, RTA_DST);
ret = sa_equal_msg(sa, (struct sockaddr *)&sin6, msg, sizeof(msg));
@@ -145,23 +149,15 @@ ATF_TC_BODY(rtm_add_v6_ll_lle_success, tc)
ret = sa_equal_msg_flags(sa, (struct sockaddr *)ðer, msg, 
sizeof(msg), sa_flags);
RTSOCK_ATF_REQUIRE_MSG(rtm, ret != 0, "GATEWAY sa diff: %s", msg);
 
+#if 0
+   /* Disable the check until https://reviews.freebsd.org/D22003 merge */
/* Some additional checks to verify kernel has filled in interface data 
*/
struct sockaddr_dl *sdl = (struct sockaddr_dl *)sa;
RTSOCK_ATF_REQUIRE_MSG(rtm, sdl->sdl_type > 0, "sdl_type not set");
+#endif
 }
 
-ATF_TC_CLEANUP(rtm_add_v6_ll_lle_success, tc)
-{
-   CLEANUP_AFTER_TEST;
-}
-
-ATF_TC_WITH_CLEANUP(rtm_add_v6_gu_lle_success);
-ATF_TC_HEAD(rtm_add_v6_gu_lle_success, tc)
-{
-
-   DESCRIBE_ROOT_TEST("Tests addition of global IPv6 ND entry");
-}
-
+RTM_DECLARE_ROOT_TEST(rtm_add_v6_gu_lle_success, "Tests addition of global 
IPv6 ND entry");
 ATF_TC_BODY(rtm_add_v6_gu_lle_success, tc)
 {
DECLARE_TEST_VARS;
@@ -194,7 +190,7 @@ ATF_TC_BODY(rtm_add_v6_gu_lle_success, tc)
 
/* XXX: where is uRPF?! this should fail */
 
-   rtm = rtsock_read_rtm(c->rtsock_fd, buffer, sizeof(buffer));
+   rtm = rtsock_read_rtm_reply(c->rtsock_fd, buffer, sizeof(buffer), 
rtm->rtm_seq);
 
sa = rtsock_find_rtm_sa(rtm, RTA_DST);
ret = sa_equal_msg(sa, (struct sockaddr *)&sin6, msg, sizeof(msg));
@@ -205,23 +201,15 @@ ATF_TC_BODY(rtm_add_v6_gu_lle_success, tc)
ret = sa_equal_msg_flags(sa, (struct sockaddr *)ðer, msg, 
sizeof(msg), sa_flags);
RTSOCK_ATF_REQUIRE_MSG(rtm, ret != 0, "GATEWAY sa diff: %s", msg);
 
+#if 0
+   /* Disable the check until https://reviews.freebsd.org/D22003 merge */
/* Some additional checks to verify kernel has filled in interface data 
*/
struct sockaddr_dl *sdl = (struct sockaddr_dl *)sa;
RTSOCK_ATF_REQUIRE_MSG(rtm, sdl->sdl_type > 0, "sdl_type not set");
+#endif
 }
 
-ATF_TC_CLEANUP(rtm_add_v6_gu_lle_success, tc)
-{
-   CLEANUP_AFTER_TEST;
-}
-
-ATF_TC_WITH_CLEANUP(rtm_add_v4_gu_lle_success);
-ATF_TC_HEAD(rtm_add_v4_gu_lle_success, tc)
-{
-
-   DESCRIBE_ROOT_TEST("Tests addition of IPv4 ARP entry");
-}
-
+RTM_DECLARE_ROOT_TEST(rtm_add_v4_gu_lle_success, "Tests addition of IPv4 ARP 
entry");
 ATF_TC_BODY(rtm_add_v4_gu_lle_success, tc)
 {
DECLARE_TEST_VARS;
@@ -250,7 +238,7 @@ ATF_TC_BODY(rtm_add_v4_gu_lle_success, tc)
 *  af=link len=54 sdl_index=3 if_name=tap4242 addr=52:54:00:14:E3:10
 */
 
-   rtm = rtsock_read_rtm(c->rtsock_fd, buffer, sizeof(buffer));
+   rtm = rtsock_read_rtm_reply(c->rtsock_fd, buff

Re: svn commit: r357833 - head/tests/sys/pjdfstest/tests

2020-02-12 Thread Enji Cooper
On Wed, Feb 12, 2020 at 9:37 AM Ed Maste  wrote:
>
> Author: emaste
> Date: Wed Feb 12 17:37:32 2020
> New Revision: 357833
> URL: https://svnweb.freebsd.org/changeset/base/357833
>
> Log:
>   Tag pjdfstest symlink with pkgbase package
>
>   As with the rest of pjdfstest, tag the symlink with package=tests.
>   The tests -> . symlink seems a little strange but that's independent
>   of pkgbase.

Sidenote: the reason for the symlink was to facilitate integrating the
test suite without having to completely refactor the code.
Thanks,
-Enji
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357842 - head/sys/netipsec

2020-02-12 Thread Mateusz Guzik
Author: mjg
Date: Wed Feb 12 20:18:29 2020
New Revision: 357842
URL: https://svnweb.freebsd.org/changeset/base/357842

Log:
  netipsec: fix a mismatched uma_zfree -> uma_zfree_pcpu
  
  PR:   244077
  Reported by:  lwhsu
  Fixes: r357805 ("amd64: store per-cpu allocations subtracted by __pcpu")

Modified:
  head/sys/netipsec/key.c

Modified: head/sys/netipsec/key.c
==
--- head/sys/netipsec/key.c Wed Feb 12 20:06:41 2020(r357841)
+++ head/sys/netipsec/key.c Wed Feb 12 20:18:29 2020(r357842)
@@ -3128,7 +3128,7 @@ key_delsav(struct secasvar *sav)
if ((sav->flags & SADB_X_EXT_F_CLONED) == 0) {
mtx_destroy(sav->lock);
free(sav->lock, M_IPSEC_MISC);
-   uma_zfree(V_key_lft_zone, sav->lft_c);
+   uma_zfree_pcpu(V_key_lft_zone, sav->lft_c);
}
free(sav, M_IPSEC_SA);
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357841 - head/usr.bin/diff

2020-02-12 Thread Mateusz Piotrowski
Author: 0mp (doc,ports committer)
Date: Wed Feb 12 20:06:41 2020
New Revision: 357841
URL: https://svnweb.freebsd.org/changeset/base/357841

Log:
  diff.1: Fix style & document -y as extension to POSIX
  
  - Long options must be stylized with the Fl macro as well.
  
  Reviewed by:  bapt
  Approved by:  bcr (mentor)
  Differential Revision:https://reviews.freebsd.org/D23642

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

Modified: head/usr.bin/diff/diff.1
==
--- head/usr.bin/diff/diff.1Wed Feb 12 19:06:34 2020(r357840)
+++ head/usr.bin/diff/diff.1Wed Feb 12 20:06:41 2020(r357841)
@@ -30,7 +30,7 @@
 .\" @(#)diff.1 8.1 (Berkeley) 6/30/93
 .\" $FreeBSD$
 .\"
-.Dd February 7, 2020
+.Dd February 12, 2020
 .Dt DIFF 1
 .Os
 .Sh NAME
@@ -184,17 +184,17 @@
 .Ar dir1 dir2
 .Nm diff
 .Op Fl aBbditwW
-.Op --expand-tabs
-.Op --ignore-all-blanks
-.Op --ignore-blank-lines
-.Op --ignore-case
-.Op --minimal
-.Op --no-ignore-file-name-case
-.Op --strip-trailing-cr
-.Op --suppress-common-lines
-.Op --tabsize
-.Op --text
-.Op --width
+.Op Fl -expand-tabs
+.Op Fl -ignore-all-blanks
+.Op Fl -ignore-blank-lines
+.Op Fl -ignore-case
+.Op Fl -minimal
+.Op Fl -no-ignore-file-name-case
+.Op Fl -strip-trailing-cr
+.Op Fl -suppress-common-lines
+.Op Fl -tabsize
+.Op Fl -text
+.Op Fl -width
 .Fl y | Fl -side-by-side
 .Ar file1 file2
 .Sh DESCRIPTION
@@ -637,7 +637,7 @@ utility is compliant with the
 specification.
 .Pp
 The flags
-.Op Fl aDdIiLlNnPpqSsTtwXx
+.Op Fl aDdIiLlNnPpqSsTtwXxy
 are extensions to that specification.
 .Sh HISTORY
 A
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357840 - head/sys/kern

2020-02-12 Thread Kyle Evans
Author: kevans
Date: Wed Feb 12 19:06:34 2020
New Revision: 357840
URL: https://svnweb.freebsd.org/changeset/base/357840

Log:
  sys/kern sysent: re-add dependency on capabilities.conf
  
  r356868 inadvertently removed this, so changes to capabilities.conf were no
  longer considered for being outdated.

Modified:
  head/sys/kern/Makefile

Modified: head/sys/kern/Makefile
==
--- head/sys/kern/Makefile  Wed Feb 12 19:05:10 2020(r357839)
+++ head/sys/kern/Makefile  Wed Feb 12 19:06:34 2020(r357840)
@@ -3,6 +3,7 @@
 #
 # Makefile for init_sysent
 
+SRCS+= capabilities.conf
 SYSENT_CONF=
 GENERATED= init_sysent.c   \
syscalls.c  \
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357839 - in head/sys: compat/freebsd32 kern

2020-02-12 Thread Ed Maste
Author: emaste
Date: Wed Feb 12 19:05:10 2020
New Revision: 357839
URL: https://svnweb.freebsd.org/changeset/base/357839

Log:
  regen sysent after r357831, r357838
  
  Capability mode changes allowing fdatasync and getloginclass.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/compat/freebsd32/freebsd32_sysent.c
  head/sys/kern/init_sysent.c

Modified: head/sys/compat/freebsd32/freebsd32_sysent.c
==
--- head/sys/compat/freebsd32/freebsd32_sysent.cWed Feb 12 18:59:00 
2020(r357838)
+++ head/sys/compat/freebsd32/freebsd32_sysent.cWed Feb 12 19:05:10 
2020(r357839)
@@ -598,7 +598,7 @@ struct sysent freebsd32_sysent[] = {
{ AS(pdgetpid_args), (sy_call_t *)sys_pdgetpid, AUE_PDGETPID, NULL, 0, 
0, SYF_CAPENABLED, SY_THR_STATIC },  /* 520 = pdgetpid */
{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT },  
/* 521 = pdwait4 */
{ AS(freebsd32_pselect_args), (sy_call_t *)freebsd32_pselect, 
AUE_SELECT, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC },  /* 522 = 
freebsd32_pselect */
-   { AS(getloginclass_args), (sy_call_t *)sys_getloginclass, 
AUE_GETLOGINCLASS, NULL, 0, 0, 0, SY_THR_STATIC },/* 523 = getloginclass */
+   { AS(getloginclass_args), (sy_call_t *)sys_getloginclass, 
AUE_GETLOGINCLASS, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC },   /* 523 = 
getloginclass */
{ AS(setloginclass_args), (sy_call_t *)sys_setloginclass, 
AUE_SETLOGINCLASS, NULL, 0, 0, 0, SY_THR_STATIC },/* 524 = setloginclass */
{ AS(rctl_get_racct_args), (sy_call_t *)sys_rctl_get_racct, AUE_NULL, 
NULL, 0, 0, 0, SY_THR_STATIC },   /* 525 = rctl_get_racct */
{ AS(rctl_get_rules_args), (sy_call_t *)sys_rctl_get_rules, AUE_NULL, 
NULL, 0, 0, 0, SY_THR_STATIC },   /* 526 = rctl_get_rules */
@@ -635,7 +635,7 @@ struct sysent freebsd32_sysent[] = {
{ AS(freebsd32_utimensat_args), (sy_call_t *)freebsd32_utimensat, 
AUE_FUTIMESAT, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC },   /* 547 = 
freebsd32_utimensat */
{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT },  
/* 548 = obsolete numa_getaffinity */
{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT },  
/* 549 = obsolete numa_setaffinity */
-   { AS(fdatasync_args), (sy_call_t *)sys_fdatasync, AUE_FSYNC, NULL, 0, 
0, 0, SY_THR_STATIC },/* 550 = fdatasync */
+   { AS(fdatasync_args), (sy_call_t *)sys_fdatasync, AUE_FSYNC, NULL, 0, 
0, SYF_CAPENABLED, SY_THR_STATIC },   /* 550 = fdatasync */
{ AS(freebsd32_fstat_args), (sy_call_t *)freebsd32_fstat, AUE_FSTAT, 
NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC },   /* 551 = freebsd32_fstat */
{ AS(freebsd32_fstatat_args), (sy_call_t *)freebsd32_fstatat, 
AUE_FSTATAT, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 552 = 
freebsd32_fstatat */
{ AS(freebsd32_fhstat_args), (sy_call_t *)freebsd32_fhstat, AUE_FHSTAT, 
NULL, 0, 0, 0, SY_THR_STATIC }, /* 553 = freebsd32_fhstat */

Modified: head/sys/kern/init_sysent.c
==
--- head/sys/kern/init_sysent.c Wed Feb 12 18:59:00 2020(r357838)
+++ head/sys/kern/init_sysent.c Wed Feb 12 19:05:10 2020(r357839)
@@ -578,7 +578,7 @@ struct sysent sysent[] = {
{ AS(pdgetpid_args), (sy_call_t *)sys_pdgetpid, AUE_PDGETPID, NULL, 0, 
0, SYF_CAPENABLED, SY_THR_STATIC },  /* 520 = pdgetpid */
{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT },  
/* 521 = pdwait4 */
{ AS(pselect_args), (sy_call_t *)sys_pselect, AUE_SELECT, NULL, 0, 0, 
SYF_CAPENABLED, SY_THR_STATIC },  /* 522 = pselect */
-   { AS(getloginclass_args), (sy_call_t *)sys_getloginclass, 
AUE_GETLOGINCLASS, NULL, 0, 0, 0, SY_THR_STATIC },/* 523 = getloginclass */
+   { AS(getloginclass_args), (sy_call_t *)sys_getloginclass, 
AUE_GETLOGINCLASS, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC },   /* 523 = 
getloginclass */
{ AS(setloginclass_args), (sy_call_t *)sys_setloginclass, 
AUE_SETLOGINCLASS, NULL, 0, 0, 0, SY_THR_STATIC },/* 524 = setloginclass */
{ AS(rctl_get_racct_args), (sy_call_t *)sys_rctl_get_racct, AUE_NULL, 
NULL, 0, 0, 0, SY_THR_STATIC },   /* 525 = rctl_get_racct */
{ AS(rctl_get_rules_args), (sy_call_t *)sys_rctl_get_rules, AUE_NULL, 
NULL, 0, 0, 0, SY_THR_STATIC },   /* 526 = rctl_get_rules */
@@ -605,7 +605,7 @@ struct sysent sysent[] = {
{ AS(utimensat_args), (sy_call_t *)sys_utimensat, AUE_FUTIMESAT, NULL, 
0, 0, SYF_CAPENABLED, SY_THR_STATIC },   /* 547 = utimensat */
{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT },  
/* 548 = obsolete numa_getaffinity */
{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT },  
   

svn commit: r357838 - head/sys/kern

2020-02-12 Thread Ed Maste
Author: emaste
Date: Wed Feb 12 18:59:00 2020
New Revision: 357838
URL: https://svnweb.freebsd.org/changeset/base/357838

Log:
  Allow getloginclass in capability mode
  
  As with e.g. getgroups and getlogin it allows querying current process
  credential state.
  
  Reported by:  sig...@gmail.com via kevans
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/kern/capabilities.conf

Modified: head/sys/kern/capabilities.conf
==
--- head/sys/kern/capabilities.conf Wed Feb 12 18:48:39 2020
(r357837)
+++ head/sys/kern/capabilities.conf Wed Feb 12 18:59:00 2020
(r357838)
@@ -288,6 +288,7 @@ getitimer
 getgid
 getgroups
 getlogin
+getloginclass
 
 ##
 ## Allow querying certain trivial global state.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357837 - stable/11/lib/libc/gen

2020-02-12 Thread Brooks Davis
Author: brooks
Date: Wed Feb 12 18:48:39 2020
New Revision: 357837
URL: https://svnweb.freebsd.org/changeset/base/357837

Log:
  MFC r356942:
  
  Correct a misleading indent.
  
  This dates to before the beginning of our repo and was found by clang 10.
  
  Sponsored by: DARPA

Modified:
  stable/11/lib/libc/gen/ualarm.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/lib/libc/gen/ualarm.c
==
--- stable/11/lib/libc/gen/ualarm.c Wed Feb 12 18:40:29 2020
(r357836)
+++ stable/11/lib/libc/gen/ualarm.c Wed Feb 12 18:48:39 2020
(r357837)
@@ -56,6 +56,5 @@ ualarm(useconds_t usecs, useconds_t reload)
 
if (setitimer(ITIMER_REAL, &new, &old) == 0)
return (old.it_value.tv_sec * USPS + old.it_value.tv_usec);
-   /* else */
-   return (-1);
+   return (-1);
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357836 - stable/12/lib/libc/gen

2020-02-12 Thread Brooks Davis
Author: brooks
Date: Wed Feb 12 18:40:29 2020
New Revision: 357836
URL: https://svnweb.freebsd.org/changeset/base/357836

Log:
  MFC r356942:
  
  Correct a misleading indent.
  
  This dates to before the beginning of our repo and was found by clang 10.
  
  Sponsored by: DARPA

Modified:
  stable/12/lib/libc/gen/ualarm.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/lib/libc/gen/ualarm.c
==
--- stable/12/lib/libc/gen/ualarm.c Wed Feb 12 18:11:07 2020
(r357835)
+++ stable/12/lib/libc/gen/ualarm.c Wed Feb 12 18:40:29 2020
(r357836)
@@ -56,6 +56,5 @@ ualarm(useconds_t usecs, useconds_t reload)
 
if (setitimer(ITIMER_REAL, &new, &old) == 0)
return (old.it_value.tv_sec * USPS + old.it_value.tv_usec);
-   /* else */
-   return (-1);
+   return (-1);
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357835 - head/tests/sys/fs/fusefs

2020-02-12 Thread Alan Somers
Author: asomers
Date: Wed Feb 12 18:11:07 2020
New Revision: 357835
URL: https://svnweb.freebsd.org/changeset/base/357835

Log:
  fusefs: fix some memory leaks in the tests.
  
  Oddly, most of these were not detected by Coverity.
  
  Reported by:  Coverity (one of them, anyway)
  Coverity CID: 1404490
  MFC after:2 weeks

Modified:
  head/tests/sys/fs/fusefs/read.cc
  head/tests/sys/fs/fusefs/write.cc

Modified: head/tests/sys/fs/fusefs/read.cc
==
--- head/tests/sys/fs/fusefs/read.ccWed Feb 12 18:09:20 2020
(r357834)
+++ head/tests/sys/fs/fusefs/read.ccWed Feb 12 18:11:07 2020
(r357835)
@@ -778,6 +778,7 @@ TEST_F(Read, cache_block)
ASSERT_EQ(bufsize, read(fd, buf, bufsize)) << strerror(errno);
ASSERT_EQ(0, memcmp(buf, contents1, bufsize));
leak(fd);
+   free(contents);
 }
 
 /* Reading with sendfile should work (though it obviously won't be 0-copy) */
@@ -899,6 +900,8 @@ TEST_P(ReadAhead, readahead) {
ASSERT_EQ(0, memcmp(rbuf, contents, bufsize));
 
leak(fd);
+   free(rbuf);
+   free(contents);
 }
 
 INSTANTIATE_TEST_CASE_P(RA, ReadAhead,

Modified: head/tests/sys/fs/fusefs/write.cc
==
--- head/tests/sys/fs/fusefs/write.cc   Wed Feb 12 18:09:20 2020
(r357834)
+++ head/tests/sys/fs/fusefs/write.cc   Wed Feb 12 18:11:07 2020
(r357835)
@@ -300,6 +300,8 @@ TEST_F(Write, append_to_cached)
/* Write the new data.  There should be no more read operations */
ASSERT_EQ(BUFSIZE, write(fd, CONTENTS, BUFSIZE)) << strerror(errno);
leak(fd);
+   free(oldbuf);
+   free(oldcontents);
 }
 
 TEST_F(Write, append_direct_io)
@@ -782,6 +784,8 @@ TEST_F(WriteCluster, clustering)
<< strerror(errno);
}
close(fd);
+   free(wbuf2x);
+   free(wbuf);
 }
 
 /* 
@@ -825,6 +829,7 @@ TEST_F(WriteCluster, DISABLED_cluster_write_err)
<< strerror(errno);
}
close(fd);
+   free(wbuf);
 }
 
 /*
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357834 - in head: . share/mk

2020-02-12 Thread Brooks Davis
Author: brooks
Date: Wed Feb 12 18:09:20 2020
New Revision: 357834
URL: https://svnweb.freebsd.org/changeset/base/357834

Log:
  Make the warning for deprecated NO_ variables an error.
  
  Support for NO_CTF, NO_DEBUG_FILES, NO_INSTALLLIB, NO_MAN, NO_PROFILE,
  and NO_WARNS as deprecated in 2014 with a warning added for each one
  found. Turn these into error in preperation for removal of compatability
  support before FreeBSD 13.
  
  This was previously committed in r354909 and reverted in r355011 due to
  unforseen impacts on ports.  I've since corrected all amd64 and i386
  ports reported in prior runs as well as instance of these variables I
  found via grep.

Modified:
  head/UPDATING
  head/share/mk/bsd.opts.mk

Modified: head/UPDATING
==
--- head/UPDATING   Wed Feb 12 17:37:32 2020(r357833)
+++ head/UPDATING   Wed Feb 12 18:09:20 2020(r357834)
@@ -26,6 +26,14 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 13.x IS SLOW:
disable the most expensive debugging functionality run
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
 
+20200212:
+   Defining the long deprecated NO_CTF, NO_DEBUG_FILES, NO_INSTALLLIB,
+   NO_MAN, NO_PROFILE, and NO_WARNS variables is now an error.  Update
+   your Makefiles and scripts to define MK_=no instead as required.
+
+   One exception to this is that program or library Makefiles should
+   define MAN to empty rather than setting MK_MAN=no.
+
 20200108:
Clang/LLVM is now the default compiler and LLD the default
linker for riscv64.

Modified: head/share/mk/bsd.opts.mk
==
--- head/share/mk/bsd.opts.mk   Wed Feb 12 17:37:32 2020(r357833)
+++ head/share/mk/bsd.opts.mk   Wed Feb 12 18:09:20 2020(r357834)
@@ -100,7 +100,7 @@ __DEFAULT_DEPENDENT_OPTIONS = \
 PROFILE \
 WARNS
 .if defined(NO_${var})
-.warning "NO_${var} is defined, but deprecated. Please use MK_${var}=no 
instead."
+.error "NO_${var} is defined, but deprecated. Please use MK_${var}=no instead."
 MK_${var}:=no
 .endif
 .endfor
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r357805 - head/sys/amd64/include

2020-02-12 Thread Mateusz Guzik
On 2/12/20, Gleb Smirnoff  wrote:
> On Wed, Feb 12, 2020 at 11:12:14AM +, Mateusz Guzik wrote:
> M> Author: mjg
> M> Date: Wed Feb 12 11:12:13 2020
> M> New Revision: 357805
> M> URL: https://svnweb.freebsd.org/changeset/base/357805
> M>
> M> Log:
> M>   amd64: store per-cpu allocations subtracted by __pcpu
> M>
> M>   This eliminates a runtime subtraction from counter_u64_add.
> M>
> M>   before:
> M>   mov0x4f00ed(%rip),%rax# 0x80c01788
> 
> M>   sub0x808ff6(%rip),%rax# 0x80f1a698 <__pcpu>
> M>   addq   $0x1,%gs:(%rax)
> M>
> M>   after:
> M>   mov0x4f02fd(%rip),%rax# 0x80c01788
> 
> M>   addq   $0x1,%gs:(%rax)
> M>
> M>   Reviewed by: jeff
> M>   Differential Revision:   https://reviews.freebsd.org/D23570
>
> Neat optimization! Thanks. Why didn't we do it back when created counter?
>

Don't look at me, I did not work on it.

You can top it for counters like the above -- most actual counters are
known to be there at compilatin time and they never disappear. Meaning
that in the simplest case they can just be a part of one big array in
struct pcpu. Then assembly could resort to addq $0x1,%gs:(someoffset)
removing the mov loading the address -- faster single threaded and less
cache use.

I'm confident I noted this at least few times.

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


svn commit: r357833 - head/tests/sys/pjdfstest/tests

2020-02-12 Thread Ed Maste
Author: emaste
Date: Wed Feb 12 17:37:32 2020
New Revision: 357833
URL: https://svnweb.freebsd.org/changeset/base/357833

Log:
  Tag pjdfstest symlink with pkgbase package
  
  As with the rest of pjdfstest, tag the symlink with package=tests.
  The tests -> . symlink seems a little strange but that's independent
  of pkgbase.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  head/tests/sys/pjdfstest/tests/Makefile

Modified: head/tests/sys/pjdfstest/tests/Makefile
==
--- head/tests/sys/pjdfstest/tests/Makefile Wed Feb 12 17:30:09 2020
(r357832)
+++ head/tests/sys/pjdfstest/tests/Makefile Wed Feb 12 17:37:32 2020
(r357833)
@@ -18,7 +18,7 @@ misc.sh: ${PJDFSTEST_SRCDIR}/tests/misc.sh
 afterinstall: install-tests-symlink
 install-tests-symlink: .PHONY
rm -f ${DESTDIR}${TESTSDIR}/tests
-   ${INSTALL_SYMLINK} . ${DESTDIR}${TESTSDIR}/tests
+   ${INSTALL_SYMLINK} -T "package=tests" . ${DESTDIR}${TESTSDIR}/tests
 
 TESTS_SUBDIRS= chflags
 TESTS_SUBDIRS+=chmod
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357832 - head/usr.sbin/rmt

2020-02-12 Thread Ed Maste
Author: emaste
Date: Wed Feb 12 17:30:09 2020
New Revision: 357832
URL: https://svnweb.freebsd.org/changeset/base/357832

Log:
  tag /etc/rmt symlink with pkgbase package
  
  For historical reasons the "remote magtape protocol module" rmt gets
  invoked as /etc/rmt, which is a symlink to /usr/sbin/rmt.  Put it in the
  utilities package, as /usr/sbin/rmt is.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  head/usr.sbin/rmt/Makefile

Modified: head/usr.sbin/rmt/Makefile
==
--- head/usr.sbin/rmt/Makefile  Wed Feb 12 17:12:26 2020(r357831)
+++ head/usr.sbin/rmt/Makefile  Wed Feb 12 17:30:09 2020(r357832)
@@ -7,6 +7,7 @@ MAN=rmt.8
 # called from /usr/src/etc/Makefile
 etc-rmt:
rm -f ${DESTDIR}/etc/rmt
-   ${INSTALL_RSYMLINK} ..${BINDIR}/rmt ${DESTDIR}/etc/rmt
+   ${INSTALL_RSYMLINK} -T "package=utilities" \
+   ..${BINDIR}/rmt ${DESTDIR}/etc/rmt
 
 .include 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r357805 - head/sys/amd64/include

2020-02-12 Thread Gleb Smirnoff
On Wed, Feb 12, 2020 at 11:12:14AM +, Mateusz Guzik wrote:
M> Author: mjg
M> Date: Wed Feb 12 11:12:13 2020
M> New Revision: 357805
M> URL: https://svnweb.freebsd.org/changeset/base/357805
M> 
M> Log:
M>   amd64: store per-cpu allocations subtracted by __pcpu
M>   
M>   This eliminates a runtime subtraction from counter_u64_add.
M>   
M>   before:
M>   mov0x4f00ed(%rip),%rax# 0x80c01788 
M>   sub0x808ff6(%rip),%rax# 0x80f1a698 <__pcpu>
M>   addq   $0x1,%gs:(%rax)
M>   
M>   after:
M>   mov0x4f02fd(%rip),%rax# 0x80c01788 
M>   addq   $0x1,%gs:(%rax)
M>   
M>   Reviewed by:   jeff
M>   Differential Revision: https://reviews.freebsd.org/D23570

Neat optimization! Thanks. Why didn't we do it back when created counter?

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


svn commit: r357831 - head/sys/kern

2020-02-12 Thread Ed Maste
Author: emaste
Date: Wed Feb 12 17:12:26 2020
New Revision: 357831
URL: https://svnweb.freebsd.org/changeset/base/357831

Log:
  Allow fdatasync in capability mode
  
  fdatasync is essentially a subset of fsync (and may be exactly fsync,
  depending on filesystem and development effort) and operates only on
  a provided fd.
  
  MFC after:1 week
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/kern/capabilities.conf

Modified: head/sys/kern/capabilities.conf
==
--- head/sys/kern/capabilities.conf Wed Feb 12 17:05:10 2020
(r357830)
+++ head/sys/kern/capabilities.conf Wed Feb 12 17:12:26 2020
(r357831)
@@ -224,6 +224,7 @@ fstatfs
 ## Allow further file descriptor-based I/O operations, subject to capability
 ## rights.
 ##
+fdatasync
 fsync
 ftruncate
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357830 - head/sys/netinet

2020-02-12 Thread Michael Tuexen
Author: tuexen
Date: Wed Feb 12 17:05:10 2020
New Revision: 357830
URL: https://svnweb.freebsd.org/changeset/base/357830

Log:
  Don't panic under INVARIANTS when we can't allocate memory for storing
  a vtag in time wait.
  This issue was found by running syzkaller.
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctp_pcb.c

Modified: head/sys/netinet/sctp_pcb.c
==
--- head/sys/netinet/sctp_pcb.c Wed Feb 12 17:02:15 2020(r357829)
+++ head/sys/netinet/sctp_pcb.c Wed Feb 12 17:05:10 2020(r357830)
@@ -4634,9 +4634,6 @@ sctp_add_vtag_to_timewait(uint32_t tag, uint32_t time,
SCTP_MALLOC(twait_block, struct sctp_tagblock *,
sizeof(struct sctp_tagblock), SCTP_M_TIMW);
if (twait_block == NULL) {
-#ifdef INVARIANTS
-   panic("Can not alloc tagblock");
-#endif
return;
}
memset(twait_block, 0, sizeof(struct sctp_tagblock));
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357829 - head/sys/netinet

2020-02-12 Thread Michael Tuexen
Author: tuexen
Date: Wed Feb 12 17:02:15 2020
New Revision: 357829
URL: https://svnweb.freebsd.org/changeset/base/357829

Log:
  Mark the socket as disconnected when freeing the association the first
  time.
  This issue was found by running syzkaller.
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctp_pcb.c

Modified: head/sys/netinet/sctp_pcb.c
==
--- head/sys/netinet/sctp_pcb.c Wed Feb 12 16:10:00 2020(r357828)
+++ head/sys/netinet/sctp_pcb.c Wed Feb 12 17:02:15 2020(r357829)
@@ -4744,6 +4744,31 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tc
else
so = inp->sctp_socket;
 
+   if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
+   (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) {
+   /*
+* For TCP type we need special handling when we are
+* connected. We also include the peel'ed off ones to.
+*/
+   if (inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED) {
+   inp->sctp_flags &= ~SCTP_PCB_FLAGS_CONNECTED;
+   inp->sctp_flags |= SCTP_PCB_FLAGS_WAS_CONNECTED;
+   if (so) {
+   SOCKBUF_LOCK(&so->so_rcv);
+   so->so_state &= ~(SS_ISCONNECTING |
+   SS_ISDISCONNECTING |
+   SS_ISCONFIRMING |
+   SS_ISCONNECTED);
+   so->so_state |= SS_ISDISCONNECTED;
+   socantrcvmore_locked(so);
+   socantsendmore(so);
+   sctp_sowwakeup(inp, so);
+   sctp_sorwakeup(inp, so);
+   SCTP_SOWAKEUP(so);
+   }
+   }
+   }
+
/*
 * We used timer based freeing if a reader or writer is in the way.
 * So we first check if we are actually being called from a timer,
@@ -4870,31 +4895,6 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tc
(inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE))
/* nothing around */
so = NULL;
-
-   if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
-   (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) {
-   /*
-* For TCP type we need special handling when we are
-* connected. We also include the peel'ed off ones to.
-*/
-   if (inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED) {
-   inp->sctp_flags &= ~SCTP_PCB_FLAGS_CONNECTED;
-   inp->sctp_flags |= SCTP_PCB_FLAGS_WAS_CONNECTED;
-   if (so) {
-   SOCKBUF_LOCK(&so->so_rcv);
-   so->so_state &= ~(SS_ISCONNECTING |
-   SS_ISDISCONNECTING |
-   SS_ISCONFIRMING |
-   SS_ISCONNECTED);
-   so->so_state |= SS_ISDISCONNECTED;
-   socantrcvmore_locked(so);
-   socantsendmore(so);
-   sctp_sowwakeup(inp, so);
-   sctp_sorwakeup(inp, so);
-   SCTP_SOWAKEUP(so);
-   }
-   }
-   }
 
/*
 * Make it invalid too, that way if its about to run it will abort
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357828 - head/stand/common

2020-02-12 Thread Kyle Evans
Author: kevans
Date: Wed Feb 12 16:10:00 2020
New Revision: 357828
URL: https://svnweb.freebsd.org/changeset/base/357828

Log:
  interp_lua: fix bogus indentation, NFC

Modified:
  head/stand/common/interp_lua.c

Modified: head/stand/common/interp_lua.c
==
--- head/stand/common/interp_lua.c  Wed Feb 12 16:09:01 2020
(r357827)
+++ head/stand/common/interp_lua.c  Wed Feb 12 16:10:00 2020
(r357828)
@@ -124,10 +124,10 @@ interp_init(void)
 
filename = LOADER_LUA;
if (interp_include(filename) != 0) {
-const char *errstr = lua_tostring(luap, -1);
-errstr = errstr == NULL ? "unknown" : errstr;
-printf("Startup error in %s:\nLUA ERROR: %s.\n", filename, 
errstr);
-lua_pop(luap, 1);
+   const char *errstr = lua_tostring(luap, -1);
+   errstr = errstr == NULL ? "unknown" : errstr;
+   printf("Startup error in %s:\nLUA ERROR: %s.\n", filename, 
errstr);
+   lua_pop(luap, 1);
setenv("autoboot_delay", "NO", 1);
}
 }
@@ -144,7 +144,7 @@ interp_run(const char *line)
luap = softc->luap;
LDBG("executing line...");
if ((status = luaL_dostring(luap, line)) != 0) {
-lua_pop(luap, 1);
+   lua_pop(luap, 1);
/*
 * The line wasn't executable as lua; run it through parse to
 * to get consistent parsing of command line arguments, then
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357827 - head/stand/common

2020-02-12 Thread Kyle Evans
Author: kevans
Date: Wed Feb 12 16:09:01 2020
New Revision: 357827
URL: https://svnweb.freebsd.org/changeset/base/357827

Log:
  lualoader: disable autoboot on high-level interpreter errors
  
  If we hit an error at this level, we are almost certainly not in any kind
  of sane state where autoboot can do the right thing. Instead of letting it
  try and probably failing, disable autoboot so they immediately get kicked
  into a loader prompt for manual remediation/diagnosis.
  
  Reviewed by:  tsoome
  MFC after:3 days
  Differential Revision:https://reviews.freebsd.org/D23611

Modified:
  head/stand/common/interp_lua.c

Modified: head/stand/common/interp_lua.c
==
--- head/stand/common/interp_lua.c  Wed Feb 12 15:59:59 2020
(r357826)
+++ head/stand/common/interp_lua.c  Wed Feb 12 16:09:01 2020
(r357827)
@@ -128,6 +128,7 @@ interp_init(void)
 errstr = errstr == NULL ? "unknown" : errstr;
 printf("Startup error in %s:\nLUA ERROR: %s.\n", filename, 
errstr);
 lua_pop(luap, 1);
+   setenv("autoboot_delay", "NO", 1);
}
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357826 - in head/contrib/elftoolchain: elfcopy libelftc

2020-02-12 Thread Ed Maste
Author: emaste
Date: Wed Feb 12 15:59:59 2020
New Revision: 357826
URL: https://svnweb.freebsd.org/changeset/base/357826

Log:
  elfcopy: set ELF OS/ABI field when converting from binary
  
  PR:   228934
  Submitted by: Tiger Gao 
  Reviewed by:  markj, jkoshy
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D23504

Modified:
  head/contrib/elftoolchain/elfcopy/main.c
  head/contrib/elftoolchain/libelftc/elftc.3
  head/contrib/elftoolchain/libelftc/elftc_bfd_find_target.3
  head/contrib/elftoolchain/libelftc/elftc_bfdtarget.c
  head/contrib/elftoolchain/libelftc/libelftc.h

Modified: head/contrib/elftoolchain/elfcopy/main.c
==
--- head/contrib/elftoolchain/elfcopy/main.cWed Feb 12 15:51:29 2020
(r357825)
+++ head/contrib/elftoolchain/elfcopy/main.cWed Feb 12 15:59:59 2020
(r357826)
@@ -1394,6 +1394,7 @@ set_output_target(struct elfcopy *ecp, const char *tar
ecp->oec = elftc_bfd_target_class(tgt);
ecp->oed = elftc_bfd_target_byteorder(tgt);
ecp->oem = elftc_bfd_target_machine(tgt);
+   ecp->abi = elftc_bfd_target_osabi(tgt);
}
if (ecp->otf == ETF_EFI || ecp->otf == ETF_PE)
ecp->oem = elftc_bfd_target_machine(tgt);

Modified: head/contrib/elftoolchain/libelftc/elftc.3
==
--- head/contrib/elftoolchain/libelftc/elftc.3  Wed Feb 12 15:51:29 2020
(r357825)
+++ head/contrib/elftoolchain/libelftc/elftc.3  Wed Feb 12 15:59:59 2020
(r357826)
@@ -23,7 +23,7 @@
 .\"
 .\" $Id: elftc.3 3645 2018-10-15 20:17:14Z jkoshy $
 .\"
-.Dd December 24, 2012
+.Dd February 12, 2020
 .Dt ELFTC 3
 .Os
 .Sh NAME
@@ -57,6 +57,8 @@ Query the byte order for a binary object descriptor.
 Query the object format for a binary object descriptor.
 .It Fn elftc_bfd_target_machine
 Query the target machine for a binary object descriptor.
+.It Fn elftc_bfd_target_osabi
+Query the target osabi for a binary object descriptor.
 .El
 .It "C++ support"
 .Bl -tag -compact -width indent

Modified: head/contrib/elftoolchain/libelftc/elftc_bfd_find_target.3
==
--- head/contrib/elftoolchain/libelftc/elftc_bfd_find_target.3  Wed Feb 12 
15:51:29 2020(r357825)
+++ head/contrib/elftoolchain/libelftc/elftc_bfd_find_target.3  Wed Feb 12 
15:59:59 2020(r357826)
@@ -23,7 +23,7 @@
 .\"
 .\" $Id: elftc_bfd_find_target.3 3752 2019-06-28 01:12:53Z emaste $
 .\"
-.Dd June 27, 2019
+.Dd February 12, 2020
 .Dt ELFTC_BFD_FIND_TARGET 3
 .Os
 .Sh NAME
@@ -48,6 +48,8 @@
 .Fn elftc_bfd_target_flavor "Elftc_Bfd_Target *target"
 .Ft "unsigned int"
 .Fn elftc_bfd_target_machine "Elftc_Bfd_Target *target"
+.Ft "unsigned int"
+.Fn elftc_bfd_target_osabi "Elftc_Bfd_Target *target"
 .Sh DESCRIPTION
 Function
 .Fn elftc_bfd_find_target

Modified: head/contrib/elftoolchain/libelftc/elftc_bfdtarget.c
==
--- head/contrib/elftoolchain/libelftc/elftc_bfdtarget.cWed Feb 12 
15:51:29 2020(r357825)
+++ head/contrib/elftoolchain/libelftc/elftc_bfdtarget.cWed Feb 12 
15:59:59 2020(r357826)
@@ -71,3 +71,10 @@ elftc_bfd_target_machine(Elftc_Bfd_Target *tgt)
 
return (tgt->bt_machine);
 }
+
+unsigned int
+elftc_bfd_target_osabi(Elftc_Bfd_Target *tgt)
+{
+
+   return (tgt->bt_osabi);
+}

Modified: head/contrib/elftoolchain/libelftc/libelftc.h
==
--- head/contrib/elftoolchain/libelftc/libelftc.h   Wed Feb 12 15:51:29 
2020(r357825)
+++ head/contrib/elftoolchain/libelftc/libelftc.h   Wed Feb 12 15:59:59 
2020(r357826)
@@ -72,6 +72,7 @@ Elftc_Bfd_Target_Flavorelftc_bfd_target_flavor(Elftc
 unsigned int   elftc_bfd_target_byteorder(Elftc_Bfd_Target *_tgt);
 unsigned int   elftc_bfd_target_class(Elftc_Bfd_Target *_tgt);
 unsigned int   elftc_bfd_target_machine(Elftc_Bfd_Target *_tgt);
+unsigned int   elftc_bfd_target_osabi(Elftc_Bfd_Target *_tgt);
 intelftc_copyfile(int _srcfd,  int _dstfd);
 intelftc_demangle(const char *_mangledname, char *_buffer,
 size_t _bufsize, unsigned int _flags);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357825 - stable/12/lib/libc/net

2020-02-12 Thread Mark Johnston
Author: markj
Date: Wed Feb 12 15:51:29 2020
New Revision: 357825
URL: https://svnweb.freebsd.org/changeset/base/357825

Log:
  MFC r357575:
  Improve validation of the sockaddr length in iruserok_sa().
  
  PR:   243747

Modified:
  stable/12/lib/libc/net/rcmd.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/lib/libc/net/rcmd.c
==
--- stable/12/lib/libc/net/rcmd.c   Wed Feb 12 15:46:33 2020
(r357824)
+++ stable/12/lib/libc/net/rcmd.c   Wed Feb 12 15:51:29 2020
(r357825)
@@ -438,8 +438,8 @@ iruserok_sa(const void *ra, int rlen, int superuser, c
struct sockaddr_storage ss;
 
/* avoid alignment issue */
-   if (rlen > sizeof(ss)) 
-   return(-1);
+   if (rlen <= 0 || rlen > sizeof(ss))
+   return (-1);
memcpy(&ss, ra, rlen);
raddr = (struct sockaddr *)&ss;
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357824 - stable/12/sys/amd64/amd64

2020-02-12 Thread Mark Johnston
Author: markj
Date: Wed Feb 12 15:46:33 2020
New Revision: 357824
URL: https://svnweb.freebsd.org/changeset/base/357824

Log:
  MFC r357573:
  Fix map locking in the CLEAR_PKRU sysarch(2) handler.

Modified:
  stable/12/sys/amd64/amd64/sys_machdep.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/amd64/amd64/sys_machdep.c
==
--- stable/12/sys/amd64/amd64/sys_machdep.c Wed Feb 12 15:26:56 2020
(r357823)
+++ stable/12/sys/amd64/amd64/sys_machdep.c Wed Feb 12 15:46:33 2020
(r357824)
@@ -380,7 +380,7 @@ sysarch(struct thread *td, struct sysarch_args *uap)
error = pmap_pkru_clear(PCPU_GET(curpmap),
(vm_offset_t)a64pkru.addr,
(vm_offset_t)a64pkru.addr + a64pkru.len);
-   vm_map_unlock(map);
+   vm_map_unlock_read(map);
break;
 
default:
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357823 - head/sys/netinet

2020-02-12 Thread Randall Stewart
Author: rrs
Date: Wed Feb 12 15:26:56 2020
New Revision: 357823
URL: https://svnweb.freebsd.org/changeset/base/357823

Log:
  Lets get the real correct version.. gessh. I need
  more coffee evidently.
  
  Sponsored by: Netflix

Modified:
  head/sys/netinet/tcp_ratelimit.c

Modified: head/sys/netinet/tcp_ratelimit.c
==
--- head/sys/netinet/tcp_ratelimit.cWed Feb 12 14:50:13 2020
(r357822)
+++ head/sys/netinet/tcp_ratelimit.cWed Feb 12 15:26:56 2020
(r357823)
@@ -49,9 +49,11 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#define TCPSTATES  /* for logging */
+#include 
+#include 
 #include 
 #include 
+#define TCPSTATES  /* for logging */
 #include 
 #ifdef INET6
 #include 
@@ -284,7 +286,7 @@ rs_defer_destroy(struct tcp_rate_set *rs)
 
/* Set flag to only defer once. */
rs->rs_flags |= RS_FUNERAL_SCHD;
-   epoch_call(net_epoch, &rs->rs_epoch_ctx, rs_destroy);
+   NET_EPOCH_CALL(rs_destroy, &rs->rs_epoch_ctx);
 }
 
 #ifdef INET
@@ -878,7 +880,7 @@ rt_setup_rate(struct inpcb *inp, struct ifnet *ifp, ui
struct epoch_tracker et;
int err;
 
-   epoch_enter_preempt(net_epoch_preempt, &et);
+   NET_EPOCH_ENTER(et);
 use_real_interface:
CK_LIST_FOREACH(rs, &int_rs, next) {
/*
@@ -911,14 +913,14 @@ use_real_interface:
 */
if (rs->rs_disable && error)
*error = ENODEV;
-   epoch_exit_preempt(net_epoch_preempt, &et);
+   NET_EPOCH_EXIT(et);
return (NULL);
}
 
if ((rs == NULL) || (rs->rs_disable != 0)) {
if (rs->rs_disable && error)
*error = ENOSPC;
-   epoch_exit_preempt(net_epoch_preempt, &et);
+   NET_EPOCH_EXIT(et);
return (NULL);
}
if (rs->rs_flags & RS_IS_DEFF) {
@@ -929,7 +931,7 @@ use_real_interface:
if (tifp == NULL) {
if (rs->rs_disable && error)
*error = ENOTSUP;
-   epoch_exit_preempt(net_epoch_preempt, &et);
+   NET_EPOCH_EXIT(et);
return (NULL);
}
goto use_real_interface;
@@ -938,7 +940,7 @@ use_real_interface:
((rs->rs_flows_using + 1) > rs->rs_flow_limit)) {
if (error)
*error = ENOSPC;
-   epoch_exit_preempt(net_epoch_preempt, &et);
+   NET_EPOCH_EXIT(et);
return (NULL);
}
rte = tcp_find_suitable_rate(rs, bytes_per_sec, flags);
@@ -962,7 +964,7 @@ use_real_interface:
 */
atomic_add_64(&rs->rs_flows_using, 1);
}
-   epoch_exit_preempt(net_epoch_preempt, &et);
+   NET_EPOCH_EXIT(et);
return (rte);
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357822 - stable/11/sys/netpfil/pf

2020-02-12 Thread Glen Barber
Author: gjb
Date: Wed Feb 12 14:50:13 2020
New Revision: 357822
URL: https://svnweb.freebsd.org/changeset/base/357822

Log:
  MFC r332404 (kp):
   pf: limit ioctl to a reasonable and tuneable number of elements
  
   pf ioctls frequently take a variable number of elements as argument.
   This can potentially allow users to request very large allocations.
   These will fail, but even a failing M_NOWAIT might tie up resources
   and result in concurrent M_WAITOK allocations entering vm_wait and
   inducing reclamation of caches.
  
   Limit these ioctls to what should be a reasonable value, but allow
   users to tune it should they need to.
  
  Sponsored by: Rubicon Communications, LLC (netgate.com)

Modified:
  stable/11/sys/netpfil/pf/pf.c
  stable/11/sys/netpfil/pf/pf_ioctl.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/netpfil/pf/pf.c
==
--- stable/11/sys/netpfil/pf/pf.c   Wed Feb 12 14:06:02 2020
(r357821)
+++ stable/11/sys/netpfil/pf/pf.c   Wed Feb 12 14:50:13 2020
(r357822)
@@ -363,11 +363,14 @@ u_longpf_hashmask;
 u_long pf_srchashmask;
 static u_long  pf_hashsize;
 static u_long  pf_srchashsize;
+u_long pf_ioctl_maxcount = 65535;
 
 SYSCTL_ULONG(_net_pf, OID_AUTO, states_hashsize, CTLFLAG_RDTUN,
 &pf_hashsize, 0, "Size of pf(4) states hashtable");
 SYSCTL_ULONG(_net_pf, OID_AUTO, source_nodes_hashsize, CTLFLAG_RDTUN,
 &pf_srchashsize, 0, "Size of pf(4) source nodes hashtable");
+SYSCTL_ULONG(_net_pf, OID_AUTO, request_maxcount, CTLFLAG_RDTUN,
+&pf_ioctl_maxcount, 0, "Maximum number of tables, addresses, ... in a 
single ioctl() call");
 
 VNET_DEFINE(void *, pf_swi_cookie);
 

Modified: stable/11/sys/netpfil/pf/pf_ioctl.c
==
--- stable/11/sys/netpfil/pf/pf_ioctl.c Wed Feb 12 14:06:02 2020
(r357821)
+++ stable/11/sys/netpfil/pf/pf_ioctl.c Wed Feb 12 14:50:13 2020
(r357822)
@@ -86,8 +86,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #endif
 
-#define PF_TABLES_MAX_REQUEST   65535 /* Maximum tables per request. */
-
 static struct pf_pool  *pf_get_pool(char *, u_int32_t, u_int8_t, u_int32_t,
u_int8_t, u_int8_t, u_int8_t);
 
@@ -215,6 +213,8 @@ pfsync_detach_ifnet_t *pfsync_detach_ifnet_ptr;
 /* pflog */
 pflog_packet_t *pflog_packet_ptr = NULL;
 
+extern u_long  pf_ioctl_maxcount;
+
 static void
 pfattach_vnet(void)
 {
@@ -2528,7 +2528,8 @@ DIOCCHANGEADDR_error:
break;
}
 
-   if (io->pfrio_size < 0 || io->pfrio_size > 
PF_TABLES_MAX_REQUEST) {
+   if (io->pfrio_size < 0 || io->pfrio_size > pf_ioctl_maxcount ||
+   WOULD_OVERFLOW(io->pfrio_size, sizeof(struct pfr_table))) {
error = ENOMEM;
break;
}
@@ -2559,7 +2560,8 @@ DIOCCHANGEADDR_error:
break;
}
 
-   if (io->pfrio_size < 0 || io->pfrio_size > 
PF_TABLES_MAX_REQUEST) {
+   if (io->pfrio_size < 0 || io->pfrio_size > pf_ioctl_maxcount ||
+   WOULD_OVERFLOW(io->pfrio_size, sizeof(struct pfr_table))) {
error = ENOMEM;
break;
}
@@ -2732,6 +2734,7 @@ DIOCCHANGEADDR_error:
break;
}
if (io->pfrio_size < 0 ||
+   io->pfrio_size > pf_ioctl_maxcount ||
WOULD_OVERFLOW(io->pfrio_size, sizeof(struct pfr_addr))) {
error = EINVAL;
break;
@@ -2769,6 +2772,7 @@ DIOCCHANGEADDR_error:
break;
}
if (io->pfrio_size < 0 ||
+   io->pfrio_size > pf_ioctl_maxcount ||
WOULD_OVERFLOW(io->pfrio_size, sizeof(struct pfr_addr))) {
error = EINVAL;
break;
@@ -2810,7 +2814,8 @@ DIOCCHANGEADDR_error:
break;
}
count = max(io->pfrio_size, io->pfrio_size2);
-   if (WOULD_OVERFLOW(count, sizeof(struct pfr_addr))) {
+   if (count > pf_ioctl_maxcount ||
+   WOULD_OVERFLOW(count, sizeof(struct pfr_addr))) {
error = EINVAL;
break;
}
@@ -2848,6 +2853,7 @@ DIOCCHANGEADDR_error:
break;
}
if (io->pfrio_size < 0 ||
+   io->pfrio_size > pf_ioctl_maxcount ||
WOULD_OVERFLOW(io->pfrio_size, sizeof(struct pfr_addr))) {
error = EINVAL;
break;
@@ -2879,6 +2885,7 @@ DIOCCHANGEADDR_error:
break;
}
if (io->pfrio_size < 0 ||
+ 

svn commit: r357821 - head/sys/riscv/riscv

2020-02-12 Thread Mitchell Horne
Author: mhorne
Date: Wed Feb 12 14:06:02 2020
New Revision: 357821
URL: https://svnweb.freebsd.org/changeset/base/357821

Log:
  Implement vm.pmap.kernel_maps for RISC-V
  
  This is taken from the arm64 version, with the following simplifications:
  
  - Our current pmap implementation uses a 3-level paging scheme
  - The "mode" field has been omitted since RISC-V PTEs don't encode
typical mode attributes
  
  Reviewed by:  markj
  Differential Revision:https://reviews.freebsd.org/D23594

Modified:
  head/sys/riscv/riscv/pmap.c

Modified: head/sys/riscv/riscv/pmap.c
==
--- head/sys/riscv/riscv/pmap.c Wed Feb 12 13:58:37 2020(r357820)
+++ head/sys/riscv/riscv/pmap.c Wed Feb 12 14:06:02 2020(r357821)
@@ -131,6 +131,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -4487,3 +4488,170 @@ pmap_get_tables(pmap_t pmap, vm_offset_t va, pd_entry_
 
return (true);
 }
+
+/*
+ * Track a range of the kernel's virtual address space that is contiguous
+ * in various mapping attributes.
+ */
+struct pmap_kernel_map_range {
+   vm_offset_t sva;
+   pt_entry_t attrs;
+   int l3pages;
+   int l2pages;
+   int l1pages;
+};
+
+static void
+sysctl_kmaps_dump(struct sbuf *sb, struct pmap_kernel_map_range *range,
+vm_offset_t eva)
+{
+
+   if (eva <= range->sva)
+   return;
+
+   sbuf_printf(sb, "0x%016lx-0x%016lx r%c%c%c%c %d %d %d\n",
+   range->sva, eva,
+   (range->attrs & PTE_W) == PTE_W ? 'w' : '-',
+   (range->attrs & PTE_X) == PTE_X ? 'x' : '-',
+   (range->attrs & PTE_U) == PTE_U ? 'u' : 's',
+   (range->attrs & PTE_G) == PTE_G ? 'g' : '-',
+   range->l1pages, range->l2pages, range->l3pages);
+
+   /* Reset to sentinel value. */
+   range->sva = 0xul;
+}
+
+/*
+ * Determine whether the attributes specified by a page table entry match those
+ * being tracked by the current range.
+ */
+static bool
+sysctl_kmaps_match(struct pmap_kernel_map_range *range, pt_entry_t attrs)
+{
+
+   return (range->attrs == attrs);
+}
+
+static void
+sysctl_kmaps_reinit(struct pmap_kernel_map_range *range, vm_offset_t va,
+pt_entry_t attrs)
+{
+
+   memset(range, 0, sizeof(*range));
+   range->sva = va;
+   range->attrs = attrs;
+}
+
+/*
+ * Given a leaf PTE, derive the mapping's attributes. If they do not match
+ * those of the current run, dump the address range and its attributes, and
+ * begin a new run.
+ */
+static void
+sysctl_kmaps_check(struct sbuf *sb, struct pmap_kernel_map_range *range,
+vm_offset_t va, pd_entry_t l1e, pd_entry_t l2e, pt_entry_t l3e)
+{
+   pt_entry_t attrs;
+
+   /* The PTE global bit is inherited by lower levels. */
+   attrs = l1e & PTE_G;
+   if ((l1e & PTE_RWX) != 0)
+   attrs |= l1e & (PTE_RWX | PTE_U);
+   else if (l2e != 0)
+   attrs |= l2e & PTE_G;
+   if ((l2e & PTE_RWX) != 0)
+   attrs |= l2e & (PTE_RWX | PTE_U);
+   else if (l3e != 0)
+   attrs |= l3e & (PTE_RWX | PTE_U | PTE_G);
+
+   if (range->sva > va || !sysctl_kmaps_match(range, attrs)) {
+   sysctl_kmaps_dump(sb, range, va);
+   sysctl_kmaps_reinit(range, va, attrs);
+   }
+}
+
+static int
+sysctl_kmaps(SYSCTL_HANDLER_ARGS)
+{
+   struct pmap_kernel_map_range range;
+   struct sbuf sbuf, *sb;
+   pd_entry_t l1e, *l2, l2e;
+   pt_entry_t *l3, l3e;
+   vm_offset_t sva;
+   vm_paddr_t pa;
+   int error, i, j, k;
+
+   error = sysctl_wire_old_buffer(req, 0);
+   if (error != 0)
+   return (error);
+   sb = &sbuf;
+   sbuf_new_for_sysctl(sb, NULL, PAGE_SIZE, req);
+
+   /* Sentinel value. */
+   range.sva = 0xul;
+
+   /*
+* Iterate over the kernel page tables without holding the kernel pmap
+* lock. Kernel page table pages are never freed, so at worst we will
+* observe inconsistencies in the output.
+*/
+   sva = VM_MIN_KERNEL_ADDRESS;
+   for (i = pmap_l1_index(sva); i < Ln_ENTRIES; i++) {
+   if (i == pmap_l1_index(DMAP_MIN_ADDRESS))
+   sbuf_printf(sb, "\nDirect map:\n");
+   else if (i == pmap_l1_index(VM_MIN_KERNEL_ADDRESS))
+   sbuf_printf(sb, "\nKernel map:\n");
+
+   l1e = kernel_pmap->pm_l1[i];
+   if ((l1e & PTE_V) == 0) {
+   sysctl_kmaps_dump(sb, &range, sva);
+   sva += L1_SIZE;
+   continue;
+   }
+   if ((l1e & PTE_RWX) != 0) {
+   sysctl_kmaps_check(sb, &range, sva, l1e, 0, 0);
+   range.l1pages++;
+   sva += L1_SIZE;
+   continue;
+   }
+   

svn commit: r357820 - head/sys/riscv/riscv

2020-02-12 Thread Mitchell Horne
Author: mhorne
Date: Wed Feb 12 13:58:37 2020
New Revision: 357820
URL: https://svnweb.freebsd.org/changeset/base/357820

Log:
  RISC-V: un-ifdef vm.kvm_size and vm.kvm_free
  
  Fix formatting and add CTLFLAG_MPSAFE.
  
  Reviewed by:  markj
  Differential Revision:https://reviews.freebsd.org/D23522

Modified:
  head/sys/riscv/riscv/pmap.c

Modified: head/sys/riscv/riscv/pmap.c
==
--- head/sys/riscv/riscv/pmap.c Wed Feb 12 13:37:53 2020(r357819)
+++ head/sys/riscv/riscv/pmap.c Wed Feb 12 13:58:37 2020(r357820)
@@ -1436,7 +1436,6 @@ pmap_release(pmap_t pmap)
vm_page_free(m);
 }
 
-#if 0
 static int
 kvm_size(SYSCTL_HANDLER_ARGS)
 {
@@ -1444,8 +1443,9 @@ kvm_size(SYSCTL_HANDLER_ARGS)
 
return sysctl_handle_long(oidp, &ksize, 0, req);
 }
-SYSCTL_PROC(_vm, OID_AUTO, kvm_size, CTLTYPE_LONG|CTLFLAG_RD, 
-0, 0, kvm_size, "LU", "Size of KVM");
+SYSCTL_PROC(_vm, OID_AUTO, kvm_size, CTLTYPE_LONG | CTLFLAG_RD | 
CTLFLAG_MPSAFE,
+0, 0, kvm_size, "LU",
+"Size of KVM");
 
 static int
 kvm_free(SYSCTL_HANDLER_ARGS)
@@ -1454,9 +1454,9 @@ kvm_free(SYSCTL_HANDLER_ARGS)
 
return sysctl_handle_long(oidp, &kfree, 0, req);
 }
-SYSCTL_PROC(_vm, OID_AUTO, kvm_free, CTLTYPE_LONG|CTLFLAG_RD, 
-0, 0, kvm_free, "LU", "Amount of KVM free");
-#endif /* 0 */
+SYSCTL_PROC(_vm, OID_AUTO, kvm_free, CTLTYPE_LONG | CTLFLAG_RD | 
CTLFLAG_MPSAFE,
+0, 0, kvm_free, "LU",
+"Amount of KVM free");
 
 /*
  * grow the number of kernel page table entries, if needed
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357818 - in head/sys/netinet: . cc

2020-02-12 Thread Randall Stewart
Author: rrs
Date: Wed Feb 12 13:31:36 2020
New Revision: 357818
URL: https://svnweb.freebsd.org/changeset/base/357818

Log:
  White space cleanup -- remove trailing tab's or spaces
  from any line.
  
  Sponsored by: Netflix Inc.

Modified:
  head/sys/netinet/cc/cc_cdg.c
  head/sys/netinet/cc/cc_dctcp.c
  head/sys/netinet/cc/cc_htcp.c
  head/sys/netinet/icmp6.h
  head/sys/netinet/if_ether.c
  head/sys/netinet/igmp.c
  head/sys/netinet/in.c
  head/sys/netinet/in.h
  head/sys/netinet/in_mcast.c
  head/sys/netinet/in_pcb.c
  head/sys/netinet/in_pcb.h
  head/sys/netinet/in_proto.c
  head/sys/netinet/in_rmx.c
  head/sys/netinet/ip_divert.c
  head/sys/netinet/ip_dummynet.h
  head/sys/netinet/ip_fastfwd.c
  head/sys/netinet/ip_fw.h
  head/sys/netinet/ip_icmp.c
  head/sys/netinet/ip_id.c
  head/sys/netinet/ip_input.c
  head/sys/netinet/ip_mroute.c
  head/sys/netinet/ip_options.c
  head/sys/netinet/ip_reass.c
  head/sys/netinet/raw_ip.c
  head/sys/netinet/siftr.c
  head/sys/netinet/tcp.h
  head/sys/netinet/tcp_fastopen.c
  head/sys/netinet/tcp_fsm.h
  head/sys/netinet/tcp_input.c
  head/sys/netinet/tcp_log_buf.c
  head/sys/netinet/tcp_log_buf.h
  head/sys/netinet/tcp_lro.c
  head/sys/netinet/tcp_lro.h
  head/sys/netinet/tcp_output.c
  head/sys/netinet/tcp_ratelimit.c
  head/sys/netinet/tcp_ratelimit.h
  head/sys/netinet/tcp_reass.c
  head/sys/netinet/tcp_sack.c
  head/sys/netinet/tcp_subr.c
  head/sys/netinet/tcp_syncache.c
  head/sys/netinet/tcp_timer.c
  head/sys/netinet/tcp_timer.h
  head/sys/netinet/tcp_usrreq.c
  head/sys/netinet/tcp_var.h
  head/sys/netinet/udp.h
  head/sys/netinet/udp_usrreq.c
  head/sys/netinet/udp_var.h
  head/sys/netinet/udplite.h

Modified: head/sys/netinet/cc/cc_cdg.c
==
--- head/sys/netinet/cc/cc_cdg.cWed Feb 12 13:07:09 2020
(r357817)
+++ head/sys/netinet/cc/cc_cdg.cWed Feb 12 13:31:36 2020
(r357818)
@@ -607,7 +607,7 @@ cdg_ack_received(struct cc_var *ccv, uint16_t ack_type
congestion = prob_backoff(qdiff_max);
else if (cdg_data->max_qtrend > 0)
congestion = prob_backoff(cdg_data->max_qtrend);
-   
+
/* Update estimate of queue state. */
if (cdg_data->min_qtrend > 0 &&
cdg_data->max_qtrend <= 0) {

Modified: head/sys/netinet/cc/cc_dctcp.c
==
--- head/sys/netinet/cc/cc_dctcp.c  Wed Feb 12 13:07:09 2020
(r357817)
+++ head/sys/netinet/cc/cc_dctcp.c  Wed Feb 12 13:31:36 2020
(r357818)
@@ -274,9 +274,9 @@ dctcp_cong_signal(struct cc_var *ccv, uint32_t type)
dctcp_data->bytes_total = 0;
dctcp_data->save_sndnxt = CCV(ccv, 
snd_nxt);
} else
-   CCV(ccv, snd_ssthresh) = 
+   CCV(ccv, snd_ssthresh) =
max((cwin - (((uint64_t)cwin *
-   dctcp_data->alpha) >> 
(DCTCP_SHIFT+1))), 
+   dctcp_data->alpha) >> 
(DCTCP_SHIFT+1))),
2 * mss);
CCV(ccv, snd_cwnd) = CCV(ccv, snd_ssthresh);
ENTER_CONGRECOVERY(CCV(ccv, t_flags));

Modified: head/sys/netinet/cc/cc_htcp.c
==
--- head/sys/netinet/cc/cc_htcp.c   Wed Feb 12 13:07:09 2020
(r357817)
+++ head/sys/netinet/cc/cc_htcp.c   Wed Feb 12 13:31:36 2020
(r357818)
@@ -364,7 +364,7 @@ htcp_post_recovery(struct cc_var *ccv)
pipe = tcp_compute_pipe(ccv->ccvc.tcp);
else
pipe = CCV(ccv, snd_max) - ccv->curack;
-   
+
if (pipe < CCV(ccv, snd_ssthresh))
/*
 * Ensure that cwnd down not collape to 1 MSS under

Modified: head/sys/netinet/icmp6.h
==
--- head/sys/netinet/icmp6.hWed Feb 12 13:07:09 2020(r357817)
+++ head/sys/netinet/icmp6.hWed Feb 12 13:31:36 2020(r357818)
@@ -344,7 +344,7 @@ struct nd_opt_mtu { /* MTU option */
 #defineND_OPT_NONCE_LEN((1 * 8) - 2)
 #if ((ND_OPT_NONCE_LEN + 2) % 8) != 0
 #error "(ND_OPT_NONCE_LEN + 2) must be a multiple of 8."
-#endif 
+#endif
 struct nd_opt_nonce {  /* nonce option */
u_int8_tnd_opt_nonce_type;
u_int8_tnd_opt_nonce_len;
@@ -607,7 +607,7 @@ struct icmp6stat {
 * for netinet6 code, it is already available in icp6s_outhist[].
   

svn commit: r357817 - head/sys/netinet

2020-02-12 Thread Randall Stewart
Author: rrs
Date: Wed Feb 12 13:07:09 2020
New Revision: 357817
URL: https://svnweb.freebsd.org/changeset/base/357817

Log:
  Whitespace, remove from three files trailing white
  space (leftover presents from emacs).
  
  Sponsored by: Netflix Inc.

Modified:
  head/sys/netinet/tcp_hpts.c
  head/sys/netinet/tcp_hpts.h
  head/sys/netinet/tcp_ratelimit.c

Modified: head/sys/netinet/tcp_hpts.c
==
--- head/sys/netinet/tcp_hpts.c Wed Feb 12 13:04:19 2020(r357816)
+++ head/sys/netinet/tcp_hpts.c Wed Feb 12 13:07:09 2020(r357817)
@@ -33,7 +33,7 @@ __FBSDID("$FreeBSD$");
  * Some notes about usage.
  *
  * The tcp_hpts system is designed to provide a high precision timer
- * system for tcp. Its main purpose is to provide a mechanism for 
+ * system for tcp. Its main purpose is to provide a mechanism for
  * pacing packets out onto the wire. It can be used in two ways
  * by a given TCP stack (and those two methods can be used simultaneously).
  *
@@ -59,22 +59,22 @@ __FBSDID("$FreeBSD$");
  * to prevent output processing until the time alotted has gone by.
  * Of course this is a bare bones example and the stack will probably
  * have more consideration then just the above.
- * 
+ *
  * Now the second function (actually two functions I guess :D)
- * the tcp_hpts system provides is the  ability to either abort 
- * a connection (later) or process input on a connection. 
+ * the tcp_hpts system provides is the  ability to either abort
+ * a connection (later) or process input on a connection.
  * Why would you want to do this? To keep processor locality
  * and or not have to worry about untangling any recursive
  * locks. The input function now is hooked to the new LRO
- * system as well. 
+ * system as well.
  *
  * In order to use the input redirection function the
- * tcp stack must define an input function for 
+ * tcp stack must define an input function for
  * tfb_do_queued_segments(). This function understands
  * how to dequeue a array of packets that were input and
- * knows how to call the correct processing routine. 
+ * knows how to call the correct processing routine.
  *
- * Locking in this is important as well so most likely the 
+ * Locking in this is important as well so most likely the
  * stack will need to define the tfb_do_segment_nounlock()
  * splitting tfb_do_segment() into two parts. The main processing
  * part that does not unlock the INP and returns a value of 1 or 0.
@@ -83,7 +83,7 @@ __FBSDID("$FreeBSD$");
  * The remains of tfb_do_segment() then become just a simple call
  * to the tfb_do_segment_nounlock() function and check the return
  * code and possibly unlock.
- * 
+ *
  * The stack must also set the flag on the INP that it supports this
  * feature i.e. INP_SUPPORTS_MBUFQ. The LRO code recoginizes
  * this flag as well and will queue packets when it is set.
@@ -99,11 +99,11 @@ __FBSDID("$FreeBSD$");
  *
  * There is a common functions within the rack_bbr_common code
  * version i.e. ctf_do_queued_segments(). This function
- * knows how to take the input queue of packets from 
- * tp->t_in_pkts and process them digging out 
- * all the arguments, calling any bpf tap and 
+ * knows how to take the input queue of packets from
+ * tp->t_in_pkts and process them digging out
+ * all the arguments, calling any bpf tap and
  * calling into tfb_do_segment_nounlock(). The common
- * function (ctf_do_queued_segments())  requires that 
+ * function (ctf_do_queued_segments())  requires that
  * you have defined the tfb_do_segment_nounlock() as
  * described above.
  *
@@ -113,9 +113,9 @@ __FBSDID("$FreeBSD$");
  * a stack wants to drop a connection it calls:
  *
  * tcp_set_inp_to_drop(tp, ETIMEDOUT)
- * 
- * To schedule the tcp_hpts system to call 
- * 
+ *
+ * To schedule the tcp_hpts system to call
+ *
  *tcp_drop(tp, drop_reason)
  *
  * at a future point. This is quite handy to prevent locking
@@ -284,7 +284,7 @@ sysctl_net_inet_tcp_hpts_max_sleep(SYSCTL_HANDLER_ARGS
error = sysctl_handle_int(oidp, &new, 0, req);
if (error == 0 && req->newptr) {
if ((new < (NUM_OF_HPTSI_SLOTS / 4)) ||
-   (new > HPTS_MAX_SLEEP_ALLOWED)) 
+   (new > HPTS_MAX_SLEEP_ALLOWED))
error = EINVAL;
else
hpts_sleep_max = new;
@@ -311,7 +311,7 @@ tcp_hpts_log(struct tcp_hpts_entry *hpts, struct tcpcb
 int ticks_to_run, int idx)
 {
union tcp_log_stackspecific log;
-   
+
memset(&log.u_bbr, 0, sizeof(log.u_bbr));
log.u_bbr.flex1 = hpts->p_nxt_slot;
log.u_bbr.flex2 = hpts->p_cur_slot;
@@ -616,7 +616,7 @@ tcp_hpts_remove_locked_input(struct tcp_hpts_entry *hp
  * Valid values in the flags are
  * HPTS_REMOVE_OUTPUT - remove from the output of the hpts.
  * HPTS_REMOVE_INPUT - remove from the input of the hpts.
- * Note that you can use one or both

svn commit: r357816 - head/sys/netinet

2020-02-12 Thread Randall Stewart
Author: rrs
Date: Wed Feb 12 13:04:19 2020
New Revision: 357816
URL: https://svnweb.freebsd.org/changeset/base/357816

Log:
  This small fix makes it so we properly follow
  the RFC and only enable ECN when both the
  CWR and ECT bits our set within the SYN packet.
  
  Sponsored by: Netflix Inc.
  Differential Revision:https://reviews.freebsd.org/D23645

Modified:
  head/sys/netinet/tcp_syncache.c

Modified: head/sys/netinet/tcp_syncache.c
==
--- head/sys/netinet/tcp_syncache.c Wed Feb 12 12:40:06 2020
(r357815)
+++ head/sys/netinet/tcp_syncache.c Wed Feb 12 13:04:19 2020
(r357816)
@@ -1668,7 +1668,8 @@ skip_alloc:
sc->sc_peer_mss = to->to_mss;   /* peer mss may be zero */
if (ltflags & TF_NOOPT)
sc->sc_flags |= SCF_NOOPT;
-   if ((th->th_flags & (TH_ECE|TH_CWR)) && V_tcp_do_ecn)
+   if (((th->th_flags & (TH_ECE|TH_CWR)) == (TH_ECE|TH_CWR)) &&
+   V_tcp_do_ecn)
sc->sc_flags |= SCF_ECN;
 
if (V_tcp_syncookies)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357815 - head/sys/netinet/tcp_stacks

2020-02-12 Thread Randall Stewart
Author: rrs
Date: Wed Feb 12 12:40:06 2020
New Revision: 357815
URL: https://svnweb.freebsd.org/changeset/base/357815

Log:
  Remove all trailing white space from the BBR/Rack fold. Bits
  left around by emacs (thanks emacs).

Modified:
  head/sys/netinet/tcp_stacks/bbr.c
  head/sys/netinet/tcp_stacks/rack.c
  head/sys/netinet/tcp_stacks/rack_bbr_common.c
  head/sys/netinet/tcp_stacks/rack_bbr_common.h
  head/sys/netinet/tcp_stacks/sack_filter.c
  head/sys/netinet/tcp_stacks/tcp_bbr.h
  head/sys/netinet/tcp_stacks/tcp_rack.h

Modified: head/sys/netinet/tcp_stacks/bbr.c
==
--- head/sys/netinet/tcp_stacks/bbr.c   Wed Feb 12 12:36:55 2020
(r357814)
+++ head/sys/netinet/tcp_stacks/bbr.c   Wed Feb 12 12:40:06 2020
(r357815)
@@ -208,7 +208,7 @@ static int32_t bbr_min_measurements_req = 1;/* We 
nee
 * to prevent it from being ok
 * to have no measurements). */
 static int32_t bbr_no_pacing_until = 4;
-
+
 static int32_t bbr_min_usec_delta = 2; /* 20,000 usecs */
 static int32_t bbr_min_peer_delta = 20;/* 20 units */
 static int32_t bbr_delta_percent = 150;/* 15.0 % */
@@ -380,9 +380,9 @@ static int32_t bbr_rto_max_sec = 4; /* 4 seconds */
 static int32_t bbr_hptsi_per_second = 1000;
 
 /*
- * For hptsi under bbr_cross_over connections what is delay 
+ * For hptsi under bbr_cross_over connections what is delay
  * target 7ms (in usec) combined with a seg_max of 2
- * gets us close to identical google behavior in 
+ * gets us close to identical google behavior in
  * TSO size selection (possibly more 1MSS sends).
  */
 static int32_t bbr_hptsi_segments_delay_tar = 7000;
@@ -596,9 +596,9 @@ activate_rxt:
rsm = TAILQ_FIRST(&bbr->r_ctl.rc_tmap);
if (rsm) {
idx = rsm->r_rtr_cnt - 1;
-   if (TSTMP_GEQ(rsm->r_tim_lastsent[idx], 
bbr->r_ctl.rc_tlp_rxt_last_time)) 
+   if (TSTMP_GEQ(rsm->r_tim_lastsent[idx], 
bbr->r_ctl.rc_tlp_rxt_last_time))
tstmp_touse = rsm->r_tim_lastsent[idx];
-   else 
+   else
tstmp_touse = 
bbr->r_ctl.rc_tlp_rxt_last_time;
if (TSTMP_GT(tstmp_touse, cts))
time_since_sent = cts - tstmp_touse;
@@ -673,9 +673,9 @@ activate_rxt:
}
time_since_sent = 0;
idx = rsm->r_rtr_cnt - 1;
-   if (TSTMP_GEQ(rsm->r_tim_lastsent[idx], 
bbr->r_ctl.rc_tlp_rxt_last_time)) 
+   if (TSTMP_GEQ(rsm->r_tim_lastsent[idx], 
bbr->r_ctl.rc_tlp_rxt_last_time))
tstmp_touse = rsm->r_tim_lastsent[idx];
-   else 
+   else
tstmp_touse = bbr->r_ctl.rc_tlp_rxt_last_time;
if (TSTMP_GT(tstmp_touse, cts))
time_since_sent = cts - tstmp_touse;
@@ -695,11 +695,11 @@ activate_rxt:
}
if ((bbr->rc_tlp_rtx_out == 1) &&
(rsm->r_start == bbr->r_ctl.rc_last_tlp_seq)) {
-   /* 
-* Second retransmit of the same TLP 
+   /*
+* Second retransmit of the same TLP
 * lets not.
 */
-   bbr->rc_tlp_rtx_out = 0; 
+   bbr->rc_tlp_rtx_out = 0;
goto activate_rxt;
}
if (rsm->r_start != bbr->r_ctl.rc_last_tlp_seq) {
@@ -766,7 +766,7 @@ bbr_start_hpts_timer(struct tcp_bbr *bbr, struct tcpcb
prev_delay = bbr->r_ctl.rc_last_delay_val;
if (bbr->r_ctl.rc_last_delay_val &&
(slot == 0)) {
-   /* 
+   /*
 * If a previous pacer delay was in place we
 * are not coming from the output side (where
 * we calculate a delay, more likely a timer).
@@ -777,7 +777,7 @@ bbr_start_hpts_timer(struct tcp_bbr *bbr, struct tcpcb
delay_calc = cts - bbr->rc_pacer_started;
if (delay_calc <= slot)
slot -= delay_calc;
-   } 
+   }
}
/* Do we have early to make up for by pushing out the pacing time? */
if (bbr->r_agg_early_set) {
@@ -804,8 +804,8 @@ bbr_start_hpts_timer(struct tcp_bbr *bbr, struct tcpcb
if (bbr->rc_in_persist == 0) {
delayed_ack = bbr_delack_time;
} else {
-   /* 
-* We are in persists an

svn commit: r357814 - head/sys/netinet/tcp_stacks

2020-02-12 Thread Randall Stewart
Author: rrs
Date: Wed Feb 12 12:36:55 2020
New Revision: 357814
URL: https://svnweb.freebsd.org/changeset/base/357814

Log:
  Now that all of the stats framework is
  in FreeBSD the bits that disabled stats
  when netflix-stats is not defined is no longer
  needed. Lets remove these bits so that we
  will properly use stats per its definition
  in BBR and Rack.
  
  Sponsored by: Netflix Inc
  Differential Revision:https://reviews.freebsd.org/D23088

Modified:
  head/sys/netinet/tcp_stacks/rack.c
  head/sys/netinet/tcp_stacks/rack_bbr_common.h

Modified: head/sys/netinet/tcp_stacks/rack.c
==
--- head/sys/netinet/tcp_stacks/rack.c  Wed Feb 12 12:23:46 2020
(r357813)
+++ head/sys/netinet/tcp_stacks/rack.c  Wed Feb 12 12:36:55 2020
(r357814)
@@ -1681,7 +1681,7 @@ rack_ack_received(struct tcpcb *tp, struct tcp_rack *r
tp->t_stats_gput_prev);
tp->t_flags &= ~TF_GPUTINPROG;
tp->t_stats_gput_prev = gput;
-
+#ifdef NETFLIX_PEAKRATE
if (tp->t_maxpeakrate) {
/*
 * We update t_peakrate_thr. This gives us 
roughly
@@ -1689,6 +1689,7 @@ rack_ack_received(struct tcpcb *tp, struct tcp_rack *r
 */
tcp_update_peakrate_thr(tp);
}
+#endif
}
 #endif
if (tp->snd_cwnd > tp->snd_ssthresh) {

Modified: head/sys/netinet/tcp_stacks/rack_bbr_common.h
==
--- head/sys/netinet/tcp_stacks/rack_bbr_common.h   Wed Feb 12 12:23:46 
2020(r357813)
+++ head/sys/netinet/tcp_stacks/rack_bbr_common.h   Wed Feb 12 12:36:55 
2020(r357814)
@@ -27,11 +27,6 @@
  * __FBSDID("$FreeBSD$");
  */
 
-/* XXXLAS: Couple STATS to NETFLIX_STATS until stats(3) is fully upstreamed. */
-#ifndefNETFLIX_STATS
-#undef STATS
-#endif
-
 /* Common defines and such used by both RACK and BBR */
 /* Special values for mss accounting array */
 #define TCP_MSS_ACCT_JUSTRET 0
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357813 - head/libexec/rtld-elf

2020-02-12 Thread Konstantin Belousov
Author: kib
Date: Wed Feb 12 12:23:46 2020
New Revision: 357813
URL: https://svnweb.freebsd.org/changeset/base/357813

Log:
  Fix indent.
  
  Sponsored by: The FreeBSD Foundation
  MFC after:3 days

Modified:
  head/libexec/rtld-elf/rtld.c

Modified: head/libexec/rtld-elf/rtld.c
==
--- head/libexec/rtld-elf/rtld.cWed Feb 12 11:19:07 2020
(r357812)
+++ head/libexec/rtld-elf/rtld.cWed Feb 12 12:23:46 2020
(r357813)
@@ -5627,26 +5627,30 @@ parse_args(char* argv[], int argc, bool *use_pathp, in
print_usage(argv[0]);
_exit(0);
} else if (opt == 'f') {
-   /*
-* -f XX can be used to specify a descriptor for the
-* binary named at the command line (i.e., the later
-* argument will specify the process name but the
-* descriptor is what will actually be executed)
-*/
-   if (j != arglen - 1) {
-   /* -f must be the last option in, e.g., -abcf */
-   _rtld_error("Invalid options: %s", arg);
-   rtld_die();
-   }
-   i++;
-   fd = parse_integer(argv[i]);
-   if (fd == -1) {
-   _rtld_error("Invalid file descriptor: '%s'",
-   argv[i]);
-   rtld_die();
-   }
-   *fdp = fd;
-   break;
+   /*
+* -f XX can be used to specify a
+* descriptor for the binary named at
+* the command line (i.e., the later
+* argument will specify the process
+* name but the descriptor is what
+* will actually be executed).
+*
+* -f must be the last option in, e.g., -abcf.
+*/
+   if (j != arglen - 1) {
+   _rtld_error("Invalid options: %s", arg);
+   rtld_die();
+   }
+   i++;
+   fd = parse_integer(argv[i]);
+   if (fd == -1) {
+   _rtld_error(
+   "Invalid file descriptor: '%s'",
+   argv[i]);
+   rtld_die();
+   }
+   *fdp = fd;
+   break;
} else if (opt == 'p') {
*use_pathp = true;
} else {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357812 - head/sys/kern

2020-02-12 Thread Mateusz Guzik
Author: mjg
Date: Wed Feb 12 11:19:07 2020
New Revision: 357812
URL: https://svnweb.freebsd.org/changeset/base/357812

Log:
  vfs: refactor vputx and add more comment
  
  Reviewed by:  jeff (previous version)
  Tested by:pho (previous version)
  Differential Revision:https://reviews.freebsd.org/D23530

Modified:
  head/sys/kern/vfs_subr.c

Modified: head/sys/kern/vfs_subr.c
==
--- head/sys/kern/vfs_subr.cWed Feb 12 11:18:12 2020(r357811)
+++ head/sys/kern/vfs_subr.cWed Feb 12 11:19:07 2020(r357812)
@@ -2798,14 +2798,37 @@ v_incr_devcount(struct vnode *vp)
 
 /*
  * Decrement si_usecount of the associated device, if any.
+ *
+ * The caller is required to hold the interlock when transitioning a VCHR use
+ * count to zero. This prevents a race with devfs_reclaim_vchr() that would
+ * leak a si_usecount reference. The vnode lock will also prevent this race
+ * if it is held while dropping the last ref.
+ *
+ * The race is:
+ *
+ * CPU1CPU2
+ * devfs_reclaim_vchr
+ * make v_usecount == 0
+ *   VI_LOCK
+ *   sees v_usecount == 0, no updates
+ *   vp->v_rdev = NULL;
+ *   ...
+ *   VI_UNLOCK
+ * VI_LOCK
+ * v_decr_devcount
+ *   sees v_rdev == NULL, no updates
+ *
+ * In this scenario si_devcount decrement is not performed.
  */
 static void
 v_decr_devcount(struct vnode *vp)
 {
 
+   ASSERT_VOP_LOCKED(vp, __func__);
ASSERT_VI_LOCKED(vp, __FUNCTION__);
if (vp->v_type == VCHR && vp->v_rdev != NULL) {
dev_lock();
+   VNPASS(vp->v_rdev->si_usecount > 0, vp);
vp->v_rdev->si_usecount--;
dev_unlock();
}
@@ -3154,88 +3177,71 @@ vdefer_inactive_unlocked(struct vnode *vp)
vdefer_inactive(vp);
 }
 
-enum vputx_op { VPUTX_VRELE, VPUTX_VPUT, VPUTX_VUNREF };
+enum vput_op { VRELE, VPUT, VUNREF };
 
 /*
- * Decrement the use and hold counts for a vnode.
+ * Handle ->v_usecount transitioning to 0.
  *
- * See an explanation near vget() as to why atomic operation is safe.
+ * By releasing the last usecount we take ownership of the hold count which
+ * provides liveness of the vnode, meaning we have to vdrop.
  *
+ * If the vnode is of type VCHR we may need to decrement si_usecount, see
+ * v_decr_devcount for details.
+ *
+ * For all vnodes we may need to perform inactive processing. It requires an
+ * exclusive lock on the vnode, while it is legal to call here with only a
+ * shared lock (or no locks). If locking the vnode in an expected manner fails,
+ * inactive processing gets deferred to the syncer.
+ *
  * XXX Some filesystems pass in an exclusively locked vnode and strongly depend
  * on the lock being held all the way until VOP_INACTIVE. This in particular
  * happens with UFS which adds half-constructed vnodes to the hash, where they
  * can be found by other code.
  */
 static void
-vputx(struct vnode *vp, enum vputx_op func)
+vput_final(struct vnode *vp, enum vput_op func)
 {
int error;
bool want_unlock;
 
-   KASSERT(vp != NULL, ("vputx: null vp"));
-   if (func == VPUTX_VUNREF)
-   ASSERT_VOP_LOCKED(vp, "vunref");
-   else if (func == VPUTX_VPUT)
-   ASSERT_VOP_LOCKED(vp, "vput");
-   ASSERT_VI_UNLOCKED(vp, __func__);
-   VNASSERT(vp->v_holdcnt > 0 && vp->v_usecount > 0, vp,
-   ("%s: wrong ref counts", __func__));
-
CTR2(KTR_VFS, "%s: vp %p", __func__, vp);
+   VNPASS(vp->v_holdcnt > 0, vp);
 
+   VI_LOCK(vp);
+   if (func != VRELE)
+   v_decr_devcount(vp);
+
/*
-* We want to hold the vnode until the inactive finishes to
-* prevent vgone() races.  We drop the use count here and the
-* hold count below when we're done.
-*
-* If we release the last usecount we take ownership of the hold
-* count which provides liveness of the vnode, in which case we
-* have to vdrop.
-*/
-   if (__predict_false(vp->v_type == VCHR && func == VPUTX_VRELE)) {
-   if (refcount_release_if_not_last(&vp->v_usecount))
-   return;
-   VI_LOCK(vp);
-   if (!refcount_release(&vp->v_usecount)) {
-   VI_UNLOCK(vp);
-   return;
-   }
-   } else {
-   if (!refcount_release(&vp->v_usecount)) {
-   if (func == VPUTX_VPUT)
-   VOP_UNLOCK(vp);
-   return;
-   }
-   VI_LOCK(vp);
-   }
-   v_decr_devcount(vp);
-   /*
 * By the time we got here someone else might have transitioned
 * the

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

2020-02-12 Thread Mateusz Guzik
Author: mjg
Date: Wed Feb 12 11:17:45 2020
New Revision: 357810
URL: https://svnweb.freebsd.org/changeset/base/357810

Log:
  vfs: switch to smp_rendezvous_cpus_retry for vfs_op_thread_enter/exit
  
  In particular on amd64 this eliminates an atomic op in the common case,
  trading it for IPIs in the uncommon case of catching CPUs executing the
  code while the filesystem is getting suspended or unmounted.

Modified:
  head/sys/kern/vfs_mount.c
  head/sys/kern/vfs_subr.c
  head/sys/sys/mount.h

Modified: head/sys/kern/vfs_mount.c
==
--- head/sys/kern/vfs_mount.c   Wed Feb 12 11:17:18 2020(r357809)
+++ head/sys/kern/vfs_mount.c   Wed Feb 12 11:17:45 2020(r357810)
@@ -1441,16 +1441,7 @@ vfs_op_enter(struct mount *mp)
MNT_IUNLOCK(mp);
return;
}
-   /*
-* Paired with a fence in vfs_op_thread_enter(). See the comment
-* above it for details.
-*/
-   atomic_thread_fence_seq_cst();
vfs_op_barrier_wait(mp);
-   /*
-* Paired with a fence in vfs_op_thread_exit().
-*/
-   atomic_thread_fence_acq();
CPU_FOREACH(cpu) {
mp->mnt_ref +=
zpcpu_replace_cpu(mp->mnt_ref_pcpu, 0, cpu);
@@ -1484,20 +1475,52 @@ vfs_op_exit(struct mount *mp)
MNT_IUNLOCK(mp);
 }
 
-/*
- * It is assumed the caller already posted at least an acquire barrier.
- */
+struct vfs_op_barrier_ipi {
+   struct mount *mp;
+   struct smp_rendezvous_cpus_retry_arg srcra;
+};
+
+static void
+vfs_op_action_func(void *arg)
+{
+   struct vfs_op_barrier_ipi *vfsopipi;
+   struct mount *mp;
+
+   vfsopipi = __containerof(arg, struct vfs_op_barrier_ipi, srcra);
+   mp = vfsopipi->mp;
+
+   if (!vfs_op_thread_entered(mp))
+   smp_rendezvous_cpus_done(arg);
+}
+
+static void
+vfs_op_wait_func(void *arg, int cpu)
+{
+   struct vfs_op_barrier_ipi *vfsopipi;
+   struct mount *mp;
+   int *in_op;
+
+   vfsopipi = __containerof(arg, struct vfs_op_barrier_ipi, srcra);
+   mp = vfsopipi->mp;
+
+   in_op = zpcpu_get_cpu(mp->mnt_thread_in_ops_pcpu, cpu);
+   while (atomic_load_int(in_op))
+   cpu_spinwait();
+}
+
 void
 vfs_op_barrier_wait(struct mount *mp)
 {
-   int *in_op;
-   int cpu;
+   struct vfs_op_barrier_ipi vfsopipi;
 
-   CPU_FOREACH(cpu) {
-   in_op = zpcpu_get_cpu(mp->mnt_thread_in_ops_pcpu, cpu);
-   while (atomic_load_int(in_op))
-   cpu_spinwait();
-   }
+   vfsopipi.mp = mp;
+
+   smp_rendezvous_cpus_retry(all_cpus,
+   smp_no_rendezvous_barrier,
+   vfs_op_action_func,
+   smp_no_rendezvous_barrier,
+   vfs_op_wait_func,
+   &vfsopipi.srcra);
 }
 
 #ifdef DIAGNOSTIC

Modified: head/sys/kern/vfs_subr.c
==
--- head/sys/kern/vfs_subr.cWed Feb 12 11:17:18 2020(r357809)
+++ head/sys/kern/vfs_subr.cWed Feb 12 11:17:45 2020(r357810)
@@ -6049,10 +6049,6 @@ restart:
}
MNT_IUNLOCK(mp);
if (vp != NULL) {
-   /*
-* Paired with a fence in vfs_op_thread_exit().
-*/
-   atomic_thread_fence_acq();
vfs_op_barrier_wait(mp);
vrele(vp);
}

Modified: head/sys/sys/mount.h
==
--- head/sys/sys/mount.hWed Feb 12 11:17:18 2020(r357809)
+++ head/sys/sys/mount.hWed Feb 12 11:17:45 2020(r357810)
@@ -983,14 +983,9 @@ enum mount_counter { MNT_COUNT_REF, MNT_COUNT_LOCKREF,
 intvfs_mount_fetch_counter(struct mount *, enum mount_counter);
 
 /*
- * We mark ourselves as entering the section and post a sequentially consistent
- * fence, meaning the store is completed before we get into the section and
- * mnt_vfs_ops is only read afterwards.
+ * Code transitioning mnt_vfs_ops to > 0 issues IPIs until it observes
+ * all CPUs not executing code enclosed by mnt_thread_in_ops_pcpu.
  *
- * Any thread transitioning the ops counter 0->1 does things in the opposite
- * order - first bumps the count, posts a sequentially consistent fence and
- * observes all CPUs not executing within the section.
- *
  * This provides an invariant that by the time the last CPU is observed not
  * executing, everyone else entering will see the counter > 0 and exit.
  *
@@ -1009,7 +1004,7 @@ int   vfs_mount_fetch_counter(struct mount *, enum 
mount
critical_enter();   \
MPASS(!vfs_op_thread_entered(mp));  \
zpcpu_set_protected(mp->mnt_thread_in_ops_pcpu, 1); \
-   atomic_thread_fence_seq_cst();

svn commit: r357811 - head/sys/kern

2020-02-12 Thread Mateusz Guzik
Author: mjg
Date: Wed Feb 12 11:18:12 2020
New Revision: 357811
URL: https://svnweb.freebsd.org/changeset/base/357811

Log:
  vfs: drop remaining zpcpu casts

Modified:
  head/sys/kern/vfs_mount.c

Modified: head/sys/kern/vfs_mount.c
==
--- head/sys/kern/vfs_mount.c   Wed Feb 12 11:17:45 2020(r357810)
+++ head/sys/kern/vfs_mount.c   Wed Feb 12 11:18:12 2020(r357811)
@@ -1533,9 +1533,9 @@ vfs_assert_mount_counters(struct mount *mp)
return;
 
CPU_FOREACH(cpu) {
-   if (*(int *)zpcpu_get_cpu(mp->mnt_ref_pcpu, cpu) != 0 ||
-   *(int *)zpcpu_get_cpu(mp->mnt_lockref_pcpu, cpu) != 0 ||
-   *(int *)zpcpu_get_cpu(mp->mnt_writeopcount_pcpu, cpu) != 0)
+   if (*zpcpu_get_cpu(mp->mnt_ref_pcpu, cpu) != 0 ||
+   *zpcpu_get_cpu(mp->mnt_lockref_pcpu, cpu) != 0 ||
+   *zpcpu_get_cpu(mp->mnt_writeopcount_pcpu, cpu) != 0)
vfs_dump_mount_counters(mp);
}
 }
@@ -1605,7 +1605,7 @@ vfs_mount_fetch_counter(struct mount *mp, enum mount_c
 
sum = *base;
CPU_FOREACH(cpu) {
-   sum += *(int *)zpcpu_get_cpu(pcpu, cpu);
+   sum += *zpcpu_get_cpu(pcpu, cpu);
}
return (sum);
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357809 - head/sys/kern

2020-02-12 Thread Mateusz Guzik
Author: mjg
Date: Wed Feb 12 11:17:18 2020
New Revision: 357809
URL: https://svnweb.freebsd.org/changeset/base/357809

Log:
  rms: use smp_rendezvous_cpus_retry instead of a hand-rolled variant

Modified:
  head/sys/kern/kern_rmlock.c

Modified: head/sys/kern/kern_rmlock.c
==
--- head/sys/kern/kern_rmlock.c Wed Feb 12 11:16:55 2020(r357808)
+++ head/sys/kern/kern_rmlock.c Wed Feb 12 11:17:18 2020(r357809)
@@ -991,17 +991,17 @@ rms_runlock(struct rmslock *rms)
 
 struct rmslock_ipi {
struct rmslock *rms;
-   cpuset_t signal;
+   struct smp_rendezvous_cpus_retry_arg srcra;
 };
 
 static void
-rms_wlock_IPI(void *arg)
+rms_action_func(void *arg)
 {
struct rmslock_ipi *rmsipi;
struct rmslock *rms;
int readers;
 
-   rmsipi = arg;
+   rmsipi = __containerof(arg, struct rmslock_ipi, srcra);
rms = rmsipi->rms;
 
if (*zpcpu_get(rms->readers_influx))
@@ -1009,65 +1009,40 @@ rms_wlock_IPI(void *arg)
readers = zpcpu_replace(rms->readers_pcpu, 0);
if (readers != 0)
atomic_add_int(&rms->readers, readers);
-   CPU_CLR_ATOMIC(curcpu, &rmsipi->signal);
+   smp_rendezvous_cpus_done(arg);
 }
 
 static void
+rms_wait_func(void *arg, int cpu)
+{
+   struct rmslock_ipi *rmsipi;
+   struct rmslock *rms;
+   int *in_op;
+
+   rmsipi = __containerof(arg, struct rmslock_ipi, srcra);
+   rms = rmsipi->rms;
+
+   in_op = zpcpu_get_cpu(rms->readers_influx, cpu);
+   while (atomic_load_int(in_op))
+   cpu_spinwait();
+}
+
+static void
 rms_wlock_switch(struct rmslock *rms)
 {
struct rmslock_ipi rmsipi;
-   int *in_op;
-   int cpu;
 
MPASS(rms->readers == 0);
MPASS(rms->writers == 1);
 
rmsipi.rms = rms;
 
-   /*
-* Publishes rms->writers. rlock and runlock will get this ordered
-* via IPI in the worst case.
-*/
-   atomic_thread_fence_rel();
-
-   /*
-* Collect reader counts from all CPUs using an IPI. The handler can
-* find itself running while the interrupted CPU was doing either
-* rlock or runlock in which case it will fail.
-*
-* Successful attempts clear the cpu id in the bitmap.
-*
-* In case of failure we observe all failing CPUs not executing there to
-* determine when to make the next attempt. Note that threads having
-* the var set have preemption disabled.  Setting of readers_influx
-* only uses compiler barriers making these loads unreliable, which is
-* fine -- the IPI handler will always see the correct result.
-*
-* We retry until all counts are collected. Forward progress is
-* guaranteed by that fact that the total number of threads which can
-* be caught like this is finite and they all are going to block on
-* their own.
-*/
-   CPU_COPY(&all_cpus, &rmsipi.signal);
-   for (;;) {
-   smp_rendezvous_cpus(
-   rmsipi.signal,
-   smp_no_rendezvous_barrier,
-   rms_wlock_IPI,
-   smp_no_rendezvous_barrier,
-   &rmsipi);
-
-   if (CPU_EMPTY(&rmsipi.signal))
-   break;
-
-   CPU_FOREACH(cpu) {
-   if (!CPU_ISSET(cpu, &rmsipi.signal))
-   continue;
-   in_op = zpcpu_get_cpu(rms->readers_influx, cpu);
-   while (atomic_load_int(in_op))
-   cpu_spinwait();
-   }
-   }
+   smp_rendezvous_cpus_retry(all_cpus,
+   smp_no_rendezvous_barrier,
+   rms_action_func,
+   smp_no_rendezvous_barrier,
+   rms_wait_func,
+   &rmsipi.srcra);
 }
 
 void
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2020-02-12 Thread Mateusz Guzik
Author: mjg
Date: Wed Feb 12 11:16:55 2020
New Revision: 357808
URL: https://svnweb.freebsd.org/changeset/base/357808

Log:
  Add smp_rendezvous_cpus_retry
  
  This is a wrapper around smp_rendezvous_cpus which enables use of IPI
  handlers which can fail and require retrying.
  
  wait_func argument is added to to provide a routine which can be used to
  poll CPU of interest for when the IPI can be retried.
  
  Handlers which succeed must call smp_rendezvous_cpus_done to denote that
  fact.
  
  Discussed with:jeff
  Differential Revision:https://reviews.freebsd.org/D23582

Modified:
  head/sys/kern/subr_smp.c
  head/sys/sys/smp.h

Modified: head/sys/kern/subr_smp.c
==
--- head/sys/kern/subr_smp.cWed Feb 12 11:15:33 2020(r357807)
+++ head/sys/kern/subr_smp.cWed Feb 12 11:16:55 2020(r357808)
@@ -884,6 +884,47 @@ smp_no_rendezvous_barrier(void *dummy)
 #endif
 }
 
+void
+smp_rendezvous_cpus_retry(cpuset_t map,
+   void (* setup_func)(void *),
+   void (* action_func)(void *),
+   void (* teardown_func)(void *),
+   void (* wait_func)(void *, int),
+   struct smp_rendezvous_cpus_retry_arg *arg)
+{
+   int cpu;
+
+   /*
+* Execute an action on all specified CPUs while retrying until they
+* all acknowledge completion.
+*/
+   CPU_COPY(&map, &arg->cpus);
+   for (;;) {
+   smp_rendezvous_cpus(
+   arg->cpus,
+   setup_func,
+   action_func,
+   teardown_func,
+   arg);
+
+   if (CPU_EMPTY(&arg->cpus))
+   break;
+
+   CPU_FOREACH(cpu) {
+   if (!CPU_ISSET(cpu, &arg->cpus))
+   continue;
+   wait_func(arg, cpu);
+   }
+   }
+}
+
+void
+smp_rendezvous_cpus_done(struct smp_rendezvous_cpus_retry_arg *arg)
+{
+
+   CPU_CLR_ATOMIC(curcpu, &arg->cpus);
+}
+
 /*
  * Wait for specified idle threads to switch once.  This ensures that even
  * preempted threads have cycled through the switch function once,

Modified: head/sys/sys/smp.h
==
--- head/sys/sys/smp.h  Wed Feb 12 11:15:33 2020(r357807)
+++ head/sys/sys/smp.h  Wed Feb 12 11:16:55 2020(r357808)
@@ -276,6 +276,19 @@ void   smp_rendezvous_cpus(cpuset_t,
   void (*)(void *),
   void (*)(void *),
   void *arg);
+
+struct smp_rendezvous_cpus_retry_arg {
+   cpuset_t cpus;
+};
+void   smp_rendezvous_cpus_retry(cpuset_t,
+  void (*)(void *),
+  void (*)(void *),
+  void (*)(void *),
+  void (*)(void *, int),
+  struct smp_rendezvous_cpus_retry_arg *);
+
+void   smp_rendezvous_cpus_done(struct smp_rendezvous_cpus_retry_arg *);
+
 #endif /* !LOCORE */
 #endif /* _KERNEL */
 #endif /* _SYS_SMP_H_ */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357807 - head/sys/amd64/include

2020-02-12 Thread Mateusz Guzik
Author: mjg
Date: Wed Feb 12 11:15:33 2020
New Revision: 357807
URL: https://svnweb.freebsd.org/changeset/base/357807

Log:
  amd64: provide custom zpcpu set/add/sub routines
  
  Note that clobbers are highly overzealous, can be cleaned up later.

Modified:
  head/sys/amd64/include/counter.h
  head/sys/amd64/include/pcpu.h

Modified: head/sys/amd64/include/counter.h
==
--- head/sys/amd64/include/counter.hWed Feb 12 11:14:23 2020
(r357806)
+++ head/sys/amd64/include/counter.hWed Feb 12 11:15:33 2020
(r357807)
@@ -86,10 +86,7 @@ counter_u64_add(counter_u64_t c, int64_t inc)
 {
 
KASSERT(IS_BSP() || c != EARLY_COUNTER, ("EARLY_COUNTER used on AP"));
-   __asm __volatile("addq\t%1,%%gs:(%0)"
-   :
-   : "r" (c), "ri" (inc)
-   : "memory", "cc");
+   zpcpu_add(c, inc);
 }
 
 #endif /* ! __MACHINE_COUNTER_H__ */

Modified: head/sys/amd64/include/pcpu.h
==
--- head/sys/amd64/include/pcpu.h   Wed Feb 12 11:14:23 2020
(r357806)
+++ head/sys/amd64/include/pcpu.h   Wed Feb 12 11:15:33 2020
(r357807)
@@ -244,6 +244,63 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x c
 #define zpcpu_base_to_offset(base) (void *)((uintptr_t)(base) - 
(uintptr_t)&__pcpu[0])
 #define zpcpu_offset_to_base(base) (void *)((uintptr_t)(base) + 
(uintptr_t)&__pcpu[0])
 
+#define zpcpu_sub_protected(base, n) do {  \
+   ZPCPU_ASSERT_PROTECTED();   \
+   zpcpu_sub(base, n); \
+} while (0)
+
+#define zpcpu_set_protected(base, n) do {  \
+   __typeof(*base) __n = (n);  \
+   ZPCPU_ASSERT_PROTECTED();   \
+   switch (sizeof(*base)) {\
+   case 4: \
+   __asm __volatile("movl\t%1,%%gs:(%0)"   \
+   : : "r" (base), "ri" (__n) : "memory", "cc");   \
+   break;  \
+   case 8: \
+   __asm __volatile("movq\t%1,%%gs:(%0)"   \
+   : : "r" (base), "ri" (__n) : "memory", "cc");   \
+   break;  \
+   default:\
+   *zpcpu_get(base) = __n; \
+   }   \
+} while (0);
+
+#define zpcpu_add(base, n) do {
\
+   __typeof(*base) __n = (n);  \
+   CTASSERT(sizeof(*base) == 4 || sizeof(*base) == 8); \
+   switch (sizeof(*base)) {\
+   case 4: \
+   __asm __volatile("addl\t%1,%%gs:(%0)"   \
+   : : "r" (base), "ri" (__n) : "memory", "cc");   \
+   break;  \
+   case 8: \
+   __asm __volatile("addq\t%1,%%gs:(%0)"   \
+   : : "r" (base), "ri" (__n) : "memory", "cc");   \
+   break;  \
+   }   \
+} while (0)
+
+#define zpcpu_add_protected(base, n) do {  \
+   ZPCPU_ASSERT_PROTECTED();   \
+   zpcpu_add(base, n); \
+} while (0)
+
+#define zpcpu_sub(base, n) do {
\
+   __typeof(*base) __n = (n);  \
+   CTASSERT(sizeof(*base) == 4 || sizeof(*base) == 8); \
+   switch (sizeof(*base)) {\
+   case 4: \
+   __asm __volatile("subl\t%1,%%gs:(%0)"   \
+   : : "r" (base), "ri" (__n) : "memory", "cc");   \
+   break;  \
+   case 8: \
+   __asm __volatile("subq\t%1,%%gs:(%0)"   \
+   : : "r" (base), "ri" (__n) : "memory", "cc");   \
+   break;  \
+   }  

svn commit: r357806 - head/sys/sys

2020-02-12 Thread Mateusz Guzik
Author: mjg
Date: Wed Feb 12 11:14:23 2020
New Revision: 357806
URL: https://svnweb.freebsd.org/changeset/base/357806

Log:
  Dedup zpcpu assertions into one macro and guard the rest with #ifndef
  
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/sys/pcpu.h

Modified: head/sys/sys/pcpu.h
==
--- head/sys/sys/pcpu.h Wed Feb 12 11:12:13 2020(r357805)
+++ head/sys/sys/pcpu.h Wed Feb 12 11:14:23 2020(r357806)
@@ -228,6 +228,10 @@ extern struct pcpu *cpuid_to_pcpu[];
 #endif
 #definecurproc (curthread->td_proc)
 
+#ifndef ZPCPU_ASSERT_PROTECTED
+#define ZPCPU_ASSERT_PROTECTED() MPASS(curthread->td_critnest > 0)
+#endif
+
 #ifndef zpcpu_offset_cpu
 #define zpcpu_offset_cpu(cpu)  (UMA_PCPU_ALLOC_SIZE * cpu)
 #endif
@@ -277,26 +281,32 @@ extern struct pcpu *cpuid_to_pcpu[];
_old;   \
 })
 
+#ifndef zpcpu_set_protected
 #define zpcpu_set_protected(base, val) ({  \
-   MPASS(curthread->td_critnest > 0);  \
+   ZPCPU_ASSERT_PROTECTED();   \
__typeof(val) *_ptr = zpcpu_get(base);  \
\
*_ptr = (val);  \
 })
+#endif
 
+#ifndef zpcpu_add_protected
 #define zpcpu_add_protected(base, val) ({  \
-   MPASS(curthread->td_critnest > 0);  \
+   ZPCPU_ASSERT_PROTECTED();   \
__typeof(val) *_ptr = zpcpu_get(base);  \
\
*_ptr += (val); \
 })
+#endif
 
+#ifndef zpcpu_sub_protected
 #define zpcpu_sub_protected(base, val) ({  \
-   MPASS(curthread->td_critnest > 0);  \
+   ZPCPU_ASSERT_PROTECTED();   \
__typeof(val) *_ptr = zpcpu_get(base);  \
\
*_ptr -= (val); \
 })
+#endif
 
 /*
  * Machine dependent callouts.  cpu_pcpu_init() is responsible for
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357805 - head/sys/amd64/include

2020-02-12 Thread Mateusz Guzik
Author: mjg
Date: Wed Feb 12 11:12:13 2020
New Revision: 357805
URL: https://svnweb.freebsd.org/changeset/base/357805

Log:
  amd64: store per-cpu allocations subtracted by __pcpu
  
  This eliminates a runtime subtraction from counter_u64_add.
  
  before:
  mov0x4f00ed(%rip),%rax# 0x80c01788 
  sub0x808ff6(%rip),%rax# 0x80f1a698 <__pcpu>
  addq   $0x1,%gs:(%rax)
  
  after:
  mov0x4f02fd(%rip),%rax# 0x80c01788 
  addq   $0x1,%gs:(%rax)
  
  Reviewed by:  jeff
  Differential Revision:https://reviews.freebsd.org/D23570

Modified:
  head/sys/amd64/include/counter.h
  head/sys/amd64/include/pcpu.h

Modified: head/sys/amd64/include/counter.h
==
--- head/sys/amd64/include/counter.hWed Feb 12 11:11:22 2020
(r357804)
+++ head/sys/amd64/include/counter.hWed Feb 12 11:12:13 2020
(r357805)
@@ -33,7 +33,7 @@
 
 #include 
 
-#defineEARLY_COUNTER   &temp_bsp_pcpu.pc_early_dummy_counter
+#defineEARLY_COUNTER   (void *)__offsetof(struct pcpu, 
pc_early_dummy_counter)
 
 #definecounter_enter() do {} while (0)
 #definecounter_exit()  do {} while (0)
@@ -43,6 +43,7 @@ static inline uint64_t
 counter_u64_read_one(counter_u64_t c, int cpu)
 {
 
+   MPASS(c != EARLY_COUNTER);
return (*zpcpu_get_cpu(c, cpu));
 }
 
@@ -65,6 +66,7 @@ counter_u64_zero_one_cpu(void *arg)
counter_u64_t c;
 
c = arg;
+   MPASS(c != EARLY_COUNTER);
*(zpcpu_get(c)) = 0;
 }
 
@@ -86,7 +88,7 @@ counter_u64_add(counter_u64_t c, int64_t inc)
KASSERT(IS_BSP() || c != EARLY_COUNTER, ("EARLY_COUNTER used on AP"));
__asm __volatile("addq\t%1,%%gs:(%0)"
:
-   : "r" ((char *)c - (char *)&__pcpu[0]), "ri" (inc)
+   : "r" (c), "ri" (inc)
: "memory", "cc");
 }
 

Modified: head/sys/amd64/include/pcpu.h
==
--- head/sys/amd64/include/pcpu.h   Wed Feb 12 11:11:22 2020
(r357804)
+++ head/sys/amd64/include/pcpu.h   Wed Feb 12 11:12:13 2020
(r357805)
@@ -240,6 +240,10 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x c
 
 #defineIS_BSP()(PCPU_GET(cpuid) == 0)
 
+#define zpcpu_offset_cpu(cpu)  ((uintptr_t)&__pcpu[0] + UMA_PCPU_ALLOC_SIZE * 
cpu)
+#define zpcpu_base_to_offset(base) (void *)((uintptr_t)(base) - 
(uintptr_t)&__pcpu[0])
+#define zpcpu_offset_to_base(base) (void *)((uintptr_t)(base) + 
(uintptr_t)&__pcpu[0])
+
 #else /* !__GNUCLIKE_ASM || !__GNUCLIKE___TYPEOF */
 
 #error "this file needs to be ported to your compiler"
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357804 - in head/sys: kern riscv/include sys vm

2020-02-12 Thread Mateusz Guzik
Author: mjg
Date: Wed Feb 12 11:11:22 2020
New Revision: 357804
URL: https://svnweb.freebsd.org/changeset/base/357804

Log:
  Store offset into zpcpu allocations in the per-cpu area.
  
  This shorten zpcpu_get and allows more optimizations.
  
  Reviewed by:  jeff
  Differential Revision:https://reviews.freebsd.org/D23570

Modified:
  head/sys/kern/subr_pcpu.c
  head/sys/riscv/include/pcpu.h
  head/sys/sys/pcpu.h
  head/sys/vm/uma_core.c

Modified: head/sys/kern/subr_pcpu.c
==
--- head/sys/kern/subr_pcpu.c   Wed Feb 12 11:10:10 2020(r357803)
+++ head/sys/kern/subr_pcpu.c   Wed Feb 12 11:11:22 2020(r357804)
@@ -95,6 +95,7 @@ pcpu_init(struct pcpu *pcpu, int cpuid, size_t size)
cpu_pcpu_init(pcpu, cpuid, size);
pcpu->pc_rm_queue.rmq_next = &pcpu->pc_rm_queue;
pcpu->pc_rm_queue.rmq_prev = &pcpu->pc_rm_queue;
+   pcpu->pc_zpcpu_offset = zpcpu_offset_cpu(cpuid);
 }
 
 void

Modified: head/sys/riscv/include/pcpu.h
==
--- head/sys/riscv/include/pcpu.h   Wed Feb 12 11:10:10 2020
(r357803)
+++ head/sys/riscv/include/pcpu.h   Wed Feb 12 11:11:22 2020
(r357804)
@@ -48,7 +48,7 @@
struct pmap *pc_curpmap;/* Currently active pmap */ \
uint32_t pc_pending_ipis;   /* IPIs pending to this CPU */  \
uint32_t pc_hart;   /* Hart ID */   \
-   char __pad[57]
+   char __pad[49]
 
 #ifdef _KERNEL
 

Modified: head/sys/sys/pcpu.h
==
--- head/sys/sys/pcpu.h Wed Feb 12 11:10:10 2020(r357803)
+++ head/sys/sys/pcpu.h Wed Feb 12 11:11:22 2020(r357804)
@@ -194,6 +194,7 @@ struct pcpu {
struct rm_queue pc_rm_queue;/* rmlock list of trackers */
uintptr_t   pc_dynamic; /* Dynamic per-cpu data area */
uint64_tpc_early_dummy_counter; /* Startup time counter(9) */
+   uintptr_t   pc_zpcpu_offset;/* Offset into zpcpu allocs */
 
/*
 * Keep MD fields last, so that CPU-specific variations on a
@@ -227,14 +228,28 @@ extern struct pcpu *cpuid_to_pcpu[];
 #endif
 #definecurproc (curthread->td_proc)
 
+#ifndef zpcpu_offset_cpu
+#define zpcpu_offset_cpu(cpu)  (UMA_PCPU_ALLOC_SIZE * cpu)
+#endif
+#ifndef zpcpu_offset
+#define zpcpu_offset() (PCPU_GET(zpcpu_offset))
+#endif
+
+#ifndef zpcpu_base_to_offset
+#define zpcpu_base_to_offset(base) (base)
+#endif
+#ifndef zpcpu_offset_to_base
+#define zpcpu_offset_to_base(base) (base)
+#endif
+
 /* Accessor to elements allocated via UMA_ZONE_PCPU zone. */
 #define zpcpu_get(base) ({ 
\
-   __typeof(base) _ptr = (void *)((char *)(base) + UMA_PCPU_ALLOC_SIZE * 
curcpu);  \
+   __typeof(base) _ptr = (void *)((char *)(base) + zpcpu_offset());
\
_ptr;   
\
 })
 
 #define zpcpu_get_cpu(base, cpu) ({
\
-   __typeof(base) _ptr = (void *)((char *)(base) + UMA_PCPU_ALLOC_SIZE * 
cpu); \
+   __typeof(base) _ptr = (void *)((char *)(base) + zpcpu_offset_cpu(cpu)); 
\
_ptr;   
\
 })
 

Modified: head/sys/vm/uma_core.c
==
--- head/sys/vm/uma_core.c  Wed Feb 12 11:10:10 2020(r357803)
+++ head/sys/vm/uma_core.c  Wed Feb 12 11:11:22 2020(r357804)
@@ -2944,34 +2944,39 @@ uma_zwait(uma_zone_t zone)
 void *
 uma_zalloc_pcpu_arg(uma_zone_t zone, void *udata, int flags)
 {
-   void *item;
+   void *item, *pcpu_item;
 #ifdef SMP
int i;
 
MPASS(zone->uz_flags & UMA_ZONE_PCPU);
 #endif
item = uma_zalloc_arg(zone, udata, flags & ~M_ZERO);
-   if (item != NULL && (flags & M_ZERO)) {
+   if (item == NULL)
+   return (NULL);
+   pcpu_item = zpcpu_base_to_offset(item);
+   if (flags & M_ZERO) {
 #ifdef SMP
for (i = 0; i <= mp_maxid; i++)
-   bzero(zpcpu_get_cpu(item, i), zone->uz_size);
+   bzero(zpcpu_get_cpu(pcpu_item, i), zone->uz_size);
 #else
bzero(item, zone->uz_size);
 #endif
}
-   return (item);
+   return (pcpu_item);
 }
 
 /*
  * A stub while both regular and pcpu cases are identical.
  */
 void
-uma_zfree_pcpu_arg(uma_zone_t zone, void *item, void *udata)
+uma_zfree_pcpu_arg(uma_zone_t zone, void *pcpu_item, void *udata)
 {
+   void *item;
 
 #ifdef SMP
MPASS(zone->uz_flags & UMA_ZONE_PCPU);
 #endif
+   item = zpcpu_offset_to_base(pcpu_item);
uma_zf

svn commit: r357803 - head/sys/kern

2020-02-12 Thread Mateusz Guzik
Author: mjg
Date: Wed Feb 12 11:10:10 2020
New Revision: 357803
URL: https://svnweb.freebsd.org/changeset/base/357803

Log:
  epoch: convert zpcpu_get_cpua(.., curcpu) to zpcpu_get

Modified:
  head/sys/kern/subr_epoch.c

Modified: head/sys/kern/subr_epoch.c
==
--- head/sys/kern/subr_epoch.c  Wed Feb 12 10:03:25 2020(r357802)
+++ head/sys/kern/subr_epoch.c  Wed Feb 12 11:10:10 2020(r357803)
@@ -357,7 +357,7 @@ static epoch_record_t
 epoch_currecord(epoch_t epoch)
 {
 
-   return (zpcpu_get_cpu(epoch->e_pcpu_record, curcpu));
+   return (zpcpu_get(epoch->e_pcpu_record));
 }
 
 #define INIT_CHECK(epoch)  \
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357802 - head/sys/dev/mlx5/mlx5_en

2020-02-12 Thread Hans Petter Selasky
Author: hselasky
Date: Wed Feb 12 10:03:25 2020
New Revision: 357802
URL: https://svnweb.freebsd.org/changeset/base/357802

Log:
  Add support for debugnet in mlx5en(4).
  
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c

Modified: head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
==
--- head/sys/dev/mlx5/mlx5_en/mlx5_en_main.cWed Feb 12 09:58:19 2020
(r357801)
+++ head/sys/dev/mlx5/mlx5_en/mlx5_en_main.cWed Feb 12 10:03:25 2020
(r357802)
@@ -33,6 +33,8 @@
 #include 
 #include 
 
+#include 
+
 #ifndef ETH_DRIVER_VERSION
 #defineETH_DRIVER_VERSION  "3.5.2"
 #endif
@@ -399,6 +401,8 @@ static const struct media mlx5e_ext_mode_table[MLX5E_E
},
 };
 
+DEBUGNET_DEFINE(mlx5_en);
+
 MALLOC_DEFINE(M_MLX5EN, "MLX5EN", "MLX5 Ethernet");
 
 static void
@@ -,6 +4448,9 @@ mlx5e_create_ifp(struct mlx5_core_dev *mdev)
/* Set autoselect by default */
ifmedia_set(&priv->media, IFM_ETHER | IFM_AUTO | IFM_FDX |
IFM_ETH_RXPAUSE | IFM_ETH_TXPAUSE);
+
+   DEBUGNET_SET(ifp, mlx5_en);
+
ether_ifattach(ifp, dev_addr);
 
/* Register for VLAN events */
@@ -4590,6 +4597,71 @@ mlx5e_destroy_ifp(struct mlx5_core_dev *mdev, void *vp
if_free(ifp);
free(priv, M_MLX5EN);
 }
+
+#ifdef DEBUGNET
+static void
+mlx5_en_debugnet_init(struct ifnet *dev, int *nrxr, int *ncl, int *clsize)
+{
+   struct mlx5e_priv *priv = if_getsoftc(dev);
+
+   PRIV_LOCK(priv);
+   *nrxr = priv->params.num_channels;
+   *ncl = DEBUGNET_MAX_IN_FLIGHT;
+   *clsize = MLX5E_MAX_RX_BYTES;
+   PRIV_UNLOCK(priv);
+}
+
+static void
+mlx5_en_debugnet_event(struct ifnet *dev, enum debugnet_ev event)
+{
+}
+
+static int
+mlx5_en_debugnet_transmit(struct ifnet *dev, struct mbuf *m)
+{
+   struct mlx5e_priv *priv = if_getsoftc(dev);
+   struct mlx5e_sq *sq;
+   int err;
+
+   if ((if_getdrvflags(dev) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
+   IFF_DRV_RUNNING || (priv->media_status_last & IFM_ACTIVE) == 0)
+   return (ENOENT);
+
+   sq = &priv->channel[0].sq[0];
+
+   if (sq->running == 0) {
+   m_freem(m);
+   return (ENOENT);
+   }
+
+   if (mlx5e_sq_xmit(sq, &m) != 0) {
+   m_freem(m);
+   err = ENOBUFS;
+   } else {
+   err = 0;
+   }
+
+   if (likely(sq->doorbell.d64 != 0)) {
+   mlx5e_tx_notify_hw(sq, sq->doorbell.d32, 0);
+   sq->doorbell.d64 = 0;
+   }
+   return (err);
+}
+
+static int
+mlx5_en_debugnet_poll(struct ifnet *dev, int count)
+{
+   struct mlx5e_priv *priv = if_getsoftc(dev);
+
+   if ((if_getdrvflags(dev) & IFF_DRV_RUNNING) == 0 ||
+   (priv->media_status_last & IFM_ACTIVE) == 0)
+   return (ENOENT);
+
+   mlx5_poll_interrupts(priv->mdev);
+
+   return (0);
+}
+#endif /* DEBUGNET */
 
 static void *
 mlx5e_get_ifp(void *vpriv)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357801 - in head/sys/dev/mlx5: . mlx5_core

2020-02-12 Thread Hans Petter Selasky
Author: hselasky
Date: Wed Feb 12 09:58:19 2020
New Revision: 357801
URL: https://svnweb.freebsd.org/changeset/base/357801

Log:
  Add support for disabling and polling MSIX interrupts in mlx5core.
  
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/dev/mlx5/driver.h
  head/sys/dev/mlx5/mlx5_core/mlx5_eq.c
  head/sys/dev/mlx5/mlx5_core/mlx5_main.c

Modified: head/sys/dev/mlx5/driver.h
==
--- head/sys/dev/mlx5/driver.h  Wed Feb 12 09:19:47 2020(r357800)
+++ head/sys/dev/mlx5/driver.h  Wed Feb 12 09:58:19 2020(r357801)
@@ -1180,4 +1180,7 @@ static inline bool mlx5_rl_is_supported(struct mlx5_co
 }
 #endif
 
+void mlx5_disable_interrupts(struct mlx5_core_dev *);
+void mlx5_poll_interrupts(struct mlx5_core_dev *);
+
 #endif /* MLX5_DRIVER_H */

Modified: head/sys/dev/mlx5/mlx5_core/mlx5_eq.c
==
--- head/sys/dev/mlx5/mlx5_core/mlx5_eq.c   Wed Feb 12 09:19:47 2020
(r357800)
+++ head/sys/dev/mlx5/mlx5_core/mlx5_eq.c   Wed Feb 12 09:58:19 2020
(r357801)
@@ -739,3 +739,28 @@ static void mlx5_port_general_notification_event(struc
}
 }
 
+void
+mlx5_disable_interrupts(struct mlx5_core_dev *dev)
+{
+   int nvec = dev->priv.eq_table.num_comp_vectors + MLX5_EQ_VEC_COMP_BASE;
+   int x;
+
+   for (x = 0; x != nvec; x++)
+   disable_irq(dev->priv.msix_arr[x].vector);
+}
+
+void
+mlx5_poll_interrupts(struct mlx5_core_dev *dev)
+{
+   struct mlx5_eq *eq;
+
+   if (unlikely(dev->priv.disable_irqs != 0))
+   return;
+
+   mlx5_eq_int(dev, &dev->priv.eq_table.cmd_eq);
+   mlx5_eq_int(dev, &dev->priv.eq_table.async_eq);
+   mlx5_eq_int(dev, &dev->priv.eq_table.pages_eq);
+
+   list_for_each_entry(eq, &dev->priv.eq_table.comp_eqs_list, list)
+   mlx5_eq_int(dev, eq);
+}

Modified: head/sys/dev/mlx5/mlx5_core/mlx5_main.c
==
--- head/sys/dev/mlx5/mlx5_core/mlx5_main.c Wed Feb 12 09:19:47 2020
(r357800)
+++ head/sys/dev/mlx5/mlx5_core/mlx5_main.c Wed Feb 12 09:58:19 2020
(r357801)
@@ -1585,7 +1585,7 @@ done:
return 0;
 }
 
-static void mlx5_disable_interrupts(struct mlx5_core_dev *mdev)
+static void mlx5_shutdown_disable_interrupts(struct mlx5_core_dev *mdev)
 {
int nvec = mdev->priv.eq_table.num_comp_vectors + MLX5_EQ_VEC_COMP_BASE;
int x;
@@ -1609,7 +1609,7 @@ static void shutdown_one(struct pci_dev *pdev)
set_bit(MLX5_INTERFACE_STATE_TEARDOWN, &dev->intf_state);
 
/* disable all interrupts */
-   mlx5_disable_interrupts(dev);
+   mlx5_shutdown_disable_interrupts(dev);
 
err = mlx5_try_fast_unload(dev);
if (err)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357800 - head/sys/net

2020-02-12 Thread Hans Petter Selasky
Author: hselasky
Date: Wed Feb 12 09:19:47 2020
New Revision: 357800
URL: https://svnweb.freebsd.org/changeset/base/357800

Log:
  Use NET_TASK_INIT() and NET_GROUPTASK_INIT() for drivers that process
  incoming packets in taskqueue context.
  
  This patch extends r357772.
  
  Tested by:y...@mm.st
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/net/iflib.c

Modified: head/sys/net/iflib.c
==
--- head/sys/net/iflib.cWed Feb 12 08:30:07 2020(r357799)
+++ head/sys/net/iflib.cWed Feb 12 09:19:47 2020(r357800)
@@ -6060,23 +6060,25 @@ iflib_softirq_alloc_generic(if_ctx_t ctx, if_irq_t irq
gtask = &ctx->ifc_txqs[qid].ift_task;
tqg = qgroup_if_io_tqg;
fn = _task_fn_tx;
+   GROUPTASK_INIT(gtask, 0, fn, q);
break;
case IFLIB_INTR_RX:
q = &ctx->ifc_rxqs[qid];
gtask = &ctx->ifc_rxqs[qid].ifr_task;
tqg = qgroup_if_io_tqg;
fn = _task_fn_rx;
+   NET_GROUPTASK_INIT(gtask, 0, fn, q);
break;
case IFLIB_INTR_IOV:
q = ctx;
gtask = &ctx->ifc_vflr_task;
tqg = qgroup_if_config_tqg;
fn = _task_fn_iov;
+   GROUPTASK_INIT(gtask, 0, fn, q);
break;
default:
panic("unknown net intr type");
}
-   GROUPTASK_INIT(gtask, 0, fn, q);
if (irq != NULL) {
err = iflib_irq_set_affinity(ctx, irq, type, qid, gtask, tqg,
q, name);
@@ -6111,7 +6113,6 @@ iflib_legacy_setup(if_ctx_t ctx, driver_filter_t filte
struct grouptask *gtask;
struct resource *res;
struct taskqgroup *tqg;
-   gtask_fn_t *fn;
void *q;
int err, tqrid;
bool rx_only;
@@ -6121,7 +6122,6 @@ iflib_legacy_setup(if_ctx_t ctx, driver_filter_t filte
gtask = &rxq[0].ifr_task;
tqg = qgroup_if_io_tqg;
tqrid = *rid;
-   fn = _task_fn_rx;
rx_only = (ctx->ifc_sctx->isc_flags & IFLIB_SINGLE_IRQ_RX_ONLY) != 0;
 
ctx->ifc_flags |= IFC_LEGACY;
@@ -6136,7 +6136,7 @@ iflib_legacy_setup(if_ctx_t ctx, driver_filter_t filte
iflib_fast_intr_rxtx, NULL, info, name);
if (err != 0)
return (err);
-   GROUPTASK_INIT(gtask, 0, fn, q);
+   NET_GROUPTASK_INIT(gtask, 0, _task_fn_rx, q);
res = irq->ii_res;
taskqgroup_attach(tqg, gtask, q, dev, res, name);
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r357799 - head/sys/net

2020-02-12 Thread Hans Petter Selasky
Author: hselasky
Date: Wed Feb 12 08:30:07 2020
New Revision: 357799
URL: https://svnweb.freebsd.org/changeset/base/357799

Log:
  Make sure the so-called end of receive interrupts don't starve in iflib.
  
  When the receive ring cannot be filled with mbufs, due to lack of memory,
  no more interrupts may be generated to fill the receive ring later on.
  Make sure to have a watchdog, to try refilling the receive ring from time
  to time, hopefully when more mbufs are available.
  
  Differential Revision:https://reviews.freebsd.org/D23315
  MFC after:1 week
  Reviewed by:  gallatin@
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/net/iflib.c

Modified: head/sys/net/iflib.c
==
--- head/sys/net/iflib.cWed Feb 12 06:56:04 2020(r357798)
+++ head/sys/net/iflib.cWed Feb 12 08:30:07 2020(r357799)
@@ -129,6 +129,9 @@ __FBSDID("$FreeBSD$");
  */
 MALLOC_DEFINE(M_IFLIB, "iflib", "ifnet library");
 
+#defineIFLIB_RXEOF_MORE (1U << 0)
+#defineIFLIB_RXEOF_EMPTY (2U << 0)
+
 struct iflib_txq;
 typedef struct iflib_txq *iflib_txq_t;
 struct iflib_rxq;
@@ -434,6 +437,7 @@ struct iflib_rxq {
uint8_t ifr_fl_offset;
struct lro_ctrl ifr_lc;
struct grouptaskifr_task;
+   struct callout  ifr_watchdog;
struct iflib_filter_info ifr_filter_info;
iflib_dma_info_tifr_ifdi;
 
@@ -1940,7 +1944,7 @@ _rxq_refill_cb(void *arg, bus_dma_segment_t *segs, int
  * (Re)populate an rxq free-buffer list with up to @count new packet buffers.
  * The caller must assure that @count does not exceed the queue's capacity.
  */
-static void
+static uint8_t
 _iflib_fl_refill(if_ctx_t ctx, iflib_fl_t fl, int count)
 {
struct if_rxd_update iru;
@@ -2069,9 +2073,11 @@ _iflib_fl_refill(if_ctx_t ctx, iflib_fl_t fl, int coun
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
ctx->isc_rxd_flush(ctx->ifc_softc, fl->ifl_rxq->ifr_id, fl->ifl_id, 
pidx);
fl->ifl_fragidx = frag_idx;
+
+   return (n == -1 ? 0 : IFLIB_RXEOF_EMPTY);
 }
 
-static __inline void
+static __inline uint8_t
 __iflib_fl_refill_lt(if_ctx_t ctx, iflib_fl_t fl, int max)
 {
/* we avoid allowing pidx to catch up with cidx as it confuses ixl */
@@ -2084,7 +2090,8 @@ __iflib_fl_refill_lt(if_ctx_t ctx, iflib_fl_t fl, int 
MPASS(reclaimable == delta);
 
if (reclaimable > 0)
-   _iflib_fl_refill(ctx, fl, min(max, reclaimable));
+   return (_iflib_fl_refill(ctx, fl, min(max, reclaimable)));
+   return (0);
 }
 
 uint8_t
@@ -2172,7 +2179,7 @@ iflib_fl_setup(iflib_fl_t fl)
/* avoid pre-allocating zillions of clusters to an idle card
 * potentially speeding up attach
 */
-   _iflib_fl_refill(ctx, fl, min(128, fl->ifl_size));
+   (void) _iflib_fl_refill(ctx, fl, min(128, fl->ifl_size));
MPASS(min(128, fl->ifl_size) == fl->ifl_credits);
if (min(128, fl->ifl_size) != fl->ifl_credits)
return (ENOBUFS);
@@ -2738,7 +2745,15 @@ iflib_get_ip_forwarding(struct lro_ctrl *lc __unused, 
 }
 #endif
 
-static bool
+static void
+_task_fn_rx_watchdog(void *context)
+{
+   iflib_rxq_t rxq = context;
+
+   GROUPTASK_ENQUEUE(&rxq->ifr_task);
+}
+
+static uint8_t
 iflib_rxeof(iflib_rxq_t rxq, qidx_t budget)
 {
if_t ifp;
@@ -2752,6 +2767,7 @@ iflib_rxeof(iflib_rxq_t rxq, qidx_t budget)
iflib_fl_t fl;
int lro_enabled;
bool v4_forwarding, v6_forwarding, lro_possible;
+   uint8_t retval = 0;
 
/*
 * XXX early demux data packets so that if_input processing only handles
@@ -2772,9 +2788,9 @@ iflib_rxeof(iflib_rxq_t rxq, qidx_t budget)
cidxp = &rxq->ifr_fl[0].ifl_cidx;
if ((avail = iflib_rxd_avail(ctx, rxq, *cidxp, budget)) == 0) {
for (i = 0, fl = &rxq->ifr_fl[0]; i < sctx->isc_nfl; i++, fl++)
-   __iflib_fl_refill_lt(ctx, fl, budget + 8);
+   retval |= __iflib_fl_refill_lt(ctx, fl, budget + 8);
DBG_COUNTER_INC(rx_unavail);
-   return (false);
+   return (retval);
}
 
/* pfil needs the vnet to be set */
@@ -2832,7 +2848,7 @@ iflib_rxeof(iflib_rxq_t rxq, qidx_t budget)
CURVNET_RESTORE();
/* make sure that we can refill faster than drain */
for (i = 0, fl = &rxq->ifr_fl[0]; i < sctx->isc_nfl; i++, fl++)
-   __iflib_fl_refill_lt(ctx, fl, budget + 8);
+   retval |= __iflib_fl_refill_lt(ctx, fl, budget + 8);
 
lro_enabled = (if_getcapenable(ifp) & IFCAP_LRO);
if (lro_enabled)
@@ -2891,15 +2907,15 @@ iflib_rxeof(iflib_rxq_t rxq, qidx_t budget)
 #if defined(INET6) || defined(INET)
tcp_lro_flush_all(&rxq->ifr_lc);
 #endif
-   if (avail)
-   return true;
-   return (