Re: svn commit: r342197 - head/sys/dev/usb/net

2018-12-18 Thread Alexey Dokuchaev
On Tue, Dec 18, 2018 at 07:38:13PM +, Gleb Smirnoff wrote:
> New Revision: 342197
> URL: https://svnweb.freebsd.org/changeset/base/342197
> 
> Log:
>   Use mbufq instead of ifqueue to queue mbufs.
> 
> Modified:
>   head/sys/dev/usb/net/uhso.c

For the less aware folks reading through the code changes, it would be
nice if you'd explained the reason for this change, rather than simply
translated the diff in English.

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


svn commit: r342214 - in head/sys: conf dev/fxp modules/fxp

2018-12-18 Thread Mark Johnston
Author: markj
Date: Wed Dec 19 04:54:32 2018
New Revision: 342214
URL: https://svnweb.freebsd.org/changeset/base/342214

Log:
  Remove a use of a negative array index from fxp(4).
  
  This fixes a warning seen when compiling amd64 GENERIC with clang 7.
  Also remove the workaround added in r337324.  clang 7 and gcc 4.2
  generate the same code with or without the code change.
  
  Reviewed by:  imp (previous version)
  MFC after:3 days
  Differential Revision:https://reviews.freebsd.org/D18603

Modified:
  head/sys/conf/files
  head/sys/conf/kern.mk
  head/sys/dev/fxp/if_fxp.c
  head/sys/dev/fxp/if_fxpreg.h
  head/sys/modules/fxp/Makefile

Modified: head/sys/conf/files
==
--- head/sys/conf/files Wed Dec 19 03:23:23 2018(r342213)
+++ head/sys/conf/files Wed Dec 19 04:54:32 2018(r342214)
@@ -1782,8 +1782,7 @@ dev/flash/cqspi.c optional cqspi fdt xdma
 dev/flash/mx25l.c  optional mx25l
 dev/flash/n25q.c   optional n25q fdt
 dev/flash/qspi_if.moptional cqspi fdt | n25q fdt
-dev/fxp/if_fxp.c   optional fxp \
-   compile-with "${NORMAL_C} ${NO_WARRAY_BOUNDS}"
+dev/fxp/if_fxp.c   optional fxp
 dev/fxp/inphy.coptional fxp
 dev/gem/if_gem.c   optional gem
 dev/gem/if_gem_pci.c   optional gem pci

Modified: head/sys/conf/kern.mk
==
--- head/sys/conf/kern.mk   Wed Dec 19 03:23:23 2018(r342213)
+++ head/sys/conf/kern.mk   Wed Dec 19 04:54:32 2018(r342214)
@@ -25,7 +25,6 @@ NO_WUNNEEDED_INTERNAL_DECL=   -Wno-error-unneeded-intern
 NO_WSOMETIMES_UNINITIALIZED=   -Wno-error-sometimes-uninitialized
 NO_WCAST_QUAL= -Wno-error-cast-qual
 NO_WTAUTOLOGICAL_POINTER_COMPARE= -Wno-tautological-pointer-compare
-NO_WARRAY_BOUNDS=  -Wno-error-array-bounds
 # Several other warnings which might be useful in some cases, but not severe
 # enough to error out the whole kernel build.  Display them anyway, so there is
 # some incentive to fix them eventually.

