svn commit: r368468 - head/sys/net

2020-12-08 Thread Gleb Smirnoff
Author: glebius
Date: Tue Dec  8 23:54:09 2020
New Revision: 368468
URL: https://svnweb.freebsd.org/changeset/base/368468

Log:
  Fixup r368446 with KERN_TLS.

Modified:
  head/sys/net/if_lagg.c

Modified: head/sys/net/if_lagg.c
==
--- head/sys/net/if_lagg.c  Tue Dec  8 23:38:26 2020(r368467)
+++ head/sys/net/if_lagg.c  Tue Dec  8 23:54:09 2020(r368468)
@@ -1806,11 +1806,11 @@ lagg_snd_tag_alloc(struct ifnet *ifp,
lp = lookup_snd_tag_port(ifp, params->hdr.flowid,
params->hdr.flowtype, params->hdr.numa_domain);
if (lp == NULL) {
-   LAGG_RUNLOCK();
+   NET_EPOCH_EXIT(et);
return (EOPNOTSUPP);
}
if (lp->lp_ifp == NULL) {
-   LAGG_RUNLOCK();
+   NET_EPOCH_EXIT(et);
return (EOPNOTSUPP);
}
lp_ifp = lp->lp_ifp;
___
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: r368448 - head/sys/net

2020-12-08 Thread Gleb Smirnoff
Author: glebius
Date: Tue Dec  8 16:46:00 2020
New Revision: 368448
URL: https://svnweb.freebsd.org/changeset/base/368448

Log:
  The list of ports in configuration path shall be protected by locks,
  epoch shall be used only for fast path.  Thus use LAGG_XLOCK() in
  lagg_[un]register_vlan.  This fixes sleeping in epoch panic.
  
  PR:   240609

Modified:
  head/sys/net/if_lagg.c

Modified: head/sys/net/if_lagg.c
==
--- head/sys/net/if_lagg.c  Tue Dec  8 16:43:35 2020(r368447)
+++ head/sys/net/if_lagg.c  Tue Dec  8 16:46:00 2020(r368448)
@@ -471,17 +471,16 @@ lagg_proto_portreq(struct lagg_softc *sc, struct lagg_
 static void
 lagg_register_vlan(void *arg, struct ifnet *ifp, u_int16_t vtag)
 {
-   struct epoch_tracker et;
struct lagg_softc *sc = ifp->if_softc;
struct lagg_port *lp;
 
if (ifp->if_softc !=  arg)   /* Not our event */
return;
 
-   NET_EPOCH_ENTER(et);
+   LAGG_XLOCK(sc);
CK_SLIST_FOREACH(lp, >sc_ports, lp_entries)
EVENTHANDLER_INVOKE(vlan_config, lp->lp_ifp, vtag);
-   NET_EPOCH_EXIT(et);
+   LAGG_XUNLOCK(sc);
 }
 
 /*
@@ -491,17 +490,16 @@ lagg_register_vlan(void *arg, struct ifnet *ifp, u_int
 static void
 lagg_unregister_vlan(void *arg, struct ifnet *ifp, u_int16_t vtag)
 {
-   struct epoch_tracker et;
struct lagg_softc *sc = ifp->if_softc;
struct lagg_port *lp;
 
if (ifp->if_softc !=  arg)   /* Not our event */
return;
 
-   NET_EPOCH_ENTER(et);
+   LAGG_XLOCK(sc);
CK_SLIST_FOREACH(lp, >sc_ports, lp_entries)
EVENTHANDLER_INVOKE(vlan_unconfig, lp->lp_ifp, vtag);
-   NET_EPOCH_EXIT(et);
+   LAGG_XUNLOCK(sc);
 }
 
 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: r368446 - head/sys/net

2020-12-08 Thread Gleb Smirnoff
Author: glebius
Date: Tue Dec  8 16:36:46 2020
New Revision: 368446
URL: https://svnweb.freebsd.org/changeset/base/368446

Log:
  Convert LAGG_RLOCK() to NET_EPOCH_ENTER(). No functional changes.

Modified:
  head/sys/net/if_lagg.c

Modified: head/sys/net/if_lagg.c
==
--- head/sys/net/if_lagg.c  Tue Dec  8 15:51:05 2020(r368445)
+++ head/sys/net/if_lagg.c  Tue Dec  8 16:36:46 2020(r368446)
@@ -84,11 +84,6 @@ __FBSDID("$FreeBSD$");
 extern voidnd6_setmtu(struct ifnet *);
 #endif
 
-#defineLAGG_RLOCK()struct epoch_tracker lagg_et; 
epoch_enter_preempt(net_epoch_preempt, _et)
-#defineLAGG_RUNLOCK()  epoch_exit_preempt(net_epoch_preempt, _et)
-#defineLAGG_RLOCK_ASSERT() NET_EPOCH_ASSERT()
-#defineLAGG_UNLOCK_ASSERT()MPASS(!in_epoch(net_epoch_preempt))
-
 #defineLAGG_SX_INIT(_sc)   sx_init(&(_sc)->sc_sx, "if_lagg sx")
 #defineLAGG_SX_DESTROY(_sc)sx_destroy(&(_sc)->sc_sx)
 #defineLAGG_XLOCK(_sc) sx_xlock(&(_sc)->sc_sx)
@@ -476,16 +471,17 @@ lagg_proto_portreq(struct lagg_softc *sc, struct lagg_
 static void
 lagg_register_vlan(void *arg, struct ifnet *ifp, u_int16_t vtag)
 {
+   struct epoch_tracker et;
struct lagg_softc *sc = ifp->if_softc;
struct lagg_port *lp;
 
if (ifp->if_softc !=  arg)   /* Not our event */
return;
 
-   LAGG_RLOCK();
+   NET_EPOCH_ENTER(et);
CK_SLIST_FOREACH(lp, >sc_ports, lp_entries)
EVENTHANDLER_INVOKE(vlan_config, lp->lp_ifp, vtag);
-   LAGG_RUNLOCK();
+   NET_EPOCH_EXIT(et);
 }
 
 /*
@@ -495,16 +491,17 @@ lagg_register_vlan(void *arg, struct ifnet *ifp, u_int
 static void
 lagg_unregister_vlan(void *arg, struct ifnet *ifp, u_int16_t vtag)
 {
+   struct epoch_tracker et;
struct lagg_softc *sc = ifp->if_softc;
struct lagg_port *lp;
 
if (ifp->if_softc !=  arg)   /* Not our event */
return;
 
-   LAGG_RLOCK();
+   NET_EPOCH_ENTER(et);
CK_SLIST_FOREACH(lp, >sc_ports, lp_entries)
EVENTHANDLER_INVOKE(vlan_unconfig, lp->lp_ifp, vtag);
-   LAGG_RUNLOCK();
+   NET_EPOCH_EXIT(et);
 }
 
 static int
@@ -1011,6 +1008,7 @@ lagg_port_destroy(struct lagg_port *lp, int rundelport
 static int
 lagg_port_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
 {
+   struct epoch_tracker et;
struct lagg_reqport *rp = (struct lagg_reqport *)data;
struct lagg_softc *sc;
struct lagg_port *lp = NULL;
@@ -1035,15 +1033,15 @@ lagg_port_ioctl(struct ifnet *ifp, u_long cmd, caddr_t
break;
}
 
-   LAGG_RLOCK();
+   NET_EPOCH_ENTER(et);
if ((lp = ifp->if_lagg) == NULL || lp->lp_softc != sc) {
error = ENOENT;
-   LAGG_RUNLOCK();
+   NET_EPOCH_EXIT(et);
break;
}
 
lagg_port2req(lp, rp);
-   LAGG_RUNLOCK();
+   NET_EPOCH_EXIT(et);
break;
 
case SIOCSIFCAP:
@@ -1096,6 +1094,7 @@ fallback:
 static uint64_t
 lagg_get_counter(struct ifnet *ifp, ift_counter cnt)
 {
+   struct epoch_tracker et;
struct lagg_softc *sc;
struct lagg_port *lp;
struct ifnet *lpifp;
@@ -1107,7 +1106,7 @@ lagg_get_counter(struct ifnet *ifp, ift_counter cnt)
sc = (struct lagg_softc *)ifp->if_softc;
 
vsum = 0;
-   LAGG_RLOCK();
+   NET_EPOCH_ENTER(et);
CK_SLIST_FOREACH(lp, >sc_ports, lp_entries) {
/* Saved attached value */
oldval = lp->port_counters.val[cnt];
@@ -1117,7 +1116,7 @@ lagg_get_counter(struct ifnet *ifp, ift_counter cnt)
/* Calculate diff and save new */
vsum += newval - oldval;
}
-   LAGG_RUNLOCK();
+   NET_EPOCH_EXIT(et);
 
/*
 * Add counter data which might be added by upper
@@ -1218,6 +1217,7 @@ lagg_port2req(struct lagg_port *lp, struct lagg_reqpor
 static void
 lagg_watchdog_infiniband(void *arg)
 {
+   struct epoch_tracker et;
struct lagg_softc *sc;
struct lagg_port *lp;
struct ifnet *ifp;
@@ -1234,7 +1234,7 @@ lagg_watchdog_infiniband(void *arg)
 * a guarantee against too frequent events. This operation
 * does not have to be atomic.
 */
-   LAGG_RLOCK();
+   NET_EPOCH_ENTER(et);
lp = lagg_link_active(sc, sc->sc_primary);
if (lp != NULL) {
ifp = sc->sc_ifp;
@@ -1248,7 +1248,7 @@ lagg_watchdog_infiniband(void *arg)
CURVNET_RESTORE();
}
}
-   LAGG_RUNLOCK();
+   NET_EPOCH_EXIT(et);
 
callout_reset(>sc_watchdog, hz, _watchdog_infiniband, arg);
 }
@@ -1314,6 +1314,7 @@ lagg_stop(struct lagg_softc *sc)
 static 

svn commit: r368287 - head/sbin/bectl

2020-12-02 Thread Gleb Smirnoff
Author: glebius
Date: Wed Dec  2 21:53:28 2020
New Revision: 368287
URL: https://svnweb.freebsd.org/changeset/base/368287

Log:
  Fix r368197: suppress error printing for the "check" command.
  
  Reviewed by:  kevans

Modified:
  head/sbin/bectl/bectl.c

Modified: head/sbin/bectl/bectl.c
==
--- head/sbin/bectl/bectl.c Wed Dec  2 21:44:41 2020(r368286)
+++ head/sbin/bectl/bectl.c Wed Dec  2 21:53:28 2020(r368287)
@@ -585,8 +585,9 @@ main(int argc, char *argv[])
}
 
if ((be = libbe_init(root)) == NULL) {
-   fprintf(stderr, "libbe_init(\"%s\") failed.\n",
-   root != NULL ? root : "");
+   if (!cmd->silent)
+   fprintf(stderr, "libbe_init(\"%s\") failed.\n",
+   root != NULL ? root : "");
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"


Re: svn commit: r368197 - head/sbin/bectl

2020-12-02 Thread Gleb Smirnoff
  Kyle,

On Wed, Dec 02, 2020 at 12:08:43PM -0600, Kyle Evans wrote:
K> > K> This should be gated on !cmd->silent, because some paths have
K> > K> consumers that are specifically designed to not have to deal with
K> > K> redirecting stderr. It was quite intentional that this didn't
K> > K> previously print anything.
K> >
K> > AFAIK, the only command that has cmd->silent is "check".
K> >
K> > I can't agree that it should suppress stderr in case of libbe_init()
K> > failure. Failure of the library is something different to failed
K> > check of current system. It is permanent failure, meaning that command
K> > is being with incorrect root argument or ZFS is missing at all. Pretty
K> > much the same as using bectl with incorrect arguments or options.
K> >
K> 
K> The sole purpose of `bectl check` is to weed out if bectl will work
K> (i.e. if libbe_init succeeds) so that scripts like freebsd-update can
K> determine if they're running on a system or with a root (`bectl -r`)
K> that can work with boot environments. It is not meant to give
K> diagnostics like that upon failure, its sole purpose is to know if
K> your script should proceed with doing bectl-y things safely or if it
K> will just be fraught with peril.

Understood. Sorry for my mistake. Is this patch a correct one?

Index: bectl.c
===
--- bectl.c (revision 368197)
+++ bectl.c (working copy)
@@ -585,8 +585,9 @@ main(int argc, char *argv[])
}
 
if ((be = libbe_init(root)) == NULL) {
-   fprintf(stderr, "libbe_init(\"%s\") failed.\n",
-   root != NULL ? root : "");
+   if (!cmd->silent)
+       fprintf(stderr, "libbe_init(\"%s\") failed.\n",
+   root != NULL ? root : "");
return (-1);
}

-- 
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"


Re: svn commit: r368197 - head/sbin/bectl

2020-12-02 Thread Gleb Smirnoff
  Kyle,

On Mon, Nov 30, 2020 at 08:28:58PM -0600, Kyle Evans wrote:
K> > Log:
K> >   Print at least something when failing.
K> >
K> > Modified:
K> >   head/sbin/bectl/bectl.c
K> >
K> > Modified: head/sbin/bectl/bectl.c
K> > 
==
K> > --- head/sbin/bectl/bectl.c Mon Nov 30 20:58:42 2020(r368196)
K> > +++ head/sbin/bectl/bectl.c Mon Nov 30 21:05:31 2020(r368197)
K> > @@ -584,8 +584,11 @@ main(int argc, char *argv[])
K> > return (usage(false));
K> > }
K> >
K> > -   if ((be = libbe_init(root)) == NULL)
K> > +   if ((be = libbe_init(root)) == NULL) {
K> > +   fprintf(stderr, "libbe_init(\"%s\") failed.\n",
K> > +   root != NULL ? root : "");
K> > return (-1);
K> > +   }
K> >
K> > libbe_print_on_error(be, !cmd->silent);
K> >
K> 
K> This should be gated on !cmd->silent, because some paths have
K> consumers that are specifically designed to not have to deal with
K> redirecting stderr. It was quite intentional that this didn't
K> previously print anything.

AFAIK, the only command that has cmd->silent is "check".

I can't agree that it should suppress stderr in case of libbe_init()
failure. Failure of the library is something different to failed
check of current system. It is permanent failure, meaning that command
is being with incorrect root argument or ZFS is missing at all. Pretty
much the same as using bectl with incorrect arguments or options.

-- 
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: r368197 - head/sbin/bectl

2020-11-30 Thread Gleb Smirnoff
Author: glebius
Date: Mon Nov 30 21:05:31 2020
New Revision: 368197
URL: https://svnweb.freebsd.org/changeset/base/368197

Log:
  Print at least something when failing.

Modified:
  head/sbin/bectl/bectl.c

Modified: head/sbin/bectl/bectl.c
==
--- head/sbin/bectl/bectl.c Mon Nov 30 20:58:42 2020(r368196)
+++ head/sbin/bectl/bectl.c Mon Nov 30 21:05:31 2020(r368197)
@@ -584,8 +584,11 @@ main(int argc, char *argv[])
return (usage(false));
}
 
-   if ((be = libbe_init(root)) == NULL)
+   if ((be = libbe_init(root)) == NULL) {
+   fprintf(stderr, "libbe_init(\"%s\") failed.\n",
+   root != NULL ? root : "");
return (-1);
+   }
 
libbe_print_on_error(be, !cmd->silent);
 
___
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: r367824 - head/sbin/savecore

2020-11-18 Thread Gleb Smirnoff
Author: glebius
Date: Thu Nov 19 02:20:38 2020
New Revision: 367824
URL: https://svnweb.freebsd.org/changeset/base/367824

Log:
  Add '-u' switch that would uncompress cores that were compressed by
  kernel during dump time.
  
  A real life scenario is that cores are compressed to reduce
  size of dumpon partition, but we either don't care about space
  in the /var/crash or we have a filesystem level compression of
  /var/crash. And we want cores to be uncompressed in /var/crash
  because we'd like to instantily read them with kgdb. In this
  case we want kernel to write cores compressed, but savecore(1)
  write them uncompressed.
  
  Reviewed by:  markj, gallatin
  Relnotes: yes
  Differential Revision:https://reviews.freebsd.org/D27245

Modified:
  head/sbin/savecore/Makefile
  head/sbin/savecore/savecore.8
  head/sbin/savecore/savecore.c

Modified: head/sbin/savecore/Makefile
==
--- head/sbin/savecore/Makefile Thu Nov 19 00:03:15 2020(r367823)
+++ head/sbin/savecore/Makefile Thu Nov 19 02:20:38 2020(r367824)
@@ -6,8 +6,10 @@ VAR_CRASH= /var/crash
 VAR_CRASH_MODE=0750
 CONFSDIR=  VAR_CRASH
 PROG=  savecore
-LIBADD=xo z
+LIBADD=xo z zstd
 MAN=   savecore.8
+
+CFLAGS+=   -I${SRCTOP}/sys/contrib/zstd/lib
 
 .include 
 

Modified: head/sbin/savecore/savecore.8
==
--- head/sbin/savecore/savecore.8   Thu Nov 19 00:03:15 2020
(r367823)
+++ head/sbin/savecore/savecore.8   Thu Nov 19 02:20:38 2020
(r367824)
@@ -28,7 +28,7 @@
 .\" From: @(#)savecore.8   8.1 (Berkeley) 6/5/93
 .\" $FreeBSD$
 .\"
-.Dd March 17, 2018
+.Dd November 17, 2020
 .Dt SAVECORE 8
 .Os
 .Sh NAME
@@ -45,7 +45,7 @@
 .Op Ar device ...
 .Nm
 .Op Fl -libxo
-.Op Fl fkvz
+.Op Fl fkuvz
 .Op Fl m Ar maxdumps
 .Op Ar directory Op Ar device ...
 .Sh DESCRIPTION
@@ -92,6 +92,8 @@ Once the number of stored dumps is equal to
 .Ar maxdumps
 the counter will restart from
 .Dv 0 .
+.It Fl u
+Uncompress the dump in case it was compressed by the kernel.
 .It Fl v
 Print out some additional debugging information.
 Specify twice for more information.

Modified: head/sbin/savecore/savecore.c
==
--- head/sbin/savecore/savecore.c   Thu Nov 19 00:03:15 2020
(r367823)
+++ head/sbin/savecore/savecore.c   Thu Nov 19 02:20:38 2020
(r367824)
@@ -86,6 +86,9 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#defineZ_SOLO
+#include 
+#include 
 
 #include 
 #include 
@@ -102,7 +105,7 @@ __FBSDID("$FreeBSD$");
 
 static cap_channel_t *capsyslog;
 static fileargs_t *capfa;
-static bool checkfor, compress, clear, force, keep;/* flags */
+static bool checkfor, compress, uncompress, clear, force, keep;/* 
flags */
 static int verbose;
 static int nfound, nsaved, nerr;   /* statistics */
 static int maxdumps;
@@ -441,22 +444,155 @@ compare_magic(const struct kerneldumpheader *kdh, cons
 #define BLOCKSIZE (1<<12)
 #define BLOCKMASK (~(BLOCKSIZE-1))
 
+static size_t
+sparsefwrite(const char *buf, size_t nr, FILE *fp)
+{
+   size_t nw, he, hs;
+
+   for (nw = 0; nw < nr; nw = he) {
+   /* find a contiguous block of zeroes */
+   for (hs = nw; hs < nr; hs += BLOCKSIZE) {
+   for (he = hs; he < nr && buf[he] == 0; ++he)
+   /* nothing */ ;
+   /* is the hole long enough to matter? */
+   if (he >= hs + BLOCKSIZE)
+   break;
+   }
+
+   /* back down to a block boundary */
+   he &= BLOCKMASK;
+
+   /*
+* 1) Don't go beyond the end of the buffer.
+* 2) If the end of the buffer is less than
+*BLOCKSIZE bytes away, we're at the end
+*of the file, so just grab what's left.
+*/
+   if (hs + BLOCKSIZE > nr)
+   hs = he = nr;
+
+   /*
+* At this point, we have a partial ordering:
+* nw <= hs <= he <= nr
+* If hs > nw, buf[nw..hs] contains non-zero
+* data. If he > hs, buf[hs..he] is all zeroes.
+*/
+   if (hs > nw)
+   if (fwrite(buf + nw, hs - nw, 1, fp) != 1)
+   break;
+   if (he > hs)
+   if (fseeko(fp, he - hs, SEEK_CUR) == -1)
+   break;
+   }
+
+   return (nw);
+}
+
+static char *zbuf;
+static size_t zbufsize;
+
+static size_t
+GunzipWrite(z_stream *z, char *in, size_t insize, FILE *fp)
+{
+   static bool firstblock = true;  /* XXX not re-entrable/usable 

svn commit: r367307 - head/sbin/savecore

2020-11-03 Thread Gleb Smirnoff
Author: glebius
Date: Tue Nov  3 22:04:32 2020
New Revision: 367307
URL: https://svnweb.freebsd.org/changeset/base/367307

Log:
  Style, not functional changes:
  - Improve spelling of a false check [1]
  - A missing line from r367150.
  
  Submitted by: kib

Modified:
  head/sbin/savecore/savecore.c

Modified: head/sbin/savecore/savecore.c
==
--- head/sbin/savecore/savecore.c   Tue Nov  3 21:38:59 2020
(r367306)
+++ head/sbin/savecore/savecore.c   Tue Nov  3 22:04:32 2020
(r367307)
@@ -677,7 +677,7 @@ DoFile(const char *savedir, int savedirfd, const char 
dtoh32(kdhl.version), device);
 
status = STATUS_BAD;
-   if (force == false)
+   if (!force)
goto closefd;
}
} else if (compare_magic(, KERNELDUMPMAGIC)) {
@@ -687,7 +687,7 @@ DoFile(const char *savedir, int savedirfd, const char 
dtoh32(kdhl.version), device);
 
status = STATUS_BAD;
-   if (force == false)
+   if (!force)
goto closefd;
}
switch (kdhl.compression) {
@@ -711,7 +711,7 @@ DoFile(const char *savedir, int savedirfd, const char 
device);
 
status = STATUS_BAD;
-   if (force == false)
+   if (!force)
goto closefd;
 
if (compare_magic(, KERNELDUMPMAGIC_CLEARED)) {
@@ -728,7 +728,7 @@ DoFile(const char *savedir, int savedirfd, const char 
dtoh32(kdhl.version), device);
 
status = STATUS_BAD;
-   if (force == false)
+   if (!force)
goto closefd;
}
}
@@ -742,7 +742,7 @@ DoFile(const char *savedir, int savedirfd, const char 
"parity error on last dump header on %s", device);
nerr++;
status = STATUS_BAD;
-   if (force == false)
+   if (!force)
goto closefd;
}
dumpextent = dtoh64(kdhl.dumpextent);
@@ -773,7 +773,7 @@ DoFile(const char *savedir, int savedirfd, const char 
"first and last dump headers disagree on %s", device);
nerr++;
status = STATUS_BAD;
-   if (force == false)
+   if (!force)
goto closefd;
} else {
status = STATUS_GOOD;
@@ -1148,7 +1148,7 @@ main(int argc, char **argv)
verbose++;
break;
case 'z':
-   compress = 1;
+   compress = true;
break;
case '?':
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: r367150 - head/sbin/savecore

2020-10-29 Thread Gleb Smirnoff
Author: glebius
Date: Thu Oct 29 23:15:11 2020
New Revision: 367150
URL: https://svnweb.freebsd.org/changeset/base/367150

Log:
  Convert flags from int to bool.  Some (compress) were already used in
  comparisons with bool values.  No functional changes.

Modified:
  head/sbin/savecore/savecore.c

Modified: head/sbin/savecore/savecore.c
==
--- head/sbin/savecore/savecore.c   Thu Oct 29 22:22:27 2020
(r367149)
+++ head/sbin/savecore/savecore.c   Thu Oct 29 23:15:11 2020
(r367150)
@@ -102,7 +102,8 @@ __FBSDID("$FreeBSD$");
 
 static cap_channel_t *capsyslog;
 static fileargs_t *capfa;
-static int checkfor, compress, clear, force, keep, verbose;/* flags */
+static bool checkfor, compress, clear, force, keep;/* flags */
+static int verbose;
 static int nfound, nsaved, nerr;   /* statistics */
 static int maxdumps;
 
@@ -676,7 +677,7 @@ DoFile(const char *savedir, int savedirfd, const char 
dtoh32(kdhl.version), device);
 
status = STATUS_BAD;
-   if (force == 0)
+   if (force == false)
goto closefd;
}
} else if (compare_magic(, KERNELDUMPMAGIC)) {
@@ -686,7 +687,7 @@ DoFile(const char *savedir, int savedirfd, const char 
dtoh32(kdhl.version), device);
 
status = STATUS_BAD;
-   if (force == 0)
+   if (force == false)
goto closefd;
}
switch (kdhl.compression) {
@@ -710,7 +711,7 @@ DoFile(const char *savedir, int savedirfd, const char 
device);
 
status = STATUS_BAD;
-   if (force == 0)
+   if (force == false)
goto closefd;
 
if (compare_magic(, KERNELDUMPMAGIC_CLEARED)) {
@@ -727,7 +728,7 @@ DoFile(const char *savedir, int savedirfd, const char 
dtoh32(kdhl.version), device);
 
status = STATUS_BAD;
-   if (force == 0)
+   if (force == false)
goto closefd;
}
}
@@ -741,7 +742,7 @@ DoFile(const char *savedir, int savedirfd, const char 
"parity error on last dump header on %s", device);
nerr++;
status = STATUS_BAD;
-   if (force == 0)
+   if (force == false)
goto closefd;
}
dumpextent = dtoh64(kdhl.dumpextent);
@@ -772,7 +773,7 @@ DoFile(const char *savedir, int savedirfd, const char 
"first and last dump headers disagree on %s", device);
nerr++;
status = STATUS_BAD;
-   if (force == 0)
+   if (force == false)
goto closefd;
} else {
status = STATUS_GOOD;
@@ -1110,7 +,8 @@ main(int argc, char **argv)
char **devs;
int i, ch, error, savedirfd;
 
-   checkfor = compress = clear = force = keep = verbose = 0;
+   checkfor = compress = clear = force = keep = false;
+   verbose = 0;
nfound = nsaved = nerr = 0;
savedir = ".";
 
@@ -1124,16 +1126,16 @@ main(int argc, char **argv)
while ((ch = getopt(argc, argv, "Ccfkm:vz")) != -1)
switch(ch) {
case 'C':
-   checkfor = 1;
+   checkfor = true;
break;
case 'c':
-   clear = 1;
+   clear = true;
break;
case 'f':
-   force = 1;
+   force = true;
break;
case 'k':
-   keep = 1;
+   keep = true;
break;
case 'm':
maxdumps = atoi(optarg);
___
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: r366945 - head/share/man/man9

2020-10-22 Thread Gleb Smirnoff
Author: glebius
Date: Thu Oct 22 18:00:07 2020
New Revision: 366945
URL: https://svnweb.freebsd.org/changeset/base/366945

Log:
  Fix typo

Modified:
  head/share/man/man9/pfil.9

Modified: head/share/man/man9/pfil.9
==
--- head/share/man/man9/pfil.9  Thu Oct 22 17:47:51 2020(r366944)
+++ head/share/man/man9/pfil.9  Thu Oct 22 18:00:07 2020(r366945)
@@ -144,7 +144,7 @@ Link-layer packets.
 .El
 .Pp
 Default rulesets are automatically linked to these heads to preserve
-historical behavavior.
+historical behaviour.
 .Sh SEE ALSO
 .Xr ipfilter 4 ,
 .Xr ipfw 4 ,
___
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: r360037 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2020-09-22 Thread Gleb Smirnoff
  Kyle,

On Thu, Sep 03, 2020 at 12:49:41PM -0500, Kyle Evans wrote:
K> > Author: glebius
K> > Date: Fri Apr 17 06:05:08 2020
K> > New Revision: 360037
K> > URL: https://svnweb.freebsd.org/changeset/base/360037
K> >
K> > Log:
K> >   Make ZFS depend on xdr.ko only.  It doesn't need kernel RPC.
K> >
K> >   Differential Revision:https://reviews.freebsd.org/D24408
K> >
K> 
K> Would you object to me MFC'ing this series to stable/12? It's pretty
K> useful for building a good MINIMAL config with zfs support, and would
K> probably allow us to drop a __FreeBSD_version split of dependencies in
K> the short-to-mid term from OpenZFS if we don't need to pretend that
K> OpenZFS will build on 11. None of it looked too invasive for stable
K> from a cursory glance.

My apologies for the delay. Of course, these changes can be easily MFCed.
Go forward for it.

-- 
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"


Re: svn commit: r365071 - in head/sys: net net/altq net/route net80211 netgraph netgraph/atm netgraph/atm/ccatm netgraph/atm/sscfu netgraph/atm/sscop netgraph/atm/uni netgraph/bluetooth/common netgrap

2020-09-21 Thread Gleb Smirnoff
  Mateusz,

On Fri, Sep 04, 2020 at 02:15:04PM -0400, Andrew Gallatin wrote:
A> I do the upstream sync between the Netflix tree and
A> FreeBSD-current about every 3 weeks (unless glebius beats
A> me to the punch and does it first :).  I anticipate that
A> this blank line sweep will cause lots of conflicts for us.
A> I understand this is progress, and I don't object, and I'm
A> not asking for a revert, but please understand that cleanups
A> like this do have hidden costs.  I expect that other commercial
A> entities who contribute to FreeBSD will have the same issue,
A> and I also anticipate it will cause problems with MFCs

sorry for chiming in late, but I'm about to bump at this change.

An advice for future sweeps like that. Include the script you
used for the sweep into the commit message. Then, mergers, like
me, will run same script on their tree before doing a merge and
there will be no conflict.

Example commit: https://svnweb.freebsd.org/base?view=revision=360579

-- 
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: r365504 - head/sys/kern

2020-09-09 Thread Gleb Smirnoff
Author: glebius
Date: Wed Sep  9 16:13:33 2020
New Revision: 365504
URL: https://svnweb.freebsd.org/changeset/base/365504

Log:
  In r354148 the goal was to check THREAD_CAN_SLEEP() only once for the
  purpose of epoch_trace() and for calling subsequent panic, but to keep
  code fully under INVARIANTS, so don't use bare function call to panic().
  However, at the last stage of review a true value slipped in, while
  always false was assumed.  I checked that in email archive with kib@.
  
  Noticed by:   trasz

Modified:
  head/sys/kern/subr_sleepqueue.c
  head/sys/kern/subr_trap.c

Modified: head/sys/kern/subr_sleepqueue.c
==
--- head/sys/kern/subr_sleepqueue.c Wed Sep  9 13:16:20 2020
(r365503)
+++ head/sys/kern/subr_sleepqueue.c Wed Sep  9 16:13:33 2020
(r365504)
@@ -325,7 +325,7 @@ sleepq_add(const void *wchan, struct lock_object *lock
 #ifdef EPOCH_TRACE
epoch_trace_list(curthread);
 #endif
-   KASSERT(1,
+   KASSERT(0,
("%s: td %p to sleep on wchan %p with sleeping prohibited",
__func__, td, wchan));
}

Modified: head/sys/kern/subr_trap.c
==
--- head/sys/kern/subr_trap.c   Wed Sep  9 13:16:20 2020(r365503)
+++ head/sys/kern/subr_trap.c   Wed Sep  9 16:13:33 2020(r365504)
@@ -187,7 +187,7 @@ userret(struct thread *td, struct trapframe *frame)
 #ifdef EPOCH_TRACE
epoch_trace_list(curthread);
 #endif
-   KASSERT(1, ("userret: Returning with sleep disabled"));
+   KASSERT(0, ("userret: Returning with sleep disabled"));
}
KASSERT(td->td_pinned == 0 || (td->td_pflags & TDP_CALLCHAIN) != 0,
("userret: Returning with with pinned thread"));
___
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: r353419 - head/sys/net

2020-08-30 Thread Gleb Smirnoff
On Fri, Aug 28, 2020 at 02:31:30PM -0700, Oleksandr Tymoshenko wrote:
O> Gleb Smirnoff (gleb...@freebsd.org) wrote:
O> > Author: glebius
O> > Date: Thu Oct 10 23:42:55 2019
O> > New Revision: 353419
O> > URL: https://svnweb.freebsd.org/changeset/base/353419
O> > 
O> > Log:
O> >   Provide new KPI for network drivers to access lists of interface
O> >   addresses.  The KPI doesn't reveal neither how addresses are stored,
O> >   how the access to them is synchronized, neither reveal struct ifaddr
O> >   and struct ifmaddr.
O> >   
O> >   Reviewed by: gallatin, erj, hselasky, philip, stevek
O> >   Differential Revision:   https://reviews.freebsd.org/D21943
O> 
O> Hi Gleb,
O> 
O> Are there any plans to MFC this change and the subsequent API consumer 
changes?
O> Lack of this API in 12 makes MFCing unrelated eth driver fixes hard.

I don't plan to MFC it, but there is nothing that would blocks such MFC.

Of course internals of the functions would be different - using mutex instead
of the epoch to sync access to address lists.

I can provide patch for you, but you would be responsive for MFC. I don't
have any 12-based systems to test changes.

-- 
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: r364975 - head/sys/dev/mn

2020-08-30 Thread Gleb Smirnoff
Author: glebius
Date: Sun Aug 30 17:13:04 2020
New Revision: 364975
URL: https://svnweb.freebsd.org/changeset/base/364975

Log:
  Followup on r364922. Old comment said that the only reason to put
  the hook at queue mode was that mn_rx_intr() doesn't run at splnet
  level. In today's netgraph the only legitimate reason for queue mode
  is recursion avoidance. So I see no reason for queue mode here.
  
  Not tested!

Modified:
  head/sys/dev/mn/if_mn.c

Modified: head/sys/dev/mn/if_mn.c
==
--- head/sys/dev/mn/if_mn.c Sun Aug 30 16:27:58 2020(r364974)
+++ head/sys/dev/mn/if_mn.c Sun Aug 30 17:13:04 2020(r364975)
@@ -743,8 +743,6 @@ ngmn_connect(hook_p hook)
if (!(u & 1))
printf("%s: init chan %d stat %08x\n", sc->name, chan, u);
sc->m32x->stat = 1; 
-   /* force outward queueing */
-   NG_HOOK_FORCE_QUEUE(NG_HOOK_PEER(hook));
 
return (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: r364441 - head/stand/i386/zfsboot

2020-08-20 Thread Gleb Smirnoff
Author: glebius
Date: Thu Aug 20 20:31:47 2020
New Revision: 364441
URL: https://svnweb.freebsd.org/changeset/base/364441

Log:
  When we have a command returned by zfs_nextboot() that is longer
  than command in the loader.conf, the latter needs to be nul terminated,
  otherwise garbage trailer left from zfs_nextboot() will be passed to
  parse_cmd() together with loader.conf command.
  
  While here, reset cmd to empty string if read() returns error.
  
  Reviewed by:  tsoome

Modified:
  head/stand/i386/zfsboot/zfsboot.c

Modified: head/stand/i386/zfsboot/zfsboot.c
==
--- head/stand/i386/zfsboot/zfsboot.c   Thu Aug 20 20:11:58 2020
(r364440)
+++ head/stand/i386/zfsboot/zfsboot.c   Thu Aug 20 20:31:47 2020
(r364441)
@@ -248,7 +248,12 @@ main(void)
fd = open(PATH_DOTCONFIG, O_RDONLY);
 
if (fd != -1) {
-   read(fd, cmd, sizeof (cmd));
+   ssize_t cmdlen;
+
+   if ((cmdlen = read(fd, cmd, sizeof(cmd))) > 0)
+   cmd[cmdlen] = '\0';
+   else
+   *cmd = '\0';
close(fd);
}
 
___
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: r364310 - in head/sys: kern vm

2020-08-17 Thread Gleb Smirnoff
Author: glebius
Date: Mon Aug 17 15:37:08 2020
New Revision: 364310
URL: https://svnweb.freebsd.org/changeset/base/364310

Log:
  With INVARIANTS panic immediately if M_WAITOK is requested in a
  non-sleepable context.  Previously only _sleep() would panic.
  This will catch misuse of M_WAITOK at development stage rather
  than at stress load stage.
  
  Reviewed by:  markj
  Differential Revision:https://reviews.freebsd.org/D26027

Modified:
  head/sys/kern/kern_malloc.c
  head/sys/vm/uma_core.c

Modified: head/sys/kern/kern_malloc.c
==
--- head/sys/kern/kern_malloc.c Mon Aug 17 15:11:46 2020(r364309)
+++ head/sys/kern/kern_malloc.c Mon Aug 17 15:37:08 2020(r364310)
@@ -618,6 +618,9 @@ void *
unsigned long osize = size;
 #endif
 
+   KASSERT((flags & M_WAITOK) == 0 || THREAD_CAN_SLEEP(),
+   ("malloc(M_WAITOK) in non-sleepable context"));
+
 #ifdef MALLOC_DEBUG
va = NULL;
if (malloc_dbg(, , mtp, flags) != 0)

Modified: head/sys/vm/uma_core.c
==
--- head/sys/vm/uma_core.c  Mon Aug 17 15:11:46 2020(r364309)
+++ head/sys/vm/uma_core.c  Mon Aug 17 15:37:08 2020(r364310)
@@ -3328,6 +3328,9 @@ uma_zalloc_smr(uma_zone_t zone, int flags)
uma_cache_bucket_t bucket;
uma_cache_t cache;
 
+   KASSERT((flags & M_WAITOK) == 0 || THREAD_CAN_SLEEP(),
+   ("uma_zalloc_smr(M_WAITOK) in non-sleepable context"));
+
 #ifdef UMA_ZALLOC_DEBUG
void *item;
 
@@ -3351,6 +3354,9 @@ uma_zalloc_arg(uma_zone_t zone, void *udata, int flags
 {
uma_cache_bucket_t bucket;
uma_cache_t cache;
+
+   KASSERT((flags & M_WAITOK) == 0 || THREAD_CAN_SLEEP(),
+   ("uma_zalloc(M_WAITOK) in non-sleepable context"));
 
/* Enable entropy collection for RANDOM_ENABLE_UMA kernel option */
random_harvest_fast_uma(, sizeof(zone), RANDOM_UMA);
___
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: r364117 - in head: sbin/ipfw sys/netpfil/ipfw

2020-08-11 Thread Gleb Smirnoff
Author: glebius
Date: Tue Aug 11 15:46:22 2020
New Revision: 364117
URL: https://svnweb.freebsd.org/changeset/base/364117

Log:
  ipfw: make the "frag" keyword accept additional options "mf",
  "df", "rf" and "offset".  This allows to match on specific
  bits of ip_off field.
  
  For compatibility reasons lack of keyword means "offset".
  
  Reviewed by:  ae
  Differential Revision:https://reviews.freebsd.org/D26021

Modified:
  head/sbin/ipfw/ipfw.8
  head/sbin/ipfw/ipfw2.c
  head/sys/netpfil/ipfw/ip_fw2.c

Modified: head/sbin/ipfw/ipfw.8
==
--- head/sbin/ipfw/ipfw.8   Tue Aug 11 15:08:32 2020(r364116)
+++ head/sbin/ipfw/ipfw.8   Tue Aug 11 15:46:22 2020(r364117)
@@ -1,7 +1,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd June 21, 2019
+.Dd August 10, 2020
 .Dt IPFW 8
 .Os
 .Sh NAME
@@ -600,7 +600,7 @@ See Section
 By name or address
 .It Misc. IP header fields
 Version, type of service, datagram length, identification,
-fragment flag (non-zero IP offset),
+fragmentation flags,
 Time To Live
 .It IP options
 .It IPv6 Extension headers
@@ -1602,12 +1602,29 @@ Matches IPv6 packets containing any of the flow labels
 .Ar labels .
 .Ar labels
 is a comma separated list of numeric flow labels.
-.It Cm frag
-Matches packets that are fragments and not the first
-fragment of an IP datagram.
-Note that these packets will not have
-the next protocol header (e.g.\& TCP, UDP) so options that look into
-these headers cannot match.
+.It Cm frag Ar spec
+Matches IPv4 packets whose
+.Cm ip_off 
+field contains the comma separated list of IPv4 fragmentation
+options specified in
+.Ar spec .
+The recognized options are:
+.Cm df
+.Pq Dv don't fragment ,
+.Cm mf
+.Pq Dv more fragments ,
+.Cm rf
+.Pq Dv reserved fragment bit
+.Cm offset
+.Pq Dv non-zero fragment offset .
+The absence of a particular options may be denoted
+with a
+.Ql \&! .
+.Pp
+Empty list of options defaults to matching on non-zero fragment offset.
+Such rule would match all not the first fragment datagrams,
+both IPv4 and IPv6.
+This is a backward compatibility with older rulesets.
 .It Cm gid Ar group
 Matches all TCP or UDP packets sent by or received for a
 .Ar group .

Modified: head/sbin/ipfw/ipfw2.c
==
--- head/sbin/ipfw/ipfw2.c  Tue Aug 11 15:08:32 2020(r364116)
+++ head/sbin/ipfw/ipfw2.c  Tue Aug 11 15:46:22 2020(r364117)
@@ -168,6 +168,14 @@ static struct _s_x f_iptos[] = {
{ NULL, 0 }
 };
 
+static struct _s_x f_ipoff[] = {
+   { "rf", IP_RF >> 8 },
+   { "df", IP_DF >> 8 },
+   { "mf", IP_MF >> 8 },
+   { "offset", 0x1 },
+   { NULL, 0}
+};
+
 struct _s_x f_ipdscp[] = {
{ "af11", IPTOS_DSCP_AF11 >> 2 },   /* 001010 */
{ "af12", IPTOS_DSCP_AF12 >> 2 },   /* 001100 */
@@ -1531,7 +1539,7 @@ print_instruction(struct buf_pr *bp, const struct form
IPPROTO_ETHERTYPE, cmd->opcode);
break;
case O_FRAG:
-   bprintf(bp, " frag");
+   print_flags(bp, "frag", cmd, f_ipoff);
break;
case O_FIB:
bprintf(bp, " fib %u", cmd->arg1);
@@ -4553,7 +4561,15 @@ read_options:
break;
 
case TOK_FRAG:
-   fill_cmd(cmd, O_FRAG, 0, 0);
+   fill_flags_cmd(cmd, O_FRAG, f_ipoff, *av);
+   /*
+* Compatibility: no argument after "frag"
+* keyword equals to "frag offset".
+*/
+   if (cmd->arg1 == 0)
+   cmd->arg1 = 0x1;
+   else
+   av++;
break;
 
case TOK_LAYER2:

Modified: head/sys/netpfil/ipfw/ip_fw2.c
==
--- head/sys/netpfil/ipfw/ip_fw2.c  Tue Aug 11 15:08:32 2020
(r364116)
+++ head/sys/netpfil/ipfw/ip_fw2.c  Tue Aug 11 15:46:22 2020
(r364117)
@@ -1944,7 +1944,23 @@ do { 
\
break;
 
case O_FRAG:
-   match = (offset != 0);
+   if (is_ipv4) {
+   /*
+* Since flags_match() works with
+* uint8_t we pack ip_off into 8 bits.
+* For this match offset is a boolean.
+*/
+   match = flags_match(cmd,
+   ((ntohs(ip->ip_off) & ~IP_OFFMASK)
+   >> 8) | (offset != 

Re: svn commit: r364072 - in head/sys: netinet netinet6

2020-08-10 Thread Gleb Smirnoff
  Hans,

On Mon, Aug 10, 2020 at 10:40:20AM +, Hans Petter Selasky wrote:
H> Author: hselasky
H> Date: Mon Aug 10 10:40:19 2020
H> New Revision: 364072
H> URL: https://svnweb.freebsd.org/changeset/base/364072
H> 
H> Log:
H>   Use proper prototype for SYSINIT() functions.
H>   Mark the unused argument using the __unused macro.
H>   
H>   Discussed with:kib@
H>   MFC after: 1 week
H>   Sponsored by:  Mellanox Technologies

Why just do not use the SYSINIT at all?

Index: in_mcast.c
===
--- in_mcast.c  (revision 364098)
+++ in_mcast.c  (working copy)
@@ -229,17 +229,10 @@ inm_is_ifp_detached(const struct in_multi *inm)
  * dedicated thread to avoid deadlocks when draining inm_release tasks.
  */
 TASKQUEUE_DEFINE_THREAD(inm_free);
-static struct task inm_free_task;
 static struct in_multi_head inm_free_list = SLIST_HEAD_INITIALIZER();
 static void inm_release_task(void *arg __unused, int pending __unused);
+static struct task inm_free_task = TASK_INITIALIZER(0, inm_release_task, NULL);
 
-static void
-inm_init(void *arg __unused)
-{
-   TASK_INIT(_free_task, 0, inm_release_task, NULL);
-}
-SYSINIT(inm_init, SI_SUB_TASKQ, SI_ORDER_ANY, inm_init, NULL);
-
 void
 inm_release_wait(void *arg __unused)
 {

Same for inm6.

-- 
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: r362982 - head

2020-07-06 Thread Gleb Smirnoff
Author: glebius
Date: Tue Jul  7 02:43:53 2020
New Revision: 362982
URL: https://svnweb.freebsd.org/changeset/base/362982

Log:
  Fixup r362981: remove gzipped manual pages.
  
  Pointy hat to:glebius

Modified:
  head/ObsoleteFiles.inc

Modified: head/ObsoleteFiles.inc
==
--- head/ObsoleteFiles.inc  Tue Jul  7 02:41:51 2020(r362981)
+++ head/ObsoleteFiles.inc  Tue Jul  7 02:43:53 2020(r362982)
@@ -37,10 +37,10 @@
 # done
 
 # 20200706: update of sglist(9), r360574
-OLD_FILES+=usr/share/man/man9/sglist_append_ext_pgs.9
-OLD_FILES+=usr/share/man/man9/sglist_append_mb_ext_pgs.9
-OLD_FILES+=usr/share/man/man9/sglist_count_ext_pgs.9
-OLD_FILES+=usr/share/man/man9/sglist_count_mb_ext_pgs.9
+OLD_FILES+=usr/share/man/man9/sglist_append_ext_pgs.9.gz
+OLD_FILES+=usr/share/man/man9/sglist_append_mb_ext_pgs.9.gz
+OLD_FILES+=usr/share/man/man9/sglist_count_ext_pgs.9.gz
+OLD_FILES+=usr/share/man/man9/sglist_count_mb_ext_pgs.9.gz
 
 # 20200617: update opencsd to 0.14.2
 OLD_FILES+=usr/include/opencsd/etmv4/trc_pkt_elem_etmv4d.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: r362981 - in head: . share/man/man9

2020-07-06 Thread Gleb Smirnoff
Author: glebius
Date: Tue Jul  7 02:41:51 2020
New Revision: 362981
URL: https://svnweb.freebsd.org/changeset/base/362981

Log:
  Fixup for r360574: install new mlinks for sglist(9) and remove old ones.

Modified:
  head/ObsoleteFiles.inc
  head/share/man/man9/Makefile

Modified: head/ObsoleteFiles.inc
==
--- head/ObsoleteFiles.inc  Tue Jul  7 00:42:23 2020(r362980)
+++ head/ObsoleteFiles.inc  Tue Jul  7 02:41:51 2020(r362981)
@@ -36,6 +36,12 @@
 #   xargs -n1 | sort | uniq -d;
 # done
 
+# 20200706: update of sglist(9), r360574
+OLD_FILES+=usr/share/man/man9/sglist_append_ext_pgs.9
+OLD_FILES+=usr/share/man/man9/sglist_append_mb_ext_pgs.9
+OLD_FILES+=usr/share/man/man9/sglist_count_ext_pgs.9
+OLD_FILES+=usr/share/man/man9/sglist_count_mb_ext_pgs.9
+
 # 20200617: update opencsd to 0.14.2
 OLD_FILES+=usr/include/opencsd/etmv4/trc_pkt_elem_etmv4d.h
 

Modified: head/share/man/man9/Makefile
==
--- head/share/man/man9/MakefileTue Jul  7 00:42:23 2020
(r362980)
+++ head/share/man/man9/MakefileTue Jul  7 02:41:51 2020
(r362981)
@@ -1902,9 +1902,8 @@ MLINKS+=sf_buf.9 sf_buf_alloc.9 \
 MLINKS+=sglist.9 sglist_alloc.9 \
sglist.9 sglist_append.9 \
sglist.9 sglist_append_bio.9 \
-   sglist.9 sglist_append_ext_pgs.9 \
-   sglist.9 sglist_append_mb_ext_pgs.9 \
sglist.9 sglist_append_mbuf.9 \
+   sglist.9 sglist_append_mbuf_epg.9 \
sglist.9 sglist_append_phys.9 \
sglist.9 sglist_append_sglist.9 \
sglist.9 sglist_append_uio.9 \
@@ -1914,8 +1913,7 @@ MLINKS+=sglist.9 sglist_alloc.9 \
sglist.9 sglist_clone.9 \
sglist.9 sglist_consume_uio.9 \
sglist.9 sglist_count.9 \
-   sglist.9 sglist_count_ext_pgs.9 \
-   sglist.9 sglist_count_mb_ext_pgs.9 \
+   sglist.9 sglist_count_mbuf_epg.9 \
sglist.9 sglist_count_vmpages.9 \
sglist.9 sglist_free.9 \
sglist.9 sglist_hold.9 \
___
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: r362148 - head/contrib/nvi/common

2020-06-22 Thread Gleb Smirnoff
  Yuri, Zhihao,

this commit totally broke Russian input for me in nvi. After
exiting edit mode, nvi immediately converts all text to ???.

I don't have any special settings in my environment. All I have
is "russian" class for my user which yields in these environment
variables:

declare -x LANG="ru_RU.UTF-8"
declare -x MM_CHARSET="UTF-8"
declare -x XTERM_LOCALE="ru_RU.UTF-8"

I'm already digging into that problem, but may be you have
a clue immediately.

On Sat, Jun 13, 2020 at 02:11:02PM +, Yuri Pankov wrote:
Y> Author: yuripv
Y> Date: Sat Jun 13 14:11:02 2020
Y> New Revision: 362148
Y> URL: https://svnweb.freebsd.org/changeset/base/362148
Y> 
Y> Log:
Y>   nvi: fallback to ISO8859-1 as last resort
Y>   
Y>   Current logic of using user's locale encoding that is UTF-8 doesn't make
Y>   much sense if we already failed the looks_utf8() check and skipped
Y>   encoding set using "fileencoding" as being UTF-8 as well; fallback to
Y>   ISO8859-1 in that case.
Y>   
Y>   Reviewed by:   Zhihao Yuan 
Y>   Differential Revision: https://reviews.freebsd.org/D24919
Y> 
Y> Modified:
Y>   head/contrib/nvi/common/exf.c
Y> 
Y> Modified: head/contrib/nvi/common/exf.c
Y> 
==
Y> --- head/contrib/nvi/common/exf.cSat Jun 13 09:16:07 2020
(r362147)
Y> +++ head/contrib/nvi/common/exf.cSat Jun 13 14:11:02 2020
(r362148)
Y> @@ -1237,7 +1237,10 @@ file_encinit(SCR *sp)
Y>  }
Y>  
Y>  /*
Y> - * Detect UTF-8 and fallback to the locale/preset encoding.
Y> + * 1. Check for valid UTF-8.
Y> + * 2. Check if fallback fileencoding is set and is NOT UTF-8.
Y> + * 3. Check if user locale's encoding is NOT UTF-8.
Y> + * 4. Use ISO8859-1 as last resort.
Y>   *
Y>   * XXX
Y>   * A manually set O_FILEENCODING indicates the "fallback
Y> @@ -1246,9 +1249,13 @@ file_encinit(SCR *sp)
Y>   */
Y>  if (looks_utf8(buf, blen) > 1)
Y>  o_set(sp, O_FILEENCODING, OS_STRDUP, "utf-8", 0);
Y> -else if (!O_ISSET(sp, O_FILEENCODING) ||
Y> -!strcasecmp(O_STR(sp, O_FILEENCODING), "utf-8"))
Y> +else if (O_ISSET(sp, O_FILEENCODING) &&
Y> +strcasecmp(O_STR(sp, O_FILEENCODING), "utf-8") != 0)
Y> +/* Use fileencoding as is */ ;
Y> +else if (strcasecmp(codeset(), "utf-8") != 0)
Y>  o_set(sp, O_FILEENCODING, OS_STRDUP, codeset(), 0);
Y> +else
Y> +o_set(sp, O_FILEENCODING, OS_STRDUP, "iso8859-1", 0);
Y>  
Y>  conv_enc(sp, O_FILEENCODING, 0);
Y>  #endif
Y> ___
Y> svn-src-all@freebsd.org mailing list
Y> https://lists.freebsd.org/mailman/listinfo/svn-src-all
Y> To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

-- 
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: r360873 - stable/12/contrib/bsnmp/snmpd

2020-05-10 Thread Gleb Smirnoff
Author: glebius
Date: Sun May 10 14:46:46 2020
New Revision: 360873
URL: https://svnweb.freebsd.org/changeset/base/360873

Log:
  Merge r360138:
  
Fix immediate crash when snmpd is bound to a specific IP address.
  
The code that sets up msghdr must first fully fill in the msghdr
itself, and only then use CMSG_xxx() macros.
  
  PR:   246323

Modified:
  stable/12/contrib/bsnmp/snmpd/trans_inet.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/contrib/bsnmp/snmpd/trans_inet.c
==
--- stable/12/contrib/bsnmp/snmpd/trans_inet.c  Sun May 10 14:09:30 2020
(r360872)
+++ stable/12/contrib/bsnmp/snmpd/trans_inet.c  Sun May 10 14:46:46 2020
(r360873)
@@ -71,7 +71,7 @@ typedef void input_func(int, void *);
 typedef int activate_func(struct inet_port *);
 typedef void deactivate_func(struct inet_port *);
 typedef void parse_ctrl_func(struct port_sock *, const struct msghdr *);
-typedef void setsrc_func(struct port_sock *, struct msghdr *);
+typedef void setsrc_func(struct port_sock *, struct msghdr *, char *);
 
 static create_func ipv4_create;
 static input_func ipv4_input;
@@ -401,13 +401,12 @@ inet_send2(struct tport *tp, const u_char *buf, size_t
msg.msg_name = (void *)pi->peer;
msg.msg_namelen = pi->peerlen;
 
-   msg.msg_control = NULL;
-   msg.msg_controllen = 0;
-
char cbuf[XMIT_CBUF_SIZE];
if (s->set_ret_source) {
-   msg.msg_control = cbuf;
-   s->setsrc(s, );
+   s->setsrc(s, , cbuf);
+   } else {
+   msg.msg_control = NULL;
+   msg.msg_controllen = 0;
}
 
return (sendmsg(s->input.fd, , 0));
@@ -638,18 +637,20 @@ ipv4_parse_ctrl(struct port_sock *sock, const struct m
  * \param msg  message
  */
 static void
-ipv4_setsrc(struct port_sock *sock, struct msghdr *msg)
+ipv4_setsrc(struct port_sock *sock, struct msghdr *msg, char *cbuf)
 {
-   struct cmsghdr *cmsg = CMSG_FIRSTHDR(msg);
+   struct cmsghdr *cmsg;
 
+   msg->msg_control = cbuf;
+   msg->msg_controllen = CMSG_SPACE(sizeof(struct in_addr));
+
/* select outgoing interface by setting source address */
+   cmsg = CMSG_FIRSTHDR(msg);
cmsg->cmsg_level = IPPROTO_IP;
cmsg->cmsg_type = IP_SENDSRCADDR;
cmsg->cmsg_len = CMSG_LEN(sizeof(struct in_addr));
memcpy(CMSG_DATA(cmsg), >ret_source.a4,
sizeof(struct in_addr));
-
-   msg->msg_controllen = CMSG_SPACE(sizeof(struct in_addr));
 }
 
 /**
@@ -877,18 +878,20 @@ ipv6_parse_ctrl(struct port_sock *sock, const struct m
  * \param msg  message
  */
 static void
-ipv6_setsrc(struct port_sock *sock, struct msghdr *msg)
+ipv6_setsrc(struct port_sock *sock, struct msghdr *msg, char *cbuf)
 {
-   struct cmsghdr *cmsg = CMSG_FIRSTHDR(msg);
+   struct cmsghdr *cmsg;
 
+   msg->msg_control = cbuf;
+   msg->msg_controllen = CMSG_SPACE(sizeof(struct in6_pktinfo));
+
/* select outgoing interface by setting source address */
+   cmsg = CMSG_FIRSTHDR(msg);
cmsg->cmsg_level = IPPROTO_IPV6;
cmsg->cmsg_type = IPV6_PKTINFO;
cmsg->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo));
memcpy(CMSG_DATA(cmsg), >ret_source.a6,
sizeof(struct in6_pktinfo));
-
-   msg->msg_controllen = CMSG_SPACE(sizeof(struct in6_pktinfo));
 }
 
 /**
___
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: r360583 - in head/sys: kern netinet sys

2020-05-02 Thread Gleb Smirnoff
Author: glebius
Date: Sun May  3 00:37:16 2020
New Revision: 360583
URL: https://svnweb.freebsd.org/changeset/base/360583

Log:
  Step 4.2: start divorce of M_EXT and M_EXTPG
  
  They have more differencies than similarities. For now there is lots
  of code that would check for M_EXT only and work correctly on M_EXTPG
  buffers, so still carry M_EXT bit together with M_EXTPG. However,
  prepare some code for explicit check for M_EXTPG.
  
  Reviewed by:  gallatin
  Differential Revision:https://reviews.freebsd.org/D24598

Modified:
  head/sys/kern/kern_mbuf.c
  head/sys/kern/kern_sendfile.c
  head/sys/kern/subr_sglist.c
  head/sys/kern/uipc_mbuf.c
  head/sys/kern/uipc_sockbuf.c
  head/sys/netinet/tcp_output.c
  head/sys/netinet/tcp_pcap.c
  head/sys/sys/mbuf.h

Modified: head/sys/kern/kern_mbuf.c
==
--- head/sys/kern/kern_mbuf.c   Sun May  3 00:27:41 2020(r360582)
+++ head/sys/kern/kern_mbuf.c   Sun May  3 00:37:16 2020(r360583)
@@ -115,7 +115,7 @@ int nmbjumbop;  /* limits number of 
page size jumbo c
 int nmbjumbo9; /* limits number of 9k jumbo clusters */
 int nmbjumbo16;/* limits number of 16k jumbo clusters 
*/
 
-bool mb_use_ext_pgs;   /* use EXT_PGS mbufs for sendfile & TLS */
+bool mb_use_ext_pgs;   /* use M_EXTPG mbufs for sendfile & TLS */
 SYSCTL_BOOL(_kern_ipc, OID_AUTO, mb_use_ext_pgs, CTLFLAG_RWTUN,
 _use_ext_pgs, 0,
 "Use unmapped mbufs for sendfile(2) and TLS offload");
@@ -822,7 +822,7 @@ mb_reclaim(uma_zone_t zone __unused, int pending __unu
 
 /*
  * Free "count" units of I/O from an mbuf chain.  They could be held
- * in EXT_PGS or just as a normal mbuf.  This code is intended to be
+ * in M_EXTPG or just as a normal mbuf.  This code is intended to be
  * called in an error path (I/O error, closed connection, etc).
  */
 void
@@ -831,8 +831,7 @@ mb_free_notready(struct mbuf *m, int count)
int i;
 
for (i = 0; i < count && m != NULL; i++) {
-   if ((m->m_flags & M_EXT) != 0 &&
-   m->m_ext.ext_type == EXT_PGS) {
+   if ((m->m_flags & M_EXTPG) != 0) {
m->m_epg_nrdy--;
if (m->m_epg_nrdy != 0)
continue;
@@ -860,9 +859,8 @@ mb_unmapped_compress(struct mbuf *m)
 * a packet header, it would only be able to hold MHLEN bytes
 * and m_data would have to be initialized differently.
 */
-   KASSERT((m->m_flags & M_PKTHDR) == 0 && (m->m_flags & M_EXT) &&
-   m->m_ext.ext_type == EXT_PGS,
-("%s: m %p !M_EXT or !EXT_PGS or M_PKTHDR", __func__, m));
+   KASSERT((m->m_flags & M_PKTHDR) == 0 && (m->m_flags & M_EXTPG),
+("%s: m %p !M_EXTPG or M_PKTHDR", __func__, m));
KASSERT(m->m_len <= MLEN, ("m_len too large %p", m));
 
if (m->m_ext.ext_flags & EXT_FLAG_EMBREF) {
@@ -902,12 +900,12 @@ mb_unmapped_compress(struct mbuf *m)
  * unmapped data is stored in an mbuf with an EXT_SFBUF external
  * cluster.  These mbufs use an sf_buf to provide a valid KVA for the
  * associated physical page.  They also hold a reference on the
- * original EXT_PGS mbuf to ensure the physical page doesn't go away.
+ * original M_EXTPG mbuf to ensure the physical page doesn't go away.
  * Finally, any TLS trailer data is stored in a regular mbuf.
  *
  * mb_unmapped_free_mext() is the ext_free handler for the EXT_SFBUF
  * mbufs.  It frees the associated sf_buf and releases its reference
- * on the original EXT_PGS mbuf.
+ * on the original M_EXTPG mbuf.
  *
  * _mb_unmapped_to_ext() is a helper function that converts a single
  * unmapped mbuf into a chain of mbufs.
@@ -926,9 +924,9 @@ mb_unmapped_free_mext(struct mbuf *m)
sf = m->m_ext.ext_arg1;
sf_buf_free(sf);
 
-   /* Drop the reference on the backing EXT_PGS mbuf. */
+   /* Drop the reference on the backing M_EXTPG mbuf. */
old_m = m->m_ext.ext_arg2;
-   mb_free_ext(old_m);
+   mb_free_extpg(old_m);
 }
 
 static struct mbuf *
@@ -1109,7 +1107,7 @@ mb_unmapped_to_ext(struct mbuf *top)
 }
 
 /*
- * Allocate an empty EXT_PGS mbuf.  The ext_free routine is
+ * Allocate an empty M_EXTPG mbuf.  The ext_free routine is
  * responsible for freeing any pages backing this mbuf when it is
  * freed.
  */
@@ -1133,7 +1131,6 @@ mb_alloc_ext_pgs(int how, m_ext_free_t ext_free)
m->m_epg_so = NULL;
m->m_data = NULL;
m->m_flags |= (M_EXT | M_RDONLY | M_EXTPG);
-   m->m_ext.ext_type = EXT_PGS;
m->m_ext.ext_flags = EXT_FLAG_EMBREF;
m->m_ext.ext_count = 1;
m->m_ext.ext_size = 0;
@@ -1206,24 +1203,6 @@ mb_free_ext(struct mbuf *m)
uma_zfree(zone_jumbo16, m->m_ext.ext_buf);
uma_zfree(zone_mbuf, mref);
break;
-   case EXT_PGS: {

svn commit: r360582 - in head/sys: dev/cxgbe dev/cxgbe/crypto dev/cxgbe/tom kern sys

2020-05-02 Thread Gleb Smirnoff
Author: glebius
Date: Sun May  3 00:27:41 2020
New Revision: 360582
URL: https://svnweb.freebsd.org/changeset/base/360582

Log:
  Mechanically rename MBUF_EXT_PGS_ASSERT() to M_ASSERTEXTPG() to match
  classical M_ASSERTPKTHDR.
  
  Reviewed by:  gallatin
  Differential Revision:https://reviews.freebsd.org/D24598

Modified:
  head/sys/dev/cxgbe/crypto/t4_kern_tls.c
  head/sys/dev/cxgbe/t4_sge.c
  head/sys/dev/cxgbe/tom/t4_cpl_io.c
  head/sys/kern/kern_mbuf.c
  head/sys/kern/subr_bus_dma.c
  head/sys/kern/subr_sglist.c
  head/sys/kern/uipc_mbuf.c
  head/sys/sys/mbuf.h

Modified: head/sys/dev/cxgbe/crypto/t4_kern_tls.c
==
--- head/sys/dev/cxgbe/crypto/t4_kern_tls.c Sun May  3 00:21:11 2020
(r360581)
+++ head/sys/dev/cxgbe/crypto/t4_kern_tls.c Sun May  3 00:27:41 2020
(r360582)
@@ -903,7 +903,7 @@ ktls_tcp_payload_length(struct tlspcb *tlsp, struct mb
struct tls_record_layer *hdr;
u_int plen, mlen;
 
-   MBUF_EXT_PGS_ASSERT(m_tls);
+   M_ASSERTEXTPG(m_tls);
hdr = (void *)m_tls->m_epg_hdr;
plen = ntohs(hdr->tls_length);
 
@@ -957,7 +957,7 @@ ktls_payload_offset(struct tlspcb *tlsp, struct mbuf *
u_int mlen;
 #endif
 
-   MBUF_EXT_PGS_ASSERT(m_tls);
+   M_ASSERTEXTPG(m_tls);
hdr = (void *)m_tls->m_epg_hdr;
plen = ntohs(hdr->tls_length);
 #ifdef INVARIANTS
@@ -1002,7 +1002,7 @@ ktls_wr_len(struct tlspcb *tlsp, struct mbuf *m, struc
struct tls_record_layer *hdr;
u_int imm_len, offset, plen, wr_len, tlen;
 
-   MBUF_EXT_PGS_ASSERT(m_tls);
+   M_ASSERTEXTPG(m_tls);
 
/*
 * Determine the size of the TLS record payload to send
@@ -1466,7 +1466,7 @@ ktls_write_tunnel_packet(struct sge_txq *txq, void *ds
M_ASSERTPKTHDR(m);
 
/* Locate the template TLS header. */
-   MBUF_EXT_PGS_ASSERT(m_tls);
+   M_ASSERTEXTPG(m_tls);
 
/* This should always be the last TLS record in a chain. */
MPASS(m_tls->m_next == NULL);
@@ -1593,7 +1593,7 @@ ktls_write_tls_wr(struct tlspcb *tlsp, struct sge_txq 
using_scratch = (eq->sidx - pidx < SGE_MAX_WR_LEN / EQ_ESIZE);
 
/* Locate the TLS header. */
-   MBUF_EXT_PGS_ASSERT(m_tls);
+   M_ASSERTEXTPG(m_tls);
hdr = (void *)m_tls->m_epg_hdr;
plen = TLS_HEADER_LENGTH + ntohs(hdr->tls_length) - m_tls->m_epg_trllen;
 

Modified: head/sys/dev/cxgbe/t4_sge.c
==
--- head/sys/dev/cxgbe/t4_sge.c Sun May  3 00:21:11 2020(r360581)
+++ head/sys/dev/cxgbe/t4_sge.c Sun May  3 00:27:41 2020(r360582)
@@ -2417,7 +2417,7 @@ count_mbuf_ext_pgs(struct mbuf *m, int skip, vm_paddr_
int i, len, off, pglen, pgoff, seglen, segoff;
int nsegs = 0;
 
-   MBUF_EXT_PGS_ASSERT(m);
+   M_ASSERTEXTPG(m);
off = mtod(m, vm_offset_t);
len = m->m_len;
off += skip;

Modified: head/sys/dev/cxgbe/tom/t4_cpl_io.c
==
--- head/sys/dev/cxgbe/tom/t4_cpl_io.c  Sun May  3 00:21:11 2020
(r360581)
+++ head/sys/dev/cxgbe/tom/t4_cpl_io.c  Sun May  3 00:27:41 2020
(r360582)
@@ -1927,7 +1927,7 @@ aiotx_free_pgs(struct mbuf *m)
struct kaiocb *job;
vm_page_t pg;
 
-   MBUF_EXT_PGS_ASSERT(m);
+   M_ASSERTEXTPG(m);
job = m->m_ext.ext_arg1;
 #ifdef VERBOSE_TRACES
CTR3(KTR_CXGBE, "%s: completed %d bytes for tid %d", __func__,

Modified: head/sys/kern/kern_mbuf.c
==
--- head/sys/kern/kern_mbuf.c   Sun May  3 00:21:11 2020(r360581)
+++ head/sys/kern/kern_mbuf.c   Sun May  3 00:27:41 2020(r360582)
@@ -941,7 +941,7 @@ _mb_unmapped_to_ext(struct mbuf *m)
volatile u_int *refcnt;
u_int ref_inc = 0;
 
-   MBUF_EXT_PGS_ASSERT(m);
+   M_ASSERTEXTPG(m);
len = m->m_len;
KASSERT(m->m_epg_tls == NULL, ("%s: can't convert TLS mbuf %p",
__func__, m));

Modified: head/sys/kern/subr_bus_dma.c
==
--- head/sys/kern/subr_bus_dma.cSun May  3 00:21:11 2020
(r360581)
+++ head/sys/kern/subr_bus_dma.cSun May  3 00:27:41 2020
(r360582)
@@ -121,7 +121,7 @@ _bus_dmamap_load_mbuf_epg(bus_dma_tag_t dmat, bus_dmam
 {
int error, i, off, len, pglen, pgoff, seglen, segoff;
 
-   MBUF_EXT_PGS_ASSERT(m);
+   M_ASSERTEXTPG(m);
 
len = m->m_len;
error = 0;

Modified: head/sys/kern/subr_sglist.c
==
--- head/sys/kern/subr_sglist.c Sun May  3 00:21:11 2020(r360581)
+++ head/sys/kern/subr_sglist.c Sun May  3 00:27:41 2020(r360582)
@@ -388,7 +388,7 @@ 

svn commit: r360581 - in head/sys: dev/cxgbe dev/cxgbe/crypto dev/cxgbe/tom dev/mlx5/mlx5_en kern netinet sys

2020-05-02 Thread Gleb Smirnoff
Author: glebius
Date: Sun May  3 00:21:11 2020
New Revision: 360581
URL: https://svnweb.freebsd.org/changeset/base/360581

Log:
  Step 4.1: mechanically rename M_NOMAP to M_EXTPG
  
  Reviewed by:  gallatin
  Differential Revision:https://reviews.freebsd.org/D24598

Modified:
  head/sys/dev/cxgbe/crypto/t4_kern_tls.c
  head/sys/dev/cxgbe/t4_sge.c
  head/sys/dev/cxgbe/tom/t4_cpl_io.c
  head/sys/dev/cxgbe/tom/t4_tls.c
  head/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c
  head/sys/kern/kern_mbuf.c
  head/sys/kern/kern_sendfile.c
  head/sys/kern/subr_bus_dma.c
  head/sys/kern/subr_sglist.c
  head/sys/kern/uipc_ktls.c
  head/sys/kern/uipc_mbuf.c
  head/sys/kern/uipc_sockbuf.c
  head/sys/kern/uipc_socket.c
  head/sys/netinet/tcp_output.c
  head/sys/netinet/tcp_pcap.c
  head/sys/sys/mbuf.h

Modified: head/sys/dev/cxgbe/crypto/t4_kern_tls.c
==
--- head/sys/dev/cxgbe/crypto/t4_kern_tls.c Sun May  3 00:15:18 2020
(r360580)
+++ head/sys/dev/cxgbe/crypto/t4_kern_tls.c Sun May  3 00:21:11 2020
(r360581)
@@ -1208,7 +1208,7 @@ t6_ktls_parse_pkt(struct mbuf *m, int *nsegsp, int *le
 
/* Assume all headers are in 'm' for now. */
MPASS(m->m_next != NULL);
-   MPASS(m->m_next->m_flags & M_NOMAP);
+   MPASS(m->m_next->m_flags & M_EXTPG);
 
tot_len = 0;
 
@@ -1218,7 +1218,7 @@ t6_ktls_parse_pkt(struct mbuf *m, int *nsegsp, int *le
 */
*nsegsp = 0;
for (m_tls = m->m_next; m_tls != NULL; m_tls = m_tls->m_next) {
-   MPASS(m_tls->m_flags & M_NOMAP);
+   MPASS(m_tls->m_flags & M_EXTPG);
 
wr_len = ktls_wr_len(tlsp, m, m_tls, );
 #ifdef VERBOSE_TRACES
@@ -2265,7 +2265,7 @@ t6_ktls_write_wr(struct sge_txq *txq, void *dst, struc
 * for that record.
 */
for (m_tls = m->m_next; m_tls != NULL; m_tls = m_tls->m_next) {
-   MPASS(m_tls->m_flags & M_NOMAP);
+   MPASS(m_tls->m_flags & M_EXTPG);
 
/*
 * Determine the initial TCP sequence number for this

Modified: head/sys/dev/cxgbe/t4_sge.c
==
--- head/sys/dev/cxgbe/t4_sge.c Sun May  3 00:15:18 2020(r360580)
+++ head/sys/dev/cxgbe/t4_sge.c Sun May  3 00:21:11 2020(r360581)
@@ -2497,7 +2497,7 @@ count_mbuf_nsegs(struct mbuf *m, int skip, uint8_t *cf
skip -= len;
continue;
}
-   if ((m->m_flags & M_NOMAP) != 0) {
+   if ((m->m_flags & M_EXTPG) != 0) {
*cflags |= MC_NOMAP;
nsegs += count_mbuf_ext_pgs(m, skip, );
skip = 0;
@@ -5836,7 +5836,7 @@ write_ethofld_wr(struct cxgbe_rate_tag *cst, struct fw
immhdrs -= m0->m_len;
continue;
}
-   if (m0->m_flags & M_NOMAP)
+   if (m0->m_flags & M_EXTPG)
sglist_append_mbuf_epg(, m0,
mtod(m0, vm_offset_t), m0->m_len);
 else

Modified: head/sys/dev/cxgbe/tom/t4_cpl_io.c
==
--- head/sys/dev/cxgbe/tom/t4_cpl_io.c  Sun May  3 00:15:18 2020
(r360580)
+++ head/sys/dev/cxgbe/tom/t4_cpl_io.c  Sun May  3 00:21:11 2020
(r360581)
@@ -610,7 +610,7 @@ write_tx_sgl(void *dst, struct mbuf *start, struct mbu
 
i = -1;
for (m = start; m != stop; m = m->m_next) {
-   if (m->m_flags & M_NOMAP)
+   if (m->m_flags & M_EXTPG)
rc = sglist_append_mbuf_epg(, m,
mtod(m, vm_offset_t), m->m_len);
else
@@ -731,7 +731,7 @@ t4_push_frames(struct adapter *sc, struct toepcb *toep
for (m = sndptr; m != NULL; m = m->m_next) {
int n;
 
-   if (m->m_flags & M_NOMAP) {
+   if (m->m_flags & M_EXTPG) {
 #ifdef KERN_TLS
if (m->m_epg_tls != NULL) {
toep->flags |= TPF_KTLS;
@@ -772,7 +772,7 @@ t4_push_frames(struct adapter *sc, struct toepcb *toep
break;
}
 
-   if (m->m_flags & M_NOMAP)
+   if (m->m_flags & M_EXTPG)
nomap_mbuf_seen = true;
if (max_nsegs_1mbuf < n)
max_nsegs_1mbuf = n;

Modified: head/sys/dev/cxgbe/tom/t4_tls.c
==
--- head/sys/dev/cxgbe/tom/t4_tls.c Sun May  3 00:15:18 2020
(r360580)
+++ head/sys/dev/cxgbe/tom/t4_tls.c Sun May  3 

svn commit: r360579 - in head/sys: dev/cxgbe dev/cxgbe/crypto dev/cxgbe/tom dev/mlx5/mlx5_en kern netinet netinet6 sys

2020-05-02 Thread Gleb Smirnoff
Author: glebius
Date: Sun May  3 00:12:56 2020
New Revision: 360579
URL: https://svnweb.freebsd.org/changeset/base/360579

Log:
  Step 3: anonymize struct mbuf_ext_pgs and move all its fields into mbuf
  within m_epg namespace.
  All edits except the 'struct mbuf' declaration and mb_dupcl() were done
  mechanically with sed:
  
  s/->m_ext_pgs.nrdy/->m_epg_nrdy/g
  s/->m_ext_pgs.hdr_len/->m_epg_hdrlen/g
  s/->m_ext_pgs.trail_len/->m_epg_trllen/g
  s/->m_ext_pgs.first_pg_off/->m_epg_1st_off/g
  s/->m_ext_pgs.last_pg_len/->m_epg_last_len/g
  s/->m_ext_pgs.flags/->m_epg_flags/g
  s/->m_ext_pgs.record_type/->m_epg_record_type/g
  s/->m_ext_pgs.enc_cnt/->m_epg_enc_cnt/g
  s/->m_ext_pgs.tls/->m_epg_tls/g
  s/->m_ext_pgs.so/->m_epg_so/g
  s/->m_ext_pgs.seqno/->m_epg_seqno/g
  s/->m_ext_pgs.stailq/->m_epg_stailq/g
  
  Reviewed by:  gallatin
  Differential Revision:https://reviews.freebsd.org/D24598

Modified:
  head/sys/dev/cxgbe/crypto/t4_kern_tls.c
  head/sys/dev/cxgbe/t4_sge.c
  head/sys/dev/cxgbe/tom/t4_cpl_io.c
  head/sys/dev/cxgbe/tom/t4_tls.c
  head/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c
  head/sys/kern/kern_mbuf.c
  head/sys/kern/kern_sendfile.c
  head/sys/kern/subr_bus_dma.c
  head/sys/kern/subr_sglist.c
  head/sys/kern/uipc_ktls.c
  head/sys/kern/uipc_mbuf.c
  head/sys/kern/uipc_sockbuf.c
  head/sys/netinet/ip_output.c
  head/sys/netinet/tcp_output.c
  head/sys/netinet6/ip6_output.c
  head/sys/sys/mbuf.h

Modified: head/sys/dev/cxgbe/crypto/t4_kern_tls.c
==
--- head/sys/dev/cxgbe/crypto/t4_kern_tls.c Sun May  3 00:08:05 2020
(r360578)
+++ head/sys/dev/cxgbe/crypto/t4_kern_tls.c Sun May  3 00:12:56 2020
(r360579)
@@ -922,8 +922,8 @@ ktls_tcp_payload_length(struct tlspcb *tlsp, struct mb
 * trim the length to avoid sending any of the trailer.  There
 * is no way to send a partial trailer currently.
 */
-   if (mlen > TLS_HEADER_LENGTH + plen - m_tls->m_ext_pgs.trail_len)
-   mlen = TLS_HEADER_LENGTH + plen - m_tls->m_ext_pgs.trail_len;
+   if (mlen > TLS_HEADER_LENGTH + plen - m_tls->m_epg_trllen)
+   mlen = TLS_HEADER_LENGTH + plen - m_tls->m_epg_trllen;
 
 
/*
@@ -964,7 +964,7 @@ ktls_payload_offset(struct tlspcb *tlsp, struct mbuf *
mlen = mtod(m_tls, vm_offset_t) + m_tls->m_len;
MPASS(mlen < TLS_HEADER_LENGTH + plen);
 #endif
-   if (mtod(m_tls, vm_offset_t) <= m_tls->m_ext_pgs.hdr_len)
+   if (mtod(m_tls, vm_offset_t) <= m_tls->m_epg_hdrlen)
return (0);
if (tlsp->enc_mode == SCMD_CIPH_MODE_AES_GCM) {
/*
@@ -975,8 +975,8 @@ ktls_payload_offset(struct tlspcb *tlsp, struct mbuf *
 * the offset at the last byte of the record payload
 * to send the last cipher block.
 */
-   offset = min(mtod(m_tls, vm_offset_t) - 
m_tls->m_ext_pgs.hdr_len,
-   (plen - TLS_HEADER_LENGTH - m_tls->m_ext_pgs.trail_len) - 
1);
+   offset = min(mtod(m_tls, vm_offset_t) - m_tls->m_epg_hdrlen,
+   (plen - TLS_HEADER_LENGTH - m_tls->m_epg_trllen) - 1);
return (rounddown(offset, AES_BLOCK_LEN));
}
return (0);
@@ -1009,7 +1009,7 @@ ktls_wr_len(struct tlspcb *tlsp, struct mbuf *m, struc
 * excluding header and trailer.
 */
tlen = ktls_tcp_payload_length(tlsp, m_tls);
-   if (tlen <= m_tls->m_ext_pgs.hdr_len) {
+   if (tlen <= m_tls->m_epg_hdrlen) {
/*
 * For requests that only want to send the TLS header,
 * send a tunnelled packet as immediate data.
@@ -1035,7 +1035,7 @@ ktls_wr_len(struct tlspcb *tlsp, struct mbuf *m, struc
}
 
hdr = (void *)m_tls->m_epg_hdr;
-   plen = TLS_HEADER_LENGTH + ntohs(hdr->tls_length) - 
m_tls->m_ext_pgs.trail_len;
+   plen = TLS_HEADER_LENGTH + ntohs(hdr->tls_length) - m_tls->m_epg_trllen;
if (tlen < plen) {
plen = tlen;
offset = ktls_payload_offset(tlsp, m_tls);
@@ -1052,14 +1052,14 @@ ktls_wr_len(struct tlspcb *tlsp, struct mbuf *m, struc
 */
imm_len = 0;
if (offset == 0)
-   imm_len += m_tls->m_ext_pgs.hdr_len;
+   imm_len += m_tls->m_epg_hdrlen;
if (plen == tlen)
imm_len += AES_BLOCK_LEN;
wr_len += roundup2(imm_len, 16);
 
/* TLS record payload via DSGL. */
-   *nsegsp = sglist_count_mbuf_epg(m_tls, m_tls->m_ext_pgs.hdr_len + 
offset,
-   plen - (m_tls->m_ext_pgs.hdr_len + offset));
+   *nsegsp = sglist_count_mbuf_epg(m_tls, m_tls->m_epg_hdrlen + offset,
+   plen - (m_tls->m_epg_hdrlen + offset));
wr_len += ktls_sgl_size(*nsegsp);
 
wr_len = roundup2(wr_len, 16);
@@ -1595,18 +1595,18 @@ ktls_write_tls_wr(struct tlspcb *tlsp, struct sge_txq 
/* Locate 

svn commit: r360578 - head/sys/kern

2020-05-02 Thread Gleb Smirnoff
Author: glebius
Date: Sun May  3 00:08:05 2020
New Revision: 360578
URL: https://svnweb.freebsd.org/changeset/base/360578

Log:
  Step 2.5: Stop using 'struct mbuf_ext_pgs' in the kernel itself.
  
  Reviewed by:  gallatin
  Differential Revision:https://reviews.freebsd.org/D24598

Modified:
  head/sys/kern/kern_mbuf.c
  head/sys/kern/kern_sendfile.c
  head/sys/kern/uipc_ktls.c
  head/sys/kern/uipc_mbuf.c
  head/sys/kern/uipc_sockbuf.c

Modified: head/sys/kern/kern_mbuf.c
==
--- head/sys/kern/kern_mbuf.c   Sun May  3 00:03:39 2020(r360577)
+++ head/sys/kern/kern_mbuf.c   Sun May  3 00:08:05 2020(r360578)
@@ -934,7 +934,6 @@ mb_unmapped_free_mext(struct mbuf *m)
 static struct mbuf *
 _mb_unmapped_to_ext(struct mbuf *m)
 {
-   struct mbuf_ext_pgs *ext_pgs;
struct mbuf *m_new, *top, *prev, *mref;
struct sf_buf *sf;
vm_page_t pg;
@@ -943,9 +942,8 @@ _mb_unmapped_to_ext(struct mbuf *m)
u_int ref_inc = 0;
 
MBUF_EXT_PGS_ASSERT(m);
-   ext_pgs = >m_ext_pgs;
len = m->m_len;
-   KASSERT(ext_pgs->tls == NULL, ("%s: can't convert TLS mbuf %p",
+   KASSERT(m->m_ext_pgs.tls == NULL, ("%s: can't convert TLS mbuf %p",
__func__, m));
 
/* See if this is the mbuf that holds the embedded refcount. */
@@ -963,11 +961,11 @@ _mb_unmapped_to_ext(struct mbuf *m)
off = mtod(m, vm_offset_t);
 
top = NULL;
-   if (ext_pgs->hdr_len != 0) {
-   if (off >= ext_pgs->hdr_len) {
-   off -= ext_pgs->hdr_len;
+   if (m->m_ext_pgs.hdr_len != 0) {
+   if (off >= m->m_ext_pgs.hdr_len) {
+   off -= m->m_ext_pgs.hdr_len;
} else {
-   seglen = ext_pgs->hdr_len - off;
+   seglen = m->m_ext_pgs.hdr_len - off;
segoff = off;
seglen = min(seglen, len);
off = 0;
@@ -981,8 +979,8 @@ _mb_unmapped_to_ext(struct mbuf *m)
seglen);
}
}
-   pgoff = ext_pgs->first_pg_off;
-   for (i = 0; i < ext_pgs->npgs && len > 0; i++) {
+   pgoff = m->m_ext_pgs.first_pg_off;
+   for (i = 0; i < m->m_ext_pgs.npgs && len > 0; i++) {
pglen = m_epg_pagelen(m, i, pgoff);
if (off >= pglen) {
off -= pglen;
@@ -1018,9 +1016,9 @@ _mb_unmapped_to_ext(struct mbuf *m)
pgoff = 0;
};
if (len != 0) {
-   KASSERT((off + len) <= ext_pgs->trail_len,
+   KASSERT((off + len) <= m->m_ext_pgs.trail_len,
("off + len > trail (%d + %d > %d)", off, len,
-   ext_pgs->trail_len));
+   m->m_ext_pgs.trail_len));
m_new = m_get(M_NOWAIT, MT_DATA);
if (m_new == NULL)
goto fail;
@@ -1119,22 +1117,20 @@ struct mbuf *
 mb_alloc_ext_pgs(int how, m_ext_free_t ext_free)
 {
struct mbuf *m;
-   struct mbuf_ext_pgs *ext_pgs;
 
m = m_get(how, MT_DATA);
if (m == NULL)
return (NULL);
 
-   ext_pgs = >m_ext_pgs;
-   ext_pgs->npgs = 0;
-   ext_pgs->nrdy = 0;
-   ext_pgs->first_pg_off = 0;
-   ext_pgs->last_pg_len = 0;
-   ext_pgs->flags = 0;
-   ext_pgs->hdr_len = 0;
-   ext_pgs->trail_len = 0;
-   ext_pgs->tls = NULL;
-   ext_pgs->so = NULL;
+   m->m_ext_pgs.npgs = 0;
+   m->m_ext_pgs.nrdy = 0;
+   m->m_ext_pgs.first_pg_off = 0;
+   m->m_ext_pgs.last_pg_len = 0;
+   m->m_ext_pgs.flags = 0;
+   m->m_ext_pgs.hdr_len = 0;
+   m->m_ext_pgs.trail_len = 0;
+   m->m_ext_pgs.tls = NULL;
+   m->m_ext_pgs.so = NULL;
m->m_data = NULL;
m->m_flags |= (M_EXT | M_RDONLY | M_NOMAP);
m->m_ext.ext_type = EXT_PGS;

Modified: head/sys/kern/kern_sendfile.c
==
--- head/sys/kern/kern_sendfile.c   Sun May  3 00:03:39 2020
(r360577)
+++ head/sys/kern/kern_sendfile.c   Sun May  3 00:08:05 2020
(r360578)
@@ -188,7 +188,6 @@ sendfile_free_mext(struct mbuf *m)
 static void
 sendfile_free_mext_pg(struct mbuf *m)
 {
-   struct mbuf_ext_pgs *ext_pgs;
vm_page_t pg;
int flags, i;
bool cache_last;
@@ -197,11 +196,10 @@ sendfile_free_mext_pg(struct mbuf *m)
("%s: m %p !M_EXT or !EXT_PGS", __func__, m));
 
cache_last = m->m_ext.ext_flags & EXT_FLAG_CACHE_LAST;
-   ext_pgs = >m_ext_pgs;
flags = (m->m_ext.ext_flags & EXT_FLAG_NOCACHE) != 0 ? VPR_TRYFREE : 0;
 
-   for (i = 0; i < ext_pgs->npgs; i++) {
-   if (cache_last && i == ext_pgs->npgs - 1)
+   for (i = 0; i < m->m_ext_pgs.npgs; i++) {
+   if (cache_last && i == m->m_ext_pgs.npgs - 1)
 

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

2020-05-02 Thread Gleb Smirnoff
Author: glebius
Date: Sun May  3 00:03:39 2020
New Revision: 360577
URL: https://svnweb.freebsd.org/changeset/base/360577

Log:
  Make MBUF_EXT_PGS_ASSERT_SANITY() a macro, so that it prints file:line.
  While here, stop using struct mbuf_ext_pgs.
  
  Reviewed by:  gallatin
  Differential Revision:https://reviews.freebsd.org/D24598

Modified:
  head/sys/kern/kern_mbuf.c
  head/sys/sys/mbuf.h

Modified: head/sys/kern/kern_mbuf.c
==
--- head/sys/kern/kern_mbuf.c   Sat May  2 23:58:20 2020(r360576)
+++ head/sys/kern/kern_mbuf.c   Sun May  3 00:03:39 2020(r360577)
@@ -1145,40 +1145,6 @@ mb_alloc_ext_pgs(int how, m_ext_free_t ext_free)
return (m);
 }
 
-#ifdef INVARIANT_SUPPORT
-void
-mb_ext_pgs_check(struct mbuf *m)
-{
-   struct mbuf_ext_pgs *ext_pgs = >m_ext_pgs;
-
-   /*
-* NB: This expects a non-empty buffer (npgs > 0 and
-* last_pg_len > 0).
-*/
-   KASSERT(ext_pgs->npgs > 0,
-   ("ext_pgs with no valid pages: %p", ext_pgs));
-   KASSERT(ext_pgs->npgs <= nitems(m->m_epg_pa),
-   ("ext_pgs with too many pages: %p", ext_pgs));
-   KASSERT(ext_pgs->nrdy <= ext_pgs->npgs,
-   ("ext_pgs with too many ready pages: %p", ext_pgs));
-   KASSERT(ext_pgs->first_pg_off < PAGE_SIZE,
-   ("ext_pgs with too large page offset: %p", ext_pgs));
-   KASSERT(ext_pgs->last_pg_len > 0,
-   ("ext_pgs with zero last page length: %p", ext_pgs));
-   KASSERT(ext_pgs->last_pg_len <= PAGE_SIZE,
-   ("ext_pgs with too large last page length: %p", ext_pgs));
-   if (ext_pgs->npgs == 1) {
-   KASSERT(ext_pgs->first_pg_off + ext_pgs->last_pg_len <=
-   PAGE_SIZE, ("ext_pgs with single page too large: %p",
-   ext_pgs));
-   }
-   KASSERT(ext_pgs->hdr_len <= sizeof(m->m_epg_hdr),
-   ("ext_pgs with too large header length: %p", ext_pgs));
-   KASSERT(ext_pgs->trail_len <= sizeof(m->m_epg_trail),
-   ("ext_pgs with too large header length: %p", ext_pgs));
-}
-#endif
-
 /*
  * Clean up after mbufs with M_EXT storage attached to them if the
  * reference count hits 1.

Modified: head/sys/sys/mbuf.h
==
--- head/sys/sys/mbuf.h Sat May  2 23:58:20 2020(r360576)
+++ head/sys/sys/mbuf.h Sun May  3 00:03:39 2020(r360577)
@@ -401,13 +401,36 @@ m_epg_pagelen(const struct mbuf *m, int pidx, int pgof
}
 }
 
-#ifdef INVARIANT_SUPPORT
-void   mb_ext_pgs_check(struct mbuf *m);
-#endif
 #ifdef INVARIANTS
-#defineMBUF_EXT_PGS_ASSERT_SANITY(m)   mb_ext_pgs_check((m))
+#defineMCHECK(ex, msg) KASSERT((ex),   \
+   ("Multi page mbuf %p with " #msg " at %s:%d",   \
+   m, __FILE__, __LINE__))
+/*
+ * NB: This expects a non-empty buffer (npgs > 0 and
+ * last_pg_len > 0).
+ */
+#defineMBUF_EXT_PGS_ASSERT_SANITY(m)   do {
\
+   MCHECK(m->m_ext_pgs.npgs > 0, "no valid pages");\
+   MCHECK(m->m_ext_pgs.npgs <= nitems(m->m_epg_pa),\
+   "too many pages");  \
+   MCHECK(m->m_ext_pgs.nrdy <= m->m_ext_pgs.npgs,  \
+   "too many ready pages");\
+   MCHECK(m->m_ext_pgs.first_pg_off < PAGE_SIZE,   \
+   "too large page offset");   \
+   MCHECK(m->m_ext_pgs.last_pg_len > 0, "zero last page length");  \
+   MCHECK(m->m_ext_pgs.last_pg_len <= PAGE_SIZE,   \
+   "too large last page length");  \
+   if (m->m_ext_pgs.npgs == 1) \
+   MCHECK(m->m_ext_pgs.first_pg_off +  \
+   m->m_ext_pgs.last_pg_len <=  PAGE_SIZE, \
+   "single page too large");   \
+   MCHECK(m->m_ext_pgs.hdr_len <= sizeof(m->m_epg_hdr),\
+   "too large header length"); \
+   MCHECK(m->m_ext_pgs.trail_len <= sizeof(m->m_epg_trail),\
+   "too large header length"); \
+} while (0)
 #else
-#defineMBUF_EXT_PGS_ASSERT_SANITY(m)
+#defineMBUF_EXT_PGS_ASSERT_SANITY(m)   do {} while (0);
 #endif
 #endif
 
___
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: r360576 - in head/sys/dev: cxgbe/crypto cxgbe/tom mlx5/mlx5_en

2020-05-02 Thread Gleb Smirnoff
Author: glebius
Date: Sat May  2 23:58:20 2020
New Revision: 360576
URL: https://svnweb.freebsd.org/changeset/base/360576

Log:
  Step 2.4: Stop using 'struct mbuf_ext_pgs' in drivers.
  
  Reviewed by:  gallatin, hselasky
  Differential Revision:https://reviews.freebsd.org/D24598

Modified:
  head/sys/dev/cxgbe/crypto/t4_kern_tls.c
  head/sys/dev/cxgbe/tom/t4_cpl_io.c
  head/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c

Modified: head/sys/dev/cxgbe/crypto/t4_kern_tls.c
==
--- head/sys/dev/cxgbe/crypto/t4_kern_tls.c Sat May  2 23:52:35 2020
(r360575)
+++ head/sys/dev/cxgbe/crypto/t4_kern_tls.c Sat May  2 23:58:20 2020
(r360576)
@@ -900,12 +900,10 @@ ktls_base_wr_size(struct tlspcb *tlsp)
 static u_int
 ktls_tcp_payload_length(struct tlspcb *tlsp, struct mbuf *m_tls)
 {
-   struct mbuf_ext_pgs *ext_pgs;
struct tls_record_layer *hdr;
u_int plen, mlen;
 
MBUF_EXT_PGS_ASSERT(m_tls);
-   ext_pgs = _tls->m_ext_pgs;
hdr = (void *)m_tls->m_epg_hdr;
plen = ntohs(hdr->tls_length);
 
@@ -924,8 +922,8 @@ ktls_tcp_payload_length(struct tlspcb *tlsp, struct mb
 * trim the length to avoid sending any of the trailer.  There
 * is no way to send a partial trailer currently.
 */
-   if (mlen > TLS_HEADER_LENGTH + plen - ext_pgs->trail_len)
-   mlen = TLS_HEADER_LENGTH + plen - ext_pgs->trail_len;
+   if (mlen > TLS_HEADER_LENGTH + plen - m_tls->m_ext_pgs.trail_len)
+   mlen = TLS_HEADER_LENGTH + plen - m_tls->m_ext_pgs.trail_len;
 
 
/*
@@ -953,7 +951,6 @@ ktls_tcp_payload_length(struct tlspcb *tlsp, struct mb
 static u_int
 ktls_payload_offset(struct tlspcb *tlsp, struct mbuf *m_tls)
 {
-   struct mbuf_ext_pgs *ext_pgs;
struct tls_record_layer *hdr;
u_int offset, plen;
 #ifdef INVARIANTS
@@ -961,14 +958,13 @@ ktls_payload_offset(struct tlspcb *tlsp, struct mbuf *
 #endif
 
MBUF_EXT_PGS_ASSERT(m_tls);
-   ext_pgs = _tls->m_ext_pgs;
hdr = (void *)m_tls->m_epg_hdr;
plen = ntohs(hdr->tls_length);
 #ifdef INVARIANTS
mlen = mtod(m_tls, vm_offset_t) + m_tls->m_len;
MPASS(mlen < TLS_HEADER_LENGTH + plen);
 #endif
-   if (mtod(m_tls, vm_offset_t) <= ext_pgs->hdr_len)
+   if (mtod(m_tls, vm_offset_t) <= m_tls->m_ext_pgs.hdr_len)
return (0);
if (tlsp->enc_mode == SCMD_CIPH_MODE_AES_GCM) {
/*
@@ -979,8 +975,8 @@ ktls_payload_offset(struct tlspcb *tlsp, struct mbuf *
 * the offset at the last byte of the record payload
 * to send the last cipher block.
 */
-   offset = min(mtod(m_tls, vm_offset_t) - ext_pgs->hdr_len,
-   (plen - TLS_HEADER_LENGTH - ext_pgs->trail_len) - 1);
+   offset = min(mtod(m_tls, vm_offset_t) - 
m_tls->m_ext_pgs.hdr_len,
+   (plen - TLS_HEADER_LENGTH - m_tls->m_ext_pgs.trail_len) - 
1);
return (rounddown(offset, AES_BLOCK_LEN));
}
return (0);
@@ -1003,19 +999,17 @@ static int
 ktls_wr_len(struct tlspcb *tlsp, struct mbuf *m, struct mbuf *m_tls,
 int *nsegsp)
 {
-   struct mbuf_ext_pgs *ext_pgs;
struct tls_record_layer *hdr;
u_int imm_len, offset, plen, wr_len, tlen;
 
MBUF_EXT_PGS_ASSERT(m_tls);
-   ext_pgs = _tls->m_ext_pgs;
 
/*
 * Determine the size of the TLS record payload to send
 * excluding header and trailer.
 */
tlen = ktls_tcp_payload_length(tlsp, m_tls);
-   if (tlen <= ext_pgs->hdr_len) {
+   if (tlen <= m_tls->m_ext_pgs.hdr_len) {
/*
 * For requests that only want to send the TLS header,
 * send a tunnelled packet as immediate data.
@@ -1041,7 +1035,7 @@ ktls_wr_len(struct tlspcb *tlsp, struct mbuf *m, struc
}
 
hdr = (void *)m_tls->m_epg_hdr;
-   plen = TLS_HEADER_LENGTH + ntohs(hdr->tls_length) - ext_pgs->trail_len;
+   plen = TLS_HEADER_LENGTH + ntohs(hdr->tls_length) - 
m_tls->m_ext_pgs.trail_len;
if (tlen < plen) {
plen = tlen;
offset = ktls_payload_offset(tlsp, m_tls);
@@ -1058,14 +1052,14 @@ ktls_wr_len(struct tlspcb *tlsp, struct mbuf *m, struc
 */
imm_len = 0;
if (offset == 0)
-   imm_len += ext_pgs->hdr_len;
+   imm_len += m_tls->m_ext_pgs.hdr_len;
if (plen == tlen)
imm_len += AES_BLOCK_LEN;
wr_len += roundup2(imm_len, 16);
 
/* TLS record payload via DSGL. */
-   *nsegsp = sglist_count_mbuf_epg(m_tls, ext_pgs->hdr_len + offset,
-   plen - (ext_pgs->hdr_len + offset));
+   *nsegsp = sglist_count_mbuf_epg(m_tls, m_tls->m_ext_pgs.hdr_len + 
offset,
+   plen - (m_tls->m_ext_pgs.hdr_len + offset));
wr_len += 

svn commit: r360575 - in head/sys: dev/cxgbe dev/cxgbe/tom kern sys

2020-05-02 Thread Gleb Smirnoff
Author: glebius
Date: Sat May  2 23:52:35 2020
New Revision: 360575
URL: https://svnweb.freebsd.org/changeset/base/360575

Log:
  Step 2.3: Rename mbuf_ext_pg_len() to m_epg_pagelen() that
uses mbuf argument.
  
  Reviewed by:  gallatin
  Differential Revision:https://reviews.freebsd.org/D24598

Modified:
  head/sys/dev/cxgbe/t4_sge.c
  head/sys/dev/cxgbe/tom/t4_tls.c
  head/sys/kern/kern_mbuf.c
  head/sys/kern/subr_bus_dma.c
  head/sys/kern/subr_sglist.c
  head/sys/kern/uipc_ktls.c
  head/sys/kern/uipc_mbuf.c
  head/sys/sys/mbuf.h

Modified: head/sys/dev/cxgbe/t4_sge.c
==
--- head/sys/dev/cxgbe/t4_sge.c Sat May  2 23:46:29 2020(r360574)
+++ head/sys/dev/cxgbe/t4_sge.c Sat May  2 23:52:35 2020(r360575)
@@ -2441,7 +2441,7 @@ count_mbuf_ext_pgs(struct mbuf *m, int skip, vm_paddr_
}
pgoff = m->m_ext_pgs.first_pg_off;
for (i = 0; i < m->m_ext_pgs.npgs && len > 0; i++) {
-   pglen = mbuf_ext_pg_len(>m_ext_pgs, i, pgoff);
+   pglen = m_epg_pagelen(m, i, pgoff);
if (off >= pglen) {
off -= pglen;
pgoff = 0;

Modified: head/sys/dev/cxgbe/tom/t4_tls.c
==
--- head/sys/dev/cxgbe/tom/t4_tls.c Sat May  2 23:46:29 2020
(r360574)
+++ head/sys/dev/cxgbe/tom/t4_tls.c Sat May  2 23:52:35 2020
(r360575)
@@ -1655,13 +1655,13 @@ write_ktlstx_sgl(void *dst, struct mbuf *m, int nsegs)
/* Figure out the first S/G length. */
pa = m->m_epg_pa[0] + m->m_ext_pgs.first_pg_off;
usgl->addr0 = htobe64(pa);
-   len = mbuf_ext_pg_len(>m_ext_pgs, 0, m->m_ext_pgs.first_pg_off);
+   len = m_epg_pagelen(m, 0, m->m_ext_pgs.first_pg_off);
pa += len;
for (i = 1; i < m->m_ext_pgs.npgs; i++) {
if (m->m_epg_pa[i] != pa)
break;
-   len += mbuf_ext_pg_len(>m_ext_pgs, i, 0);
-   pa += mbuf_ext_pg_len(>m_ext_pgs, i, 0);
+   len += m_epg_pagelen(m, i, 0);
+   pa += m_epg_pagelen(m, i, 0);
}
usgl->len0 = htobe32(len);
 #ifdef INVARIANTS
@@ -1679,11 +1679,11 @@ write_ktlstx_sgl(void *dst, struct mbuf *m, int nsegs)
 #endif
pa = m->m_epg_pa[i];
usgl->sge[j / 2].addr[j & 1] = htobe64(pa);
-   len = mbuf_ext_pg_len(>m_ext_pgs, i, 0);
+   len = m_epg_pagelen(m, i, 0);
pa += len;
} else {
-   len += mbuf_ext_pg_len(>m_ext_pgs, i, 0);
-   pa += mbuf_ext_pg_len(>m_ext_pgs, i, 0);
+   len += m_epg_pagelen(m, i, 0);
+   pa += m_epg_pagelen(m, i, 0);
}
}
if (j >= 0) {

Modified: head/sys/kern/kern_mbuf.c
==
--- head/sys/kern/kern_mbuf.c   Sat May  2 23:46:29 2020(r360574)
+++ head/sys/kern/kern_mbuf.c   Sat May  2 23:52:35 2020(r360575)
@@ -983,7 +983,7 @@ _mb_unmapped_to_ext(struct mbuf *m)
}
pgoff = ext_pgs->first_pg_off;
for (i = 0; i < ext_pgs->npgs && len > 0; i++) {
-   pglen = mbuf_ext_pg_len(ext_pgs, i, pgoff);
+   pglen = m_epg_pagelen(m, i, pgoff);
if (off >= pglen) {
off -= pglen;
pgoff = 0;

Modified: head/sys/kern/subr_bus_dma.c
==
--- head/sys/kern/subr_bus_dma.cSat May  2 23:46:29 2020
(r360574)
+++ head/sys/kern/subr_bus_dma.cSat May  2 23:52:35 2020
(r360575)
@@ -145,7 +145,7 @@ _bus_dmamap_load_mbuf_epg(bus_dma_tag_t dmat, bus_dmam
}
pgoff = m->m_ext_pgs.first_pg_off;
for (i = 0; i < m->m_ext_pgs.npgs && error == 0 && len > 0; i++) {
-   pglen = mbuf_ext_pg_len(>m_ext_pgs, i, pgoff);
+   pglen = m_epg_pagelen(m, i, pgoff);
if (off >= pglen) {
off -= pglen;
pgoff = 0;

Modified: head/sys/kern/subr_sglist.c
==
--- head/sys/kern/subr_sglist.c Sat May  2 23:46:29 2020(r360574)
+++ head/sys/kern/subr_sglist.c Sat May  2 23:52:35 2020(r360575)
@@ -249,7 +249,7 @@ sglist_count_mbuf_epg(struct mbuf *m, size_t off, size
nextaddr = 0;
pgoff = m->m_ext_pgs.first_pg_off;
for (i = 0; i < m->m_ext_pgs.npgs && len > 0; i++) {
-   pglen = mbuf_ext_pg_len(>m_ext_pgs, i, pgoff);
+   pglen = m_epg_pagelen(m, i, pgoff);
if (off >= pglen) {
off -= pglen;
 

svn commit: r360574 - in head: share/man/man9 sys/dev/cxgbe sys/dev/cxgbe/crypto sys/dev/cxgbe/tom sys/kern sys/sys

2020-05-02 Thread Gleb Smirnoff
Author: glebius
Date: Sat May  2 23:46:29 2020
New Revision: 360574
URL: https://svnweb.freebsd.org/changeset/base/360574

Log:
  Step 2.2:
  o Shrink sglist(9) functions to work with multipage mbufs down from
four functions to two.
  o Don't use 'struct mbuf_ext_pgs *' as argument, use struct mbuf.
  o Rename to something matching _epg.
  
  Reviewed by:  gallatin
  Differential Revision:https://reviews.freebsd.org/D24598

Modified:
  head/share/man/man9/sglist.9
  head/sys/dev/cxgbe/crypto/t4_kern_tls.c
  head/sys/dev/cxgbe/t4_sge.c
  head/sys/dev/cxgbe/tom/t4_cpl_io.c
  head/sys/kern/subr_bus_dma.c
  head/sys/kern/subr_sglist.c
  head/sys/sys/sglist.h

Modified: head/share/man/man9/sglist.9
==
--- head/share/man/man9/sglist.9Sat May  2 23:38:13 2020
(r360573)
+++ head/share/man/man9/sglist.9Sat May  2 23:46:29 2020
(r360574)
@@ -26,7 +26,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd June 28, 2019
+.Dd April 24, 2020
 .Dt SGLIST 9
 .Os
 .Sh NAME
@@ -34,9 +34,8 @@
 .Nm sglist_alloc ,
 .Nm sglist_append ,
 .Nm sglist_append_bio ,
-.Nm sglist_append_ext_pgs,
-.Nm sglist_append_mb_ext_pgs,
 .Nm sglist_append_mbuf ,
+.Nm sglist_append_mbuf_epg,
 .Nm sglist_append_phys ,
 .Nm sglist_append_sglist ,
 .Nm sglist_append_uio ,
@@ -46,8 +45,7 @@
 .Nm sglist_clone ,
 .Nm sglist_consume_uio ,
 .Nm sglist_count ,
-.Nm sglist_count_ext_pgs ,
-.Nm sglist_count_mb_ext_pgs ,
+.Nm sglist_count_mbuf_epg ,
 .Nm sglist_count_vmpages ,
 .Nm sglist_free ,
 .Nm sglist_hold ,
@@ -68,10 +66,8 @@
 .Ft int
 .Fn sglist_append_bio "struct sglist *sg" "struct bio *bp"
 .Ft int
-.Fn sglist_append_ext_pgs "struct sglist *sg" "struct mbuf_ext_pgs *ext_pgs" 
"size_t offset" "size_t len"
+.Fn sglist_append_mbuf_epg "struct sglist *sg" "struct mbuf *m" "size_t 
offset" "size_t len"
 .Ft int
-.Fn sglist_append_mb_ext_pgs "struct sglist *sg" "struct mbuf *m"
-.Ft int
 .Fn sglist_append_mbuf "struct sglist *sg" "struct mbuf *m"
 .Ft int
 .Fn sglist_append_phys "struct sglist *sg" "vm_paddr_t paddr" "size_t len"
@@ -92,10 +88,8 @@
 .Ft int
 .Fn sglist_count "void *buf" "size_t len"
 .Ft int
-.Fn sglist_count_ext_pgs "struct mbuf_ext_pgs *ext_pgs" "size_t offset" 
"size_t len"
+.Fn sglist_count_mbuf_epg "struct mbuf *m" "size_t offset" "size_t len"
 .Ft int
-.Fn sglist_count_mb_ext_pgs "struct mbuf *m"
-.Ft int
 .Fn sglist_count_vmpages "vm_page_t *m" "size_t pgoff" "size_t len"
 .Ft void
 .Fn sglist_free "struct sglist *sg"
@@ -158,20 +152,15 @@ and is
 bytes long.
 .Pp
 The
-.Nm sglist_count_ext_pgs
+.Nm sglist_count_mbuf_epg
 function returns the number of scatter/gather list elements needed to describe
-the unmapped external mbuf buffer
-.Fa ext_pgs .
+the external multipage mbuf buffer
+.Fa m .
 The ranges start at an offset of
 .Fa offset
 relative to the start of the buffer and is
 .Fa len
 bytes long.
-The
-.Nm sglist_count_mb_ext_pgs
-function returns the number of scatter/gather list elements needed to describe
-the physical address ranges of a single unmapped mbuf
-.Fa m .
 .Pp
 The
 .Nm sglist_count_vmpages
@@ -265,9 +254,11 @@ to the scatter/gather list
 .Fa sg .
 .Pp
 The
-.Nm sglist_append_ext_pgs
-function appends the physical address ranges described by the unmapped
-external mbuf buffer
+.Nm sglist_append_mbuf_epg
+function appends the physical address ranges described by the
+external multipage
+.Xr mbuf 9
+buffer
 .Fa ext_pgs
 to the scatter/gather list
 .Fa sg .
@@ -278,17 +269,9 @@ within
 and continue for
 .Fa len
 bytes.
-.Pp
-The
-.Nm sglist_append_mb_ext_pgs
-function appends the physical address ranges described by the unmapped
-mbuf
-.Fa m
-to the scatter/gather list
-.Fa sg .
 Note that unlike
 .Nm sglist_append_mbuf ,
-.Nm sglist_append_mb_ext_pgs
+.Nm sglist_append_mbuf_epg
 only adds ranges for a single mbuf,
 not an entire mbuf chain.
 .Pp

Modified: head/sys/dev/cxgbe/crypto/t4_kern_tls.c
==
--- head/sys/dev/cxgbe/crypto/t4_kern_tls.c Sat May  2 23:38:13 2020
(r360573)
+++ head/sys/dev/cxgbe/crypto/t4_kern_tls.c Sat May  2 23:46:29 2020
(r360574)
@@ -1064,7 +1064,7 @@ ktls_wr_len(struct tlspcb *tlsp, struct mbuf *m, struc
wr_len += roundup2(imm_len, 16);
 
/* TLS record payload via DSGL. */
-   *nsegsp = sglist_count_ext_pgs(m_tls, ext_pgs->hdr_len + offset,
+   *nsegsp = sglist_count_mbuf_epg(m_tls, ext_pgs->hdr_len + offset,
plen - (ext_pgs->hdr_len + offset));
wr_len += ktls_sgl_size(*nsegsp);
 
@@ -1799,7 +1799,7 @@ ktls_write_tls_wr(struct tlspcb *tlsp, struct sge_txq 
 
/* Recalculate 'nsegs' if cached value is not available. */
if (nsegs == 0)
-   nsegs = sglist_count_ext_pgs(m_tls, ext_pgs->hdr_len +
+   nsegs = sglist_count_mbuf_epg(m_tls, ext_pgs->hdr_len +
offset, plen - (ext_pgs->hdr_len + 

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

2020-05-02 Thread Gleb Smirnoff
Author: glebius
Date: Sat May  2 23:38:13 2020
New Revision: 360573
URL: https://svnweb.freebsd.org/changeset/base/360573

Log:
  Step 2.1: Build TLS workqueue from mbufs, not struct mbuf_ext_pgs.
  
  Reviewed by:  gallatin
  Differential Revision:https://reviews.freebsd.org/D24598

Modified:
  head/sys/kern/kern_mbuf.c
  head/sys/kern/uipc_ktls.c
  head/sys/sys/ktls.h
  head/sys/sys/mbuf.h

Modified: head/sys/kern/kern_mbuf.c
==
--- head/sys/kern/kern_mbuf.c   Sat May  2 22:56:22 2020(r360572)
+++ head/sys/kern/kern_mbuf.c   Sat May  2 23:38:13 2020(r360573)
@@ -1246,7 +1246,6 @@ mb_free_ext(struct mbuf *m)
break;
case EXT_PGS: {
 #ifdef KERN_TLS
-   struct mbuf_ext_pgs *pgs;
struct ktls_session *tls;
 #endif
 
@@ -1254,11 +1253,10 @@ mb_free_ext(struct mbuf *m)
("%s: ext_free not set", __func__));
mref->m_ext.ext_free(mref);
 #ifdef KERN_TLS
-   pgs = >m_ext_pgs;
-   tls = pgs->tls;
+   tls = mref->m_ext_pgs.tls;
if (tls != NULL &&
!refcount_release_if_not_last(>refcount))
-   ktls_enqueue_to_free(pgs);
+   ktls_enqueue_to_free(mref);
else
 #endif
uma_zfree(zone_mbuf, mref);

Modified: head/sys/kern/uipc_ktls.c
==
--- head/sys/kern/uipc_ktls.c   Sat May  2 22:56:22 2020(r360572)
+++ head/sys/kern/uipc_ktls.c   Sat May  2 23:38:13 2020(r360573)
@@ -79,7 +79,7 @@ __FBSDID("$FreeBSD$");
 
 struct ktls_wq {
struct mtx  mtx;
-   STAILQ_HEAD(, mbuf_ext_pgs) head;
+   STAILQ_HEAD(, mbuf) head;
boolrunning;
 } __aligned(CACHE_LINE_SIZE);
 
@@ -1430,16 +1430,19 @@ ktls_frame(struct mbuf *top, struct ktls_session *tls,
 }
 
 void
-ktls_enqueue_to_free(struct mbuf_ext_pgs *pgs)
+ktls_enqueue_to_free(struct mbuf *m)
 {
+   struct mbuf_ext_pgs *pgs;
struct ktls_wq *wq;
bool running;
 
+   pgs = >m_ext_pgs;
+
/* Mark it for freeing. */
pgs->flags |= EPG_FLAG_2FREE;
wq = _wq[pgs->tls->wq_index];
mtx_lock(>mtx);
-   STAILQ_INSERT_TAIL(>head, pgs, stailq);
+   STAILQ_INSERT_TAIL(>head, m, m_ext_pgs.stailq);
running = wq->running;
mtx_unlock(>mtx);
if (!running)
@@ -1472,7 +1475,7 @@ ktls_enqueue(struct mbuf *m, struct socket *so, int pa
 
wq = _wq[pgs->tls->wq_index];
mtx_lock(>mtx);
-   STAILQ_INSERT_TAIL(>head, pgs, stailq);
+   STAILQ_INSERT_TAIL(>head, m, m_ext_pgs.stailq);
running = wq->running;
mtx_unlock(>mtx);
if (!running)
@@ -1481,11 +1484,12 @@ ktls_enqueue(struct mbuf *m, struct socket *so, int pa
 }
 
 static __noinline void
-ktls_encrypt(struct mbuf_ext_pgs *pgs)
+ktls_encrypt(struct mbuf *top)
 {
struct ktls_session *tls;
struct socket *so;
-   struct mbuf *m, *top;
+   struct mbuf *m;
+   struct mbuf_ext_pgs *pgs;
vm_paddr_t parray[1 + btoc(TLS_MAX_MSG_SIZE_V10_2)];
struct iovec src_iov[1 + btoc(TLS_MAX_MSG_SIZE_V10_2)];
struct iovec dst_iov[1 + btoc(TLS_MAX_MSG_SIZE_V10_2)];
@@ -1493,15 +1497,14 @@ ktls_encrypt(struct mbuf_ext_pgs *pgs)
int error, i, len, npages, off, total_pages;
bool is_anon;
 
-   so = pgs->so;
-   tls = pgs->tls;
-   top = __containerof(pgs, struct mbuf, m_ext_pgs);
-   KASSERT(tls != NULL, ("tls = NULL, top = %p, pgs = %p\n", top, pgs));
-   KASSERT(so != NULL, ("so = NULL, top = %p, pgs = %p\n", top, pgs));
+   so = top->m_ext_pgs.so;
+   tls = top->m_ext_pgs.tls;
+   KASSERT(tls != NULL, ("tls = NULL, top = %p\n", top));
+   KASSERT(so != NULL, ("so = NULL, top = %p\n", top));
 #ifdef INVARIANTS
-   pgs->so = NULL;
+   top->m_ext_pgs.so = NULL;
 #endif
-   total_pages = pgs->enc_cnt;
+   total_pages = top->m_ext_pgs.enc_cnt;
npages = 0;
 
/*
@@ -1631,10 +1634,8 @@ static void
 ktls_work_thread(void *ctx)
 {
struct ktls_wq *wq = ctx;
-   struct mbuf_ext_pgs *p, *n;
-   struct ktls_session *tls;
-   struct mbuf *m;
-   STAILQ_HEAD(, mbuf_ext_pgs) local_head;
+   struct mbuf *m, *n;
+   STAILQ_HEAD(, mbuf) local_head;
 
 #if defined(__aarch64__) || defined(__amd64__) || defined(__i386__)
fpu_kern_thread(0);
@@ -1651,14 +1652,12 @@ ktls_work_thread(void *ctx)
STAILQ_CONCAT(_head, >head);
mtx_unlock(>mtx);
 
-   STAILQ_FOREACH_SAFE(p, _head, stailq, n) {
-   if (p->flags & EPG_FLAG_2FREE) {
-   tls = 

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

2020-05-02 Thread Gleb Smirnoff
Author: glebius
Date: Sat May  2 22:56:22 2020
New Revision: 360572
URL: https://svnweb.freebsd.org/changeset/base/360572

Log:
  Get rid of the mbuf self-pointing pointer.
  
  Reviewed by:  gallatin
  Differential Revision:https://reviews.freebsd.org/D24598

Modified:
  head/sys/kern/uipc_ktls.c
  head/sys/sys/mbuf.h

Modified: head/sys/kern/uipc_ktls.c
==
--- head/sys/kern/uipc_ktls.c   Sat May  2 22:49:14 2020(r360571)
+++ head/sys/kern/uipc_ktls.c   Sat May  2 22:56:22 2020(r360572)
@@ -1436,7 +1436,7 @@ ktls_enqueue_to_free(struct mbuf_ext_pgs *pgs)
bool running;
 
/* Mark it for freeing. */
-   pgs->mbuf = NULL;
+   pgs->flags |= EPG_FLAG_2FREE;
wq = _wq[pgs->tls->wq_index];
mtx_lock(>mtx);
STAILQ_INSERT_TAIL(>head, pgs, stailq);
@@ -1463,7 +1463,6 @@ ktls_enqueue(struct mbuf *m, struct socket *so, int pa
KASSERT(pgs->tls->mode == TCP_TLS_MODE_SW, ("!SW TLS mbuf"));
 
pgs->enc_cnt = page_count;
-   pgs->mbuf = m;
 
/*
 * Save a pointer to the socket.  The caller is responsible
@@ -1496,12 +1495,11 @@ ktls_encrypt(struct mbuf_ext_pgs *pgs)
 
so = pgs->so;
tls = pgs->tls;
-   top = pgs->mbuf;
+   top = __containerof(pgs, struct mbuf, m_ext_pgs);
KASSERT(tls != NULL, ("tls = NULL, top = %p, pgs = %p\n", top, pgs));
KASSERT(so != NULL, ("so = NULL, top = %p, pgs = %p\n", top, pgs));
 #ifdef INVARIANTS
pgs->so = NULL;
-   pgs->mbuf = NULL;
 #endif
total_pages = pgs->enc_cnt;
npages = 0;
@@ -1654,14 +1652,14 @@ ktls_work_thread(void *ctx)
mtx_unlock(>mtx);
 
STAILQ_FOREACH_SAFE(p, _head, stailq, n) {
-   if (p->mbuf != NULL) {
-   ktls_encrypt(p);
-   counter_u64_add(ktls_cnt_on, -1);
-   } else {
+   if (p->flags & EPG_FLAG_2FREE) {
tls = p->tls;
ktls_free(tls);
m = __containerof(p, struct mbuf, m_ext_pgs);
uma_zfree(zone_mbuf, m);
+   } else {
+   ktls_encrypt(p);
+   counter_u64_add(ktls_cnt_on, -1);
}
}
}

Modified: head/sys/sys/mbuf.h
==
--- head/sys/sys/mbuf.h Sat May  2 22:49:14 2020(r360571)
+++ head/sys/sys/mbuf.h Sat May  2 22:56:22 2020(r360572)
@@ -365,13 +365,13 @@ struct mbuf {
uint16_t last_pg_len;
uint8_t flags;
 #defineEPG_FLAG_ANON   0x1 /* Data can be encrypted in place. */
+#defineEPG_FLAG_2FREE  0x2 /* Scheduled for free. */
uint8_t record_type;
uint8_t spare[2];
int enc_cnt;
struct ktls_session *tls;
struct socket   *so;
uint64_tseqno;
-   struct mbuf *mbuf;
STAILQ_ENTRY(mbuf_ext_pgs) stailq;
} m_ext_pgs;
};
___
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: r360571 - in head/sys: kern sys

2020-05-02 Thread Gleb Smirnoff
Author: glebius
Date: Sat May  2 22:49:14 2020
New Revision: 360571
URL: https://svnweb.freebsd.org/changeset/base/360571

Log:
  Start moving into EPG_/epg_ namespace.  There is only one flag, but
  next commit brings in second flag, so let them already be in the
  future namespace.
  
  Reviewed by:  gallatin
  Differential Revision:https://reviews.freebsd.org/D24598

Modified:
  head/sys/kern/uipc_ktls.c
  head/sys/kern/uipc_mbuf.c
  head/sys/sys/mbuf.h

Modified: head/sys/kern/uipc_ktls.c
==
--- head/sys/kern/uipc_ktls.c   Sat May  2 22:44:23 2020(r360570)
+++ head/sys/kern/uipc_ktls.c   Sat May  2 22:49:14 2020(r360571)
@@ -1545,7 +1545,7 @@ ktls_encrypt(struct mbuf_ext_pgs *pgs)
 * (from sendfile), anonymous wired pages are
 * allocated and assigned to the destination iovec.
 */
-   is_anon = (pgs->flags & MBUF_PEXT_FLAG_ANON) != 0;
+   is_anon = (pgs->flags & EPG_FLAG_ANON) != 0;
 
off = pgs->first_pg_off;
for (i = 0; i < pgs->npgs; i++, off = 0) {
@@ -1601,7 +1601,7 @@ retry_page:
m->m_ext.ext_free = mb_free_mext_pgs;
 
/* Pages are now writable. */
-   pgs->flags |= MBUF_PEXT_FLAG_ANON;
+   pgs->flags |= EPG_FLAG_ANON;
}
 
/*

Modified: head/sys/kern/uipc_mbuf.c
==
--- head/sys/kern/uipc_mbuf.c   Sat May  2 22:44:23 2020(r360570)
+++ head/sys/kern/uipc_mbuf.c   Sat May  2 22:49:14 2020(r360571)
@@ -1678,7 +1678,7 @@ m_uiotombuf_nomap(struct uio *uio, int how, int len, i
prev->m_next = mb;
prev = mb;
pgs = >m_ext_pgs;
-   pgs->flags = MBUF_PEXT_FLAG_ANON;
+   pgs->flags = EPG_FLAG_ANON;
needed = length = MIN(maxseg, total);
for (i = 0; needed > 0; i++, needed -= PAGE_SIZE) {
 retry_page:

Modified: head/sys/sys/mbuf.h
==
--- head/sys/sys/mbuf.h Sat May  2 22:44:23 2020(r360570)
+++ head/sys/sys/mbuf.h Sat May  2 22:49:14 2020(r360571)
@@ -229,8 +229,6 @@ struct pkthdr {
 #defineMBUF_PEXT_MAX_BYTES 
\
 (MBUF_PEXT_MAX_PGS * PAGE_SIZE + MBUF_PEXT_HDR_LEN + MBUF_PEXT_TRAIL_LEN)
 
-#define MBUF_PEXT_FLAG_ANON1   /* Data can be encrypted in place. */
-
 struct ktls_session;
 struct socket;
 
@@ -366,6 +364,7 @@ struct mbuf {
uint16_t first_pg_off;
uint16_t last_pg_len;
uint8_t flags;
+#defineEPG_FLAG_ANON   0x1 /* Data can be encrypted in place. */
uint8_t record_type;
uint8_t spare[2];
int enc_cnt;
___
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: r360570 - head/sys/kern

2020-05-02 Thread Gleb Smirnoff
Author: glebius
Date: Sat May  2 22:44:23 2020
New Revision: 360570
URL: https://svnweb.freebsd.org/changeset/base/360570

Log:
  In mb_unmapped_compress() we don't need mbuf structure to keep data,
  but we need buffer of MLEN bytes.  This isn't just a simplification,
  but important fixup, because previous commit shrinked sizeof(struct
  mbuf) down below MSIZE, and instantiating an mbuf on stack no longer
  provides enough data.
  
  Reviewed by:  gallatin
  Differential Revision:https://reviews.freebsd.org/D24598

Modified:
  head/sys/kern/kern_mbuf.c

Modified: head/sys/kern/kern_mbuf.c
==
--- head/sys/kern/kern_mbuf.c   Sat May  2 22:39:26 2020(r360569)
+++ head/sys/kern/kern_mbuf.c   Sat May  2 22:44:23 2020(r360570)
@@ -853,7 +853,7 @@ int
 mb_unmapped_compress(struct mbuf *m)
 {
volatile u_int *refcnt;
-   struct mbuf m_temp;
+   char buf[MLEN];
 
/*
 * Assert that 'm' does not have a packet header.  If 'm' had
@@ -876,12 +876,8 @@ mb_unmapped_compress(struct mbuf *m)
if (*refcnt != 1)
return (EBUSY);
 
-   m_init(_temp, M_NOWAIT, MT_DATA, 0);
+   m_copydata(m, 0, m->m_len, buf);
 
-   /* copy data out of old mbuf */
-   m_copydata(m, 0, m->m_len, mtod(_temp, char *));
-   m_temp.m_len = m->m_len;
-
/* Free the backing pages. */
m->m_ext.ext_free(m);
 
@@ -889,8 +885,8 @@ mb_unmapped_compress(struct mbuf *m)
m->m_flags &= ~(M_EXT | M_RDONLY | M_NOMAP);
m->m_data = m->m_dat;
 
-   /* copy data back into m */
-   m_copydata(_temp, 0, m_temp.m_len, mtod(m, char *));
+   /* Copy data back into m. */
+   bcopy(buf, mtod(m, char *), m->m_len);
 
return (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: r360569 - in head/sys: dev/cxgbe dev/cxgbe/crypto dev/cxgbe/tom kern sys

2020-05-02 Thread Gleb Smirnoff
Author: glebius
Date: Sat May  2 22:39:26 2020
New Revision: 360569
URL: https://svnweb.freebsd.org/changeset/base/360569

Log:
  Continuation of multi page mbuf redesign from r359919.
  
  The following series of patches addresses three things:
  
  Now that array of pages is embedded into mbuf, we no longer need
  separate structure to pass around, so struct mbuf_ext_pgs is an
  artifact of the first implementation. And struct mbuf_ext_pgs_data
  is a crutch to accomodate the main idea r359919 with minimal churn.
  
  Also, M_EXT of type EXT_PGS are just a synonym of M_NOMAP.
  
  The namespace for the newfeature is somewhat inconsistent and
  sometimes has a lengthy prefixes. In these patches we will
  gradually bring the namespace to "m_epg" prefix for all mbuf
  fields and most functions.
  
  Step 1 of 4:
  
   o Anonymize mbuf_ext_pgs_data, embed in m_ext
   o Embed mbuf_ext_pgs
   o Start documenting all this entanglement
  
  Reviewed by:  gallatin
  Differential Revision:https://reviews.freebsd.org/D24598

Modified:
  head/sys/dev/cxgbe/crypto/t4_kern_tls.c
  head/sys/dev/cxgbe/t4_sge.c
  head/sys/dev/cxgbe/tom/t4_cpl_io.c
  head/sys/dev/cxgbe/tom/t4_tls.c
  head/sys/kern/kern_mbuf.c
  head/sys/kern/kern_sendfile.c
  head/sys/kern/subr_bus_dma.c
  head/sys/kern/subr_sglist.c
  head/sys/kern/uipc_ktls.c
  head/sys/kern/uipc_mbuf.c
  head/sys/sys/mbuf.h
  head/sys/sys/sglist.h

Modified: head/sys/dev/cxgbe/crypto/t4_kern_tls.c
==
--- head/sys/dev/cxgbe/crypto/t4_kern_tls.c Sat May  2 20:47:58 2020
(r360568)
+++ head/sys/dev/cxgbe/crypto/t4_kern_tls.c Sat May  2 22:39:26 2020
(r360569)
@@ -906,7 +906,7 @@ ktls_tcp_payload_length(struct tlspcb *tlsp, struct mb
 
MBUF_EXT_PGS_ASSERT(m_tls);
ext_pgs = _tls->m_ext_pgs;
-   hdr = (void *)ext_pgs->m_epg_hdr;
+   hdr = (void *)m_tls->m_epg_hdr;
plen = ntohs(hdr->tls_length);
 
/*
@@ -962,7 +962,7 @@ ktls_payload_offset(struct tlspcb *tlsp, struct mbuf *
 
MBUF_EXT_PGS_ASSERT(m_tls);
ext_pgs = _tls->m_ext_pgs;
-   hdr = (void *)ext_pgs->m_epg_hdr;
+   hdr = (void *)m_tls->m_epg_hdr;
plen = ntohs(hdr->tls_length);
 #ifdef INVARIANTS
mlen = mtod(m_tls, vm_offset_t) + m_tls->m_len;
@@ -1040,7 +1040,7 @@ ktls_wr_len(struct tlspcb *tlsp, struct mbuf *m, struc
return (wr_len);
}
 
-   hdr = (void *)ext_pgs->m_epg_hdr;
+   hdr = (void *)m_tls->m_epg_hdr;
plen = TLS_HEADER_LENGTH + ntohs(hdr->tls_length) - ext_pgs->trail_len;
if (tlen < plen) {
plen = tlen;
@@ -1064,7 +1064,7 @@ ktls_wr_len(struct tlspcb *tlsp, struct mbuf *m, struc
wr_len += roundup2(imm_len, 16);
 
/* TLS record payload via DSGL. */
-   *nsegsp = sglist_count_ext_pgs(ext_pgs, ext_pgs->hdr_len + offset,
+   *nsegsp = sglist_count_ext_pgs(m_tls, ext_pgs->hdr_len + offset,
plen - (ext_pgs->hdr_len + offset));
wr_len += ktls_sgl_size(*nsegsp);
 
@@ -1543,7 +1543,7 @@ ktls_write_tunnel_packet(struct sge_txq *txq, void *ds
(m->m_pkthdr.l2hlen + m->m_pkthdr.l3hlen + sizeof(*tcp)));
 
/* Copy the subset of the TLS header requested. */
-   copy_to_txd(>eq, (char *)ext_pgs->m_epg_hdr +
+   copy_to_txd(>eq, (char *)m_tls->m_epg_hdr +
mtod(m_tls, vm_offset_t), , m_tls->m_len);
txq->imm_wrs++;
 
@@ -1604,7 +1604,7 @@ ktls_write_tls_wr(struct tlspcb *tlsp, struct sge_txq 
/* Locate the TLS header. */
MBUF_EXT_PGS_ASSERT(m_tls);
ext_pgs = _tls->m_ext_pgs;
-   hdr = (void *)ext_pgs->m_epg_hdr;
+   hdr = (void *)m_tls->m_epg_hdr;
plen = TLS_HEADER_LENGTH + ntohs(hdr->tls_length) - ext_pgs->trail_len;
 
/* Determine how much of the TLS record to send. */
@@ -1799,7 +1799,7 @@ ktls_write_tls_wr(struct tlspcb *tlsp, struct sge_txq 
 
/* Recalculate 'nsegs' if cached value is not available. */
if (nsegs == 0)
-   nsegs = sglist_count_ext_pgs(ext_pgs, ext_pgs->hdr_len +
+   nsegs = sglist_count_ext_pgs(m_tls, ext_pgs->hdr_len +
offset, plen - (ext_pgs->hdr_len + offset));
 
/* Calculate the size of the TLS work request. */
@@ -2031,7 +2031,7 @@ ktls_write_tls_wr(struct tlspcb *tlsp, struct sge_txq 
/* Populate the TLS header */
out = (void *)(tx_data + 1);
if (offset == 0) {
-   memcpy(out, ext_pgs->m_epg_hdr, ext_pgs->hdr_len);
+   memcpy(out, m_tls->m_epg_hdr, ext_pgs->hdr_len);
out += ext_pgs->hdr_len;
}
 
@@ -2067,7 +2067,7 @@ ktls_write_tls_wr(struct tlspcb *tlsp, struct sge_txq 
 
/* SGL for record payload */
sglist_reset(txq->gl);
-   if (sglist_append_ext_pgs(txq->gl, ext_pgs, ext_pgs->hdr_len + offset,
+   if (sglist_append_ext_pgs(txq->gl, m_tls, 

svn commit: r360138 - head/contrib/bsnmp/snmpd

2020-04-20 Thread Gleb Smirnoff
Author: glebius
Date: Mon Apr 20 23:32:49 2020
New Revision: 360138
URL: https://svnweb.freebsd.org/changeset/base/360138

Log:
  Fix immediate crash when snmpd is bound to a specific IP address.
  
  The code that sets up msghdr must first fully fill in the msghdr
  itself, and only then use CMSG_xxx() macros.
  
  Silence from: harti, one week

Modified:
  head/contrib/bsnmp/snmpd/trans_inet.c

Modified: head/contrib/bsnmp/snmpd/trans_inet.c
==
--- head/contrib/bsnmp/snmpd/trans_inet.c   Mon Apr 20 22:57:15 2020
(r360137)
+++ head/contrib/bsnmp/snmpd/trans_inet.c   Mon Apr 20 23:32:49 2020
(r360138)
@@ -71,7 +71,7 @@ typedef void input_func(int, void *);
 typedef int activate_func(struct inet_port *);
 typedef void deactivate_func(struct inet_port *);
 typedef void parse_ctrl_func(struct port_sock *, const struct msghdr *);
-typedef void setsrc_func(struct port_sock *, struct msghdr *);
+typedef void setsrc_func(struct port_sock *, struct msghdr *, char *);
 
 static create_func ipv4_create;
 static input_func ipv4_input;
@@ -401,13 +401,12 @@ inet_send2(struct tport *tp, const u_char *buf, size_t
msg.msg_name = (void *)pi->peer;
msg.msg_namelen = pi->peerlen;
 
-   msg.msg_control = NULL;
-   msg.msg_controllen = 0;
-
char cbuf[XMIT_CBUF_SIZE];
if (s->set_ret_source) {
-   msg.msg_control = cbuf;
-   s->setsrc(s, );
+   s->setsrc(s, , cbuf);
+   } else {
+   msg.msg_control = NULL;
+   msg.msg_controllen = 0;
}
 
return (sendmsg(s->input.fd, , 0));
@@ -638,18 +637,20 @@ ipv4_parse_ctrl(struct port_sock *sock, const struct m
  * \param msg  message
  */
 static void
-ipv4_setsrc(struct port_sock *sock, struct msghdr *msg)
+ipv4_setsrc(struct port_sock *sock, struct msghdr *msg, char *cbuf)
 {
-   struct cmsghdr *cmsg = CMSG_FIRSTHDR(msg);
+   struct cmsghdr *cmsg;
 
+   msg->msg_control = cbuf;
+   msg->msg_controllen = CMSG_SPACE(sizeof(struct in_addr));
+
/* select outgoing interface by setting source address */
+   cmsg = CMSG_FIRSTHDR(msg);
cmsg->cmsg_level = IPPROTO_IP;
cmsg->cmsg_type = IP_SENDSRCADDR;
cmsg->cmsg_len = CMSG_LEN(sizeof(struct in_addr));
memcpy(CMSG_DATA(cmsg), >ret_source.a4,
sizeof(struct in_addr));
-
-   msg->msg_controllen = CMSG_SPACE(sizeof(struct in_addr));
 }
 
 /**
@@ -878,18 +879,20 @@ ipv6_parse_ctrl(struct port_sock *sock, const struct m
  * \param msg  message
  */
 static void
-ipv6_setsrc(struct port_sock *sock, struct msghdr *msg)
+ipv6_setsrc(struct port_sock *sock, struct msghdr *msg, char *cbuf)
 {
-   struct cmsghdr *cmsg = CMSG_FIRSTHDR(msg);
+   struct cmsghdr *cmsg;
 
+   msg->msg_control = cbuf;
+   msg->msg_controllen = CMSG_SPACE(sizeof(struct in6_pktinfo));
+
/* select outgoing interface by setting source address */
+   cmsg = CMSG_FIRSTHDR(msg);
cmsg->cmsg_level = IPPROTO_IPV6;
cmsg->cmsg_type = IPV6_PKTINFO;
cmsg->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo));
memcpy(CMSG_DATA(cmsg), >ret_source.a6,
sizeof(struct in6_pktinfo));
-
-   msg->msg_controllen = CMSG_SPACE(sizeof(struct in6_pktinfo));
 }
 
 /**
___
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: r360036 - in head/sys: conf modules modules/krpc modules/xdr rpc xdr

2020-04-17 Thread Gleb Smirnoff
Author: glebius
Date: Fri Apr 17 06:04:20 2020
New Revision: 360036
URL: https://svnweb.freebsd.org/changeset/base/360036

Log:
  Split XDR into separate kernel module.  Make krpc depend on xdr.
  
  Reviewed by:  rmacklem
  Differential Revision:https://reviews.freebsd.org/D24408

Added:
  head/sys/modules/xdr/
  head/sys/modules/xdr/Makefile   (contents, props changed)
Modified:
  head/sys/conf/files
  head/sys/conf/options
  head/sys/modules/Makefile
  head/sys/modules/krpc/Makefile
  head/sys/rpc/rpc_generic.c
  head/sys/xdr/xdr.c

Modified: head/sys/conf/files
==
--- head/sys/conf/files Fri Apr 17 06:02:13 2020(r360035)
+++ head/sys/conf/files Fri Apr 17 06:04:20 2020(r360036)
@@ -4983,9 +4983,9 @@ xen/xenbus/xenbusb.c  optional xenhvm
 xen/xenbus/xenbusb_front.c optional xenhvm
 xen/xenbus/xenbusb_back.c  optional xenhvm
 xen/xenmem/xenmem_if.m optional xenhvm
-xdr/xdr.c  optional krpc | nfslockd | nfscl | nfsd
-xdr/xdr_array.coptional krpc | nfslockd | nfscl | nfsd
-xdr/xdr_mbuf.c optional krpc | nfslockd | nfscl | nfsd
-xdr/xdr_mem.c  optional krpc | nfslockd | nfscl | nfsd
-xdr/xdr_reference.coptional krpc | nfslockd | nfscl | nfsd
-xdr/xdr_sizeof.c   optional krpc | nfslockd | nfscl | nfsd
+xdr/xdr.c  optional xdr | krpc | nfslockd | nfscl | nfsd
+xdr/xdr_array.coptional xdr | krpc | nfslockd | nfscl 
| nfsd
+xdr/xdr_mbuf.c optional xdr | krpc | nfslockd | nfscl | nfsd
+xdr/xdr_mem.c  optional xdr | krpc | nfslockd | nfscl | nfsd
+xdr/xdr_reference.coptional xdr | krpc | nfslockd | nfscl | nfsd
+xdr/xdr_sizeof.c   optional xdr | krpc | nfslockd | nfscl | nfsd

Modified: head/sys/conf/options
==
--- head/sys/conf/options   Fri Apr 17 06:02:13 2020(r360035)
+++ head/sys/conf/options   Fri Apr 17 06:04:20 2020(r360036)
@@ -469,6 +469,7 @@ TCP_RFC7413_MAX_KEYSopt_inet.h
 TCP_RFC7413_MAX_PSKS   opt_inet.h
 TCP_SIGNATURE  opt_ipsec.h
 VLAN_ARRAY opt_vlan.h
+XDR
 XBONEHACK
 
 #

Modified: head/sys/modules/Makefile
==
--- head/sys/modules/Makefile   Fri Apr 17 06:02:13 2020(r360035)
+++ head/sys/modules/Makefile   Fri Apr 17 06:04:20 2020(r360036)
@@ -385,6 +385,7 @@ SUBDIR= \
${_wpi} \
${_wpifw} \
${_x86bios} \
+   xdr \
xl \
xz \
zlib

Modified: head/sys/modules/krpc/Makefile
==
--- head/sys/modules/krpc/Makefile  Fri Apr 17 06:02:13 2020
(r360035)
+++ head/sys/modules/krpc/Makefile  Fri Apr 17 06:04:20 2020
(r360036)
@@ -1,6 +1,6 @@
 # $FreeBSD$
 
-.PATH: ${SRCTOP}/sys/rpc ${SRCTOP}/sys/xdr
+.PATH: ${SRCTOP}/sys/rpc
 KMOD=  krpc
 SRCS=  auth_none.c \
auth_unix.c \
@@ -22,13 +22,6 @@ SRCS=auth_none.c \
svc_dg.c \
svc_generic.c \
svc_vc.c \
-
-SRCS+= xdr.c \
-   xdr_array.c \
-   xdr_mbuf.c \
-   xdr_mem.c \
-   xdr_reference.c \
-   xdr_sizeof.c
 
 SRCS+= opt_inet6.h
 

Added: head/sys/modules/xdr/Makefile
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/modules/xdr/Makefile   Fri Apr 17 06:04:20 2020
(r360036)
@@ -0,0 +1,12 @@
+# $FreeBSD$
+
+.PATH: ${SRCTOP}/sys/xdr
+KMOD=  xdr
+SRCS=  xdr.c \
+   xdr_array.c \
+   xdr_mbuf.c \
+   xdr_mem.c \
+   xdr_reference.c \
+   xdr_sizeof.c
+
+.include 

Modified: head/sys/rpc/rpc_generic.c
==
--- head/sys/rpc/rpc_generic.c  Fri Apr 17 06:02:13 2020(r360035)
+++ head/sys/rpc/rpc_generic.c  Fri Apr 17 06:04:20 2020(r360036)
@@ -882,3 +882,4 @@ DECLARE_MODULE(krpc, krpc_mod, SI_SUB_VFS, SI_ORDER_AN
 
 /* So that loader and kldload(2) can find us, wherever we are.. */
 MODULE_VERSION(krpc, 1);
+MODULE_DEPEND(krpc, xdr, 1, 1, 1);

Modified: head/sys/xdr/xdr.c
==
--- head/sys/xdr/xdr.c  Fri Apr 17 06:02:13 2020(r360035)
+++ head/sys/xdr/xdr.c  Fri Apr 17 06:04:20 2020(r360036)
@@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -836,3 +837,20 @@ xdr_u_longlong_t(XDR *xdrs, u_longlong_t *ullp)
 */
return (xdr_uint64_t(xdrs, (uint64_t *)ullp));
 }
+
+/*
+ * Kernel module glue
+ */
+static int
+xdr_modevent(module_t mod, 

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

2020-04-17 Thread Gleb Smirnoff
Author: glebius
Date: Fri Apr 17 06:05:08 2020
New Revision: 360037
URL: https://svnweb.freebsd.org/changeset/base/360037

Log:
  Make ZFS depend on xdr.ko only.  It doesn't need kernel RPC.
  
  Differential Revision:https://reviews.freebsd.org/D24408

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Fri Apr 
17 06:04:20 2020(r360036)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Fri Apr 
17 06:05:08 2020(r360037)
@@ -7333,6 +7333,6 @@ static moduledata_t zfs_mod = {
 DECLARE_MODULE(zfsctrl, zfs_mod, SI_SUB_VFS, SI_ORDER_ANY);
 MODULE_VERSION(zfsctrl, 1);
 MODULE_DEPEND(zfsctrl, opensolaris, 1, 1, 1);
-MODULE_DEPEND(zfsctrl, krpc, 1, 1, 1);
+MODULE_DEPEND(zfsctrl, xdr, 1, 1, 1);
 MODULE_DEPEND(zfsctrl, acl_nfs4, 1, 1, 1);
 MODULE_DEPEND(zfsctrl, zlib, 1, 1, 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: r360035 - in head/sys: rpc xdr

2020-04-17 Thread Gleb Smirnoff
Author: glebius
Date: Fri Apr 17 06:02:13 2020
New Revision: 360035
URL: https://svnweb.freebsd.org/changeset/base/360035

Log:
  Move M_RPC malloc type into XDR.  Both RPC and XDR libraries use
  this type, but since RPC depends on XDR (not vice versa) we need
  it defined in XDR to make the module loadable without RPC.
  
  Reviewed by:  rmacklem
  Differential Revision:https://reviews.freebsd.org/D24408

Modified:
  head/sys/rpc/rpc_prot.c
  head/sys/xdr/xdr.c

Modified: head/sys/rpc/rpc_prot.c
==
--- head/sys/rpc/rpc_prot.c Fri Apr 17 05:59:38 2020(r360034)
+++ head/sys/rpc/rpc_prot.c Fri Apr 17 06:02:13 2020(r360035)
@@ -61,8 +61,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-MALLOC_DEFINE(M_RPC, "rpc", "Remote Procedure Call");
-
 #define assert(exp)KASSERT(exp, ("bad arguments"))
 
 static enum clnt_stat accepted(enum accept_stat, struct rpc_err *);

Modified: head/sys/xdr/xdr.c
==
--- head/sys/xdr/xdr.c  Fri Apr 17 05:59:38 2020(r360034)
+++ head/sys/xdr/xdr.c  Fri Apr 17 06:02:13 2020(r360035)
@@ -65,6 +65,8 @@ typedef u_quad_tu_longlong_t;   /* ANSI unsign
 #define XDR_FALSE  ((long) 0)
 #define XDR_TRUE   ((long) 1)
 
+MALLOC_DEFINE(M_RPC, "rpc", "Remote Procedure Call");
+
 /*
  * for unit alignment
  */
___
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: r360034 - head/sys/netgraph

2020-04-17 Thread Gleb Smirnoff
Author: glebius
Date: Fri Apr 17 05:59:38 2020
New Revision: 360034
URL: https://svnweb.freebsd.org/changeset/base/360034

Log:
  Don't initialize m->m_data to m->m_pktdat, this is already done by the
  mbuf allocator.  That was the last remnant of such code in the kernel.

Modified:
  head/sys/netgraph/ng_tty.c

Modified: head/sys/netgraph/ng_tty.c
==
--- head/sys/netgraph/ng_tty.c  Fri Apr 17 02:22:15 2020(r360033)
+++ head/sys/netgraph/ng_tty.c  Fri Apr 17 05:59:38 2020(r360034)
@@ -439,7 +439,6 @@ ngt_rint_bypass(struct tty *tp, const void *buf, size_
 * Odd, we have changed from non-bypass to bypass. It is
 * unlikely but not impossible, flush the data first.
 */
-   sc->m->m_data = sc->m->m_pktdat;
NG_SEND_DATA_ONLY(error, sc->hook, sc->m);
sc->m = NULL;
}
@@ -495,7 +494,6 @@ ngt_rint(struct tty *tp, char c, int flags)
 
/* Ship off mbuf if it's time */
if (sc->hotchar == -1 || c == sc->hotchar || m->m_len >= MHLEN) {
-   m->m_data = m->m_pktdat;
sc->m = NULL;
NG_SEND_DATA_ONLY(error, sc->hook, m);  /* Will queue */
}
___
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: r359168 - head

2020-03-24 Thread Gleb Smirnoff
On Fri, Mar 20, 2020 at 04:02:46PM +, Ed Maste wrote:
E> Author: emaste
E> Date: Fri Mar 20 16:02:45 2020
E> New Revision: 359168
E> URL: https://svnweb.freebsd.org/changeset/base/359168
E> 
E> Log:
E>   remove ancient pre-2000 ObsoleteFiles.inc entries
E>   
E>   We support 10.3 as the minimum version to install from, which was
E>   released in the mid-2010s.  There's a lot of ancient ObsoleteFiles.inc
E>   history that serves no purpose today; start by removing entries from
E>   1999 and earlier.

I understand that rationale is to speedup 'make delete-old' times, and
trimming the default file definitely makes sense. However, what about
keeping the full ObsoleteFiles.inc version, at least for documenting
purposes?

-- 
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"


Re: svn commit: r359016 - head/sys/netinet

2020-03-20 Thread Gleb Smirnoff
  Andrew,

On Mon, Mar 16, 2020 at 02:03:27PM +, Andrew Gallatin wrote:
A> Log:
A>   Avoid a cache miss accessing an mbuf ext_pgs pointer when doing SW kTLS.
A>   
A>   For a Netflix 90Gb/s 100% TLS software kTLS workload, this reduces
A>   the CPI of tcp_m_copym() from ~3.5 to ~2.5 as reported by vtune.
A>   
A>   Reviewed by:   jtl, rrs
A>   Sponsored by:  Netflix
A>   Differential Revision: https://reviews.freebsd.org/D23998
A> 
A> Modified:
A>   head/sys/netinet/tcp_output.c
A> 
A> Modified: head/sys/netinet/tcp_output.c
A> 
==
A> --- head/sys/netinet/tcp_output.cMon Mar 16 13:53:29 2020
(r359015)
A> +++ head/sys/netinet/tcp_output.cMon Mar 16 14:03:27 2020
(r359016)
A> @@ -1907,7 +1907,7 @@ tcp_m_copym(struct mbuf *m, int32_t off0, int32_t *ple
A>  top = NULL;
A>  pkthdrlen = NULL;
A>  #ifdef KERN_TLS
A> -if (m->m_flags & M_NOMAP)
A> +if (hw_tls && (m->m_flags & M_NOMAP))
A>  tls = m->m_ext.ext_pgs->tls;
A>  else
A>  tls = NULL;

IMHO, such changes must always be accompanied by a comment. Otherwise, I
can easily imagine someone in couple of years "optimizing" it back with
commit message "Remove extraneous check. m->m_ext.ext_pgs->tls is NULL when tls 
is off"

-- 
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"


Re: svn commit: r358655 - head/sbin/mount_nfs

2020-03-12 Thread Gleb Smirnoff
On Thu, Mar 05, 2020 at 11:15:04PM +0100, Dimitry Andric wrote:
D> > S> > Why don't just declare the buffer as:
D> > S> >
D> > S> >   struct if_msghdr buf;
D> > S> >
D> > S> > and then do:
D> > S> >
D> > S> >   nread = read(s, , sizeof buf);
D> > S> >
D> > S> > ?  You are never reading more than one if_msghdr anyway, and then 
there
D> > S> > is no need to cast anything.
D> > S>
D> > S> My inspiration: route socket can return other messages (man 4 route)
D> > 
D> > Yes, exactly. We don't know what size next datagram is going to be.
D> 
D> Oh, in that case this code seems completely wrong.  How do you know the
D> full datagram will be delivered with one read() call?
D> 
D> If it always is, then there is no need to read more than the size of
D> struct if_msghdr, since you are not using any data beyond it.  So in
D> that case, you can suffice with read(..., sizeof(if_msghdr)).
D> 
D> If the read() call will return partial results, you must repeatedly call
D> it in a loop, until you either reach EOF, or have enough data. In that
D> case, a buffer with the size of if_msghdr is also enough, since you
D> never need to read beyond that.

Sorry for delayed answer. The routing socket is a datagram socket,
it isn't like TCP, it can't deliver partial datagrams. If we don't
supply enough space for datagram that arrived, it won't be delivered.

So the right solution is suppling plenty of space, but parse only
part we are interested in.

-- 
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: r358686 - head/sbin/mount_nfs

2020-03-05 Thread Gleb Smirnoff
Author: glebius
Date: Thu Mar  5 21:01:47 2020
New Revision: 358686
URL: https://svnweb.freebsd.org/changeset/base/358686

Log:
  Align the buffer to the alignment of the structure we expect.
  
  Submitted by: Slawa Olhovchenkov 

Modified:
  head/sbin/mount_nfs/mount_nfs.c

Modified: head/sbin/mount_nfs/mount_nfs.c
==
--- head/sbin/mount_nfs/mount_nfs.c Thu Mar  5 20:53:43 2020
(r358685)
+++ head/sbin/mount_nfs/mount_nfs.c Thu Mar  5 21:01:47 2020
(r358686)
@@ -514,7 +514,7 @@ sec_num_to_name(int flavor)
 static time_t
 rtm_ifinfo_sleep(time_t sec)
 {
-   char buf[2048];
+   char buf[2048] __aligned(__alignof(struct if_msghdr));
fd_set rfds;
struct timeval tv, start;
ssize_t nread;
___
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: r358655 - head/sbin/mount_nfs

2020-03-05 Thread Gleb Smirnoff
On Thu, Mar 05, 2020 at 09:30:41PM +0300, Slawa Olhovchenkov wrote:
S> > > On Thu, Mar 05, 2020 at 08:35:15PM +0300, Slawa Olhovchenkov wrote:
S> > > S> > > D> sbin/mount_nfs/mount_nfs.c:549:10: error: cast from 'char *' 
to 'struct
S> > > S> > > D> if_msghdr *' increases required alignment from 1 to 4
S> > > S> > > D> [-Werror,-Wcast-align]
S> > > S> > > D> ifm = (struct if_msghdr *)buf;
S> > > S> > > D>   ^~~
S> > > S> > > D> 1 error generated.
S> > > S> > > D>
S> > > S> > > D> In practice I don't think the buffer can ever get misaligned, 
so can you
S> > > S> > > D> please add a NO_WCAST_ALIGN= to the Makefile?
S> > > S> > >
S> > > S> > > route(8) handles the same problem via intermediate (void *) cast. 
What is
S> > > S> > > preferred way to solve the problem? Change compiler flags file 
wide, or
S> > > S> > > just through (void *) cast?
S> > > S> >
S> > > S> > Copy to aligned buffer or got SIGBUS on some architectures?
S> > > S>
S> > > S> char buf[2048] __aligned(__alignof(struct if_msghdr));
S> > > S>
S> > > S> resolve this watning.
S> > > 
S> > > Thanks, Slawa! I think this is the most elegant solution.
S> > 
S> > Why don't just declare the buffer as:
S> > 
S> >   struct if_msghdr buf;
S> > 
S> > and then do:
S> > 
S> >   nread = read(s, , sizeof buf);
S> > 
S> > ?  You are never reading more than one if_msghdr anyway, and then there
S> > is no need to cast anything.
S> 
S> My inspiration: route socket can return other messages (man 4 route)

Yes, exactly. We don't know what size next datagram is going to be.

-- 
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"


Re: svn commit: r358655 - head/sbin/mount_nfs

2020-03-05 Thread Gleb Smirnoff
On Thu, Mar 05, 2020 at 08:35:15PM +0300, Slawa Olhovchenkov wrote:
S> > > D> sbin/mount_nfs/mount_nfs.c:549:10: error: cast from 'char *' to 
'struct
S> > > D> if_msghdr *' increases required alignment from 1 to 4
S> > > D> [-Werror,-Wcast-align]
S> > > D> ifm = (struct if_msghdr *)buf;
S> > > D>   ^~~
S> > > D> 1 error generated.
S> > > D> 
S> > > D> In practice I don't think the buffer can ever get misaligned, so can 
you
S> > > D> please add a NO_WCAST_ALIGN= to the Makefile?
S> > > 
S> > > route(8) handles the same problem via intermediate (void *) cast. What is
S> > > preferred way to solve the problem? Change compiler flags file wide, or
S> > > just through (void *) cast?
S> > 
S> > Copy to aligned buffer or got SIGBUS on some architectures?
S> 
S> char buf[2048] __aligned(__alignof(struct if_msghdr));
S> 
S> resolve this watning.

Thanks, Slawa! I think this is the most elegant solution.

-- 
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"


Re: svn commit: r358655 - head/sbin/mount_nfs

2020-03-05 Thread Gleb Smirnoff
On Thu, Mar 05, 2020 at 03:29:23PM +0100, Dimitry Andric wrote:
D> On 2020-03-04 23:27, Gleb Smirnoff wrote:
D> > Author: glebius
D> > Date: Wed Mar  4 22:27:16 2020
D> > New Revision: 358655
D> > URL: https://svnweb.freebsd.org/changeset/base/358655
D> > 
D> > Log:
D> >When a machine boots the NFS mounting script is executed after
D> >interfaces are configured, but for many interfaces (e.g. all Intel)
D> >ifconfig causes link renegotiation, so the first attempt to mount
D> >NFS always fails. After that mount_nfs sleeps for 30 seconds, while
D> >only a couple seconds are actually required for interface to get up.
D> >Instead of sleeping, do select(2) on routing socket and check if
D> >some interface became UP and in this case retry immediately.
D> 
D> At least on i386, this causes a -Werror warning:
D> 
D> sbin/mount_nfs/mount_nfs.c:549:10: error: cast from 'char *' to 'struct
D> if_msghdr *' increases required alignment from 1 to 4
D> [-Werror,-Wcast-align]
D> ifm = (struct if_msghdr *)buf;
D>   ^~~
D> 1 error generated.
D> 
D> In practice I don't think the buffer can ever get misaligned, so can you
D> please add a NO_WCAST_ALIGN= to the Makefile?

route(8) handles the same problem via intermediate (void *) cast. What is
preferred way to solve the problem? Change compiler flags file wide, or
just through (void *) cast?

-- 
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"


Re: svn commit: r358451 - in head/sys: kern vm

2020-03-04 Thread Gleb Smirnoff
8,7 @@ sendfile_swapin(vm_object_t obj, struct sf_io *sfio, i
J>   */
J>  for (j = i + 1; j < i + count - 1; j++)
J>  if (pa[j] == bogus_page) {
J> -pa[j] = vm_page_lookup(obj,
J> +pa[j] = vm_page_relookup(obj,
J>  OFF_TO_IDX(vmoff(j, off)));
J>  KASSERT(pa[j], ("%s: page %p[%d] disappeared",
J>  __func__, pa, j));
J> @@ -484,9 +477,6 @@ sendfile_swapin(vm_object_t obj, struct sf_io *sfio, i
J>  i += count;
J>  (*nios)++;
J>  }
J> -
J> -if (locked)
J> -VM_OBJECT_WUNLOCK(obj);
J>  
J>  if (*nios == 0 && npages != 0)
J>  SFSTAT_INC(sf_noiocnt);
J> 
J> Modified: head/sys/kern/vfs_bio.c
J> 
==
J> --- head/sys/kern/vfs_bio.c  Fri Feb 28 21:31:40 2020(r358450)
J> +++ head/sys/kern/vfs_bio.c  Fri Feb 28 21:42:48 2020(r358451)
J> @@ -2878,11 +2878,8 @@ vfs_vmio_iodone(struct buf *bp)
J>   */
J>  m = bp->b_pages[i];
J>  if (m == bogus_page) {
J> -if (bogus == false) {
J> -bogus = true;
J> -VM_OBJECT_RLOCK(obj);
J> -}
J> -m = vm_page_lookup(obj, OFF_TO_IDX(foff));
J> +bogus = true;
J> +m = vm_page_relookup(obj, OFF_TO_IDX(foff));
J>  if (m == NULL)
J>  panic("biodone: page disappeared!");
J>  bp->b_pages[i] = m;
J> @@ -2905,8 +2902,6 @@ vfs_vmio_iodone(struct buf *bp)
J>  foff = (foff + PAGE_SIZE) & ~(off_t)PAGE_MASK;
J>  iosize -= resid;
J>  }
J> -if (bogus)
J> -VM_OBJECT_RUNLOCK(obj);
J>  vm_object_pip_wakeupn(obj, bp->b_npages);
J>  if (bogus && buf_mapped(bp)) {
J>  BUF_CHECK_MAPPED(bp);
J> @@ -4470,22 +4465,16 @@ vfs_unbusy_pages(struct buf *bp)
J>  int i;
J>  vm_object_t obj;
J>  vm_page_t m;
J> -bool bogus;
J>  
J>  runningbufwakeup(bp);
J>  if (!(bp->b_flags & B_VMIO))
J>  return;
J>  
J>  obj = bp->b_bufobj->bo_object;
J> -bogus = false;
J>  for (i = 0; i < bp->b_npages; i++) {
J>  m = bp->b_pages[i];
J>  if (m == bogus_page) {
J> -if (bogus == false) {
J> -bogus = true;
J> -VM_OBJECT_RLOCK(obj);
J> -}
J> -m = vm_page_lookup(obj, OFF_TO_IDX(bp->b_offset) + i);
J> +m = vm_page_relookup(obj, OFF_TO_IDX(bp->b_offset) + i);
J>  if (!m)
J>  panic("vfs_unbusy_pages: page missing\n");
J>  bp->b_pages[i] = m;
J> @@ -4498,8 +4487,6 @@ vfs_unbusy_pages(struct buf *bp)
J>  }
J>  vm_page_sunbusy(m);
J>  }
J> -if (bogus)
J> -VM_OBJECT_RUNLOCK(obj);
J>  vm_object_pip_wakeupn(obj, bp->b_npages);
J>  }
J>  
J> 
J> Modified: head/sys/vm/vm_page.c
J> 
==
J> --- head/sys/vm/vm_page.cFri Feb 28 21:31:40 2020(r358450)
J> +++ head/sys/vm/vm_page.cFri Feb 28 21:42:48 2020(r358451)
J> @@ -1671,6 +1671,24 @@ vm_page_lookup(vm_object_t object, vm_pindex_t pindex)
J>  }
J>  
J>  /*
J> + *  vm_page_relookup:
J> + *
J> + *  Returns a page that must already have been busied by
J> + *  the caller.  Used for bogus page replacement.
J> + */
J> +vm_page_t
J> +vm_page_relookup(vm_object_t object, vm_pindex_t pindex)
J> +{
J> +vm_page_t m;
J> +
J> +m = vm_radix_lookup_unlocked(>rtree, pindex);
J> +KASSERT(m != NULL && vm_page_busied(m) &&
J> +m->object == object && m->pindex == pindex,
J> +("vm_page_relookup: Invalid page %p", m));
J> +return (m);
J> +}
J> +
J> +/*
J>   * This should only be used by lockless functions for releasing transient
J>   * incorrect acquires.  The page may have been freed after we acquired a
J>   * busy lock.  In this case busy_lock == VPB_FREED and we have nothing
J> 
J> Modified: head/sys/vm/vm_page.h
J> 
==
J> --- head/sys/vm/vm_page.hFri Feb 28 21:31:40 2020(r

svn commit: r358658 - head

2020-03-04 Thread Gleb Smirnoff
Author: glebius
Date: Wed Mar  4 23:49:20 2020
New Revision: 358658
URL: https://svnweb.freebsd.org/changeset/base/358658

Log:
  Add a missing bktr header.

Modified:
  head/ObsoleteFiles.inc

Modified: head/ObsoleteFiles.inc
==
--- head/ObsoleteFiles.inc  Wed Mar  4 22:32:40 2020(r358657)
+++ head/ObsoleteFiles.inc  Wed Mar  4 23:49:20 2020(r358658)
@@ -39,6 +39,7 @@
 # 20200301: bktr removed
 OLD_DIRS+=usr/include/dev/bktr
 OLD_FILES+=usr/include/dev/bktr/ioctl_bktr.h
+OLD_FILES+=usr/include/dev/bktr/ioctl_bt848.h
 OLD_FILES+=usr/include/dev/bktr/ioctl_meteor.h
 .if ${TARGET_ARCH} == "i386"
 OLD_FILES+=usr/include/machine/ioctl_bktr.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: r358657 - in head: share/man/man4 sys/netgraph

2020-03-04 Thread Gleb Smirnoff
Author: glebius
Date: Wed Mar  4 22:32:40 2020
New Revision: 358657
URL: https://svnweb.freebsd.org/changeset/base/358657

Log:
  Fix spelling of "dropped".
  
  Submitted by: Lutz Donnerhacke
  Differential Revision:https://reviews.freebsd.org/D23954

Modified:
  head/share/man/man4/ng_car.4
  head/sys/netgraph/ng_car.c
  head/sys/netgraph/ng_car.h

Modified: head/share/man/man4/ng_car.4
==
--- head/share/man/man4/ng_car.4Wed Mar  4 22:31:41 2020
(r358656)
+++ head/share/man/man4/ng_car.4Wed Mar  4 22:32:40 2020
(r358657)
@@ -163,7 +163,7 @@ Return node statistics as
 .Bd -literal
 struct ng_car_hookstats {
uint64_t passed_pkts;   /* Counter for passed packets */
-   uint64_t droped_pkts;   /* Counter for dropped packets */
+   uint64_t dropped_pkts;  /* Counter for dropped packets */
uint64_t green_pkts;/* Counter for green packets */
uint64_t yellow_pkts;   /* Counter for yellow packets */
uint64_t red_pkts;  /* Counter for red packets */

Modified: head/sys/netgraph/ng_car.c
==
--- head/sys/netgraph/ng_car.c  Wed Mar  4 22:31:41 2020(r358656)
+++ head/sys/netgraph/ng_car.c  Wed Mar  4 22:32:40 2020(r358657)
@@ -286,7 +286,7 @@ ng_car_rcvdata(hook_p hook, item_p item )
default:\
/* Drop packet and return. */   \
NG_FREE_ITEM(item); \
-   ++hinfo->stats.droped_pkts; \
+   ++hinfo->stats.dropped_pkts;\
return (0); \
}   \
} while (0)
@@ -730,7 +730,7 @@ ng_car_enqueue(struct hookinfo *hinfo, item_p item)
(hinfo->te + len >= NG_CAR_QUEUE_SIZE)) {
/* Drop packet. */
++hinfo->stats.red_pkts;
-   ++hinfo->stats.droped_pkts;
+   ++hinfo->stats.dropped_pkts;
NG_FREE_M(m);
 
hinfo->te = 0;

Modified: head/sys/netgraph/ng_car.h
==
--- head/sys/netgraph/ng_car.h  Wed Mar  4 22:31:41 2020(r358656)
+++ head/sys/netgraph/ng_car.h  Wed Mar  4 22:32:40 2020(r358657)
@@ -42,7 +42,7 @@
 /* Per hook statistics counters */
 struct ng_car_hookstats {
u_int64_t passed_pkts;  /* Counter for passed packets */
-   u_int64_t droped_pkts;  /* Counter for droped packets */
+   u_int64_t dropped_pkts; /* Counter for dropped packets */
u_int64_t green_pkts;   /* Counter for green packets */
u_int64_t yellow_pkts;  /* Counter for yellow packets */
u_int64_t red_pkts; /* Counter for red packets */
@@ -50,7 +50,7 @@ struct ng_car_hookstats {
 };
 #define NG_CAR_HOOKSTATS   {   \
  { "passed",   _parse_uint64_type   },  \
- { "droped",   _parse_uint64_type   },  \
+ { "dropped",  _parse_uint64_type   },  \
  { "green",_parse_uint64_type   },  \
  { "yellow",   _parse_uint64_type   },  \
  { "red",  _parse_uint64_type   },  \
___
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: r358656 - head/sys/dev/wtap

2020-03-04 Thread Gleb Smirnoff
Author: glebius
Date: Wed Mar  4 22:31:41 2020
New Revision: 358656
URL: https://svnweb.freebsd.org/changeset/base/358656

Log:
  Remove unused function.

Modified:
  head/sys/dev/wtap/if_wtap.c
  head/sys/dev/wtap/if_wtapvar.h

Modified: head/sys/dev/wtap/if_wtap.c
==
--- head/sys/dev/wtap/if_wtap.c Wed Mar  4 22:27:16 2020(r358655)
+++ head/sys/dev/wtap/if_wtap.c Wed Mar  4 22:31:41 2020(r358656)
@@ -448,44 +448,6 @@ wtap_inject(struct wtap_softc *sc, struct mbuf *m)
   mtx_unlock(>sc_mtx);
 }
 
-void
-wtap_rx_deliver(struct wtap_softc *sc, struct mbuf *m)
-{
-   struct epoch_tracker et;
-   struct ieee80211com *ic = >sc_ic;
-   struct ieee80211_node *ni;
-   int type;
-#if 0
-   DWTAP_PRINTF("%s\n", __func__);
-#endif
-
-   DWTAP_PRINTF("[%d] receiving m=%p\n", sc->id, m);
-   if (m == NULL) {/* NB: shouldn't happen */
-   ic_printf(ic, "%s: no mbuf!\n", __func__);
-   }
-
-   ieee80211_dump_pkt(ic, mtod(m, caddr_t), 0,0,0);
-
-   /*
- * Locate the node for sender, track state, and then
- * pass the (referenced) node up to the 802.11 layer
- * for its use.
- */
-   ni = ieee80211_find_rxnode_withkey(ic,
-   mtod(m, const struct ieee80211_frame_min *),IEEE80211_KEYIX_NONE);
-   NET_EPOCH_ENTER(et);
-   if (ni != NULL) {
-   /*
-* Sending station is known, dispatch directly.
-*/
-   type = ieee80211_input(ni, m, 1<<7, 10);
-   ieee80211_free_node(ni);
-   } else {
-   type = ieee80211_input_all(ic, m, 1<<7, 10);
-   }
-   NET_EPOCH_EXIT(et);
-}
-
 static void
 wtap_rx_proc(void *arg, int npending)
 {

Modified: head/sys/dev/wtap/if_wtapvar.h
==
--- head/sys/dev/wtap/if_wtapvar.h  Wed Mar  4 22:27:16 2020
(r358655)
+++ head/sys/dev/wtap/if_wtapvar.h  Wed Mar  4 22:31:41 2020
(r358656)
@@ -154,6 +154,5 @@ voidwtap_suspend(struct wtap_softc *);
 void   wtap_shutdown(struct wtap_softc *);
 void   wtap_intr(struct wtap_softc *);
 void   wtap_inject(struct wtap_softc *, struct mbuf *);
-void   wtap_rx_deliver(struct wtap_softc *, struct mbuf *);
 
 #endif
___
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: r358655 - head/sbin/mount_nfs

2020-03-04 Thread Gleb Smirnoff
Author: glebius
Date: Wed Mar  4 22:27:16 2020
New Revision: 358655
URL: https://svnweb.freebsd.org/changeset/base/358655

Log:
  When a machine boots the NFS mounting script is executed after
  interfaces are configured, but for many interfaces (e.g. all Intel)
  ifconfig causes link renegotiation, so the first attempt to mount
  NFS always fails. After that mount_nfs sleeps for 30 seconds, while
  only a couple seconds are actually required for interface to get up.
  
  Instead of sleeping, do select(2) on routing socket and check if
  some interface became UP and in this case retry immediately.
  
  Reviewed by:  rmacklem
  Differential Revision:https://reviews.freebsd.org/D23934

Modified:
  head/sbin/mount_nfs/mount_nfs.c

Modified: head/sbin/mount_nfs/mount_nfs.c
==
--- head/sbin/mount_nfs/mount_nfs.c Wed Mar  4 22:23:24 2020
(r358654)
+++ head/sbin/mount_nfs/mount_nfs.c Wed Mar  4 22:27:16 2020
(r358655)
@@ -65,6 +65,8 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
+#include 
+#include 
 
 #include 
 #include 
@@ -505,6 +507,59 @@ sec_num_to_name(int flavor)
return (NULL);
 }
 
+/*
+ * Wait for RTM_IFINFO message with interface that is IFF_UP and with
+ * link on, or until timeout expires.  Returns seconds left.
+ */
+static time_t
+rtm_ifinfo_sleep(time_t sec)
+{
+   char buf[2048];
+   fd_set rfds;
+   struct timeval tv, start;
+   ssize_t nread;
+   int n, s;
+
+   s = socket(PF_ROUTE, SOCK_RAW, 0);
+   if (s < 0)
+   err(EX_OSERR, "socket");
+   (void)gettimeofday(, NULL);
+
+   for (tv.tv_sec = sec, tv.tv_usec = 0;
+   tv.tv_sec > 0;
+   (void)gettimeofday(, NULL),
+   tv.tv_sec = sec - (tv.tv_sec - start.tv_sec)) {
+   FD_ZERO();
+   FD_SET(s, );
+   n = select(s + 1, , NULL, NULL, );
+   if (n == 0)
+   continue;
+   if (n == -1) {
+   if (errno == EINTR)
+   continue;
+   else
+   err(EX_SOFTWARE, "select");
+   }
+   nread = read(s, buf, 2048);
+   if (nread < 0)
+   err(EX_OSERR, "read");
+   if ((size_t)nread >= sizeof(struct if_msghdr)) {
+   struct if_msghdr *ifm;
+
+   ifm = (struct if_msghdr *)buf;
+   if (ifm->ifm_version == RTM_VERSION &&
+   ifm->ifm_type == RTM_IFINFO &&
+   (ifm->ifm_flags & IFF_UP) &&
+   ifm->ifm_data.ifi_link_state != LINK_STATE_DOWN)
+   break;
+   }
+   }
+
+   close(s);
+
+   return (tv.tv_sec);
+}
+
 static int
 getnfsargs(char *spec, struct iovec **iov, int *iovlen)
 {
@@ -638,7 +693,12 @@ getnfsargs(char *spec, struct iovec **iov, int *iovlen
if (daemon(0, 0) != 0)
err(1, "daemon");
}
-   sleep(60);
+   /*
+* If rtm_ifinfo_sleep() returns non-zero, don't count
+* that as a retry attempt.
+*/
+   if (rtm_ifinfo_sleep(60) && retrycnt != 0)
+   retrycnt++;
}
freeaddrinfo(ai_nfs);
 
___
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: r358317 - head/sys/kern

2020-02-26 Thread Gleb Smirnoff
On Tue, Feb 25, 2020 at 12:02:29PM -0800, Ravi Pokala wrote:
R>   When sendfile_swapin() sweeps through pages in search for a bogus page
R>   skip first and last pages.  This is a micro optimisation.
R> 
R> Yes, but *why* skip the first and last pages?

We may have inserted bogus pages in the middle of a request. We never substitute
first or last.

-- 
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: r358320 - head/sys/kern

2020-02-25 Thread Gleb Smirnoff
Author: glebius
Date: Tue Feb 25 19:29:05 2020
New Revision: 358320
URL: https://svnweb.freebsd.org/changeset/base/358320

Log:
  Generalize resources freeing in sendfile with different scenarios.
  Now we execute sendfile_iodone() in all possible cases, which
  guarantees that vm_object_pip_wakeup() is called and sfio structure
  is freed.
  
  At the beginning of sendfile initialize sfio->m to NULL, that would
  indicate that the mbuf chain either doesn't exist, or belongs to the
  syscall (not to I/O completion).  Fill sfio->m only at a point when
  we are positive that there are I/Os ongoing and before releasing
  syscall's reference on sfio.
  
  In sendfile_iodone() perform vm_object_pip_wakeup() once last
  reference is released, then check for sfio->m.  NULL pointer
  indicates that we need only to free the memory.
  
  Reviewed by:  jtl, gallatin

Modified:
  head/sys/kern/kern_sendfile.c

Modified: head/sys/kern/kern_sendfile.c
==
--- head/sys/kern/kern_sendfile.c   Tue Feb 25 19:26:40 2020
(r358319)
+++ head/sys/kern/kern_sendfile.c   Tue Feb 25 19:29:05 2020
(r358320)
@@ -258,7 +258,7 @@ static void
 sendfile_iodone(void *arg, vm_page_t *pg, int count, int error)
 {
struct sf_io *sfio = arg;
-   struct socket *so = sfio->so;
+   struct socket *so;
 
for (int i = 0; i < count; i++)
if (pg[i] != bogus_page)
@@ -272,12 +272,15 @@ sendfile_iodone(void *arg, vm_page_t *pg, int count, i
 
vm_object_pip_wakeup(sfio->obj);
 
-   if (__predict_false(sfio->error && sfio->m == NULL)) {
+   if (sfio->m == NULL) {
/*
-* I/O operation failed, but pru_send hadn't been executed -
-* nothing had been sent to the socket.  The syscall has
-* returned error to the user.
+* Either I/O operation failed, or we failed to allocate
+* buffers, or we bailed out on first busy page, or we
+* succeeded filling the request without any I/Os. Anyway,
+* pru_send hadn't been executed - nothing had been sent
+* to the socket yet.
 */
+   MPASS((curthread->td_pflags & TDP_KTHREAD) == 0);
free(sfio, M_TEMP);
return;
}
@@ -291,6 +294,7 @@ sendfile_iodone(void *arg, vm_page_t *pg, int count, i
KASSERT(sfio->tls == NULL,
("non-ext_pgs mbuf with TLS session"));
 #endif
+   so = sfio->so;
CURVNET_SET(so->so_vnet);
if (__predict_false(sfio->error)) {
/*
@@ -663,7 +667,7 @@ vn_sendfile(struct file *fp, int sockfd, struct uio *h
for (off = offset; rem > 0; ) {
struct sf_io *sfio;
vm_page_t *pa;
-   struct mbuf *mtail;
+   struct mbuf *m0, *mtail;
int nios, space, npages, rhpages;
 
mtail = NULL;
@@ -819,11 +823,9 @@ retry_space:
sfio = malloc(sizeof(struct sf_io) +
npages * sizeof(vm_page_t), M_TEMP, M_WAITOK);
refcount_init(>nios, 1);
-   sfio->so = so;
sfio->obj = obj;
sfio->error = 0;
-   vm_object_pip_add(obj, 1);
-
+   sfio->m = NULL;
 #ifdef KERN_TLS
/*
 * This doesn't use ktls_hold() because sfio->m will
@@ -832,13 +834,12 @@ retry_space:
 */
sfio->tls = tls;
 #endif
-
+   vm_object_pip_add(obj, 1);
error = sendfile_swapin(obj, sfio, , off, space, npages,
rhpages, flags);
if (error != 0) {
if (vp != NULL)
VOP_UNLOCK(vp);
-   sfio->m = NULL;
sendfile_iodone(sfio, NULL, 0, error);
goto done;
}
@@ -876,8 +877,6 @@ retry_space:
}
 
for (int i = 0; i < npages; i++) {
-   struct mbuf *m0;
-
/*
 * If a page wasn't grabbed successfully, then
 * trim the array. Can happen only with SF_NODISKIO.
@@ -922,8 +921,6 @@ retry_space:
mtx_unlock(>mtx);
}
ext_pgs = m0->m_ext.ext_pgs;
-   if (i == 0)
-   sfio->m = m0;
ext_pgs_idx = 0;
 
/* Append to mbuf chain. */
@@ -1006,9 +1003,6 @@ retry_space:
(vmoff(i, off) & PAGE_MASK);
m0->m_len = xfsize(i, npages, off, space);
 
- 

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

2020-02-25 Thread Gleb Smirnoff
Author: glebius
Date: Tue Feb 25 19:26:40 2020
New Revision: 358319
URL: https://svnweb.freebsd.org/changeset/base/358319

Log:
  Make ktls_frame() never fail.  Caller must supply correct mbufs.
  This makes sendfile code a bit simplier.

Modified:
  head/sys/kern/kern_sendfile.c
  head/sys/kern/uipc_ktls.c
  head/sys/kern/uipc_socket.c
  head/sys/sys/ktls.h

Modified: head/sys/kern/kern_sendfile.c
==
--- head/sys/kern/kern_sendfile.c   Tue Feb 25 19:12:40 2020
(r358318)
+++ head/sys/kern/kern_sendfile.c   Tue Feb 25 19:26:40 2020
(r358319)
@@ -1046,12 +1046,8 @@ prepend_header:
 
CURVNET_SET(so->so_vnet);
 #ifdef KERN_TLS
-   if (tls != NULL) {
-   error = ktls_frame(m, tls, _enq_cnt,
-   TLS_RLTYPE_APP);
-   if (error != 0)
-   goto done;
-   }
+   if (tls != NULL)
+   ktls_frame(m, tls, _enq_cnt, TLS_RLTYPE_APP);
 #endif
if (nios == 0) {
/*

Modified: head/sys/kern/uipc_ktls.c
==
--- head/sys/kern/uipc_ktls.c   Tue Feb 25 19:12:40 2020(r358318)
+++ head/sys/kern/uipc_ktls.c   Tue Feb 25 19:26:40 2020(r358319)
@@ -1231,7 +1231,7 @@ ktls_seq(struct sockbuf *sb, struct mbuf *m)
  * encryption.  The returned value should be passed to ktls_enqueue
  * when scheduling encryption of this chain of mbufs.
  */
-int
+void
 ktls_frame(struct mbuf *top, struct ktls_session *tls, int *enq_cnt,
 uint8_t record_type)
 {
@@ -1250,10 +1250,8 @@ ktls_frame(struct mbuf *top, struct ktls_session *tls,
 * records whose payload does not exceed the maximum
 * frame length.
 */
-   if (m->m_len > maxlen || m->m_len == 0)
-   return (EINVAL);
-   tls_len = m->m_len;
-
+   KASSERT(m->m_len <= maxlen && m->m_len > 0,
+   ("ktls_frame: m %p len %d\n", m, m->m_len));
/*
 * TLS frames require unmapped mbufs to store session
 * info.
@@ -1261,6 +1259,7 @@ ktls_frame(struct mbuf *top, struct ktls_session *tls,
KASSERT((m->m_flags & M_NOMAP) != 0,
("ktls_frame: mapped mbuf %p (top = %p)\n", m, top));
 
+   tls_len = m->m_len;
pgs = m->m_ext.ext_pgs;
 
/* Save a reference to the session. */
@@ -1346,7 +1345,6 @@ ktls_frame(struct mbuf *top, struct ktls_session *tls,
*enq_cnt += pgs->npgs;
}
}
-   return (0);
 }
 
 void

Modified: head/sys/kern/uipc_socket.c
==
--- head/sys/kern/uipc_socket.c Tue Feb 25 19:12:40 2020(r358318)
+++ head/sys/kern/uipc_socket.c Tue Feb 25 19:26:40 2020(r358319)
@@ -1591,12 +1591,8 @@ restart:
M_NOMAP |
((flags & MSG_EOR) ? M_EOR : 0));
if (top != NULL) {
-   error = ktls_frame(top, tls,
+   ktls_frame(top, tls,
_enq_cnt, tls_rtype);
-   if (error) {
-   m_freem(top);
-   goto release;
-   }
}
tls_rtype = TLS_RLTYPE_APP;
} else

Modified: head/sys/sys/ktls.h
==
--- head/sys/sys/ktls.h Tue Feb 25 19:12:40 2020(r358318)
+++ head/sys/sys/ktls.h Tue Feb 25 19:26:40 2020(r358319)
@@ -177,7 +177,7 @@ int ktls_crypto_backend_register(struct ktls_crypto_ba
 int ktls_crypto_backend_deregister(struct ktls_crypto_backend *be);
 int ktls_enable_tx(struct socket *so, struct tls_enable *en);
 void ktls_destroy(struct ktls_session *tls);
-int ktls_frame(struct mbuf *m, struct ktls_session *tls, int *enqueue_cnt,
+void ktls_frame(struct mbuf *m, struct ktls_session *tls, int *enqueue_cnt,
 uint8_t record_type);
 void ktls_seq(struct sockbuf *sb, struct mbuf *m);
 void ktls_enqueue(struct mbuf *m, struct socket *so, int page_count);
___
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: r358317 - head/sys/kern

2020-02-25 Thread Gleb Smirnoff
Author: glebius
Date: Tue Feb 25 19:11:20 2020
New Revision: 358317
URL: https://svnweb.freebsd.org/changeset/base/358317

Log:
  When sendfile_swapin() sweeps through pages in search for a bogus page
  skip first and last pages.  This is a micro optimisation.

Modified:
  head/sys/kern/kern_sendfile.c

Modified: head/sys/kern/kern_sendfile.c
==
--- head/sys/kern/kern_sendfile.c   Tue Feb 25 19:04:39 2020
(r358316)
+++ head/sys/kern/kern_sendfile.c   Tue Feb 25 19:11:20 2020
(r358317)
@@ -462,7 +462,7 @@ sendfile_swapin(vm_object_t obj, struct sf_io *sfio, i
 * Restore the valid page pointers.  They are already
 * unbusied, but still wired.
 */
-   for (j = i; j < i + count; j++)
+   for (j = i + 1; j < i + count - 1; j++)
if (pa[j] == bogus_page) {
pa[j] = vm_page_lookup(obj,
OFF_TO_IDX(vmoff(j, off)));
___
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: r358301 - in head/sys: dev/beri/virtio/network dev/dpaa dev/hyperv/netvsc dev/if_ndis dev/mlx5/mlx5_en dev/ntb/if_ntb dev/sbni dev/virtio/network mips/nlm/dev/net net

2020-02-24 Thread Gleb Smirnoff
Author: glebius
Date: Mon Feb 24 21:07:30 2020
New Revision: 358301
URL: https://svnweb.freebsd.org/changeset/base/358301

Log:
  Although most of the NIC drivers are epoch ready, due to peer pressure
  switch over to opt-in instead of opt-out for epoch.
  
  Instead of IFF_NEEDSEPOCH, provide IFF_KNOWSEPOCH. If driver marks
  itself with IFF_KNOWSEPOCH, then ether_input() would not enter epoch
  when processing its packets.
  
  Now this will create recursive entrance in epoch in >90% network
  drivers, but will guarantee safeness of the transition.
  
  Mark several tested drivers as IFF_KNOWSEPOCH.
  
  Reviewed by:  hselasky, jeff, bz, gallatin
  Differential Revision:https://reviews.freebsd.org/D23674

Modified:
  head/sys/dev/beri/virtio/network/if_vtbe.c
  head/sys/dev/dpaa/if_dtsec.c
  head/sys/dev/hyperv/netvsc/if_hn.c
  head/sys/dev/if_ndis/if_ndis.c
  head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
  head/sys/dev/ntb/if_ntb/if_ntb.c
  head/sys/dev/sbni/if_sbni.c
  head/sys/dev/virtio/network/if_vtnet.c
  head/sys/mips/nlm/dev/net/xlpge.c
  head/sys/net/if.c
  head/sys/net/if.h
  head/sys/net/if_ethersubr.c
  head/sys/net/iflib.c

Modified: head/sys/dev/beri/virtio/network/if_vtbe.c
==
--- head/sys/dev/beri/virtio/network/if_vtbe.c  Mon Feb 24 19:50:28 2020
(r358300)
+++ head/sys/dev/beri/virtio/network/if_vtbe.c  Mon Feb 24 21:07:30 2020
(r358301)
@@ -613,7 +613,7 @@ vtbe_attach(device_t dev)
ifp->if_softc = sc;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX |
-IFF_MULTICAST | IFF_PROMISC | IFF_NEEDSEPOCH);
+IFF_MULTICAST | IFF_PROMISC);
ifp->if_capabilities = IFCAP_VLAN_MTU;
ifp->if_capenable = ifp->if_capabilities;
ifp->if_start = vtbe_txstart;

Modified: head/sys/dev/dpaa/if_dtsec.c
==
--- head/sys/dev/dpaa/if_dtsec.cMon Feb 24 19:50:28 2020
(r358300)
+++ head/sys/dev/dpaa/if_dtsec.cMon Feb 24 21:07:30 2020
(r358301)
@@ -688,7 +688,7 @@ dtsec_attach(device_t dev)
 
ifp->if_softc = sc;
ifp->if_mtu = ETHERMTU; /* TODO: Configure */
-   ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST | IFF_NEEDSEPOCH;
+   ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST;
ifp->if_init = dtsec_if_init;
ifp->if_start = dtsec_if_start;
ifp->if_ioctl = dtsec_if_ioctl;

Modified: head/sys/dev/hyperv/netvsc/if_hn.c
==
--- head/sys/dev/hyperv/netvsc/if_hn.c  Mon Feb 24 19:50:28 2020
(r358300)
+++ head/sys/dev/hyperv/netvsc/if_hn.c  Mon Feb 24 21:07:30 2020
(r358301)
@@ -2362,8 +2362,7 @@ hn_attach(device_t dev)
 */
 
ifp->if_baudrate = IF_Gbps(10);
-   ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST |
-   IFF_NEEDSEPOCH;
+   ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = hn_ioctl;
ifp->if_init = hn_init;
 #ifdef HN_IFSTART_SUPPORT

Modified: head/sys/dev/if_ndis/if_ndis.c
==
--- head/sys/dev/if_ndis/if_ndis.c  Mon Feb 24 19:50:28 2020
(r358300)
+++ head/sys/dev/if_ndis/if_ndis.c  Mon Feb 24 21:07:30 2020
(r358301)
@@ -967,8 +967,7 @@ ndis_ifattach(struct ndis_softc *sc)
 
if_initname(ifp, device_get_name(sc->ndis_dev),
device_get_unit(sc->ndis_dev));
-   ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST |
-   IFF_NEEDSEPOCH;
+   ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = ndis_ifioctl;
ifp->if_start = ndis_ifstart;
ifp->if_init = ndis_init;

Modified: head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
==
--- head/sys/dev/mlx5/mlx5_en/mlx5_en_main.cMon Feb 24 19:50:28 2020
(r358300)
+++ head/sys/dev/mlx5/mlx5_en/mlx5_en_main.cMon Feb 24 21:07:30 2020
(r358301)
@@ -4275,7 +4275,8 @@ mlx5e_create_ifp(struct mlx5_core_dev *mdev)
if_initname(ifp, "mce", device_get_unit(mdev->pdev->dev.bsddev));
ifp->if_mtu = ETHERMTU;
ifp->if_init = mlx5e_open;
-   ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
+   ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST |
+   IFF_KNOWSEPOCH;
ifp->if_ioctl = mlx5e_ioctl;
ifp->if_transmit = mlx5e_xmit;
ifp->if_qflush = if_qflush;

Modified: head/sys/dev/ntb/if_ntb/if_ntb.c
==
--- head/sys/dev/ntb/if_ntb/if_ntb.cMon Feb 24 19:50:28 2020
(r358300)
+++ 

svn commit: r358194 - head/sys/netgraph

2020-02-20 Thread Gleb Smirnoff
Author: glebius
Date: Fri Feb 21 04:18:15 2020
New Revision: 358194
URL: https://svnweb.freebsd.org/changeset/base/358194

Log:
  Rework second part of r357558.  Unroll the macro and allocate memory in
  sleepable manner before entering the epoch for the send.

Modified:
  head/sys/netgraph/ng_socket.c

Modified: head/sys/netgraph/ng_socket.c
==
--- head/sys/netgraph/ng_socket.c   Fri Feb 21 04:10:41 2020
(r358193)
+++ head/sys/netgraph/ng_socket.c   Fri Feb 21 04:18:15 2020
(r358194)
@@ -410,6 +410,7 @@ ngd_send(struct socket *so, int flags, struct mbuf *m,
struct sockaddr_ng *const sap = (struct sockaddr_ng *) addr;
int len, error;
hook_p  hook = NULL;
+   item_p  item;
charhookname[NG_HOOKSIZ];
 
if ((pcbp == NULL) || (control != NULL)) {
@@ -462,8 +463,10 @@ ngd_send(struct socket *so, int flags, struct mbuf *m,
}
 
/* Send data. */
+   item = ng_package_data(m, NG_WAITOK);
+   m = NULL;
NET_EPOCH_ENTER(et);
-   NG_SEND_DATA_FLAGS(error, hook, m, NG_WAITOK);
+   NG_FWD_ITEM_HOOK(error, item, hook);
NET_EPOCH_EXIT(et);
 
 release:
___
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: r358193 - head/sys/netgraph

2020-02-20 Thread Gleb Smirnoff
Author: glebius
Date: Fri Feb 21 04:10:41 2020
New Revision: 358193
URL: https://svnweb.freebsd.org/changeset/base/358193

Log:
  Revert one half of previous change r357558.  Don't enter the epoch on
  sends to control socket.  Control socket messages can run constructors
  of nodes and other stuff that is allowed to M_WAITOK.
  
  PR:   244241

Modified:
  head/sys/netgraph/ng_socket.c

Modified: head/sys/netgraph/ng_socket.c
==
--- head/sys/netgraph/ng_socket.c   Fri Feb 21 01:44:31 2020
(r358192)
+++ head/sys/netgraph/ng_socket.c   Fri Feb 21 04:10:41 2020
(r358193)
@@ -219,7 +219,6 @@ static int
 ngc_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
 struct mbuf *control, struct thread *td)
 {
-   struct epoch_tracker et;
struct ngpcb *const pcbp = sotongpcb(so);
struct ngsock *const priv = NG_NODE_PRIVATE(pcbp->sockdata->node);
struct sockaddr_ng *const sap = (struct sockaddr_ng *) addr;
@@ -338,9 +337,7 @@ ngc_send(struct socket *so, int flags, struct mbuf *m,
item->apply = 
priv->error = -1;
 
-   NET_EPOCH_ENTER(et);
error = ng_snd_item(item, 0);
-   NET_EPOCH_EXIT(et);
 
mtx_lock(>mtx);
if (priv->error == -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"


Re: svn commit: r358013 - in head/sys: net netinet netinet6

2020-02-17 Thread Gleb Smirnoff
On Mon, Feb 17, 2020 at 09:46:32AM +, Hans Petter Selasky wrote:
H> Author: hselasky
H> Date: Mon Feb 17 09:46:32 2020
H> New Revision: 358013
H> URL: https://svnweb.freebsd.org/changeset/base/358013
H> 
H> Log:
H>   Fix kernel panic while trying to read multicast stream.
H>   
H>   When VIMAGE is enabled make sure the "m_pkthdr.rcvif" pointer is set
H>   for all mbufs being input by the IGMP/MLD6 code. Else there will be a
H>   NULL-pointer dereference in the netisr code when trying to set the
H>   VNET based on the incoming mbuf. Add an assert to catch this when
H>   queueing mbufs on a netisr to make debugging of similar cases easier.
H>   
H>   Found by:  Vladislav V. Prodan
H>   PR:244002
H>   Reviewed by:   bz@
H>   MFC after: 1 week
H>   Sponsored by:  Mellanox Technologies
H> 
H> Modified:
H>   head/sys/net/netisr.c
H>   head/sys/netinet/igmp.c
H>   head/sys/netinet6/mld6.c
H> 
H> Modified: head/sys/net/netisr.c
H> 
==
H> --- head/sys/net/netisr.cMon Feb 17 01:59:55 2020(r358012)
H> +++ head/sys/net/netisr.cMon Feb 17 09:46:32 2020(r358013)
H> @@ -1056,6 +1056,8 @@ netisr_queue_src(u_int proto, uintptr_t source, struct
H>  if (m != NULL) {
H>  KASSERT(!CPU_ABSENT(cpuid), ("%s: CPU %u absent", __func__,
H>  cpuid));
H> +VNET_ASSERT(m->m_pkthdr.rcvif != NULL,
H> +("%s:%d rcvif == NULL: m=%p", __func__, __LINE__, m));
H>  error = netisr_queue_internal(proto, m, cpuid);
H>  } else
H>  error = ENOBUFS;
H> 
H> Modified: head/sys/netinet/igmp.c
H> 
==
H> --- head/sys/netinet/igmp.c  Mon Feb 17 01:59:55 2020(r358012)
H> +++ head/sys/netinet/igmp.c  Mon Feb 17 09:46:32 2020(r358013)
H> @@ -303,6 +303,7 @@ igmp_save_context(struct mbuf *m, struct ifnet *ifp)
H>  #ifdef VIMAGE
H>  m->m_pkthdr.PH_loc.ptr = ifp->if_vnet;
H>  #endif /* VIMAGE */
H> +m->m_pkthdr.rcvif = ifp;
H>  m->m_pkthdr.flowid = ifp->if_index;
H>  }
H>  
H> 
H> Modified: head/sys/netinet6/mld6.c
H> 
==
H> --- head/sys/netinet6/mld6.c Mon Feb 17 01:59:55 2020(r358012)
H> +++ head/sys/netinet6/mld6.c Mon Feb 17 09:46:32 2020(r358013)
H> @@ -283,6 +283,7 @@ mld_save_context(struct mbuf *m, struct ifnet *ifp)
H>  #ifdef VIMAGE
H>  m->m_pkthdr.PH_loc.ptr = ifp->if_vnet;
H>  #endif /* VIMAGE */
H> +m->m_pkthdr.rcvif = ifp;
H>  m->m_pkthdr.flowid = ifp->if_index;
H>  }

This functions igmp_save_context() and mld_save_context() were clearly
designed to avoid dereferencing an ifnet pointer after a packet has been
queued and dequeued on IGMP/MLD internal queue.

This patch now replicates the exactly same problem but with netisr
queue. Of course netisr not always queues, sometimes dispatches
directly, but it may do queue.

I think same thing needs to be done to netisr internally - don't
dereference m->m_pkthdr.rcvif on dequeued packets, but store the
vnet info in the m->m_pkthdr.PH_loc.ptr before queueing.

-- 
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"


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: r357779 - head/sys/sys

2020-02-11 Thread Gleb Smirnoff
Author: glebius
Date: Tue Feb 11 20:59:41 2020
New Revision: 357779
URL: https://svnweb.freebsd.org/changeset/base/357779

Log:
  Remove assertion from TASK_INIT() macro, since some users of
  sys/taskqueue.h may not have includes that define MPASS. It
  was useful during testing of r357771, but can be omitted now.
  An invalid value of priority will yield only in potential
  priority inversion, not a crash.
  
  This fixes compilation of ports/x11/nvidia-driver.

Modified:
  head/sys/sys/taskqueue.h

Modified: head/sys/sys/taskqueue.h
==
--- head/sys/sys/taskqueue.hTue Feb 11 20:41:51 2020(r357778)
+++ head/sys/sys/taskqueue.hTue Feb 11 20:59:41 2020(r357779)
@@ -121,7 +121,6 @@ voidtaskqueue_thread_enqueue(void *context);
  * Initialise a task structure.
  */
 #define TASK_INIT_FLAGS(task, priority, func, context, flags) do { \
-   MPASS((priority) >= 0 && (priority) <= 255);\
(task)->ta_pending = 0; \
(task)->ta_priority = (priority);   \
(task)->ta_flags = (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"


Re: svn commit: r357761 - head/sys/netinet

2020-02-11 Thread Gleb Smirnoff
  Michael,

On Tue, Feb 11, 2020 at 08:38:21PM +0100, Michael Tuexen wrote:
M> I can revert it and get it working in a different way. However, the
M> networking code uses ints for booleans in a lot of places. I wasn't
M> aware that we need to use bool now.

We don't need to use bool, but we should use it in any new code.
Some people may still drop ints into new code, and this can be
tolerable, but intentionally converting from bools to ints is a
move backwards and this isn't okay.

Thanks for redoing it with via ifdefs for legacy platforms.

-- 
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: r357773 - head/sys/dev/liquidio/base

2020-02-11 Thread Gleb Smirnoff
Author: glebius
Date: Tue Feb 11 19:13:34 2020
New Revision: 357773
URL: https://svnweb.freebsd.org/changeset/base/357773

Log:
  Mark lio taskqueue as requiring network epoch.

Modified:
  head/sys/dev/liquidio/base/lio_droq.c

Modified: head/sys/dev/liquidio/base/lio_droq.c
==
--- head/sys/dev/liquidio/base/lio_droq.c   Tue Feb 11 18:57:07 2020
(r357772)
+++ head/sys/dev/liquidio/base/lio_droq.c   Tue Feb 11 19:13:34 2020
(r357773)
@@ -329,7 +329,7 @@ lio_init_droq(struct octeon_device *oct, uint32_t q_no
 * output queue packet processing.
 */
lio_dev_dbg(oct, "Initializing droq%d taskqueue\n", q_no);
-   TASK_INIT(>droq_task, 0, lio_droq_bh, (void *)droq);
+   NET_TASK_INIT(>droq_task, 0, lio_droq_bh, (void *)droq);
 
droq->droq_taskqueue = taskqueue_create_fast("lio_droq_task", M_NOWAIT,
 taskqueue_thread_enqueue,
___
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: r357772 - in head/sys: dev/al_eth dev/alc dev/ale dev/ath dev/bge dev/bwn dev/bxe dev/cas dev/ena dev/malo dev/mwl dev/netmap dev/nfe dev/qlxgbe dev/re dev/rt dev/smc dev/virtio/network...

2020-02-11 Thread Gleb Smirnoff
Author: glebius
Date: Tue Feb 11 18:57:07 2020
New Revision: 357772
URL: https://svnweb.freebsd.org/changeset/base/357772

Log:
  Use NET_TASK_INIT() and NET_GROUPTASK_INIT() for drivers that process
  incoming packets in taskqueue context.
  
  Reviewed by:  hselasky
  Differential Revision:https://reviews.freebsd.org/D23518

Modified:
  head/sys/dev/al_eth/al_eth.c
  head/sys/dev/alc/if_alc.c
  head/sys/dev/ale/if_ale.c
  head/sys/dev/ath/if_ath.c
  head/sys/dev/ath/if_ath_rx.c
  head/sys/dev/bge/if_bge.c
  head/sys/dev/bwn/if_bwn.c
  head/sys/dev/bxe/bxe.c
  head/sys/dev/cas/if_cas.c
  head/sys/dev/ena/ena.c
  head/sys/dev/malo/if_malo.c
  head/sys/dev/mwl/if_mwl.c
  head/sys/dev/netmap/if_ptnet.c
  head/sys/dev/nfe/if_nfe.c
  head/sys/dev/qlxgbe/ql_os.c
  head/sys/dev/re/if_re.c
  head/sys/dev/rt/if_rt.c
  head/sys/dev/smc/if_smc.c
  head/sys/dev/virtio/network/if_vtnet.c
  head/sys/dev/vnic/nicvf_queues.c
  head/sys/dev/vr/if_vr.c
  head/sys/dev/wtap/if_wtap.c
  head/sys/dev/xl/if_xl.c
  head/sys/net/iflib.c

Modified: head/sys/dev/al_eth/al_eth.c
==
--- head/sys/dev/al_eth/al_eth.cTue Feb 11 18:48:07 2020
(r357771)
+++ head/sys/dev/al_eth/al_eth.cTue Feb 11 18:57:07 2020
(r357772)
@@ -2512,7 +2512,7 @@ al_eth_setup_rx_resources(struct al_eth_adapter *adapt
return (ENOMEM);
 
/* Allocate taskqueues */
-   TASK_INIT(_ring->enqueue_task, 0, al_eth_rx_recv_work, rx_ring);
+   NET_TASK_INIT(_ring->enqueue_task, 0, al_eth_rx_recv_work, rx_ring);
rx_ring->enqueue_tq = taskqueue_create_fast("al_rx_enque", M_NOWAIT,
taskqueue_thread_enqueue, _ring->enqueue_tq);
taskqueue_start_threads(_ring->enqueue_tq, 1, PI_NET, "%s rxeq",

Modified: head/sys/dev/alc/if_alc.c
==
--- head/sys/dev/alc/if_alc.c   Tue Feb 11 18:48:07 2020(r357771)
+++ head/sys/dev/alc/if_alc.c   Tue Feb 11 18:57:07 2020(r357772)
@@ -1387,7 +1387,7 @@ alc_attach(device_t dev)
mtx_init(>alc_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
MTX_DEF);
callout_init_mtx(>alc_tick_ch, >alc_mtx, 0);
-   TASK_INIT(>alc_int_task, 0, alc_int_task, sc);
+   NET_TASK_INIT(>alc_int_task, 0, alc_int_task, sc);
sc->alc_ident = alc_find_ident(dev);
 
/* Map the device. */

Modified: head/sys/dev/ale/if_ale.c
==
--- head/sys/dev/ale/if_ale.c   Tue Feb 11 18:48:07 2020(r357771)
+++ head/sys/dev/ale/if_ale.c   Tue Feb 11 18:57:07 2020(r357772)
@@ -467,7 +467,7 @@ ale_attach(device_t dev)
mtx_init(>ale_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
MTX_DEF);
callout_init_mtx(>ale_tick_ch, >ale_mtx, 0);
-   TASK_INIT(>ale_int_task, 0, ale_int_task, sc);
+   NET_TASK_INIT(>ale_int_task, 0, ale_int_task, sc);
 
/* Map the device. */
pci_enable_busmaster(dev);

Modified: head/sys/dev/ath/if_ath.c
==
--- head/sys/dev/ath/if_ath.c   Tue Feb 11 18:48:07 2020(r357771)
+++ head/sys/dev/ath/if_ath.c   Tue Feb 11 18:57:07 2020(r357772)
@@ -760,7 +760,7 @@ ath_attach(u_int16_t devid, struct ath_softc *sc)
taskqueue_start_threads(>sc_tq, 1, PI_NET, "%s taskq",
device_get_nameunit(sc->sc_dev));
 
-   TASK_INIT(>sc_rxtask, 0, sc->sc_rx.recv_tasklet, sc);
+   NET_TASK_INIT(>sc_rxtask, 0, sc->sc_rx.recv_tasklet, sc);
TASK_INIT(>sc_bmisstask, 0, ath_bmiss_proc, sc);
TASK_INIT(>sc_bstucktask,0, ath_bstuck_proc, sc);
TASK_INIT(>sc_resettask,0, ath_reset_proc, sc);

Modified: head/sys/dev/ath/if_ath_rx.c
==
--- head/sys/dev/ath/if_ath_rx.cTue Feb 11 18:48:07 2020
(r357771)
+++ head/sys/dev/ath/if_ath_rx.cTue Feb 11 18:57:07 2020
(r357772)
@@ -647,7 +647,6 @@ ath_rx_pkt(struct ath_softc *sc, struct ath_rx_status 
 uint64_t tsf, int nf, HAL_RX_QUEUE qtype, struct ath_buf *bf,
 struct mbuf *m)
 {
-   struct epoch_tracker et;
uint64_t rstamp;
/* XXX TODO: make this an mbuf tag? */
struct ieee80211_rx_stats rxs;
@@ -942,7 +941,6 @@ rx_accept:
rxs.c_nf_ext[i] = nf;
}
 
-   NET_EPOCH_ENTER(et);
if (ni != NULL) {
/*
 * Only punt packets for ampdu reorder processing for
@@ -988,7 +986,6 @@ rx_accept:
type = ieee80211_input_mimo_all(ic, m);
m = NULL;
}
-   NET_EPOCH_EXIT(et);
 
/*
 * At this point we have passed the frame up the stack; thus

Modified: head/sys/dev/bge/if_bge.c

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

2020-02-11 Thread Gleb Smirnoff
Author: glebius
Date: Tue Feb 11 18:48:07 2020
New Revision: 357771
URL: https://svnweb.freebsd.org/changeset/base/357771

Log:
  Add flag to struct task to mark the task as requiring network epoch.
  
  When processing a taskqueue and a task has associated epoch, then
  enter for duration of the task.  If consecutive tasks belong to the
  same epoch, batch them.  Now we are talking about the network epoch
  only.
  
  Shrink the ta_priority size to 8-bits.  No current consumers use
  a priority that won't fit into 8 bits.  Also complexity of
  taskqueue_enqueue() is a square of maximum value of priority, so
  we unlikely ever want to go over UCHAR_MAX here.
  
  Reviewed by:  hselasky
  Differential Revision:https://reviews.freebsd.org/D23518

Modified:
  head/sys/kern/subr_gtaskqueue.c
  head/sys/kern/subr_taskqueue.c
  head/sys/sys/_task.h
  head/sys/sys/epoch.h
  head/sys/sys/gtaskqueue.h
  head/sys/sys/taskqueue.h

Modified: head/sys/kern/subr_gtaskqueue.c
==
--- head/sys/kern/subr_gtaskqueue.c Tue Feb 11 18:19:56 2020
(r357770)
+++ head/sys/kern/subr_gtaskqueue.c Tue Feb 11 18:48:07 2020
(r357771)
@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -342,13 +343,16 @@ gtaskqueue_unblock(struct gtaskqueue *queue)
 static void
 gtaskqueue_run_locked(struct gtaskqueue *queue)
 {
+   struct epoch_tracker et;
struct gtaskqueue_busy tb;
struct gtask *gtask;
+   bool in_net_epoch;
 
KASSERT(queue != NULL, ("tq is NULL"));
TQ_ASSERT_LOCKED(queue);
tb.tb_running = NULL;
LIST_INSERT_HEAD(>tq_active, , tb_link);
+   in_net_epoch = false;
 
while ((gtask = STAILQ_FIRST(>tq_queue)) != NULL) {
STAILQ_REMOVE_HEAD(>tq_queue, ta_link);
@@ -358,11 +362,20 @@ gtaskqueue_run_locked(struct gtaskqueue *queue)
TQ_UNLOCK(queue);
 
KASSERT(gtask->ta_func != NULL, ("task->ta_func is NULL"));
+   if (!in_net_epoch && TASK_IS_NET(gtask)) {
+   in_net_epoch = true;
+   NET_EPOCH_ENTER(et);
+   } else if (in_net_epoch && !TASK_IS_NET(gtask)) {
+   NET_EPOCH_EXIT(et);
+   in_net_epoch = false;
+   }
gtask->ta_func(gtask->ta_context);
 
TQ_LOCK(queue);
wakeup(gtask);
}
+   if (in_net_epoch)
+   NET_EPOCH_EXIT(et);
LIST_REMOVE(, tb_link);
 }
 

Modified: head/sys/kern/subr_taskqueue.c
==
--- head/sys/kern/subr_taskqueue.c  Tue Feb 11 18:19:56 2020
(r357770)
+++ head/sys/kern/subr_taskqueue.c  Tue Feb 11 18:48:07 2020
(r357771)
@@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -371,7 +372,7 @@ taskqueue_drain_tq_queue(struct taskqueue *queue)
 * anyway) so just insert it at tail while we have the
 * queue lock.
 */
-   TASK_INIT(_barrier, USHRT_MAX, taskqueue_task_nop_fn, _barrier);
+   TASK_INIT(_barrier, UCHAR_MAX, taskqueue_task_nop_fn, _barrier);
STAILQ_INSERT_TAIL(>tq_queue, _barrier, ta_link);
queue->tq_hint = _barrier;
t_barrier.ta_pending = 1;
@@ -442,14 +443,17 @@ taskqueue_unblock(struct taskqueue *queue)
 static void
 taskqueue_run_locked(struct taskqueue *queue)
 {
+   struct epoch_tracker et;
struct taskqueue_busy tb;
struct task *task;
+   bool in_net_epoch;
int pending;
 
KASSERT(queue != NULL, ("tq is NULL"));
TQ_ASSERT_LOCKED(queue);
tb.tb_running = NULL;
LIST_INSERT_HEAD(>tq_active, , tb_link);
+   in_net_epoch = false;
 
while ((task = STAILQ_FIRST(>tq_queue)) != NULL) {
STAILQ_REMOVE_HEAD(>tq_queue, ta_link);
@@ -462,11 +466,20 @@ taskqueue_run_locked(struct taskqueue *queue)
TQ_UNLOCK(queue);
 
KASSERT(task->ta_func != NULL, ("task->ta_func is NULL"));
+   if (!in_net_epoch && TASK_IS_NET(task)) {
+   in_net_epoch = true;
+   NET_EPOCH_ENTER(et);
+   } else if (in_net_epoch && !TASK_IS_NET(task)) {
+   NET_EPOCH_EXIT(et);
+   in_net_epoch = false;
+   }
task->ta_func(task->ta_context, pending);
 
TQ_LOCK(queue);
wakeup(task);
}
+   if (in_net_epoch)
+   NET_EPOCH_EXIT(et);
LIST_REMOVE(, tb_link);
 }
 

Modified: head/sys/sys/_task.h
==
--- head/sys/sys/_task.hTue Feb 11 18:19:56 2020(r357770)
+++ 

Re: svn commit: r357728 - head/sys/sys

2020-02-10 Thread Gleb Smirnoff
On Mon, Feb 10, 2020 at 01:52:26PM +, Mateusz Guzik wrote:
M> Author: mjg
M> Date: Mon Feb 10 13:52:25 2020
M> New Revision: 357728
M> URL: https://svnweb.freebsd.org/changeset/base/357728
M> 
M> Log:
M>   Tidy up zpcpu_replace*
M>   
M>   - only compute the target address once
M>   - remove spurious type casting, zpcpu_get already return the correct type
M>   
M>   While here add missing newlines to other routines.
M> 
M> Modified:
M>   head/sys/sys/pcpu.h
M> 
M> Modified: head/sys/sys/pcpu.h
M> 
==
M> --- head/sys/sys/pcpu.h  Mon Feb 10 13:24:14 2020(r357727)
M> +++ head/sys/sys/pcpu.h  Mon Feb 10 13:52:25 2020(r357728)
M> @@ -245,32 +245,41 @@ extern struct pcpu *cpuid_to_pcpu[];
M>   * If you need atomicity use xchg.
M>   * */
M>  #define zpcpu_replace(base, val) ({ \
M> -__typeof(val) _old = *(__typeof(base))zpcpu_get(base);  \
M> -*(__typeof(val) *)zpcpu_get(base) = val;\
M> +__typeof(val) *_ptr = zpcpu_get(base);  \
M> +__typeof(val) _old; \
M> +\
M> +_old = *_ptr;   \
M> +*_ptr = val;\
M>  _old;   \
M>  })

I think this function must have only protected variant that asserts
that curthread->td_critnest is on.

zpcpu_get() sometimes can be used without critical section, when we
are fine with getting a value from a different CPU.

However, can't imagine a situation where migrating during a replace
operation is acceptable.

-- 
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: r357559 - head/sys/netgraph

2020-02-04 Thread Gleb Smirnoff
Author: glebius
Date: Wed Feb  5 03:07:20 2020
New Revision: 357559
URL: https://svnweb.freebsd.org/changeset/base/357559

Log:
  I doubt anybody in the world uses ng_device, but its write method should
  also enter the network epoch when sending data from user level to netgraph.

Modified:
  head/sys/netgraph/ng_device.c

Modified: head/sys/netgraph/ng_device.c
==
--- head/sys/netgraph/ng_device.c   Wed Feb  5 03:06:29 2020
(r357558)
+++ head/sys/netgraph/ng_device.c   Wed Feb  5 03:07:20 2020
(r357559)
@@ -46,6 +46,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -454,6 +456,7 @@ ngdread(struct cdev *dev, struct uio *uio, int flag)
 static int
 ngdwrite(struct cdev *dev, struct uio *uio, int flag)
 {
+   struct epoch_tracker et;
priv_p  priv = (priv_p )dev->si_drv1;
struct mbuf *m;
int error = 0;
@@ -469,7 +472,9 @@ ngdwrite(struct cdev *dev, struct uio *uio, int flag)
if ((m = m_uiotombuf(uio, M_NOWAIT, 0, 0, M_PKTHDR)) == NULL)
return (ENOBUFS);
 
+   NET_EPOCH_ENTER(et);
NG_SEND_DATA_ONLY(error, priv->hook, m);
+   NET_EPOCH_EXIT(et);
 
return (error);
 }
___
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: r357558 - head/sys/netgraph

2020-02-04 Thread Gleb Smirnoff
Author: glebius
Date: Wed Feb  5 03:06:29 2020
New Revision: 357558
URL: https://svnweb.freebsd.org/changeset/base/357558

Log:
  Enter the network epoch when ng_socket sends data or control from user
  land to the netgraph and potentially further down the network stack.

Modified:
  head/sys/netgraph/ng_socket.c

Modified: head/sys/netgraph/ng_socket.c
==
--- head/sys/netgraph/ng_socket.c   Wed Feb  5 02:53:40 2020
(r357557)
+++ head/sys/netgraph/ng_socket.c   Wed Feb  5 03:06:29 2020
(r357558)
@@ -58,6 +58,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -217,6 +219,7 @@ static int
 ngc_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
 struct mbuf *control, struct thread *td)
 {
+   struct epoch_tracker et;
struct ngpcb *const pcbp = sotongpcb(so);
struct ngsock *const priv = NG_NODE_PRIVATE(pcbp->sockdata->node);
struct sockaddr_ng *const sap = (struct sockaddr_ng *) addr;
@@ -335,7 +338,9 @@ ngc_send(struct socket *so, int flags, struct mbuf *m,
item->apply = 
priv->error = -1;
 
+   NET_EPOCH_ENTER(et);
error = ng_snd_item(item, 0);
+   NET_EPOCH_EXIT(et);
 
mtx_lock(>mtx);
if (priv->error == -1)
@@ -403,6 +408,7 @@ static int
 ngd_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
 struct mbuf *control, struct thread *td)
 {
+   struct epoch_tracker et;
struct ngpcb *const pcbp = sotongpcb(so);
struct sockaddr_ng *const sap = (struct sockaddr_ng *) addr;
int len, error;
@@ -459,7 +465,9 @@ ngd_send(struct socket *so, int flags, struct mbuf *m,
}
 
/* Send data. */
+   NET_EPOCH_ENTER(et);
NG_SEND_DATA_FLAGS(error, hook, m, NG_WAITOK);
+   NET_EPOCH_EXIT(et);
 
 release:
if (control != NULL)
___
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: r357557 - head/sys/netgraph

2020-02-04 Thread Gleb Smirnoff
Author: glebius
Date: Wed Feb  5 02:53:40 2020
New Revision: 357557
URL: https://svnweb.freebsd.org/changeset/base/357557

Log:
  netgraph(4) callouts need to be executed in the network epoch.

Modified:
  head/sys/netgraph/ng_base.c

Modified: head/sys/netgraph/ng_base.c
==
--- head/sys/netgraph/ng_base.c Wed Feb  5 02:30:46 2020(r357556)
+++ head/sys/netgraph/ng_base.c Wed Feb  5 02:53:40 2020(r357557)
@@ -3772,11 +3772,14 @@ ng_send_fn2(node_p node, hook_p hook, item_p pitem, ng
 static void
 ng_callout_trampoline(void *arg)
 {
+   struct epoch_tracker et;
item_p item = arg;
 
+   NET_EPOCH_ENTER(et);
CURVNET_SET(NGI_NODE(item)->nd_vnet);
ng_snd_item(item, 0);
CURVNET_RESTORE();
+   NET_EPOCH_EXIT(et);
 }
 
 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"


Re: svn commit: r357233 - head/sys/net

2020-02-04 Thread Gleb Smirnoff
  Kristof,

On Sat, Feb 01, 2020 at 07:26:48PM +, Kristof Provost wrote:
K> > K> -/* The below interface used only by epair(4). */
K> > K> +/* The below interfaces are used only by epair(4). */
K> > K> +void   if_clone_addif(struct if_clone *, struct ifnet *);
K> > K>  intif_clone_destroyif(struct if_clone *, struct ifnet *);
K> >
K> > IMHO, makes sense to move all these declaration into if_epair.c 
K> > itself.
K> >
K> Yeah, that does make sense.
K> 
K> One minor issue is that it turns out that if_clone_destroyif() isn’t 
K> just used by if_epair, but also by the wifi code.
K> 
K> How does this look?

Yes, that's what I suggested. However, now given that net80211 also
uses one of these methods, I'm not sure if isolating is a right move.

In general, we consider if_clone KPI an internal one, don't we? I
mean we don't expect 3rd party device drivers to use it. So may be
it is fine that if_clone.h exposes those functions? If no, then
we probably should hide both if_clone_addif and if_clone_destroyif
away from if_clone.h and declare them as extern in epair and net80211.

-- 
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: r357466 - head/sys/kern

2020-02-03 Thread Gleb Smirnoff
Author: glebius
Date: Mon Feb  3 20:48:57 2020
New Revision: 357466
URL: https://svnweb.freebsd.org/changeset/base/357466

Log:
  Couple protocol drain routines (frag6_drain and sctp_drain) may send
  packets.  An unexpected behaviour for memory reclamation routine.
  Anyway, we need enter the network epoch for doing that.

Modified:
  head/sys/kern/kern_mbuf.c

Modified: head/sys/kern/kern_mbuf.c
==
--- head/sys/kern/kern_mbuf.c   Mon Feb  3 20:46:31 2020(r357465)
+++ head/sys/kern/kern_mbuf.c   Mon Feb  3 20:48:57 2020(r357466)
@@ -829,15 +829,18 @@ mb_ctor_pack(void *mem, int size, void *arg, int how)
 static void
 mb_reclaim(uma_zone_t zone __unused, int pending __unused)
 {
+   struct epoch_tracker et;
struct domain *dp;
struct protosw *pr;
 
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK | WARN_PANIC, NULL, __func__);
 
+   NET_EPOCH_ENTER(et);
for (dp = domains; dp != NULL; dp = dp->dom_next)
for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
if (pr->pr_drain != NULL)
(*pr->pr_drain)();
+   NET_EPOCH_EXIT(et);
 }
 
 /*
___
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: r357291 - in head/sys/dev: bwi bwn ipw iwi iwm iwn malo mwl ral rtwn/pci wi wpi wtap

2020-01-30 Thread Gleb Smirnoff
On Thu, Jan 30, 2020 at 10:51:23AM -1000, Jeff Roberson wrote:
J> On Thu, 30 Jan 2020, Gleb Smirnoff wrote:
J> 
J> > On Thu, Jan 30, 2020 at 10:28:01AM +, Hans Petter Selasky wrote:
J> > H> Author: hselasky
J> > H> Date: Thu Jan 30 10:28:01 2020
J> > H> New Revision: 357291
J> > H> URL: https://svnweb.freebsd.org/changeset/base/357291
J> > H>
J> > H> Log:
J> > H>   Widen EPOCH(9) usage in PCI WLAN drivers.
J> > H>
J> > H>   Make sure all occurrences of ieee80211_input_xxx() in sys/dev are
J> > H>   covered by a network epoch section. Do not depend on the interrupt
J> > H>   handler nor any taskqueues being in a network epoch section.
J> > H>
J> > H>   This patch should unbreak the PCI WLAN drivers after r357004.
J> > H>
J> > H>   Pointy hat:   glebius@
J> > H>   Sponsored by: Mellanox Technologies
J> >
J> > Hey, I have reviewed all of them.
J> >
J> > The following drivers were not broken, and your change does 100%
J> > recursive epoch_enter:
J> >
J> > bwi, ipw, iwi, iwm, iwn, ral, rtwn, wi, wpi
J> >
J> > The following drivers use taskq and would be fixed by D23408:
J> >
J> > bwn, malo, mwl, wtap
J> >
J> > P.S. A funny note about wtap. You modified even a function that
J> > is a dead code - wtap_rx_deliver(). Gives some clue on quality
J> > of your sweep over all drivers.
J> 
J> I would strongly suggest that we not make more changes to this area 
J> without a discussion on a review to make sure we're all in agreement. 
J> There are some fine technical details which would benefit from multiple 
J> eyes and failing to act together is creating more conflict than is 
J> necessary.  I volunteer to be on the reviews as an impartial third party.

Don't worry, I'm not going to participate in the commit war Hans started.

-- 
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"


Re: svn commit: r357293 - head/sys/net

2020-01-30 Thread Gleb Smirnoff
On Thu, Jan 30, 2020 at 12:04:03PM +, Hans Petter Selasky wrote:
H> Author: hselasky
H> Date: Thu Jan 30 12:04:02 2020
H> New Revision: 357293
H> URL: https://svnweb.freebsd.org/changeset/base/357293
H> 
H> Log:
H>   Widen EPOCH(9) usage in netisr.
H>   
H>   Software interrupt handlers are allowed to sleep. In swi_net() there
H>   is a read lock behind NETISR_RLOCK() which in turn ends up calling
H>   msleep() which means the whole of swi_net() cannot be protected by an
H>   EPOCH(9) section. By default the NETISR_LOCKING feature is disabled.
H>   
H>   This issue was introduced by r357004. This is a preparation step for
H>   replacing the functionality provided by r357004.
H>   
H>   Found by:  kib@
H>   Sponsored by:  Mellanox Technologies

What?! NETISR_RLOCK() which in turn ends up calling msleep()? Can you please
explain this nonsense?

-- 
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"


Re: svn commit: r357291 - in head/sys/dev: bwi bwn ipw iwi iwm iwn malo mwl ral rtwn/pci wi wpi wtap

2020-01-30 Thread Gleb Smirnoff
On Thu, Jan 30, 2020 at 10:28:01AM +, Hans Petter Selasky wrote:
H> Author: hselasky
H> Date: Thu Jan 30 10:28:01 2020
H> New Revision: 357291
H> URL: https://svnweb.freebsd.org/changeset/base/357291
H> 
H> Log:
H>   Widen EPOCH(9) usage in PCI WLAN drivers.
H>   
H>   Make sure all occurrences of ieee80211_input_xxx() in sys/dev are
H>   covered by a network epoch section. Do not depend on the interrupt
H>   handler nor any taskqueues being in a network epoch section.
H>   
H>   This patch should unbreak the PCI WLAN drivers after r357004.
H>   
H>   Pointy hat:glebius@
H>   Sponsored by:  Mellanox Technologies

Hey, I have reviewed all of them.

The following drivers were not broken, and your change does 100%
recursive epoch_enter:

bwi, ipw, iwi, iwm, iwn, ral, rtwn, wi, wpi

The following drivers use taskq and would be fixed by D23408:

bwn, malo, mwl, wtap

P.S. A funny note about wtap. You modified even a function that
is a dead code - wtap_rx_deliver(). Gives some clue on quality
of your sweep over all drivers.

-- 
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"


Re: svn commit: r357291 - in head/sys/dev: bwi bwn ipw iwi iwm iwn malo mwl ral rtwn/pci wi wpi wtap

2020-01-30 Thread Gleb Smirnoff
On Thu, Jan 30, 2020 at 10:28:01AM +, Hans Petter Selasky wrote:
H> Author: hselasky
H> Date: Thu Jan 30 10:28:01 2020
H> New Revision: 357291
H> URL: https://svnweb.freebsd.org/changeset/base/357291
H> 
H> Log:
H>   Widen EPOCH(9) usage in PCI WLAN drivers.
H>   
H>   Make sure all occurrences of ieee80211_input_xxx() in sys/dev are
H>   covered by a network epoch section. Do not depend on the interrupt
H>   handler nor any taskqueues being in a network epoch section.
H>   
H>   This patch should unbreak the PCI WLAN drivers after r357004.
H>   
H>   Pointy hat:glebius@
H>   Sponsored by:  Mellanox Technologies

Just looking at the very first driver in the patch - bwi.

Why do you call it "broken"? It doesn't need any "unbreaking after r357004".
Can you please show me a callgraph where epoch_enter you added to bwi_intr()
will not be unnecessary?

-- 
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"


Re: svn commit: r357233 - head/sys/net

2020-01-30 Thread Gleb Smirnoff
On Tue, Jan 28, 2020 at 10:44:25PM +, Kristof Provost wrote:
K> Author: kp
K> Date: Tue Jan 28 22:44:24 2020
K> New Revision: 357233
K> URL: https://svnweb.freebsd.org/changeset/base/357233
K> 
K> Log:
K>   epair: Do not abuse params to register the second interface
K>   
K>   if_epair used the 'params' argument to pass a pointer to the b interface
K>   through if_clone_create().
K>   This pointer can be controlled by userspace, which means it could be 
abused to
K>   trigger a panic. While this requires PRIV_NET_IFCREATE
K>   privileges those are assigned to vnet jails, which means that vnet jails
K>   could panic the system.
K>   
K>   Reported by:   Ilja Van Sprundel 
...
K> Modified: head/sys/net/if_clone.h
K> 
==
K> --- head/sys/net/if_clone.h  Tue Jan 28 21:46:59 2020(r357232)
K> +++ head/sys/net/if_clone.h  Tue Jan 28 22:44:24 2020(r357233)
K> @@ -79,7 +79,8 @@ intif_clone_list(struct if_clonereq *);
K>  struct if_clone *if_clone_findifc(struct ifnet *);
K>  voidif_clone_addgroup(struct ifnet *, struct if_clone *);
K>  
K> -/* The below interface used only by epair(4). */
K> +/* The below interfaces are used only by epair(4). */
K> +voidif_clone_addif(struct if_clone *, struct ifnet *);
K>  int if_clone_destroyif(struct if_clone *, struct ifnet *);

IMHO, makes sense to move all these declaration into if_epair.c itself.

-- 
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: r357279 - head/sys/kern

2020-01-29 Thread Gleb Smirnoff
Author: glebius
Date: Thu Jan 30 00:18:00 2020
New Revision: 357279
URL: https://svnweb.freebsd.org/changeset/base/357279

Log:
  Fix text format definition for kern.maxvnodes, vfs.wantfreevnodes.  This
  is a regression from r356642, r356645.

Modified:
  head/sys/kern/vfs_subr.c

Modified: head/sys/kern/vfs_subr.c
==
--- head/sys/kern/vfs_subr.cWed Jan 29 22:57:54 2020(r357278)
+++ head/sys/kern/vfs_subr.cThu Jan 30 00:18:00 2020(r357279)
@@ -360,7 +360,7 @@ sysctl_maxvnodes(SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC(_kern, KERN_MAXVNODES, maxvnodes,
 CTLTYPE_ULONG | CTLFLAG_MPSAFE | CTLFLAG_RW, NULL, 0, sysctl_maxvnodes,
-"UL", "Target for maximum number of vnodes");
+"LU", "Target for maximum number of vnodes");
 
 static int
 sysctl_wantfreevnodes(SYSCTL_HANDLER_ARGS)
@@ -384,7 +384,7 @@ sysctl_wantfreevnodes(SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC(_vfs, OID_AUTO, wantfreevnodes,
 CTLTYPE_ULONG | CTLFLAG_MPSAFE | CTLFLAG_RW, NULL, 0, 
sysctl_wantfreevnodes,
-"UL", "Target for minimum number of \"free\" vnodes");
+"LU", "Target for minimum number of \"free\" vnodes");
 
 SYSCTL_ULONG(_kern, OID_AUTO, minvnodes, CTLFLAG_RW,
 , 0, "Old name for vfs.wantfreevnodes (legacy)");
___
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: r357276 - head/sys/netinet

2020-01-29 Thread Gleb Smirnoff
Author: glebius
Date: Wed Jan 29 22:48:18 2020
New Revision: 357276
URL: https://svnweb.freebsd.org/changeset/base/357276

Log:
  Fix missing NET_EPOCH_ENTER() when compiled with TCP_OFFLOAD.
  
  Reported by:  Coverity
  CID:  1413162

Modified:
  head/sys/netinet/tcp_usrreq.c

Modified: head/sys/netinet/tcp_usrreq.c
==
--- head/sys/netinet/tcp_usrreq.c   Wed Jan 29 22:43:56 2020
(r357275)
+++ head/sys/netinet/tcp_usrreq.c   Wed Jan 29 22:48:18 2020
(r357276)
@@ -911,12 +911,12 @@ tcp_usr_rcvd(struct socket *so, int flags)
if (IS_FASTOPEN(tp->t_flags) &&
(tp->t_state == TCPS_SYN_RECEIVED))
goto out;
+   NET_EPOCH_ENTER(et);
 #ifdef TCP_OFFLOAD
if (tp->t_flags & TF_TOE)
tcp_offload_rcvd(tp);
else
 #endif
-   NET_EPOCH_ENTER(et);
tp->t_fb->tfb_tcp_output(tp);
NET_EPOCH_EXIT(et);
 out:
___
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: r357203 - head/sys/compat/linux

2020-01-28 Thread Gleb Smirnoff
On Tue, Jan 28, 2020 at 01:57:25PM +, Edward Tomasz Napierala wrote:
E> Author: trasz
E> Date: Tue Jan 28 13:57:24 2020
E> New Revision: 357203
E> URL: https://svnweb.freebsd.org/changeset/base/357203
E> 
E> Log:
E>   Add TCP_CORK support to linux(4).  This fixes one of the things Nginx
E>   trips over.
E>   
E>   MFC after: 2 weeks
E>   Sponsored by:  The FreeBSD Foundation
E>   Differential Revision: https://reviews.freebsd.org/D23171

Again, out of curiosity: what is any good reason to run linux nginx
binary on FreeBSD? To lose all the nice features of FreeBSD kernel
that nginx supports?

Don't read me as if I'm against adding TCP_CORK support to linux(4).

-- 
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"


Re: svn commit: r357051 - head/sys/dev/bge

2020-01-27 Thread Gleb Smirnoff
On Sun, Jan 26, 2020 at 09:48:42AM +, John Baldwin wrote:
J> > We also are concerned about that theoretically. Haven't yet seen effect
J> > in practice, but our sessions are mostly longer living. First we have the
J> > tunable to limit batching. Second, there are some ideas on how to improve
J> > the garbage collector performance if it becomes an issue.
J> 
J> There are other workloads than Netflix. ;)  Verisign has incredibly 
short-lived
J> connections with very high turnover.  I think though that they have already
J> abandoned the in-tree network stack for a userland stack built on netmap.  
Still,
J> I think that there are probably other FreeBSD users that are probably 
somewhere
J> in the middle that shouldn't be ignored.

I understand that.

First, my change doesn't create extra work for the garbage collector, but it
potentially may affect its burstiness. If a machine has very high connection
turnover it already may exhibit some problems with the PCB garbage collector
on 12.0-RELEASE. Have we observed this yet?

Note that PCBs are very different to other things protected by the network
epoch: address lists, interface lists, firewall rules, etc. They are short
lived.

We got several ideas on how to deal with this potential problem:

1) The current PCB destructor does lots of things like freeing and
   unrefcounting associated multicast options, credentials, etc. This
   is because it was converted to epoch with a principle of minimal
   diff in r335015. However, since all operations with a PCB happen
   under its individual lock, we can free it differently. We can mark
   it INP_FREED and do all the destruction immediately, leaving only
   actual free to the garbage collector.
   Once this is achieved, the garbage collection can be batched at
   level of UMA. Jeff is working on that.

2) Use separate epoch for PCBs, leaving the network epoch for long
   lived structures only. Don't hold the PCB epoch long.

3) Just don't use epoch for PCBs. Decompose the hash lock into per
   slot hash lock.

-- 
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"


Re: svn commit: r357004 - in head/sys: kern sys

2020-01-27 Thread Gleb Smirnoff
On Fri, Jan 24, 2020 at 12:23:33PM -0800, Cy Schubert wrote:
C> > Let not the network epoch become the new Giant of EPOCH's. There might 
C> > be realtime constraints for EPOCH's aswell.
C> 
C> I also had that concern yesterday.
C> 
C> Obtaining an EPOCH higher up the call stack or lower down depends on the 
C> workload. Are there any measurements that moving the EPOCHs higher in the 
C> call stack improves one workload (and configuration) or another? Could one 
C> type of workload or configuration benefit from this at the expense of 
C> another workload or configuration?

Can you imagine a workload where calling epoch_enter/exit more often but
for a shorter period of execution would be beneficial that calling it
once for a packet?

-- 
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"


Re: svn commit: r357004 - in head/sys: kern sys

2020-01-27 Thread Gleb Smirnoff
  Hans,

On Fri, Jan 24, 2020 at 08:21:54PM +0100, Hans Petter Selasky wrote:
H> > If a driver has interrupt moderation than epoch batching counter
H> > basically won't ever grow over 1. It kicks in only of driver doesn't
H> > have it, or receives interrupts at a very high rate.
H> 
H> Depending on the load an interrupt imposes, this batching counter may 
H> cause epochs to last for a long time. Have you considered using ticks 
H> for this instead? I.E. if the congestion lasts more than two ticks, then 
H> re-acquire the EPOCH?
H> 
H> For example if the network controller spends more time processing 
H> packets then there is between interrupts, then this unconditional 1000x 
H> thing can be quite dangerous.

I didn't try using ticks instead of execution counter. It could be ticks
would be better. Needs more experiments.

H> > H> 2) You need to make a new request function for interrupts which take a
H> > H> pointer to an EPOCH and replace that IH_NET in hflags!
H> > 
H> > Initially I did that way, but then pondered over this approach and have
H> > abandoned it.  Most likely we will have just few globally recognized
H> > epochs in the kernel. And even less might be associated with interrupt
H> > handlers. Complexity and performance impact of using a pointer are
H> > noted by Drew in D23347.
H> 
H> Let not the network epoch become the new Giant of EPOCH's. There might 
H> be realtime constraints for EPOCH's aswell.

Epoch isn't a lock, so it can't become the new Giant.

-- 
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: r357102 - head/sys/dev/mlx4/mlx4_en

2020-01-24 Thread Gleb Smirnoff
Author: glebius
Date: Sat Jan 25 00:06:18 2020
New Revision: 357102
URL: https://svnweb.freebsd.org/changeset/base/357102

Log:
  Enter the network epoch in RX processing taskqueue.

Modified:
  head/sys/dev/mlx4/mlx4_en/mlx4_en_rx.c

Modified: head/sys/dev/mlx4/mlx4_en/mlx4_en_rx.c
==
--- head/sys/dev/mlx4/mlx4_en/mlx4_en_rx.c  Fri Jan 24 22:50:23 2020
(r357101)
+++ head/sys/dev/mlx4/mlx4_en/mlx4_en_rx.c  Sat Jan 25 00:06:18 2020
(r357102)
@@ -895,6 +895,7 @@ void mlx4_en_rx_irq(struct mlx4_cq *mcq)
 
 void mlx4_en_rx_que(void *context, int pending)
 {
+   struct epoch_tracker et;
 struct mlx4_en_cq *cq;
struct thread *td;
 
@@ -905,8 +906,10 @@ void mlx4_en_rx_que(void *context, int pending)
sched_bind(td, cq->curr_poll_rx_cpu_id);
thread_unlock(td);
 
+   NET_EPOCH_ENTER(et);
 while (mlx4_en_poll_rx_cq(cq, MLX4_EN_RX_BUDGET)
 == MLX4_EN_RX_BUDGET);
+   NET_EPOCH_EXIT(et);
 mlx4_en_arm_cq(cq->dev->if_softc, cq);
 }
 
___
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: r357094 - head/sys/netinet/tcp_stacks

2020-01-24 Thread Gleb Smirnoff
Author: glebius
Date: Fri Jan 24 21:56:10 2020
New Revision: 357094
URL: https://svnweb.freebsd.org/changeset/base/357094

Log:
  Enter the network epoch when rack_output() is called in setsockopt(2).

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

Modified: head/sys/netinet/tcp_stacks/rack.c
==
--- head/sys/netinet/tcp_stacks/rack.c  Fri Jan 24 21:04:33 2020
(r357093)
+++ head/sys/netinet/tcp_stacks/rack.c  Fri Jan 24 21:56:10 2020
(r357094)
@@ -10093,6 +10093,7 @@ static int
 rack_set_sockopt(struct socket *so, struct sockopt *sopt,
 struct inpcb *inp, struct tcpcb *tp, struct tcp_rack *rack)
 {
+   struct epoch_tracker et;
int32_t error = 0, optval;
 
switch (sopt->sopt_name) {
@@ -10261,7 +10262,9 @@ rack_set_sockopt(struct socket *so, struct sockopt *so
if (tp->t_flags & TF_DELACK) {
tp->t_flags &= ~TF_DELACK;
tp->t_flags |= TF_ACKNOW;
+   NET_EPOCH_ENTER(et);
rack_output(tp);
+   NET_EPOCH_EXIT(et);
}
break;
case TCP_RACK_MIN_PACE:
___
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: r357093 - in head/sys/dev: otus rtwn/usb usb/wlan

2020-01-24 Thread Gleb Smirnoff
Author: glebius
Date: Fri Jan 24 21:04:33 2020
New Revision: 357093
URL: https://svnweb.freebsd.org/changeset/base/357093

Log:
  Enter the network epoch in USB WiFi drivers when processing input
  mbuf queues.
  
  Submitted by: Idwer Vollering 

Modified:
  head/sys/dev/otus/if_otus.c
  head/sys/dev/rtwn/usb/rtwn_usb_rx.c
  head/sys/dev/usb/wlan/if_rsu.c

Modified: head/sys/dev/otus/if_otus.c
==
--- head/sys/dev/otus/if_otus.c Fri Jan 24 20:35:41 2020(r357092)
+++ head/sys/dev/otus/if_otus.c Fri Jan 24 21:04:33 2020(r357093)
@@ -1770,6 +1770,7 @@ otus_rxeof(struct usb_xfer *xfer, struct otus_data *da
 static void
 otus_bulk_rx_callback(struct usb_xfer *xfer, usb_error_t error)
 {
+   struct epoch_tracker et;
struct otus_softc *sc = usbd_xfer_softc(xfer);
struct ieee80211com *ic = >sc_ic;
struct ieee80211_frame *wh;
@@ -1820,6 +1821,7 @@ tr_setup:
 * callback and safe to unlock.
 */
OTUS_UNLOCK(sc);
+   NET_EPOCH_ENTER(et);
while ((m = mbufq_dequeue()) != NULL) {
wh = mtod(m, struct ieee80211_frame *);
ni = ieee80211_find_rxnode(ic,
@@ -1832,6 +1834,7 @@ tr_setup:
} else
(void)ieee80211_input_mimo_all(ic, m);
}
+   NET_EPOCH_EXIT(et);
 #ifdef IEEE80211_SUPPORT_SUPERG
ieee80211_ff_age_all(ic, 100);
 #endif

Modified: head/sys/dev/rtwn/usb/rtwn_usb_rx.c
==
--- head/sys/dev/rtwn/usb/rtwn_usb_rx.c Fri Jan 24 20:35:41 2020
(r357092)
+++ head/sys/dev/rtwn/usb/rtwn_usb_rx.c Fri Jan 24 21:04:33 2020
(r357093)
@@ -363,6 +363,7 @@ rtwn_rx_frame(struct rtwn_softc *sc, struct mbuf *m)
 void
 rtwn_bulk_rx_callback(struct usb_xfer *xfer, usb_error_t error)
 {
+   struct epoch_tracker et;
struct rtwn_usb_softc *uc = usbd_xfer_softc(xfer);
struct rtwn_softc *sc = >uc_sc;
struct ieee80211com *ic = >sc_ic;
@@ -399,6 +400,7 @@ tr_setup:
 * ieee80211_input() because here is at the end of a USB
 * callback and safe to unlock.
 */
+   NET_EPOCH_ENTER(et);
while (m != NULL) {
next = m->m_nextpkt;
m->m_nextpkt = NULL;
@@ -416,6 +418,7 @@ tr_setup:
RTWN_LOCK(sc);
m = next;
}
+   NET_EPOCH_EXIT(et);
break;
default:
/* needs it to the inactive queue due to a error. */

Modified: head/sys/dev/usb/wlan/if_rsu.c
==
--- head/sys/dev/usb/wlan/if_rsu.c  Fri Jan 24 20:35:41 2020
(r357092)
+++ head/sys/dev/usb/wlan/if_rsu.c  Fri Jan 24 21:04:33 2020
(r357093)
@@ -2552,6 +2552,7 @@ rsu_rxeof(struct usb_xfer *xfer, struct rsu_data *data
 static void
 rsu_bulk_rx_callback(struct usb_xfer *xfer, usb_error_t error)
 {
+   struct epoch_tracker et;
struct rsu_softc *sc = usbd_xfer_softc(xfer);
struct ieee80211com *ic = >sc_ic;
struct ieee80211_node *ni;
@@ -2586,6 +2587,7 @@ tr_setup:
 * ieee80211_input() because here is at the end of a USB
 * callback and safe to unlock.
 */
+   NET_EPOCH_ENTER(et);
while (m != NULL) {
next = m->m_next;
m->m_next = NULL;
@@ -2604,6 +2606,7 @@ tr_setup:
RSU_LOCK(sc);
m = next;
}
+   NET_EPOCH_EXIT(et);
break;
default:
/* needs it to the inactive queue due to a error. */
___
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: r357075 - in head/sys: compat/linux kern sys

2020-01-24 Thread Gleb Smirnoff
On Fri, Jan 24, 2020 at 11:57:55AM +, Edward Tomasz Napierala wrote:
E> Author: trasz
E> Date: Fri Jan 24 11:57:55 2020
E> New Revision: 357075
E> URL: https://svnweb.freebsd.org/changeset/base/357075
E> 
E> Log:
E>   Add kern_unmount() and use in Linuxulator.  No functional changes.

Just out of curiosity: what Linux binaries that do unmount may
somebody run on FreeBSD for production or just for fun?


-- 
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: r357090 - head/sys/dev/re

2020-01-24 Thread Gleb Smirnoff
Author: glebius
Date: Fri Jan 24 17:24:02 2020
New Revision: 357090
URL: https://svnweb.freebsd.org/changeset/base/357090

Log:
  re(4) uses taskqueue to process input packets.  Enter network epoch
  in there.

Modified:
  head/sys/dev/re/if_re.c

Modified: head/sys/dev/re/if_re.c
==
--- head/sys/dev/re/if_re.c Fri Jan 24 17:15:31 2020(r357089)
+++ head/sys/dev/re/if_re.c Fri Jan 24 17:24:02 2020(r357090)
@@ -2576,6 +2576,7 @@ re_intr(void *arg)
 static void
 re_int_task(void *arg, int npending)
 {
+   struct epoch_trackeret;
struct rl_softc *sc;
struct ifnet*ifp;
u_int16_t   status;
@@ -2602,8 +2603,11 @@ re_int_task(void *arg, int npending)
}
 #endif
 
-   if (status & (RL_ISR_RX_OK|RL_ISR_RX_ERR|RL_ISR_FIFO_OFLOW))
+   if (status & (RL_ISR_RX_OK|RL_ISR_RX_ERR|RL_ISR_FIFO_OFLOW)) {
+   NET_EPOCH_ENTER(et);
rval = re_rxeof(sc, NULL);
+   NET_EPOCH_EXIT(et);
+   }
 
/*
 * Some chips will ignore a second TX request issued
___
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: r357088 - head/sys/dev/ath

2020-01-24 Thread Gleb Smirnoff
Author: glebius
Date: Fri Jan 24 17:11:54 2020
New Revision: 357088
URL: https://svnweb.freebsd.org/changeset/base/357088

Log:
  ath(4) processing input packets in taskqueue.  Enter network epoch
  before calling ieee80211_input_mimo().

Modified:
  head/sys/dev/ath/if_ath_rx.c

Modified: head/sys/dev/ath/if_ath_rx.c
==
--- head/sys/dev/ath/if_ath_rx.cFri Jan 24 17:10:21 2020
(r357087)
+++ head/sys/dev/ath/if_ath_rx.cFri Jan 24 17:11:54 2020
(r357088)
@@ -647,6 +647,7 @@ ath_rx_pkt(struct ath_softc *sc, struct ath_rx_status 
 uint64_t tsf, int nf, HAL_RX_QUEUE qtype, struct ath_buf *bf,
 struct mbuf *m)
 {
+   struct epoch_tracker et;
uint64_t rstamp;
/* XXX TODO: make this an mbuf tag? */
struct ieee80211_rx_stats rxs;
@@ -941,6 +942,7 @@ rx_accept:
rxs.c_nf_ext[i] = nf;
}
 
+   NET_EPOCH_ENTER(et);
if (ni != NULL) {
/*
 * Only punt packets for ampdu reorder processing for
@@ -986,6 +988,7 @@ rx_accept:
type = ieee80211_input_mimo_all(ic, m);
m = NULL;
}
+   NET_EPOCH_EXIT(et);
 
/*
 * At this point we have passed the frame up the stack; thus
___
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: r357004 - in head/sys: kern sys

2020-01-24 Thread Gleb Smirnoff
On Fri, Jan 24, 2020 at 10:24:53AM +0100, Hans Petter Selasky wrote:
H> What you want to do here is right, but how it is implemented is wrong, 
H> in my opinion.
H> 
H> 1) Remove intr_epoch_batch. Most network drivers use interrupt 
H> moderation, and a timeout of 1000 iterations can easily become 1 second 
H> under heavly load !

If a driver has interrupt moderation than epoch batching counter
basically won't ever grow over 1. It kicks in only of driver doesn't
have it, or receives interrupts at a very high rate.

H> 2) You need to make a new request function for interrupts which take a 
H> pointer to an EPOCH and replace that IH_NET in hflags!

Initially I did that way, but then pondered over this approach and have
abandoned it.  Most likely we will have just few globally recognized
epochs in the kernel. And even less might be associated with interrupt
handlers. Complexity and performance impact of using a pointer are
noted by Drew in D23347.

-- 
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"


Re: svn commit: r357051 - head/sys/dev/bge

2020-01-23 Thread Gleb Smirnoff
On Thu, Jan 23, 2020 at 06:18:15PM -1000, Jeff Roberson wrote:
J> > That was https://reviews.freebsd.org/D23242
J> 
J> Ok thank you.  Can you tag commits so people can see the discussion?  Was 
J> it in one I missed?  When I'm committing a long patch series I include the 
J> link in all of them.

I probably now on will also include in every patch in a serie. I just
dislike that first one (usually a preparation change) closes the review.

-- 
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"


Re: svn commit: r357051 - head/sys/dev/bge

2020-01-23 Thread Gleb Smirnoff
On Thu, Jan 23, 2020 at 05:09:14PM -1000, Jeff Roberson wrote:
J> While we don't have a policy strictly requiring reviews it is the norm to 
J> have substantial changes socialized and reviewed.  I appreciate the work 
J> that you are doing but it likely should've been discussed somewhere 
J> more publicly.  I apologized if I missed it but I don't see reference to 
J> anything.

That was https://reviews.freebsd.org/D23242

J> Architecturally I am more concerned with the coarseness of net_epoch and 
J> the duration of hold becoming a resource utilization problem in high 
J> turn-over workloads.  Like short connection tcp.  Has anyone done 
J> substantial testing here?  epoch as it is today will hold every free 
J> callback for a minimum of several clock ticks and a maximum of 2x the 
J> duration of the longest epoch section time.  With preemption, etc. this 
J> could be 100s of ms of PCBs held.

We also are concerned about that theoretically. Haven't yet seen effect
in practice, but our sessions are mostly longer living. First we have the
tunable to limit batching. Second, there are some ideas on how to improve
the garbage collector performance if it becomes an issue.

-- 
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"


Re: svn commit: r357051 - head/sys/dev/bge

2020-01-23 Thread Gleb Smirnoff
On Thu, Jan 23, 2020 at 08:33:58PM -0500, Ryan Stone wrote:
R> > Because at interrupt level we can batch multiple packets in a single epoch.
R> > This speeds up unfiltered packet forwarding performance by 5%.
R> >
R> > With driver level pfil hooks I would claim even more improvement, because 
before
R> > the change we needed to enter epoch twice - once for filtering, than for 
ether_input.
R> >
R> > Epoch isn't a layer, it is a synchronisation primitive, so I disagree about
R> > statement on layering violation.
R> 
R> Epoch is a synchronization primitive, but the net_epoch is absolutely
R> a part of the networking layer.  If we need better batching then the
R> correct solution is to introduce a batched interface for drivers to
R> push packets up the stack, not to mess around at the interrupt layer.

Such interface of course would be valuable but will not cover case
when an interrupt arrives during processing of previous one. So its
batching possiblities are limited compared to interrupt level batching.

And I already noted that ether_input() isn't the only way to enter
the network stack.

R> Note that the only reason why this works for mlx4/mlx5 is that
R> linuxkpi *always* requests a INTR_TYPE_NET no matter what driver is
R> running.  This means that all drm graphics driver interrupts are now
R> running under the net_epoch:
R> 
R> 
https://svnweb.freebsd.org/base/head/sys/compat/linuxkpi/common/include/linux/interrupt.h?revision=352205=markup#l103

Well, it is not my fault that a video driver requests INTR_TYPE_NET
interrupt. I mean, you can't put this as a rationale against using
network epoch for all interrrupts that declare theirselves as network
interrupts. However, this is harmless.

-- 
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"


Re: svn commit: r357051 - head/sys/dev/bge

2020-01-23 Thread Gleb Smirnoff
On Thu, Jan 23, 2020 at 08:17:46PM -0500, Ryan Stone wrote:
R> On Thu, Jan 23, 2020 at 6:05 PM Gleb Smirnoff  wrote:
R> >
R> > On Thu, Jan 23, 2020 at 02:17:33PM -0500, Ryan Stone wrote:
R> > R> What is a driver's responsibility now for entering/leaving the net 
epoch now?
R> >
R> > For drivers that are 'special', entering the net epoch is necessary. 
Special
R> > usually means running if_input outside network interrupt context.
R> >
R> > However, there is plan to generalize entering/exiting epoch for taskqueues
R> > and callouts.
R> 
R> Why on earth is it done that way rather than putting the network epoch
R> enter/exit in ether_input?  I'm with Ian; this sounds like a huge
R> layering violation.

Another thing I should have mentioned. Doing this at interrupt level
makes much easier to maintain alternative network stacks, for example
TOE - which now has tons of hacks. Same stands for netgraph. If you
hook ng_ether on, than ether_input is skipped and packet goes to
netgraph, then it can be injected back into network stack from a
different type of node.

-- 
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"


Re: svn commit: r357051 - head/sys/dev/bge

2020-01-23 Thread Gleb Smirnoff
On Thu, Jan 23, 2020 at 08:17:46PM -0500, Ryan Stone wrote:
R> On Thu, Jan 23, 2020 at 6:05 PM Gleb Smirnoff  wrote:
R> >
R> > On Thu, Jan 23, 2020 at 02:17:33PM -0500, Ryan Stone wrote:
R> > R> What is a driver's responsibility now for entering/leaving the net 
epoch now?
R> >
R> > For drivers that are 'special', entering the net epoch is necessary. 
Special
R> > usually means running if_input outside network interrupt context.
R> >
R> > However, there is plan to generalize entering/exiting epoch for taskqueues
R> > and callouts.
R> 
R> Why on earth is it done that way rather than putting the network epoch
R> enter/exit in ether_input?  I'm with Ian; this sounds like a huge
R> layering violation.

Because at interrupt level we can batch multiple packets in a single epoch.
This speeds up unfiltered packet forwarding performance by 5%.

With driver level pfil hooks I would claim even more improvement, because before
the change we needed to enter epoch twice - once for filtering, than for 
ether_input.

Epoch isn't a layer, it is a synchronisation primitive, so I disagree about
statement on layering violation.

-- 
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"


Re: svn commit: r357051 - head/sys/dev/bge

2020-01-23 Thread Gleb Smirnoff
On Thu, Jan 23, 2020 at 04:08:32PM -0700, Ian Lepore wrote:
I> On Thu, 2020-01-23 at 15:05 -0800, Gleb Smirnoff wrote:
I> > On Thu, Jan 23, 2020 at 02:17:33PM -0500, Ryan Stone wrote:
I> > R> What is a driver's responsibility now for entering/leaving the net 
epoch now?
I> > 
I> > For drivers that are 'special', entering the net epoch is necessary. 
Special
I> > usually means running if_input outside network interrupt context.
I> > 
I> > However, there is plan to generalize entering/exiting epoch for taskqueues
I> > and callouts.
I> > 
I> 
I> That sounds every bit as horrible and out-of-place as the recent hack
I> (and it does feel very much like a horrible hack) that put network-
I> specific code into the guts of interrupt dispatching.

It isn't really a network code. You just include  which
declares the epoch KPI and a few globally recognized epochs. For now
the only one is the network epoch. 

If you want to have for a example a disk epoch also supported
by interrupt code, that would add one extra declaration to epoch.h,
and again nothing really disk related.

-- 
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"


Re: svn commit: r357051 - head/sys/dev/bge

2020-01-23 Thread Gleb Smirnoff
On Thu, Jan 23, 2020 at 02:17:33PM -0500, Ryan Stone wrote:
R> What is a driver's responsibility now for entering/leaving the net epoch now?

For drivers that are 'special', entering the net epoch is necessary. Special
usually means running if_input outside network interrupt context.

However, there is plan to generalize entering/exiting epoch for taskqueues
and callouts.

-- 
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"


  1   2   3   4   5   6   7   8   9   10   >