Modified: head/sys/dev/fxp/if_fxp.c
==
--- head/sys/dev/fxp/if_fxp.c   Wed Dec 19 03:23:23 2018(r342213)
+++ head/sys/dev/fxp/if_fxp.c   Wed Dec 19 04:54:32 2018(r342214)
@@ -1627,7 +1627,7 @@ fxp_encap(struct fxp_softc *sc, struct mbuf **m_head)
cbp->tbd_number = nseg;
/* Configure TSO. */
if (m->m_pkthdr.csum_flags & CSUM_TSO) {
-   cbp->tbd[-1].tb_size = htole32(m->m_pkthdr.tso_segsz << 16);
+   cbp->tbdtso.tb_size = htole32(m->m_pkthdr.tso_segsz << 16);
cbp->tbd[1].tb_size |= htole32(tcp_payload << 16);
cbp->ipcb_ip_schedule |= FXP_IPCB_LARGESEND_ENABLE |
FXP_IPCB_IP_CHECKSUM_ENABLE |

Modified: head/sys/dev/fxp/if_fxpreg.h
==
--- head/sys/dev/fxp/if_fxpreg.hWed Dec 19 03:23:23 2018
(r342213)
+++ head/sys/dev/fxp/if_fxpreg.hWed Dec 19 04:54:32 2018
(r342214)
@@ -281,10 +281,15 @@ struct fxp_cb_tx {
uint16_t cb_status;
uint16_t cb_command;
uint32_t link_addr;
-   uint32_t tbd_array_addr;
-   uint16_t byte_count;
-   uint8_t tx_threshold;
-   uint8_t tbd_number;
+   union {
+   struct {
+   uint32_t tbd_array_addr;
+   uint16_t byte_count;
+   uint8_t tx_threshold;
+   uint8_t tbd_number;
+   };
+   struct fxp_tbd tbdtso;
+   };
 
/*
 * The following structure isn't actually part of the TxCB,

Modified: head/sys/modules/fxp/Makefile
==
--- head/sys/modules/fxp/Makefile   Wed Dec 19 03:23:23 2018
(r342213)
+++ head/sys/modules/fxp/Makefile   Wed Dec 19 04:54:32 2018
(r342214)
@@ -6,5 +6,3 @@ KMOD=   if_fxp
 SRCS=  device_if.h bus_if.h if_fxp.c inphy.c miibus_if.h miidevs.h pci_if.h
 
 .include 
-
-CWARNFLAGS+=   ${NO_WARRAY_BOUNDS}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r342211 - head/sys/net80211

2018-12-18 Thread Andriy Voskoboinyk
Author: avos
Date: Wed Dec 19 03:08:10 2018
New Revision: 342211
URL: https://svnweb.freebsd.org/changeset/base/342211

Log:
  net80211: fix out-of-bounds read in ieee80211_amrr(9).
  
  ieee80211_alloc_node() does not initialize rateset tables; that's not
  expected by rate control modules and will result in array access at
  index -1 - where ni_essid[] array is located (zeroed at allocation, so
  there are no user-visible consequences).
  
  Just delay rate control initialization to the moment, when rateset
  tables are initiaziled; nothing will use rates here anyway.
  
  MFC after:4 days

Modified:
  head/sys/net80211/ieee80211_node.c

Modified: head/sys/net80211/ieee80211_node.c
==
--- head/sys/net80211/ieee80211_node.c  Wed Dec 19 02:34:31 2018
(r342210)
+++ head/sys/net80211/ieee80211_node.c  Wed Dec 19 03:08:10 2018
(r342211)
@@ -1417,8 +1417,6 @@ ieee80211_alloc_node(struct ieee80211_node_table *nt,
IEEE80211_NOTE(vap, IEEE80211_MSG_INACT, ni,
"%s: inact_reload %u", __func__, ni->ni_inact_reload);
 
-   ieee80211_ratectl_node_init(ni);
-
return ni;
 }
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r342208 - head/sys/dev/cxgbe/tom

2018-12-18 Thread Navdeep Parhar
Author: np
Date: Wed Dec 19 01:37:00 2018
New Revision: 342208
URL: https://svnweb.freebsd.org/changeset/base/342208

Log:
  cxgbe/t4_tom: fixes for issues on the passive open side.
  
  - Fix PR 227760 by getting the TOE to respond to the SYN after the call
to toe_syncache_add, not during it.  The kernel syncache code calls
syncache_respond just before syncache_insert.  If the ACK to the
syncache_respond is processed in another thread it may run before the
syncache_insert and won't find the entry.  Note that this affects only
t4_tom because it's the only driver trying to insert and expand
syncache entries from different threads.
  
  - Do not leak resources if an embryonic connection terminates at
SYN_RCVD because of L2 lookup failures.
  
  - Retire lctx->synq and associated code because there is never a need to
walk the list of embryonic connections associated with a listener.
The per-tid state is still called a synq entry in the driver even
though the synq itself is now gone.
  
  PR:   227760
  MFC after:2 weeks
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/tom/t4_connect.c
  head/sys/dev/cxgbe/tom/t4_cpl_io.c
  head/sys/dev/cxgbe/tom/t4_listen.c
  head/sys/dev/cxgbe/tom/t4_tom.c
  head/sys/dev/cxgbe/tom/t4_tom.h

Modified: head/sys/dev/cxgbe/tom/t4_connect.c
==
--- head/sys/dev/cxgbe/tom/t4_connect.c Wed Dec 19 00:17:22 2018
(r342207)
+++ head/sys/dev/cxgbe/tom/t4_connect.c Wed Dec 19 01:37:00 2018
(r342208)
@@ -99,7 +99,8 @@ do_act_establish(struct sge_iq *iq, const struct rss_h
goto done;
}
 
-   make_established(toep, cpl->snd_isn, cpl->rcv_isn, cpl->tcp_opt);
+   make_established(toep, be32toh(cpl->snd_isn) - 1,
+   be32toh(cpl->rcv_isn) - 1, cpl->tcp_opt);
 
if (toep->ulp_mode == ULP_MODE_TLS)
tls_establish(toep);

Modified: head/sys/dev/cxgbe/tom/t4_cpl_io.c
==
--- head/sys/dev/cxgbe/tom/t4_cpl_io.c  Wed Dec 19 00:17:22 2018
(r342207)
+++ head/sys/dev/cxgbe/tom/t4_cpl_io.c  Wed Dec 19 01:37:00 2018
(r342208)
@@ -373,18 +373,15 @@ assign_rxopt(struct tcpcb *tp, unsigned int opt)
  * Completes some final bits of initialization for just established connections
  * and changes their state to TCPS_ESTABLISHED.
  *
- * The ISNs are from after the exchange of SYNs.  i.e., the true ISN + 1.
+ * The ISNs are from the exchange of SYNs.
  */
 void
-make_established(struct toepcb *toep, uint32_t snd_isn, uint32_t rcv_isn,
-uint16_t opt)
+make_established(struct toepcb *toep, uint32_t iss, uint32_t irs, uint16_t opt)
 {
struct inpcb *inp = toep->inp;
struct socket *so = inp->inp_socket;
struct tcpcb *tp = intotcpcb(inp);
long bufsize;
-   uint32_t iss = be32toh(snd_isn) - 1;/* true ISS */
-   uint32_t irs = be32toh(rcv_isn) - 1;/* true IRS */
uint16_t tcpopt = be16toh(opt);
struct flowc_tx_params ftxp;
 
@@ -1245,22 +1242,12 @@ do_peer_close(struct sge_iq *iq, const struct rss_head
KASSERT(m == NULL, ("%s: wasn't expecting payload", __func__));
 
if (__predict_false(toep->flags & TPF_SYNQE)) {
-#ifdef INVARIANTS
-   struct synq_entry *synqe = (void *)toep;
-
-   INP_WLOCK(synqe->lctx->inp);
-   if (synqe->flags & TPF_SYNQE_HAS_L2TE) {
-   KASSERT(synqe->flags & TPF_ABORT_SHUTDOWN,
-   ("%s: listen socket closed but tid %u not aborted.",
-   __func__, tid));
-   } else {
-   /*
-* do_pass_accept_req is still running and will
-* eventually take care of this tid.
-*/
-   }
-   INP_WUNLOCK(synqe->lctx->inp);
-#endif
+   /*
+* do_pass_establish must have run before do_peer_close and if
+* this is still a synqe instead of a toepcb then the connection
+* must be getting aborted.
+*/
+   MPASS(toep->flags & TPF_ABORT_SHUTDOWN);
CTR4(KTR_CXGBE, "%s: tid %u, synqe %p (0x%x)", __func__, tid,
toep, toep->flags);
return (0);
@@ -1568,22 +1555,12 @@ do_rx_data(struct sge_iq *iq, const struct rss_header 
uint32_t ddp_placed = 0;
 
if (__predict_false(toep->flags & TPF_SYNQE)) {
-#ifdef INVARIANTS
-   struct synq_entry *synqe = (void *)toep;
-
-   INP_WLOCK(synqe->lctx->inp);
-   if (synqe->flags & TPF_SYNQE_HAS_L2TE) {
-   KASSERT(synqe->flags & TPF_ABORT_SHUTDOWN,
-   ("%s: listen socket closed but tid %u not aborted.",
-   __func__, 

svn commit: r342207 - head/sys/kern

2018-12-18 Thread Mark Johnston
Author: markj
Date: Wed Dec 19 00:17:22 2018
New Revision: 342207
URL: https://svnweb.freebsd.org/changeset/base/342207

Log:
  Fix DDB's "show malloc" after r338899.
  
  MFC after:3 days
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/kern/kern_malloc.c

Modified: head/sys/kern/kern_malloc.c
==
--- head/sys/kern/kern_malloc.c Tue Dec 18 23:22:37 2018(r342206)
+++ head/sys/kern/kern_malloc.c Wed Dec 19 00:17:22 2018(r342207)
@@ -1205,7 +1205,7 @@ restart:
 DB_SHOW_COMMAND(malloc, db_show_malloc)
 {
struct malloc_type_internal *mtip;
-   struct malloc_type_internal *mtsp;
+   struct malloc_type_stats *mtsp;
struct malloc_type *mtp;
uint64_t allocs, frees;
uint64_t alloced, freed;
@@ -1221,10 +1221,10 @@ DB_SHOW_COMMAND(malloc, db_show_malloc)
freed = 0;
for (i = 0; i <= mp_maxid; i++) {
mtsp = zpcpu_get_cpu(mtip->mti_stats, i);
-   allocs += mtip->mti_stats[i].mts_numallocs;
-   frees += mtip->mti_stats[i].mts_numfrees;
-   alloced += mtip->mti_stats[i].mts_memalloced;
-   freed += mtip->mti_stats[i].mts_memfreed;
+   allocs += mtsp->mts_numallocs;
+   frees += mtsp->mts_numfrees;
+   alloced += mtsp->mts_memalloced;
+   freed += mtsp->mts_memfreed;
}
db_printf("%18s %12ju %12juK %12ju\n",
mtp->ks_shortdesc, allocs - frees,
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r342204 - head/share/man/man4

2018-12-18 Thread Andriy Gapon
Author: avg
Date: Tue Dec 18 21:43:33 2018
New Revision: 342204
URL: https://svnweb.freebsd.org/changeset/base/342204

Log:
  cyapa.4, isl.4: cross-reference and document use of chromebook_platform(4)
  
  PR:   218632
  Reported by:  Denis Kozadaev 
  MFC after:1 week

Modified:
  head/share/man/man4/cyapa.4
  head/share/man/man4/isl.4

Modified: head/share/man/man4/cyapa.4
==
--- head/share/man/man4/cyapa.4 Tue Dec 18 21:01:48 2018(r342203)
+++ head/share/man/man4/cyapa.4 Tue Dec 18 21:43:33 2018(r342204)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd October 03, 2016
+.Dd December 18, 2018
 .Dt CYAPA 4
 .Os
 .Sh NAME
@@ -46,7 +46,13 @@ cyapa_load="YES"
 ig4_load="YES"
 .Ed
 .Pp
-In
+On many Chromebook models this driver can be automatically configured with the
+help of the
+.Xr chromebook_platform 4
+driver.
+Alternatively, the
+.Nm
+driver can be manually configured in
 .Pa /boot/device.hints :
 .Cd hint.cyapa.0.at="iicbus0"
 .Cd hint.cyapa.0.addr="0xCE"
@@ -195,6 +201,7 @@ file:
 .Dl debug.cyapa_thumbarea_percent=0
 .Dl debug.cyapa_enable_tapclick=2
 .Sh SEE ALSO
+.Xr chromebook_platform 4 ,
 .Xr ig4 4 ,
 .Xr iicbus 4 ,
 .Xr sysmouse 4 ,

Modified: head/share/man/man4/isl.4
==
--- head/share/man/man4/isl.4   Tue Dec 18 21:01:48 2018(r342203)
+++ head/share/man/man4/isl.4   Tue Dec 18 21:43:33 2018(r342204)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd October 03, 2016
+.Dd December 18, 2018
 .Dt ISL 4
 .Os
 .Sh NAME
@@ -46,7 +46,13 @@ isl_load="YES"
 ig4_load="YES"
 .Ed
 .Pp
-In
+On many Chromebook models this driver can be automatically configured with the
+help of the
+.Xr chromebook_platform 4
+driver.
+Alternatively, the
+.Nm
+driver can be manually configured in
 .Pa /boot/device.hints :
 .Cd hint.isl.0.at="iicbus0"
 .Cd hint.isl.0.addr="0x88"
@@ -106,6 +112,7 @@ $ pkg install intel-backlight
 $ sh /usr/local/share/examples/intel-backlight/isl_backlight.sh
 .Ed
 .Sh SEE ALSO
+.Xr chromebook_platform 4 ,
 .Xr ig4 4 ,
 .Xr iicbus 4
 .Sh AUTHORS
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r342197 - head/sys/dev/usb/net

2018-12-18 Thread Gleb Smirnoff
Author: glebius
Date: Tue Dec 18 19:38:13 2018
New Revision: 342197
URL: https://svnweb.freebsd.org/changeset/base/342197

Log:
  Use mbufq instead of ifqueue to queue mbufs.

Modified:
  head/sys/dev/usb/net/uhso.c

Modified: head/sys/dev/usb/net/uhso.c
==
--- head/sys/dev/usb/net/uhso.c Tue Dec 18 19:05:57 2018(r342196)
+++ head/sys/dev/usb/net/uhso.c Tue Dec 18 19:38:13 2018(r342197)
@@ -98,7 +98,7 @@ struct uhso_softc {
struct ifnet*sc_ifp;
struct mbuf *sc_mwait;  /* Partial packet */
size_t  sc_waitlen; /* No. of outstanding bytes */
-   struct ifqueue  sc_rxq;
+   struct mbufqsc_rxq;
struct callout  sc_c;
 
/* TTY related structures */
@@ -560,6 +560,7 @@ uhso_attach(device_t self)
sc->sc_dev = self;
sc->sc_udev = uaa->device;
mtx_init(>sc_mtx, "uhso", NULL, MTX_DEF);
+   mbufq_init(>sc_rxq, INT_MAX);   /* XXXGL: sane maximum */
ucom_ref(>sc_super_ucom);
 
sc->sc_radio = 1;
@@ -1626,11 +1627,13 @@ uhso_ifnet_read_callback(struct usb_xfer *xfer, usb_er
case USB_ST_TRANSFERRED:
if (actlen > 0 && (sc->sc_ifp->if_drv_flags & IFF_DRV_RUNNING)) 
{
pc = usbd_xfer_get_frame(xfer, 0);
+   if (mbufq_full(>sc_rxq))
+   break;
m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
usbd_copy_out(pc, 0, mtod(m, uint8_t *), actlen);
m->m_pkthdr.len = m->m_len = actlen;
/* Enqueue frame for further processing */
-   _IF_ENQUEUE(>sc_rxq, m);
+   mbufq_enqueue(>sc_rxq, m);
if (!callout_pending(>sc_c) ||
!callout_active(>sc_c)) {
callout_schedule(>sc_c, 1);
@@ -1676,8 +1679,7 @@ uhso_if_rxflush(void *arg)
mwait = sc->sc_mwait;
for (;;) {
if (m == NULL) {
-   _IF_DEQUEUE(>sc_rxq, m);
-   if (m == NULL)
+   if ((m = mbufq_dequeue(>sc_rxq)) == NULL)
break;
UHSO_DPRINTF(3, "dequeue m=%p, len=%d\n", m, m->m_len);
}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r342196 - head

2018-12-18 Thread Warner Losh
Author: imp
Date: Tue Dec 18 19:05:57 2018
New Revision: 342196
URL: https://svnweb.freebsd.org/changeset/base/342196

Log:
  Fix typo and formatting...

Modified:
  head/MAINTAINERS

Modified: head/MAINTAINERS
==
--- head/MAINTAINERSTue Dec 18 18:52:12 2018(r342195)
+++ head/MAINTAINERSTue Dec 18 19:05:57 2018(r342196)
@@ -110,7 +110,7 @@ iscsi(4)trasz   Pre-commit review recommended.
 rctl(8)trasz   Pre-commit review recommended.
 sys/dev/ofwnwhitehorn  Pre-commit review recommended.
 sys/dev/drm*   imp Pre-commit review requested in phabricator. Changes 
need to
-   be mirrored in gitub repo.
+   be mirrored in github repo.
 sys/dev/usb/wlan adrianPre-commit review requested, send to 
freebsd-wirel...@freebsd.org
 sys/arm/allwinner  manuPre-commit review requested
 sys/arm64/rockchip manuPre-commit review requested
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r342195 - head

2018-12-18 Thread Warner Losh
Author: imp
Date: Tue Dec 18 18:52:12 2018
New Revision: 342195
URL: https://svnweb.freebsd.org/changeset/base/342195

Log:
  add pre-commit review request for drm*.
  Move dev/usb/wlan to sys/dev/usb/wlan as it was the odd-man-out.

Modified:
  head/MAINTAINERS

Modified: head/MAINTAINERS
==
--- head/MAINTAINERSTue Dec 18 17:31:31 2018(r342194)
+++ head/MAINTAINERSTue Dec 18 18:52:12 2018(r342195)
@@ -44,7 +44,6 @@ contrib/llvm  dim Pre-commit review preferred.
 contrib/llvm/tools/lldbemaste  Pre-commit review preferred.
 contrib/netbsd-tests   freebsd-testing,ngiePre-commit review requested.
 contrib/pjdfstest  freebsd-testing,asomers,ngie,pjdPre-commit 
review requested.
-dev/usb/wlan   adrian  Pre-commit review requested, send to 
freebsd-wirel...@freebsd.org
 *env(3)secteam Due to the problematic security history of this
code, please have patches reviewed by secteam.
 etc/mail   gshapiroPre-commit review requested.  Keep in sync with 
-STABLE.
@@ -110,5 +109,8 @@ autofs(5)   trasz   Pre-commit review recommended.
 iscsi(4)   trasz   Pre-commit review recommended.
 rctl(8)trasz   Pre-commit review recommended.
 sys/dev/ofwnwhitehorn  Pre-commit review recommended.
+sys/dev/drm*   imp Pre-commit review requested in phabricator. Changes 
need to
+   be mirrored in gitub repo.
+sys/dev/usb/wlan adrianPre-commit review requested, send to 
freebsd-wirel...@freebsd.org
 sys/arm/allwinner  manuPre-commit review requested
 sys/arm64/rockchip manuPre-commit review requested
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r341578 - head/sys/dev/mlx5/mlx5_en

2018-12-18 Thread Bruce Evans

On Wed, 19 Dec 2018, Bruce Evans wrote:


On Mon, 17 Dec 2018, Andrew Gallatin wrote:


On 12/17/18 2:08 PM, Bruce Evans wrote:

* ...

iflib uses queuing techniques to significantly pessimize em NICs with 1
hardware queue.?? On fast machines, it attempts to do 1 context switch per

...

This can happen even w/o contention when "abdicate" is enabled in mp
ring. I complained about this as well, and the default was changed in
mp ring to not always "abdicate" (eg, switch to the tq to handle the
packet). Abdication substantially pessimizes Netflix style web uncontended 
workloads, but it generally helps small packet forwarding.


It is interesting that you see the opposite.  I should try benchmarking
with just a single ring.


Hmm, I didn't remember "abdicated" and never knew about the sysctl for it
(the sysctl is newer), but I notices the slowdown from near the first
commit for it (r323954) and already used the folowing workaround for it:
...
This essentialy just adds back the previous code with a flag to check
both versions.  Hopefully the sysctl can do the same thing.


It doesn't.  Setting tx_abdicate to 1 gives even more context switches (almost
twice as many, 800k/sec instead of 400k/sec, on i386 pessimized by
INVARIANTS, WITNESS, !WITNESS_SKIPSPIN, 4G KVA and more.  Without
pessimizations it does 1M/sec instea of 400k/sec).  The behaviour is easy
to understand by watchomg top -SH -m io with netblast bound to the same
CPU as the main tgq.  Then netblast does involuntary context switches at
the same rate that the tgq does voluntary context switches, and tx_abdicate=1
doubles this rare.  netblast only switches at the quantum rate (11 per second)
when not bound (I think it does null switches and it is a bug to count these
as switches, but even null switches do too much).

This is also without my usual default of !PREEMPTION && !IPI_PREEMPTION.
Binding the netblast to the same CPU as the tgq only stops the excessive
context switches wihen !PREEMPTION.  My hack might depend on this too.
Unfortunately, the hack is not in the same kernels as the sysctl, and I
already have too many combinations to test.

Another test with only 4G KVA (no INVARIANTS, etc., no PREEMPTION):
tx_abdicate=0: tgq switch rate  997-1017k/sec (16k/sec if netblast bound)
tx_abdicate=1: tgq switch rate 1300-1350k/sec (16k/sec if netblast bound)

Another test on amd64 to escape i386 4G KVA pessimizations:
tx_abdicate=0: tgq switch rate 1110-1220k/sec (16k/sec if netblast bound)
tx_abdicate=1: tgq switch rate 1360-1430k/sec (16k/sec if netblast bound)

When netblast is bound to the tgq's CPU, the tgq actually runs on another
CPU.  Apparently, the binding is weak ot this is a bugfeature in my scheduler.

When tx_abdicate=1, the switch rate is close to the packet rate.  Since the
NIC can't keep up, most packets are dropped.  On amd64 with tx_abdicate=1,
the packet rates are:

netblast bound:   313kpps sent, 1604kpps dropped
netblast unbound: 253kpps sent, 1153kpps dropped

253kpps sent is bad.  This indicates large latencies (not due to !PREEMPTION
or secheduler bugs AFAIK).  Most tests with netblast unbound seemed to saturate
the NIC at 280kpps (but the tests with netblast bound shows that the NIC can
go a little faster).  Even an old 2GHz CPU can reach 280kpps.

This shows another problem with taskqueues.  It takes context switches just
to decide to drop packets.  Previous versions of iflib were much slower at
dropping packets.  Some had rates closer to the low send rate than the 1604kpps
achieved above.  FreeBSD-5 running on a single 3 times slower CPU can drop
packets at 2124kpps, mainly by dropping them in ip_output() after peeking at
the software ifqs to see that there is no space.  IFF_MONITOR gives better
tests of the syscall overhead.

Another test with amd64 and I218V instead of PRO1000:

netblast bound, !abdicate:   1243kpps sent,   0kpps dropped  (16k/sec csw)
netblast unbound, !abdicate: 1236kpps sent,   0kpps dropped  (16k/sec csw)
netblast bound, abdicate:1485kpps sent, 243kpps dropped  (16k/sec csw)
netblast unbound, abdicate:  1407kpps sent, 1.7kpps dropped (850k/sec csw)

There is an i386 dependency after all!  !abdicate works on amd64 but not
on i386 to prevent the excessive context switches.  Unfortunately, it also
reduces kpps by almost 20% and leaves no spare CPU for dropping packets.

The best case of netblast bound, abdicate is competitive with FreeBSD-11
on i386 with EM_MULTIQUEUE: above result repeated:

netblast bound, abdicate:1485kpps sent, 243kpps dropped  (16k/sec csw)

previous best result:

FBSD-11 SMP-8 1486+241 # no iflib, use EM_MULTIQUEUE (now saturate 1Gbps)

(this is without PREEMPTION* and without binding netblast).

The above for -current also has the lowest possible CPU use (100% of 1 CPU
for all threads, while netblast unbound takes 100% of 1 CPU for netblast and
60% of another CPU for tgq), and I think the FBSD=11 case takes 100% of 1
CPU for netblast unbound and a tiny% of another CPU 

svn commit: r342193 - head/sys/dev/ichwd

2018-12-18 Thread Andriy Gapon
Author: avg
Date: Tue Dec 18 17:17:53 2018
New Revision: 342193
URL: https://svnweb.freebsd.org/changeset/base/342193

Log:
  ichwd: add a few assertions about tco_version
  
  Those should ensure correctness of ichwd_find_ich_lpc_bridge() and
  ichwd_find_ich_lpc_bridge() as well as make it easier for both humans
  and static analyzers to see the relation between tco_version and ich and
  smb variables in ichwd_identify().
  
  Reported by:  Coverity
  CID:  1396314, 1396317
  MFC after:10 days

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

Modified: head/sys/dev/ichwd/ichwd.c
==
--- head/sys/dev/ichwd/ichwd.c  Tue Dec 18 16:47:03 2018(r342192)
+++ head/sys/dev/ichwd/ichwd.c  Tue Dec 18 17:17:53 2018(r342193)
@@ -635,6 +635,13 @@ ichwd_identify(driver_t *driver, device_t parent)
return;
}
 
+   KASSERT(id_p->tco_version >= 1,
+   ("unexpected TCO version %d", id_p->tco_version));
+   KASSERT(id_p->tco_version != 4 || smb != NULL,
+   ("could not find PCI SMBus device for TCOv4"));
+   KASSERT(id_p->tco_version >= 4 || ich != NULL,
+   ("could not find PCI LPC bridge device for TCOv1-3"));
+
/* good, add child to bus */
if ((dev = device_find_child(parent, driver->name, 0)) == NULL)
dev = BUS_ADD_CHILD(parent, 0, driver->name, 0);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r342192 - head/sbin/ping

2018-12-18 Thread Mark Johnston
Author: markj
Date: Tue Dec 18 16:47:03 2018
New Revision: 342192
URL: https://svnweb.freebsd.org/changeset/base/342192

Log:
  Use caph_enter_casper() in ping(8).
  
  Reported by:  oshogbo
  MFC with: r341837
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sbin/ping/ping.c

Modified: head/sbin/ping/ping.c
==
--- head/sbin/ping/ping.c   Tue Dec 18 14:39:29 2018(r342191)
+++ head/sbin/ping/ping.c   Tue Dec 18 16:47:03 2018(r342192)
@@ -708,7 +708,7 @@ main(int argc, char *const *argv)
 * We must connect(2) our socket before this point.
 */
caph_cache_catpages();
-   if (caph_enter() < 0)
+   if (caph_enter_casper() < 0)
err(1, "cap_enter");
 
cap_rights_init(, CAP_RECV, CAP_EVENT, CAP_SETSOCKOPT);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r341578 - head/sys/dev/mlx5/mlx5_en

2018-12-18 Thread Bruce Evans

On Mon, 17 Dec 2018, Andrew Gallatin wrote:


On 12/17/18 2:08 PM, Bruce Evans wrote:

On Mon, 17 Dec 2018, Andrew Gallatin wrote:


On 12/5/18 9:20 AM, Slava Shwartsman wrote:

Author: slavash
Date: Wed Dec?? 5 14:20:57 2018
New Revision: 341578
URL: 
https://urldefense.proofpoint.com/v2/url?u=https-3A__svnweb.freebsd.org_changeset_base_341578=DwIDaQ=imBPVzF25OnBgGmVOlcsiEgHoG1i6YHLR0Sj_gZ4adc=Ed-falealxPeqc22ehgAUCLh8zlZbibZLSMWJeZro4A=BFp2c_-S0jnzRZJF2APwvTwmnmVFcyjcnBvHRZ3Locc=b7fvhOzf_b5bMVGquu4SaBhMNql5N8dVPAvpfKtz53Q= 


Log:
 mlx5en: Remove the DRBR and associated logic in the transmit path.
?? The hardware queues are deep enough currently and using the 
DRBR and associated
 callbacks only leads to more task switching in the TX path. The is 
also a race

 setting the queue_state which can lead to hung TX rings.


The point of DRBR in the tx path is not simply to provide a software ring 
for queuing excess packets.?? Rather it provides a mechanism to

avoid lock contention by shoving a packet into the software ring, where
it will later be found & processed, rather than blocking the caller on
a mtx lock. I'm concerned you may have introduced a performance
regression for use cases where you have N:1?? or N:M lock contention where 
many threads on different cores are contending for the same tx queue.?? 
The state of the art for this is no longer DRBR, but mp_ring,

as used by both cxgbe and iflib.


iflib uses queuing techniques to significantly pessimize em NICs with 1
hardware queue.?? On fast machines, it attempts to do 1 context switch per


Bruce Evans didn't write that.  Some mail program converted 2-space sentence
breaks to \xc2\xa0.


This can happen even w/o contention when "abdicate" is enabled in mp
ring. I complained about this as well, and the default was changed in
mp ring to not always "abdicate" (eg, switch to the tq to handle the
packet). Abdication substantially pessimizes Netflix style web uncontended 
workloads, but it generally helps small packet forwarding.


It is interesting that you see the opposite.  I should try benchmarking
with just a single ring.


Hmm, I didn't remember "abdicated" and never knew about the sysctl for it
(the sysctl is newer), but I notices the slowdown from near the first
commit for it (r323954) and already used the folowing workaround for it:

XX Index: iflib.c
XX ===
XX --- iflib.c  (revision 332488)
XX +++ iflib.c  (working copy)
XX @@ -1,3 +1,5 @@
XX +int bde_oldnet = 1;
XX +
XX  /*-
XX   * Copyright (c) 2014-2018, Matthew Macy 
XX   * All rights reserved.
XX @@ -3650,9 +3652,17 @@
XX  IFDI_TX_QUEUE_INTR_ENABLE(ctx, txq->ift_id);
XX  return;
XX  }
XX +if (bde_oldnet) {
XX  if (txq->ift_db_pending)
XX  ifmp_ring_enqueue(txq->ift_br, (void **), 1, TX_BATCH_SIZE);
XX +else
XX +ifmp_ring_check_drainage(txq->ift_br, TX_BATCH_SIZE);
XX +} else {
XX +if (txq->ift_db_pending)
XX +ifmp_ring_enqueue(txq->ift_br, (void **), 1, TX_BATCH_SIZE);
XX  ifmp_ring_check_drainage(txq->ift_br, TX_BATCH_SIZE);
XX +}
XX +ifmp_ring_check_drainage(txq->ift_br, TX_BATCH_SIZE);
XX  if (ctx->ifc_flags & IFC_LEGACY)
XX  IFDI_INTR_ENABLE(ctx);
XX  else {
XX @@ -3862,8 +3872,11 @@
XX  DBG_COUNTER_INC(tx_seen);
XX  err = ifmp_ring_enqueue(txq->ift_br, (void **), 1, TX_BATCH_SIZE);
XX 
XX +if (!bde_oldnet)

XX  GROUPTASK_ENQUEUE(>ift_task);
XX  if (err) {
XX +if (bde_oldnet)
XX +GROUPTASK_ENQUEUE(>ift_task);
XX  /* support forthcoming later */
XX  #ifdef DRIVER_BACKPRESSURE
XX  txq->ift_closed = TRUE;
XX @@ -3870,6 +3883,9 @@
XX  #endif
XX  ifmp_ring_check_drainage(txq->ift_br, TX_BATCH_SIZE);
XX  m_freem(m);
XX +} else if (TXQ_AVAIL(txq) < (txq->ift_size >> 1)) {
XX +if (bde_oldnet)
XX +GROUPTASK_ENQUEUE(>ift_task);
XX  }
XX 
XX  	return (err);

XX Index: mp_ring.c
XX ===
XX --- mp_ring.c(revision 332488)
XX +++ mp_ring.c(working copy)
XX @@ -1,3 +1,11 @@
XX +#include "opt_pci.h"
XX +
XX +#ifdef DEV_PCI
XX +extern int bde_oldnet;
XX +#else
XX +#define bde_oldnet  0
XX +#endif
XX +
XX  /*-
XX   * Copyright (c) 2014 Chelsio Communications, Inc.
XX   * All rights reserved.
XX @@ -454,12 +462,25 @@
XX  do {
XX  os.state = ns.state = r->state;
XX  ns.pidx_tail = pidx_stop;
XX +if (bde_oldnet)
XX +ns.flags = BUSY;
XX +else {
XX  if (os.flags == IDLE)
XX  ns.flags = ABDICATED;
XX +}
XX  } while (atomic_cmpset_rel_64(>state, os.state, ns.state) == 0);
XX  critical_exit();
XX  counter_u64_add(r->enqueues, n);
XX 
XX +if (bde_oldnet) {

XX +/*
XX + * Turn into a consumer if some other thread isn't active as a consumer
XX + * 

Re: svn commit: r249115 - in head: sbin/camcontrol sys/sys

2018-12-18 Thread Alexey Dokuchaev
On Tue, Nov 27, 2018 at 01:45:14PM +, Alexey Dokuchaev wrote:
> On Thu, Apr 04, 2013 at 11:19:52PM +, Steven Hartland wrote:
> > New Revision: 249115
> > URL: http://svnweb.freebsd.org/changeset/base/249115
> > 
> > Log:
> >   Adds security options to camcontrol this includes the ability to secure
> >   erase disks such as SSD's
> >   
> >   Adds the ability to run ATA commands via the SCSI ATA Pass-Through(16)
> >   com[m]and
> > 
> > Modified: head/sbin/camcontrol/camcontrol.c
> >  
> > [...]
> > +static int
> > +ata_do_identify(struct cam_device *device, int retry_count, int timeout,
> > +   union ccb *ccb, struct ata_params** ident_bufp)
> > +{
> > [...]
> > +
> > +   error = ata_do_28bit_cmd(device,
> > +ccb,
> > +/*retries*/retry_count,
> > +/*flags*/CAM_DIR_IN,
> > +/*protocol*/AP_PROTO_PIO_IN,
> > +/*tag_action*/MSG_SIMPLE_Q_TAG,
> > +/*command*/command,
> > +/*features*/0,
> > +/*lba*/0,
> > +/*sector_count*/(u_int8_t)sizeof(struct 
> > ata_params),
> 
> This looks strange: sizeof(struct ata_params) is 512, but it is too wide
> for u_int8_t, so it would be truncated to zero.  Should it be 1 (one) here
> instead for ATA_ATA_IDENTIFY command, since it normally returns some data
> which typically fits one sector (>=512 bytes)?

Ping.

./danfe

> > +/*data_ptr*/(u_int8_t *)ptr,
> > +/*dxfer_len*/sizeof(struct ata_params),
> > +/*timeout*/timeout ? timeout : 30 * 1000,
> > +/*quiet*/1);
> >  
> > [...]
> > +   error = ata_do_28bit_cmd(device,
> > +ccb,
> > +/*retries*/retry_count,
> > +/*flags*/CAM_DIR_IN,
> > +/*protocol*/AP_PROTO_PIO_IN,
> > +/*tag_action*/MSG_SIMPLE_Q_TAG,
> > +/*command*/retry_command,
> > +/*features*/0,
> > +/*lba*/0,
> > +/*sector_count*/(u_int8_t)
> > +sizeof(struct ata_params),
> 
> Same here.
> 
> > +/*data_ptr*/(u_int8_t *)ptr,
> > +/*dxfer_len*/sizeof(struct ata_params),
> > +/*timeout*/timeout ? timeout : 30 * 
> > 1000,
> > +/*quiet*/0);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2018-12-18 Thread Brooks Davis
Author: brooks
Date: Tue Dec 18 12:44:38 2018
New Revision: 342190
URL: https://svnweb.freebsd.org/changeset/base/342190

Log:
  const poison the `new` pointer of __sysctl.
  
  Reviewed by:  kib
  Obtained from:CheriBSD
  Sponsored by: DARPA, AFRL
  Differential Revision:https://reviews.freebsd.org/D18444

Modified:
  head/sys/compat/freebsd32/syscalls.master
  head/sys/kern/kern_sysctl.c
  head/sys/kern/syscalls.master
  head/sys/sys/sysctl.h

Modified: head/sys/compat/freebsd32/syscalls.master
==
--- head/sys/compat/freebsd32/syscalls.master   Tue Dec 18 09:16:04 2018
(r342189)
+++ head/sys/compat/freebsd32/syscalls.master   Tue Dec 18 12:44:38 2018
(r342190)
@@ -388,7 +388,7 @@
uint32_t length1, uint32_t length2); }
 202AUE_SYSCTL  STD { int freebsd32___sysctl(int *name, \
u_int namelen, void *old, \
-   uint32_t *oldlenp, void *new, \
+   uint32_t *oldlenp, const void *new, \
uint32_t newlen); }
 203AUE_MLOCK   NOPROTO { int mlock(const void *addr, \
size_t len); }

Modified: head/sys/kern/kern_sysctl.c
==
--- head/sys/kern/kern_sysctl.c Tue Dec 18 09:16:04 2018(r342189)
+++ head/sys/kern/kern_sysctl.c Tue Dec 18 12:44:38 2018(r342190)
@@ -1772,7 +1772,7 @@ sysctl_new_kernel(struct sysctl_req *req, void *p, siz
return (0);
if (req->newlen - req->newidx < l)
return (EINVAL);
-   bcopy((char *)req->newptr + req->newidx, p, l);
+   bcopy((const char *)req->newptr + req->newidx, p, l);
req->newidx += l;
return (0);
 }
@@ -1898,7 +1898,7 @@ sysctl_new_user(struct sysctl_req *req, void *p, size_
return (EINVAL);
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL,
"sysctl_new_user()");
-   error = copyin((char *)req->newptr + req->newidx, p, l);
+   error = copyin((const char *)req->newptr + req->newidx, p, l);
req->newidx += l;
return (error);
 }
@@ -2126,8 +2126,8 @@ sys___sysctl(struct thread *td, struct sysctl_args *ua
  */
 int
 userland_sysctl(struct thread *td, int *name, u_int namelen, void *old,
-size_t *oldlenp, int inkernel, void *new, size_t newlen, size_t *retval,
-int flags)
+size_t *oldlenp, int inkernel, const void *new, size_t newlen,
+size_t *retval, int flags)
 {
int error = 0, memlocked;
struct sysctl_req req;

Modified: head/sys/kern/syscalls.master
==
--- head/sys/kern/syscalls.master   Tue Dec 18 09:16:04 2018
(r342189)
+++ head/sys/kern/syscalls.master   Tue Dec 18 12:44:38 2018
(r342190)
@@ -1209,7 +1209,7 @@
u_int namelen,
_Out_writes_bytes_opt_(*oldlenp) void *old,
_Inout_opt_ size_t *oldlenp,
-   _In_reads_bytes_opt_(newlen) void *new,
+   _In_reads_bytes_opt_(newlen) const void *new,
size_t newlen
);
} __sysctl sysctl_args int

Modified: head/sys/sys/sysctl.h
==
--- head/sys/sys/sysctl.h   Tue Dec 18 09:16:04 2018(r342189)
+++ head/sys/sys/sysctl.h   Tue Dec 18 12:44:38 2018(r342190)
@@ -165,7 +165,7 @@ struct sysctl_req {
size_t   oldlen;
size_t   oldidx;
int (*oldfunc)(struct sysctl_req *, const void *, size_t);
-   void*newptr;
+   const void  *newptr;
size_t   newlen;
size_t   newidx;
int (*newfunc)(struct sysctl_req *, void *, size_t);
@@ -1083,7 +1083,7 @@ int   kernel_sysctlbyname(struct thread *td, char 
*name,
size_t *oldlenp, void *new, size_t newlen, size_t *retval,
int flags);
 intuserland_sysctl(struct thread *td, int *name, u_int namelen, void *old,
-   size_t *oldlenp, int inkernel, void *new, size_t newlen,
+   size_t *oldlenp, int inkernel, const void *new, size_t newlen,
size_t *retval, int flags);
 intsysctl_find_oid(int *name, u_int namelen, struct sysctl_oid **noid,
int *nindx, struct sysctl_req *req);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r342151 - head/stand/libsa/zfs

2018-12-18 Thread Alexey Dokuchaev
On Sun, Dec 16, 2018 at 08:58:15AM +, Toomas Soome wrote:
> New Revision: 342151
> URL: https://svnweb.freebsd.org/changeset/base/342151
> 
> Log:
>   loader: zfs reader should not probe partitionless disks
>   
> @@ -527,10 +527,11 @@ zfs_probe_dev(const char *devname, uint64_t *pool_guid
>   pa.fd = open(devname, O_RDONLY);
>   if (pa.fd == -1)
>   return (ENXIO);
> - /* Probe the whole disk */
> - ret = zfs_probe(pa.fd, pool_guid);
> - if (ret == 0)
> - return (0);
> + /*
> +  * We will not probe the whole disk, we can not boot from such

I think you mean "cannot" here.

> +  * disks and some systems will misreport the disk sizes and will
> +  * hang while accessing the disk.
> +  */

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


Re: svn commit: r341578 - head/sys/dev/mlx5/mlx5_en

2018-12-18 Thread Gary Jennejohn
On Mon, 17 Dec 2018 14:50:04 -0500
Andrew Gallatin  wrote:

> On 12/17/18 2:08 PM, Bruce Evans wrote:

[snip]
> > iflib uses queuing techniques to significantly pessimize em NICs with 1
> > hardware queue. On fast machines, it attempts to do 1 context switch per  
> 
> This can happen even w/o contention when "abdicate" is enabled in mp
> ring. I complained about this as well, and the default was changed in
> mp ring to not always "abdicate" (eg, switch to the tq to handle the
> packet). Abdication substantially pessimizes Netflix style web 
> uncontended workloads, but it generally helps small packet forwarding.
> 
> It is interesting that you see the opposite.  I should try benchmarking
> with just a single ring.
> 

Why are iflib and ifdi compiled into EVERY kernel with device
ether and/or device pci when only a few NICs actually use iflib? 
This is really unnecessary bloat in an already bloated kernel.

I use if_re which does not use iflib.

I removed iflib and ifdi from /sys/conf/files and my network
still works just fine.  It seems to me like these iflib entries
need finer-grained options, e.g. one of the NICs which use
iflib is enabled, before pulling them into the kernel build.

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