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

2020-01-23 Thread Hans Petter Selasky

On 2020-01-23 02:24, Gleb Smirnoff wrote:

Author: glebius
Date: Thu Jan 23 01:24:47 2020
New Revision: 357004
URL: https://svnweb.freebsd.org/changeset/base/357004

Log:
   Enter the network epoch for interrupt handlers of INTR_TYPE_NET.
   
   Provide tunable to limit how many times handlers may be executed

   without reentering epoch.
   
   Differential Revision:	https://reviews.freebsd.org/D23242


Modified:
   head/sys/kern/kern_intr.c
   head/sys/sys/interrupt.h

Modified: head/sys/kern/kern_intr.c
==
--- head/sys/kern/kern_intr.c   Thu Jan 23 01:20:59 2020(r357003)
+++ head/sys/kern/kern_intr.c   Thu Jan 23 01:24:47 2020(r357004)
@@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$");
  #include 
  #include 
  #include 
+#include 
  #include 
  #include 
  #include 
@@ -94,6 +95,9 @@ static int intr_storm_threshold = 0;
  SYSCTL_INT(_hw, OID_AUTO, intr_storm_threshold, CTLFLAG_RWTUN,
  &intr_storm_threshold, 0,
  "Number of consecutive interrupts before storm protection is enabled");
+static int intr_epoch_batch = 1000;
+SYSCTL_INT(_hw, OID_AUTO, intr_epoch_batch, CTLFLAG_RWTUN, &intr_epoch_batch,
+0, "Maximum interrupt handler executions without re-entering epoch(9)");
  static TAILQ_HEAD(, intr_event) event_list =
  TAILQ_HEAD_INITIALIZER(event_list);
  static struct mtx event_lock;
@@ -587,6 +591,8 @@ intr_event_add_handler(struct intr_event *ie, const ch
ih->ih_flags |= IH_MPSAFE;
if (flags & INTR_ENTROPY)
ih->ih_flags |= IH_ENTROPY;
+   if (flags & INTR_TYPE_NET)
+   ih->ih_flags |= IH_NET;
  
  	/* We can only have one exclusive handler in a event. */

mtx_lock(&ie->ie_lock);
@@ -1196,11 +1202,12 @@ ithread_execute_handlers(struct proc *p, struct intr_e
  static void
  ithread_loop(void *arg)
  {
+   struct epoch_tracker et;
struct intr_thread *ithd;
struct intr_event *ie;
struct thread *td;
struct proc *p;
-   int wake;
+   int wake, epoch_count;
  
  	td = curthread;

p = td->td_proc;
@@ -1235,8 +1242,21 @@ ithread_loop(void *arg)
 * that the load of ih_need in ithread_execute_handlers()
 * is ordered after the load of it_need here.
 */
-   while (atomic_cmpset_acq_int(&ithd->it_need, 1, 0) != 0)
+   if (ie->ie_hflags & IH_NET) {
+   epoch_count = 0;
+   NET_EPOCH_ENTER(et);
+   }
+   while (atomic_cmpset_acq_int(&ithd->it_need, 1, 0) != 0) {
ithread_execute_handlers(p, ie);
+   if ((ie->ie_hflags & IH_NET) &&
+   ++epoch_count >= intr_epoch_batch) {
+   NET_EPOCH_EXIT(et);
+   epoch_count = 0;
+   NET_EPOCH_ENTER(et);
+   }
+   }
+   if (ie->ie_hflags & IH_NET)
+   NET_EPOCH_EXIT(et);
WITNESS_WARN(WARN_PANIC, NULL, "suspending ithread");
mtx_assert(&Giant, MA_NOTOWNED);
  


Beware that iflib uses GROUP TASKs to invoke the RX-path for packet 
processing and only register a fast IRQ handler.


--HPS

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


Re: svn commit: r357002 - in head: share/man/man4 sys/conf sys/kern sys/modules/cpufreq sys/sys sys/x86/cpufreq

2020-01-23 Thread Ravi Pokala
-Original Message-
From:  on behalf of Conrad Meyer 

Date: 2020-01-22, Wednesday at 15:28
To: , , 

Subject: svn commit: r357002 - in head: share/man/man4 sys/conf sys/kern 
sys/modules/cpufreq sys/sys sys/x86/cpufreq

Author: cem
Date: Wed Jan 22 23:28:42 2020
New Revision: 357002
URL: https://svnweb.freebsd.org/changeset/base/357002

Log:
  cpufreq(4): Add support for Intel Speed Shift
  
  Intel Speed Shift is Intel's technology to control frequency in hardware,
  with hints from software.

Not to be confused with Intel Speed *Step*, right?

(/me was confused; naming things is hard)

-Ravi (rpokala@)

  Let's get a working version of this in the tree and we can refine it from
  here.
  
  Submitted by: bwidawsk, scottph
  Reviewed by:  bcr (manpages), myself
  Discussed with:   jhb, kib (earlier versions)
  With feedback from:   Greg V, gallatin, freebsdnewbie AT freenet.de
  Relnotes: yes
  Differential Revision:https://reviews.freebsd.org/D18028
 


___
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: r357038 - head/sys/netinet

2020-01-23 Thread Alexander V. Chernikov
Author: melifaro
Date: Thu Jan 23 09:14:28 2020
New Revision: 357038
URL: https://svnweb.freebsd.org/changeset/base/357038

Log:
  Fix epoch-related panic in ipdivert, ensuring in_broadcast() is called
   within epoch.
  
  Simplify gigantic div_output() by splitting it into 3 functions,
   handling preliminary setup, remote "ip[6]_output" case and
   local "netisr" case. Leave original indenting in most parts to ease
   diff comparison.  Indentation will be fixed by a followup commit.
  
  Reported by:  Nick Hibma 
  Reviewed by:  glebius
  Differential Revision:https://reviews.freebsd.org/D23317

Modified:
  head/sys/netinet/ip_divert.c

Modified: head/sys/netinet/ip_divert.c
==
--- head/sys/netinet/ip_divert.cThu Jan 23 08:45:31 2020
(r357037)
+++ head/sys/netinet/ip_divert.cThu Jan 23 09:14:28 2020
(r357038)
@@ -122,6 +122,10 @@ static u_long  div_recvspace = DIVRCVQ;/* XXX 
sysctl ?
 
 static eventhandler_tag ip_divert_event_tag;
 
+static int div_output_inbound(int fmaily, struct socket *so, struct mbuf *m,
+struct sockaddr_in *sin);
+static int div_output_outbound(int family, struct socket *so, struct mbuf *m);
+
 /*
  * Initialize divert connection block queue.
  */
@@ -308,10 +312,10 @@ div_output(struct socket *so, struct mbuf *m, struct s
 struct mbuf *control)
 {
struct epoch_tracker et;
-   struct ip *const ip = mtod(m, struct ip *);
+   const struct ip *ip;
struct m_tag *mtag;
struct ipfw_rule_ref *dt;
-   int error = 0;
+   int error, family;
 
/*
 * An mbuf may hasn't come from userland, but we pretend
@@ -330,8 +334,8 @@ div_output(struct socket *so, struct mbuf *m, struct s
mtag = m_tag_alloc(MTAG_IPFW_RULE, 0,
sizeof(struct ipfw_rule_ref), M_NOWAIT | M_ZERO);
if (mtag == NULL) {
-   error = ENOBUFS;
-   goto cantsend;
+   m_freem(m);
+   return (ENOBUFS);
}
m_tag_prepend(m, mtag);
}
@@ -349,6 +353,7 @@ div_output(struct socket *so, struct mbuf *m, struct s
dt->chain_id = 0;
dt->rulenum = sin->sin_port+1; /* host format ? */
dt->rule_id = 0;
+   /* XXX: broken for IPv6 */
/*
 * Find receive interface with the given name, stuffed
 * (if it exists) in the sin_zero[] field.
@@ -361,16 +366,55 @@ div_output(struct socket *so, struct mbuf *m, struct s
m->m_pkthdr.rcvif = ifunit(sin->sin_zero);
}
 
+   ip = mtod(m, struct ip *);
+   switch (ip->ip_v) {
+   case IPVERSION:
+   family = AF_INET;
+   break;
+   case IPV6_VERSION >> 4:
+   family = AF_INET6;
+   break;
+   default:
+   m_freem(m);
+   return (EAFNOSUPPORT);
+   }
+
/* Reinject packet into the system as incoming or outgoing */
+   NET_EPOCH_ENTER(et);
if (!sin || sin->sin_addr.s_addr == 0) {
-   struct mbuf *options = NULL;
+   dt->info |= IPFW_IS_DIVERT | IPFW_INFO_OUT;
+   error = div_output_outbound(family, so, m);
+   } else {
+   dt->info |= IPFW_IS_DIVERT | IPFW_INFO_IN;
+   error = div_output_inbound(family, so, m, sin);
+   }
+   NET_EPOCH_EXIT(et);
+
+   if (error != 0)
+   m_freem(m);
+
+   return (error);
+}
+
+/*
+ * Sends mbuf @m to the wire via ip[6]_output().
+ *
+ * Returns 0 on success, @m is consumed.
+ * On failure, returns error code. It is caller responsibility to free @m.
+ */
+static int
+div_output_outbound(int family, struct socket *so, struct mbuf *m)
+{
+   struct ip *const ip = mtod(m, struct ip *);
+
+   struct mbuf *options;
struct inpcb *inp;
+   int error;
 
-   dt->info |= IPFW_IS_DIVERT | IPFW_INFO_OUT;
inp = sotoinpcb(so);
INP_RLOCK(inp);
-   switch (ip->ip_v) {
-   case IPVERSION:
+   switch (family) {
+   case AF_INET:
/*
 * Don't allow both user specified and setsockopt
 * options, and don't allow packet length sizes that
@@ -379,29 +423,23 @@ div_output(struct socket *so, struct mbuf *m, struct s
if ip->ip_hl << 2) != sizeof(struct ip)) &&
inp->inp_options != NULL) ||
((u_short)ntohs(ip->ip_len) > m->m_pkthdr.len)) {
-   error = EINVAL;
INP_RUNLOCK(inp);
-   goto cantsend;
+   return (EINVAL);
  

svn commit: r357039 - head/sys/netinet

2020-01-23 Thread Alexander V. Chernikov
Author: melifaro
Date: Thu Jan 23 09:46:45 2020
New Revision: 357039
URL: https://svnweb.freebsd.org/changeset/base/357039

Log:
  Bring indentation back to normal after r357038.
  No functional changes.
  
  MFC after:3 weeks

Modified:
  head/sys/netinet/ip_divert.c

Modified: head/sys/netinet/ip_divert.c
==
--- head/sys/netinet/ip_divert.cThu Jan 23 09:14:28 2020
(r357038)
+++ head/sys/netinet/ip_divert.cThu Jan 23 09:46:45 2020
(r357039)
@@ -406,96 +406,95 @@ static int
 div_output_outbound(int family, struct socket *so, struct mbuf *m)
 {
struct ip *const ip = mtod(m, struct ip *);
+   struct mbuf *options;
+   struct inpcb *inp;
+   int error;
 
-   struct mbuf *options;
-   struct inpcb *inp;
-   int error;
-
-   inp = sotoinpcb(so);
-   INP_RLOCK(inp);
-   switch (family) {
-   case AF_INET:
-   /*
-* Don't allow both user specified and setsockopt
-* options, and don't allow packet length sizes that
-* will crash.
-*/
-   if ip->ip_hl << 2) != sizeof(struct ip)) &&
-   inp->inp_options != NULL) ||
-   ((u_short)ntohs(ip->ip_len) > m->m_pkthdr.len)) {
-   INP_RUNLOCK(inp);
-   return (EINVAL);
-   }
-   break;
+   inp = sotoinpcb(so);
+   INP_RLOCK(inp);
+   switch (family) {
+   case AF_INET:
+   /*
+* Don't allow both user specified and setsockopt
+* options, and don't allow packet length sizes that
+* will crash.
+*/
+   if ip->ip_hl << 2) != sizeof(struct ip)) &&
+   inp->inp_options != NULL) ||
+   ((u_short)ntohs(ip->ip_len) > m->m_pkthdr.len)) {
+   INP_RUNLOCK(inp);
+   return (EINVAL);
+   }
+   break;
 #ifdef INET6
-   case AF_INET6:
-   {
-   struct ip6_hdr *const ip6 = mtod(m, struct ip6_hdr *);
+   case AF_INET6:
+   {
+   struct ip6_hdr *const ip6 = mtod(m, struct ip6_hdr *);
 
-   /* Don't allow packet length sizes that will crash */
-   if (((u_short)ntohs(ip6->ip6_plen) > m->m_pkthdr.len)) {
-   INP_RUNLOCK(inp);
-   return (EINVAL);
-   }
-   break;
-   }
-#endif
+   /* Don't allow packet length sizes that will crash */
+   if (((u_short)ntohs(ip6->ip6_plen) > m->m_pkthdr.len)) {
+   INP_RUNLOCK(inp);
+   return (EINVAL);
}
+   break;
+   }
+#endif
+   }
 
-   /* Send packet to output processing */
-   KMOD_IPSTAT_INC(ips_rawout);/* XXX */
+   /* Send packet to output processing */
+   KMOD_IPSTAT_INC(ips_rawout);/* XXX */
 
 #ifdef MAC
-   mac_inpcb_create_mbuf(inp, m);
+   mac_inpcb_create_mbuf(inp, m);
 #endif
-   /*
-* Get ready to inject the packet into ip_output().
-* Just in case socket options were specified on the
-* divert socket, we duplicate them.  This is done
-* to avoid having to hold the PCB locks over the call
-* to ip_output(), as doing this results in a number of
-* lock ordering complexities.
-*
-* Note that we set the multicast options argument for
-* ip_output() to NULL since it should be invariant that
-* they are not present.
-*/
-   KASSERT(inp->inp_moptions == NULL,
-   ("multicast options set on a divert socket"));
-   /*
-* XXXCSJP: It is unclear to me whether or not it makes
-* sense for divert sockets to have options.  However,
-* for now we will duplicate them with the INP locks
-* held so we can use them in ip_output() without
-* requring a reference to the pcb.
-*/
-   options = NULL;
-   if (inp->inp_options != NULL) {
-   options = m_dup(inp->inp_options, M_NOWAIT);
-   if (options == NULL) {
-   INP_RUNLOCK(inp);
-   return (ENOBUFS);
-   }
+   /*
+* Get ready to inject the packet into ip_output()

svn commit: r357040 - head/sys/dev/virtio/scsi

2020-01-23 Thread Andriy Gapon
Author: avg
Date: Thu Jan 23 10:13:56 2020
New Revision: 357040
URL: https://svnweb.freebsd.org/changeset/base/357040

Log:
  virtio_scsi: use max target ID plus one as the initiator ID
  
  This bus does not really have a concept of the initiator ID, so use
  a guaranteed dummy one that won't conflict with any real target.
  
  This change fixes a problem with virtio_scsi on GCE where disks get
  sequential target IDs starting from one.  If there are seven or more
  disks, then a disk with the target ID of seven would not be discovered
  by FreeBSD as that ID was reserved as the initiator ID -- see
  scsi_scan_bus().
  
  Discussed with:   bryanv
  MFC after:2 weeks
  Sponsored by: Panzura

Modified:
  head/sys/dev/virtio/scsi/virtio_scsi.c
  head/sys/dev/virtio/scsi/virtio_scsivar.h

Modified: head/sys/dev/virtio/scsi/virtio_scsi.c
==
--- head/sys/dev/virtio/scsi/virtio_scsi.c  Thu Jan 23 09:46:45 2020
(r357039)
+++ head/sys/dev/virtio/scsi/virtio_scsi.c  Thu Jan 23 10:13:56 2020
(r357040)
@@ -937,7 +937,7 @@ vtscsi_cam_path_inquiry(struct vtscsi_softc *sc, struc
 
cpi->max_target = sc->vtscsi_max_target;
cpi->max_lun = sc->vtscsi_max_lun;
-   cpi->initiator_id = VTSCSI_INITIATOR_ID;
+   cpi->initiator_id = cpi->max_target + 1;
 
strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
strlcpy(cpi->hba_vid, "VirtIO", HBA_IDLEN);

Modified: head/sys/dev/virtio/scsi/virtio_scsivar.h
==
--- head/sys/dev/virtio/scsi/virtio_scsivar.h   Thu Jan 23 09:46:45 2020
(r357039)
+++ head/sys/dev/virtio/scsi/virtio_scsivar.h   Thu Jan 23 10:13:56 2020
(r357040)
@@ -205,11 +205,6 @@ struct vtscsi_request {
 #define VTSCSI_RESERVED_REQUESTS   10
 
 /*
- * Specification doesn't say, use traditional SCSI default.
- */
-#define VTSCSI_INITIATOR_ID7
-
-/*
  * How to wait (or not) for request completion.
  */
 #define VTSCSI_EXECUTE_ASYNC   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: r357041 - in head: stand/usb sys/modules/usb/template

2020-01-23 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Jan 23 10:40:34 2020
New Revision: 357041
URL: https://svnweb.freebsd.org/changeset/base/357041

Log:
  Fix build of stand/usb .
  
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/stand/usb/usbcore.mk
  head/sys/modules/usb/template/Makefile

Modified: head/stand/usb/usbcore.mk
==
--- head/stand/usb/usbcore.mk   Thu Jan 23 10:13:56 2020(r357040)
+++ head/stand/usb/usbcore.mk   Thu Jan 23 10:40:34 2020(r357041)
@@ -1,7 +1,7 @@
 #
 # $FreeBSD$
 #
-# Copyright (c) 2013 Hans Petter Selasky.
+# Copyright (c) 2013-2020 Hans Petter Selasky.
 # Copyright (c) 2014 SRI International
 # All rights reserved.
 #
@@ -162,6 +162,8 @@ KSRCS+= usb_template_audio.c
 KSRCS+=usb_template_phone.c
 KSRCS+=usb_template_serialnet.c
 KSRCS+=usb_template_midi.c
+KSRCS+=usb_template_multi.c
+KSRCS+=usb_template_cdceem.c
 
 #
 # USB mass storage support

Modified: head/sys/modules/usb/template/Makefile
==
--- head/sys/modules/usb/template/Makefile  Thu Jan 23 10:13:56 2020
(r357040)
+++ head/sys/modules/usb/template/Makefile  Thu Jan 23 10:40:34 2020
(r357041)
@@ -1,7 +1,7 @@
 #
 # $FreeBSD$
 #
-# Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
+# Copyright (c) 2008-2020 Hans Petter Selasky. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
@@ -44,5 +44,10 @@ SRCS=opt_bus.h opt_usb.h device_if.h bus_if.h usb_if.
usb_template_midi.c \
usb_template_multi.c \
usb_template_cdceem.c
+
+#
+# NOTE:
+# Keep source list above in sync with stand/usb/usbcore.mk
+#
 
 .include 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r357042 - in head/sys: dev/vmware/vmxnet3 modules/vmware/vmxnet3

2020-01-23 Thread Andriy Gapon
Author: avg
Date: Thu Jan 23 11:05:03 2020
New Revision: 357042
URL: https://svnweb.freebsd.org/changeset/base/357042

Log:
  vmxnet3: add support for RSS kernel option
  
  We observe at least one problem: if a UDP socket is connect(2)-ed, then a
  received packet that matches the connection cannot be matched to the
  corresponding PCB because of an incorrect flow ID.  That was oberved for DNS
  requests from the libc resolver.  We got this problem because FreeBSD
  r343291 enabled code that can set rsstype of received packets to values
  other than M_HASHTYPE_OPAQUE_HASH.  Earlier that code was under 'ifdef
  notyet'.
  
  The essence of this change is to use the system-wide RSS key instead of
  some historic hardcoded key when the software RSS is enabled and it is
  configured to use Toeplitz algorithm (the default).
  In all other cases, the driver reports the opaque hash type for received
  packets while still using Toeplitz algorithm with the internal key.
  
  PR:   242890
  Reviewed by:  pkelsey
  Sponsored by: Panzura
  Differential Revision: https://reviews.freebsd.org/D23147

Modified:
  head/sys/dev/vmware/vmxnet3/if_vmx.c
  head/sys/dev/vmware/vmxnet3/if_vmxvar.h
  head/sys/modules/vmware/vmxnet3/Makefile

Modified: head/sys/dev/vmware/vmxnet3/if_vmx.c
==
--- head/sys/dev/vmware/vmxnet3/if_vmx.cThu Jan 23 10:40:34 2020
(r357041)
+++ head/sys/dev/vmware/vmxnet3/if_vmx.cThu Jan 23 11:05:03 2020
(r357042)
@@ -23,6 +23,8 @@
 #include 
 __FBSDID("$FreeBSD$");
 
+#include "opt_rss.h"
+
 #include 
 #include 
 #include 
@@ -46,6 +48,9 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#ifdef RSS
+#include 
+#endif
 
 #include 
 #include 
@@ -1140,8 +1145,11 @@ vmxnet3_reinit_rss_shared_data(struct vmxnet3_softc *s
struct vmxnet3_driver_shared *ds;
if_softc_ctx_t scctx;
struct vmxnet3_rss_shared *rss;
+#ifdef RSS
+   uint8_t rss_algo;
+#endif
int i;
-   
+
ds = sc->vmx_ds;
scctx = sc->vmx_scctx;
rss = sc->vmx_rss;
@@ -1152,10 +1160,29 @@ vmxnet3_reinit_rss_shared_data(struct vmxnet3_softc *s
rss->hash_func = UPT1_RSS_HASH_FUNC_TOEPLITZ;
rss->hash_key_size = UPT1_RSS_MAX_KEY_SIZE;
rss->ind_table_size = UPT1_RSS_MAX_IND_TABLE_SIZE;
-   memcpy(rss->hash_key, rss_key, UPT1_RSS_MAX_KEY_SIZE);
-
-   for (i = 0; i < UPT1_RSS_MAX_IND_TABLE_SIZE; i++)
-   rss->ind_table[i] = i % scctx->isc_nrxqsets;
+#ifdef RSS
+   /*
+* If the software RSS is configured to anything else other than
+* Toeplitz, then just do Toeplitz in "hardware" for the sake of
+* the packet distribution, but report the hash as opaque to
+* disengage from the software RSS.
+*/
+   rss_algo = rss_gethashalgo();
+   if (rss_algo == RSS_HASH_TOEPLITZ) {
+   rss_getkey(rss->hash_key);
+   for (i = 0; i < UPT1_RSS_MAX_IND_TABLE_SIZE; i++) {
+   rss->ind_table[i] = rss_get_indirection_to_bucket(i) %
+   scctx->isc_nrxqsets;
+   }
+   sc->vmx_flags |= VMXNET3_FLAG_SOFT_RSS;
+   } else
+#endif
+   {
+   memcpy(rss->hash_key, rss_key, UPT1_RSS_MAX_KEY_SIZE);
+   for (i = 0; i < UPT1_RSS_MAX_IND_TABLE_SIZE; i++)
+   rss->ind_table[i] = i % scctx->isc_nrxqsets;
+   sc->vmx_flags &= ~VMXNET3_FLAG_SOFT_RSS;
+   }
 }
 
 static void
@@ -1499,29 +1526,50 @@ vmxnet3_isc_rxd_pkt_get(void *vsc, if_rxd_info_t ri)
KASSERT(rxcd->sop, ("%s: expected sop", __func__));
 
/*
-* RSS and flow ID
+* RSS and flow ID.
+* Types other than M_HASHTYPE_NONE and M_HASHTYPE_OPAQUE_HASH should
+* be used only if the software RSS is enabled and it uses the same
+* algorithm and the hash key as the "hardware".  If the software RSS
+* is not enabled, then it's simply pointless to use those types.
+* If it's enabled but with different parameters, then hash values will
+* not match.
 */
ri->iri_flowid = rxcd->rss_hash;
-   switch (rxcd->rss_type) {
-   case VMXNET3_RCD_RSS_TYPE_NONE:
-   ri->iri_flowid = ri->iri_qsidx;
-   ri->iri_rsstype = M_HASHTYPE_NONE;
-   break;
-   case VMXNET3_RCD_RSS_TYPE_IPV4:
-   ri->iri_rsstype = M_HASHTYPE_RSS_IPV4;
-   break;
-   case VMXNET3_RCD_RSS_TYPE_TCPIPV4:
-   ri->iri_rsstype = M_HASHTYPE_RSS_TCP_IPV4;
-   break;
-   case VMXNET3_RCD_RSS_TYPE_IPV6:
-   ri->iri_rsstype = M_HASHTYPE_RSS_IPV6;
-   break;
-   case VMXNET3_RCD_RSS_TYPE_TCPIPV6:
-   ri->iri_rsstype = M_HASHTYPE_RSS_TCP_IPV6;
-   break;
-   default:
-   ri->iri_rsstype = M_HASHTYPE_OPAQUE

Re: svn commit: r356919 - head/sys/x86/x86

2020-01-23 Thread Konstantin Belousov
On Wed, Jan 22, 2020 at 06:39:22PM -0800, Ryan Libby wrote:
> On Mon, Jan 20, 2020 at 9:23 AM Konstantin Belousov  wrote:
> >
> > Author: kib
> > Date: Mon Jan 20 17:23:03 2020
> > New Revision: 356919
> > URL: https://svnweb.freebsd.org/changeset/base/356919
> >
> > Log:
> >   x86: Wait for curthread to be set up as an indicator that the boot stack
> >   is no longer used.
> >
> >   pc_curthread is set by cpu_switch after it stopped using the old
> >   thread (or boot) stack.  This makes the smp_after_idle_runnable()
> >   function not dependent on the internals of the scheduler operations.
> >
> >   Reviewed by:  markj
> >   Sponsored by: The FreeBSD Foundation
> >   MFC after:1 week
> >   Differential revision:https://reviews.freebsd.org/D23276
> >
> > Modified:
> >   head/sys/x86/x86/mp_x86.c
> >
> > Modified: head/sys/x86/x86/mp_x86.c
> > ==
> > --- head/sys/x86/x86/mp_x86.c   Mon Jan 20 16:59:39 2020(r356918)
> > +++ head/sys/x86/x86/mp_x86.c   Mon Jan 20 17:23:03 2020(r356919)
> > @@ -1092,13 +1092,12 @@ init_secondary_tail(void)
> >  static void
> >  smp_after_idle_runnable(void *arg __unused)
> >  {
> > -   struct thread *idle_td;
> > +   struct pcpu *pc;
> > int cpu;
> >
> > for (cpu = 1; cpu < mp_ncpus; cpu++) {
> > -   idle_td = pcpu_find(cpu)->pc_idlethread;
> > -   while (atomic_load_int(&idle_td->td_lastcpu) == NOCPU &&
> > -   atomic_load_int(&idle_td->td_oncpu) == NOCPU)
> > +   pc = pcpu_find(cpu);
> > +   while (atomic_load_ptr(&pc->pc_curthread) == 
> > (uintptr_t)NULL)
> > cpu_spinwait();
> > kmem_free((vm_offset_t)bootstacks[cpu], kstack_pages *
> > PAGE_SIZE);
> > ___
> > svn-src-...@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"
> 
> I'm hitting a boot panic on a KVM VM that I think is because of this.
> I don't think this works as advertised, because init_secondary_tail sets
> curthread to its idlethread *itself* before it calls sched_switch.  So I
> think the current check is not enough to know that we're actually off
> the bootstack.
> 
> My panic is an AP page faults in the middle of init_secondary_tail,
> after curthread is set.  Weirdly, I only seem to hit it when I have
> disabled some CPUs (to test D23318).  I think this must just be
> affecting some aspect of the timing.

Supposed fix is https://reviews.freebsd.org/D23330
___
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: r357043 - head/sys/conf

2020-01-23 Thread Takahashi Yoshihiro
Author: nyan
Date: Thu Jan 23 13:56:12 2020
New Revision: 357043
URL: https://svnweb.freebsd.org/changeset/base/357043

Log:
  Fix kernel-tags target.
- A depend-file is broken up into .depend.*.o files. [1]
- Fix an assembly file support.
  
  PR:   241746
  Submitted by: leres [1]
  MFC after:1 week

Modified:
  head/sys/conf/kern.post.mk
  head/sys/conf/systags.sh

Modified: head/sys/conf/kern.post.mk
==
--- head/sys/conf/kern.post.mk  Thu Jan 23 11:05:03 2020(r357042)
+++ head/sys/conf/kern.post.mk  Thu Jan 23 13:56:12 2020(r357043)
@@ -389,7 +389,8 @@ kernel-cleandepend: .PHONY
rm -f .depend .depend.* ${_ILINKS}
 
 kernel-tags:
-   @[ -f .depend ] || { echo "you must make depend first"; exit 1; }
+   @ls .depend.* > /dev/null 2>&1 || \
+   { echo "you must make depend first"; exit 1; }
sh $S/conf/systags.sh
 
 kernel-install: .PHONY

Modified: head/sys/conf/systags.sh
==
--- head/sys/conf/systags.shThu Jan 23 11:05:03 2020(r357042)
+++ head/sys/conf/systags.shThu Jan 23 13:56:12 2020(r357043)
@@ -39,14 +39,14 @@
 
 rm -f tags tags.tmp tags.cfiles tags.sfiles tags.hfiles
 sed -e "s, machine/, ../../include/,g" \
-   -e 's,[a-z][^/]*/\.\./,,g' .depend | awk '{
+   -e 's,[a-z][^/]*/\.\./,,g' .depend.* | awk '{
for (i = 1; i <= NF; ++i) {
t = substr($i, length($i) - 1)
if (t == ".c")
cfiles[$i] = 1;
else if (t == ".h")
hfiles[$i] = 1;
-   else if (t == ".s")
+   else if (t == ".s" || t == ".S")
sfiles[$i] = 1;
}
};
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r357045 - head/sys/sparc64/sparc64

2020-01-23 Thread Ed Maste
Author: emaste
Date: Thu Jan 23 14:11:02 2020
New Revision: 357045
URL: https://svnweb.freebsd.org/changeset/base/357045

Log:
  Apply r355819 to sparc64 - fix assertion failure after r355784
  
  From r355819:
  Repeat the spinlock_enter/exit pattern from amd64 on other architectures
  to fix an assert violation introduced in r355784.  Without this
  spinlock_exit() may see owepreempt and switch before reducing the
  spinlock count.  amd64 had been optimized to do a single critical
  enter/exit regardless of the number of spinlocks which avoided the
  problem and this optimization had not been applied elsewhere.
  
  This is completely untested - I have no obsolete Sparc hardware - but
  someone did try testing recent changes on sparc64 (PR 243534).
  
  PR:   243534

Modified:
  head/sys/sparc64/sparc64/machdep.c

Modified: head/sys/sparc64/sparc64/machdep.c
==
--- head/sys/sparc64/sparc64/machdep.c  Thu Jan 23 14:01:03 2020
(r357044)
+++ head/sys/sparc64/sparc64/machdep.c  Thu Jan 23 14:11:02 2020
(r357045)
@@ -224,9 +224,9 @@ spinlock_enter(void)
wrpr(pil, 0, PIL_TICK);
td->td_md.md_spinlock_count = 1;
td->td_md.md_saved_pil = pil;
+   critical_enter();
} else
td->td_md.md_spinlock_count++;
-   critical_enter();
 }
 
 void
@@ -236,11 +236,12 @@ spinlock_exit(void)
register_t pil;
 
td = curthread;
-   critical_exit();
pil = td->td_md.md_saved_pil;
td->td_md.md_spinlock_count--;
-   if (td->td_md.md_spinlock_count == 0)
+   if (td->td_md.md_spinlock_count == 0) {
+   critical_exit();
wrpr(pil, pil, 0);
+   }
 }
 
 static phandle_t
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r356990 - head/etc

2020-01-23 Thread Ed Maste
On Wed, 22 Jan 2020 at 13:40, Ed Maste  wrote:
>
> Author: emaste
> Date: Wed Jan 22 18:40:19 2020
> New Revision: 356990
> URL: https://svnweb.freebsd.org/changeset/base/356990
>
> Log:
>   Tag NLS aliases with package=runtime

This commit message does not match the change, it should be
'package=utilities'. The symlink is tagged 'package=utilities'
matching the NLS data in /usr/share/locale/...
___
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: r357047 - head/tests

2020-01-23 Thread Ed Maste
Author: emaste
Date: Thu Jan 23 15:59:30 2020
New Revision: 357047
URL: https://svnweb.freebsd.org/changeset/base/357047

Log:
  Tag /usr/tests/local symlink with package=tests
  
  As with the rest of /usr/tests, so that it is handled correctly on
  pkgbase-installed/updated systems.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  head/tests/Makefile

Modified: head/tests/Makefile
==
--- head/tests/Makefile Thu Jan 23 14:14:38 2020(r357046)
+++ head/tests/Makefile Thu Jan 23 15:59:30 2020(r357047)
@@ -15,7 +15,8 @@ SUBDIR_PARALLEL=
 
 afterinstall: install-tests-local
 install-tests-local: .PHONY
-   ${INSTALL_SYMLINK} ../local/tests ${DESTDIR}${TESTSDIR}/local
+   ${INSTALL_SYMLINK} -T 'package=tests' \
+   ../local/tests ${DESTDIR}${TESTSDIR}/local
 
 .include "Makefile.inc0"
 .include 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r357048 - head/sys/arm64/arm64

2020-01-23 Thread Mark Johnston
Author: markj
Date: Thu Jan 23 16:07:27 2020
New Revision: 357048
URL: https://svnweb.freebsd.org/changeset/base/357048

Log:
  arm64: Don't enable interrupts in init_secondary().
  
  Doing so can cause deadlocks or panics during boot, if an interrupt
  handler accesses uninitialized per-CPU scheduler structures.  This seems
  to occur frequently when running under QEMU or AWS.  The idle threads
  are set up to release a spinlock section and enable interrupts in
  fork_exit(), so there is no need to enable interrupts earlier.
  
  Reviewed by:  kib
  MFC after:1 week
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D23328

Modified:
  head/sys/arm64/arm64/mp_machdep.c

Modified: head/sys/arm64/arm64/mp_machdep.c
==
--- head/sys/arm64/arm64/mp_machdep.c   Thu Jan 23 15:59:30 2020
(r357047)
+++ head/sys/arm64/arm64/mp_machdep.c   Thu Jan 23 16:07:27 2020
(r357048)
@@ -240,18 +240,12 @@ init_secondary(uint64_t cpu)
dbg_init();
pan_enable();
 
-   /* Enable interrupts */
-   intr_enable();
-
mtx_lock_spin(&ap_boot_mtx);
-
atomic_add_rel_32(&smp_cpus, 1);
-
if (smp_cpus == mp_ncpus) {
/* enable IPI's, tlb shootdown, freezes etc */
atomic_store_rel_int(&smp_started, 1);
}
-
mtx_unlock_spin(&ap_boot_mtx);
 
kcsan_cpu_init(cpu);
___
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: r357049 - in head/sys/arm64: arm64 include

2020-01-23 Thread Mark Johnston
Author: markj
Date: Thu Jan 23 16:10:38 2020
New Revision: 357049
URL: https://svnweb.freebsd.org/changeset/base/357049

Log:
  Print missing ID_AA64PFR{0,1}_EL1 register fields.
  
  MFC after:1 week
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D23213

Modified:
  head/sys/arm64/arm64/identcpu.c
  head/sys/arm64/include/armreg.h

Modified: head/sys/arm64/arm64/identcpu.c
==
--- head/sys/arm64/arm64/identcpu.c Thu Jan 23 16:07:27 2020
(r357048)
+++ head/sys/arm64/arm64/identcpu.c Thu Jan 23 16:10:38 2020
(r357049)
@@ -643,6 +643,41 @@ static struct mrs_field id_aa64mmfr2_fields[] = {
 
 
 /* ID_AA64PFR0_EL1 */
+static struct mrs_field_value id_aa64pfr0_csv3[] = {
+   MRS_FIELD_VALUE(ID_AA64PFR0_CSV3_NONE, ""),
+   MRS_FIELD_VALUE(ID_AA64PFR0_CSV3_ISOLATED, "CSV3"),
+   MRS_FIELD_VALUE_END,
+};
+
+static struct mrs_field_value id_aa64pfr0_csv2[] = {
+   MRS_FIELD_VALUE(ID_AA64PFR0_CSV2_NONE, ""),
+   MRS_FIELD_VALUE(ID_AA64PFR0_CSV2_ISOLATED, "CSV2"),
+   MRS_FIELD_VALUE(ID_AA64PFR0_CSV2_SCXTNUM, "SCXTNUM"),
+   MRS_FIELD_VALUE_END,
+};
+
+static struct mrs_field_value id_aa64pfr0_dit[] = {
+   MRS_FIELD_VALUE(ID_AA64PFR0_DIT_NONE, ""),
+   MRS_FIELD_VALUE(ID_AA64PFR0_DIT_PSTATE, "PSTATE.DIT"),
+   MRS_FIELD_VALUE_END,
+};
+
+static struct mrs_field_value id_aa64pfr0_amu[] = {
+   MRS_FIELD_VALUE(ID_AA64PFR0_AMU_NONE, ""),
+   MRS_FIELD_VALUE(ID_AA64PFR0_AMU_V1, "AMUv1"),
+   MRS_FIELD_VALUE_END,
+};
+
+static struct mrs_field_value id_aa64pfr0_mpam[] = {
+   MRS_FIELD_VALUE_NONE_IMPL(ID_AA64PFR0, MPAM, NONE, IMPL),
+   MRS_FIELD_VALUE_END,
+};
+
+static struct mrs_field_value id_aa64pfr0_sel2[] = {
+   MRS_FIELD_VALUE_NONE_IMPL(ID_AA64PFR0, SEL2, NONE, IMPL),
+   MRS_FIELD_VALUE_END,
+};
+
 static struct mrs_field_value id_aa64pfr0_sve[] = {
MRS_FIELD_VALUE_NONE_IMPL(ID_AA64PFR0, SVE, NONE, IMPL),
MRS_FIELD_VALUE_END,
@@ -696,6 +731,12 @@ static struct mrs_field_value id_aa64pfr0_el0[] = {
 };
 
 static struct mrs_field id_aa64pfr0_fields[] = {
+   MRS_FIELD(ID_AA64PFR0, CSV3, false, MRS_EXACT, id_aa64pfr0_csv3),
+   MRS_FIELD(ID_AA64PFR0, CSV2, false, MRS_EXACT, id_aa64pfr0_csv2),
+   MRS_FIELD(ID_AA64PFR0, DIT, false, MRS_EXACT, id_aa64pfr0_dit),
+   MRS_FIELD(ID_AA64PFR0, AMU, false, MRS_EXACT, id_aa64pfr0_amu),
+   MRS_FIELD(ID_AA64PFR0, MPAM, false, MRS_EXACT, id_aa64pfr0_mpam),
+   MRS_FIELD(ID_AA64PFR0, SEL2, false, MRS_EXACT, id_aa64pfr0_sel2),
MRS_FIELD(ID_AA64PFR0, SVE, false, MRS_EXACT, id_aa64pfr0_sve),
MRS_FIELD(ID_AA64PFR0, RAS, false, MRS_EXACT, id_aa64pfr0_ras),
MRS_FIELD(ID_AA64PFR0, GIC, false, MRS_EXACT, id_aa64pfr0_gic),
@@ -710,7 +751,30 @@ static struct mrs_field id_aa64pfr0_fields[] = {
 
 
 /* ID_AA64PFR1_EL1 */
+static struct mrs_field_value id_aa64pfr1_bt[] = {
+   MRS_FIELD_VALUE(ID_AA64PFR1_BT_NONE, ""),
+   MRS_FIELD_VALUE(ID_AA64PFR1_BT_IMPL, "BTI"),
+   MRS_FIELD_VALUE_END,
+};
+
+static struct mrs_field_value id_aa64pfr1_ssbs[] = {
+   MRS_FIELD_VALUE(ID_AA64PFR1_SSBS_NONE, ""),
+   MRS_FIELD_VALUE(ID_AA64PFR1_SSBS_PSTATE, "PSTATE.SSBS"),
+   MRS_FIELD_VALUE(ID_AA64PFR1_SSBS_PSTATE_MSR, "PSTATE.SSBS MSR"),
+   MRS_FIELD_VALUE_END,
+};
+
+static struct mrs_field_value id_aa64pfr1_mte[] = {
+   MRS_FIELD_VALUE(ID_AA64PFR1_MTE_NONE, ""),
+   MRS_FIELD_VALUE(ID_AA64PFR1_MTE_IMPL_EL0, "MTE EL0"),
+   MRS_FIELD_VALUE(ID_AA64PFR1_MTE_IMPL, "MTE"),
+   MRS_FIELD_VALUE_END,
+};
+
 static struct mrs_field id_aa64pfr1_fields[] = {
+   MRS_FIELD(ID_AA64PFR1, BT, false, MRS_EXACT, id_aa64pfr1_bt),
+   MRS_FIELD(ID_AA64PFR1, SSBS, false, MRS_EXACT, id_aa64pfr1_ssbs),
+   MRS_FIELD(ID_AA64PFR1, MTE, false, MRS_EXACT, id_aa64pfr1_mte),
MRS_FIELD_END,
 };
 
@@ -743,6 +807,13 @@ static struct mrs_user_reg user_regs[] = {
.Op2 = 0,
.offset = __offsetof(struct cpu_desc, id_aa64pfr0),
.fields = id_aa64pfr0_fields,
+   },
+   {   /* id_aa64pfr0_el1 */
+   .reg = ID_AA64PFR1_EL1,
+   .CRm = 4,
+   .Op2 = 1,
+   .offset = __offsetof(struct cpu_desc, id_aa64pfr1),
+   .fields = id_aa64pfr1_fields,
},
{   /* id_aa64dfr0_el1 */
.reg = ID_AA64DFR0_EL1,

Modified: head/sys/arm64/include/armreg.h
==
--- head/sys/arm64/include/armreg.h Thu Jan 23 16:07:27 2020
(r357048)
+++ head/sys/arm64/include/armreg.h Thu Jan 23 16:10:38 2020
(r357049)
@@ -517,6 +517,62 @@
 #defineID_AA64PFR0_SVE_VAL(x)  ((x) & ID_AA64PFR0_SVE_MASK)
 #define ID_AA64PFR0_SVE_NONE   (UL(0x0) << 
ID_AA64PFR0

svn commit: r357050 - head/sys/kern

2020-01-23 Thread Mark Johnston
Author: markj
Date: Thu Jan 23 16:24:51 2020
New Revision: 357050
URL: https://svnweb.freebsd.org/changeset/base/357050

Log:
  Set td_oncpu before dropping the thread lock during a switch.
  
  After r355784 we no longer hold a thread's thread lock when switching it
  out.  Preserve the previous synchronization protocol for td_oncpu by
  setting it together with td_state, before dropping the thread lock
  during a switch.
  
  Reported and tested by:   pho
  Reviewed by:  kib
  Discussed with:   jeff
  Differential Revision:https://reviews.freebsd.org/D23270

Modified:
  head/sys/kern/sched_ule.c

Modified: head/sys/kern/sched_ule.c
==
--- head/sys/kern/sched_ule.c   Thu Jan 23 16:10:38 2020(r357049)
+++ head/sys/kern/sched_ule.c   Thu Jan 23 16:24:51 2020(r357050)
@@ -2121,6 +2121,7 @@ sched_switch(struct thread *td, int flags)
 */
TDQ_LOCK_ASSERT(tdq, MA_OWNED | MA_NOTRECURSED);
newtd = choosethread();
+   newtd->td_oncpu = cpuid;
sched_pctcpu_update(td_get_sched(newtd), 0);
TDQ_UNLOCK(tdq);
 
@@ -2145,7 +2146,6 @@ sched_switch(struct thread *td, int flags)
 #endif
td->td_oncpu = NOCPU;
cpu_switch(td, newtd, mtx);
-   cpuid = td->td_oncpu = PCPU_GET(cpuid);
 
SDT_PROBE0(sched, , , on__cpu);
 #ifdef HWPMC_HOOKS
@@ -2915,6 +2915,7 @@ sched_throw(struct thread *td)
thread_lock_block(td);
}
newtd = choosethread();
+   newtd->td_oncpu = PCPU_GET(cpuid);
spinlock_enter();
TDQ_UNLOCK(tdq);
KASSERT(curthread->td_md.md_spinlock_count == 1,
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2020-01-23 Thread Gleb Smirnoff
Author: glebius
Date: Thu Jan 23 16:36:58 2020
New Revision: 357051
URL: https://svnweb.freebsd.org/changeset/base/357051

Log:
  With MSI interrupts bge(4) just schedules taskqueue.  Enter the network
  epoch in the taskqueue handler.
  
  Reported by:  kib

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

Modified: head/sys/dev/bge/if_bge.c
==
--- head/sys/dev/bge/if_bge.c   Thu Jan 23 16:24:51 2020(r357050)
+++ head/sys/dev/bge/if_bge.c   Thu Jan 23 16:36:58 2020(r357051)
@@ -4646,6 +4646,7 @@ bge_msi_intr(void *arg)
 static void
 bge_intr_task(void *arg, int pending)
 {
+   struct epoch_tracker et;
struct bge_softc *sc;
if_t ifp;
uint32_t status, status_tag;
@@ -4688,7 +4689,9 @@ bge_intr_task(void *arg, int pending)
sc->bge_rx_saved_considx != rx_prod) {
/* Check RX return ring producer/consumer. */
BGE_UNLOCK(sc);
+   NET_EPOCH_ENTER(et);
bge_rxeof(sc, rx_prod, 0);
+   NET_EPOCH_EXIT(et);
BGE_LOCK(sc);
}
if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) {
___
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: r357052 - head/sys/vm

2020-01-23 Thread Mark Johnston
Author: markj
Date: Thu Jan 23 16:45:10 2020
New Revision: 357052
URL: https://svnweb.freebsd.org/changeset/base/357052

Log:
  vm_map_submap(): Avoid unnecessary clipping.
  
  A submap can only be created from an entry spanning the entire request
  range.  In particular, if vm_map_lookup_entry() returns false or the
  returned entry contains "end".
  
  Since the only use of submaps in FreeBSD is for the static pipe and
  execve argument KVA maps, this has no functional effect.
  
  Github PR:https://github.com/freebsd/freebsd/pull/420
  Submitted by: Wuyang Chung  (original)
  Reviewed by:  dougm, kib
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D23299

Modified:
  head/sys/vm/vm_map.c

Modified: head/sys/vm/vm_map.c
==
--- head/sys/vm/vm_map.cThu Jan 23 16:36:58 2020(r357051)
+++ head/sys/vm/vm_map.cThu Jan 23 16:45:10 2020(r357052)
@@ -2477,19 +2477,12 @@ vm_map_submap(
vm_map_unlock(submap);
 
vm_map_lock(map);
-
VM_MAP_RANGE_CHECK(map, start, end);
-
-   if (vm_map_lookup_entry(map, start, &entry)) {
+   if (vm_map_lookup_entry(map, start, &entry) && entry->end >= end &&
+   (entry->eflags & MAP_ENTRY_COW) == 0 &&
+   entry->object.vm_object == NULL) {
vm_map_clip_start(map, entry, start);
-   } else
-   entry = vm_map_entry_succ(entry);
-
-   vm_map_clip_end(map, entry, end);
-
-   if ((entry->start == start) && (entry->end == end) &&
-   ((entry->eflags & MAP_ENTRY_COW) == 0) &&
-   (entry->object.vm_object == NULL)) {
+   vm_map_clip_end(map, entry, end);
entry->object.sub_map = submap;
entry->eflags |= MAP_ENTRY_IS_SUB_MAP;
result = KERN_SUCCESS;
___
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: r357053 - in head: share/man/man4 sys/netgraph

2020-01-23 Thread Mark Johnston
Author: markj
Date: Thu Jan 23 16:45:48 2020
New Revision: 357053
URL: https://svnweb.freebsd.org/changeset/base/357053

Log:
  ng_nat: Pass IPv6 packets through.
  
  ng_nat implements NAT for IPv4 traffic only.  When connected to an
  ng_ether node it erroneously handled IPv6 packets as well.
  
  This change is not sufficient: ng_nat does not do any validation of IP
  packets in this mode, even though they have not yet passed through
  ip_input().
  
  PR:   243096
  Reported by:  Robert James Hernandez 
  Reviewed by:  julian
  Differential Revision:https://reviews.freebsd.org/D23080

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

Modified: head/share/man/man4/ng_nat.4
==
--- head/share/man/man4/ng_nat.4Thu Jan 23 16:45:10 2020
(r357052)
+++ head/share/man/man4/ng_nat.4Thu Jan 23 16:45:48 2020
(r357053)
@@ -35,7 +35,7 @@
 .Sh DESCRIPTION
 An
 .Nm
-node performs network address translation (NAT) of packets
+node performs network address translation (NAT) of IPv4 packets
 passing through it.
 A
 .Nm nat

Modified: head/sys/netgraph/ng_nat.c
==
--- head/sys/netgraph/ng_nat.c  Thu Jan 23 16:45:10 2020(r357052)
+++ head/sys/netgraph/ng_nat.c  Thu Jan 23 16:45:48 2020(r357053)
@@ -795,7 +795,6 @@ ng_nat_rcvdata(hook_p hook, item_p item )
eh = mtod(m, struct ether_header *);
switch (ntohs(eh->ether_type)) {
case ETHERTYPE_IP:
-   case ETHERTYPE_IPV6:
ipofs = sizeof(struct ether_header);
break;
default:
___
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: r357054 - head/sys/x86/x86

2020-01-23 Thread Konstantin Belousov
Author: kib
Date: Thu Jan 23 17:08:33 2020
New Revision: 357054
URL: https://svnweb.freebsd.org/changeset/base/357054

Log:
  Fix r356919.
  
  Instead of waiting for pc_curthread which is overwritten by
  init_secondary_tail(), wait for non-NULL pc_curpcb, to be set by the
  first context switch.
  Assert that pc_curpcb is not set too early.
  
  Reported and tested by:   rlibby
  Reviewed by:  markj, rlibby
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D23330

Modified:
  head/sys/x86/x86/mp_x86.c

Modified: head/sys/x86/x86/mp_x86.c
==
--- head/sys/x86/x86/mp_x86.c   Thu Jan 23 16:45:48 2020(r357053)
+++ head/sys/x86/x86/mp_x86.c   Thu Jan 23 17:08:33 2020(r357054)
@@ -1084,6 +1084,11 @@ init_secondary_tail(void)
 
kcsan_cpu_init(cpuid);
 
+   /*
+* Assert that smp_after_idle_runnable condition is reasonable.
+*/
+   MPASS(PCPU_GET(curpcb) == NULL);
+
sched_throw(NULL);
 
panic("scheduler returned us to %s", __func__);
@@ -1098,7 +1103,7 @@ smp_after_idle_runnable(void *arg __unused)
 
for (cpu = 1; cpu < mp_ncpus; cpu++) {
pc = pcpu_find(cpu);
-   while (atomic_load_ptr(&pc->pc_curthread) == (uintptr_t)NULL)
+   while (atomic_load_ptr(&pc->pc_curpcb) == (uintptr_t)NULL)
cpu_spinwait();
kmem_free((vm_offset_t)bootstacks[cpu], kstack_pages *
PAGE_SIZE);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r357055 - head/sys/sparc64/sparc64

2020-01-23 Thread Mark Johnston
Author: markj
Date: Thu Jan 23 17:18:58 2020
New Revision: 357055
URL: https://svnweb.freebsd.org/changeset/base/357055

Log:
  sparc64: Busy the TSB page before freeing it in pmap_release().
  
  This is now required by vm_page_free().
  
  PR:   243534
  Reported and tested by:   Michael Reim 

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

Modified: head/sys/sparc64/sparc64/pmap.c
==
--- head/sys/sparc64/sparc64/pmap.c Thu Jan 23 17:08:33 2020
(r357054)
+++ head/sys/sparc64/sparc64/pmap.c Thu Jan 23 17:18:58 2020
(r357055)
@@ -1302,6 +1302,7 @@ pmap_release(pmap_t pm)
m = TAILQ_FIRST(&obj->memq);
m->md.pmap = NULL;
vm_page_unwire_noq(m);
+   vm_page_xbusy(m);
vm_page_free_zero(m);
}
VM_OBJECT_WUNLOCK(obj);
___
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: r357056 - head/sys/sys

2020-01-23 Thread Ed Maste
Author: emaste
Date: Thu Jan 23 17:38:17 2020
New Revision: 357056
URL: https://svnweb.freebsd.org/changeset/base/357056

Log:
  add MIPS-specific PT header ELF definitions
  
  Submitted by: David Carlier
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D19428

Modified:
  head/sys/sys/elf_common.h

Modified: head/sys/sys/elf_common.h
==
--- head/sys/sys/elf_common.h   Thu Jan 23 17:18:58 2020(r357055)
+++ head/sys/sys/elf_common.h   Thu Jan 23 17:38:17 2020(r357056)
@@ -543,6 +543,10 @@ typedef struct {
 #definePT_LOPROC   0x7000  /* First processor-specific 
type. */
 #definePT_ARM_ARCHEXT  0x7000  /* ARM arch compat information. 
*/
 #definePT_ARM_EXIDX0x7001  /* ARM exception unwind tables. 
*/
+#definePT_MIPS_REGINFO 0x7000  /* MIPS register usage 
info */
+#definePT_MIPS_RTPROC  0x7001  /* MIPS runtime 
procedure tbl */
+#definePT_MIPS_OPTIONS 0x7002  /* MIPS e_flags value*/
+#definePT_MIPS_ABIFLAGS0x7003  /* MIPS fp mode */
 #definePT_HIPROC   0x7fff  /* Last processor-specific 
type. */
 
 #definePT_OPENBSD_RANDOMIZE0x65A3DBE6  /* OpenBSD random data 
segment */
___
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: r357055 - head/sys/sparc64/sparc64

2020-01-23 Thread Jeff Roberson

On Thu, 23 Jan 2020, Mark Johnston wrote:


Author: markj
Date: Thu Jan 23 17:18:58 2020
New Revision: 357055
URL: https://svnweb.freebsd.org/changeset/base/357055

Log:
 sparc64: Busy the TSB page before freeing it in pmap_release().

 This is now required by vm_page_free().

 PR:243534
 Reported and tested by:Michael Reim 

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

Modified: head/sys/sparc64/sparc64/pmap.c
==
--- head/sys/sparc64/sparc64/pmap.c Thu Jan 23 17:08:33 2020
(r357054)
+++ head/sys/sparc64/sparc64/pmap.c Thu Jan 23 17:18:58 2020
(r357055)
@@ -1302,6 +1302,7 @@ pmap_release(pmap_t pm)
m = TAILQ_FIRST(&obj->memq);
m->md.pmap = NULL;
vm_page_unwire_noq(m);
+   vm_page_xbusy(m);


vm_page_xbusy() is unsafe long-term and I will be removing it as soon as I 
get patches into drm.  It technically 'works' now but not for great 
reasons.


Thanks,
Jeff


vm_page_free_zero(m);
}
VM_OBJECT_WUNLOCK(obj);


___
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: r357055 - head/sys/sparc64/sparc64

2020-01-23 Thread Mark Johnston
On Thu, Jan 23, 2020 at 08:22:55AM -1000, Jeff Roberson wrote:
> On Thu, 23 Jan 2020, Mark Johnston wrote:
> 
> > Author: markj
> > Date: Thu Jan 23 17:18:58 2020
> > New Revision: 357055
> > URL: https://svnweb.freebsd.org/changeset/base/357055
> > 
> > Log:
> >  sparc64: Busy the TSB page before freeing it in pmap_release().
> > 
> >  This is now required by vm_page_free().
> > 
> >  PR:243534
> >  Reported and tested by:Michael Reim 
> > 
> > Modified:
> >  head/sys/sparc64/sparc64/pmap.c
> > 
> > Modified: head/sys/sparc64/sparc64/pmap.c
> > ==
> > --- head/sys/sparc64/sparc64/pmap.c Thu Jan 23 17:08:33 2020
> > (r357054)
> > +++ head/sys/sparc64/sparc64/pmap.c Thu Jan 23 17:18:58 2020
> > (r357055)
> > @@ -1302,6 +1302,7 @@ pmap_release(pmap_t pm)
> > m = TAILQ_FIRST(&obj->memq);
> > m->md.pmap = NULL;
> > vm_page_unwire_noq(m);
> > +   vm_page_xbusy(m);
> 
> vm_page_xbusy() is unsafe long-term and I will be removing it as soon as I
> get patches into drm.  It technically 'works' now but not for great reasons.

Yeah, this is just to satisfy the interface contract.  These pages are
unmanaged, so it really shouldn't make a difference.

> Thanks,
> Jeff
> 
> > vm_page_free_zero(m);
> > }
> > VM_OBJECT_WUNLOCK(obj);
> > 
___
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: r356990 - head/etc

2020-01-23 Thread Rodney W. Grimes
[ Charset UTF-8 unsupported, converting... ]
> On Wed, 22 Jan 2020 at 13:40, Ed Maste  wrote:
> >
> > Author: emaste
> > Date: Wed Jan 22 18:40:19 2020
> > New Revision: 356990
> > URL: https://svnweb.freebsd.org/changeset/base/356990
> >
> > Log:
> >   Tag NLS aliases with package=runtime
> 
> This commit message does not match the change, it should be
> 'package=utilities'. The symlink is tagged 'package=utilities'
> matching the NLS data in /usr/share/locale/...
> 

Revert and recommit?  Note that this email message well not
be found by anyone looking at svn logs trying to find stuff.

IMHO any commit message that does not match the actual commit
should be reverted and recommitted with the correct message.

-- 
Rod Grimes rgri...@freebsd.org
___
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: r357051 - head/sys/dev/bge

2020-01-23 Thread Ryan Stone
What is a driver's responsibility now for entering/leaving the net epoch now?
___
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: r357002 - in head: share/man/man4 sys/conf sys/kern sys/modules/cpufreq sys/sys sys/x86/cpufreq

2020-01-23 Thread Conrad Meyer
(I had to look that up.)  Yeah, they're different.  Speedstep is
est(4), the ~15-year old predecessor to Speedshift.  They serve
similar purposes but purportedly (and plausibly) Speedshift does a
better job; also SpeedStep is maybe going away entirely in newer CPUs.

Current gens like Skylake and Kabylake have silicon for both, but if
intel_hwpstate(4) is enabled, est(4) doesn't work; hence the kludge in
est(4) to avoid "identifying" if intel_hwpstate(4) successfully
identified (wasn't disabled && new enough CPU).

Best,
Conrad

On Thu, Jan 23, 2020 at 12:55 AM Ravi Pokala  wrote:
>
> -Original Message-
> From:  on behalf of Conrad Meyer 
> 
> Date: 2020-01-22, Wednesday at 15:28
> To: , , 
> 
> Subject: svn commit: r357002 - in head: share/man/man4 sys/conf sys/kern 
> sys/modules/cpufreq sys/sys sys/x86/cpufreq
>
> Author: cem
> Date: Wed Jan 22 23:28:42 2020
> New Revision: 357002
> URL: https://svnweb.freebsd.org/changeset/base/357002
>
> Log:
>   cpufreq(4): Add support for Intel Speed Shift
>
>   Intel Speed Shift is Intel's technology to control frequency in 
> hardware,
>   with hints from software.
>
> Not to be confused with Intel Speed *Step*, right?
>
> (/me was confused; naming things is hard)
>
> -Ravi (rpokala@)
>
>   Let's get a working version of this in the tree and we can refine it 
> from
>   here.
>
>   Submitted by: bwidawsk, scottph
>   Reviewed by:  bcr (manpages), myself
>   Discussed with:   jhb, kib (earlier versions)
>   With feedback from:   Greg V, gallatin, freebsdnewbie AT freenet.de
>   Relnotes: yes
>   Differential Revision:https://reviews.freebsd.org/D18028
>
>
>
___
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: r356990 - head/etc

2020-01-23 Thread Cy Schubert
In message <202001231914.00njehsm030...@gndrsh.dnsmgr.net>, "Rodney W. 
Grimes"
writes:
> [ Charset UTF-8 unsupported, converting... ]
> > On Wed, 22 Jan 2020 at 13:40, Ed Maste  wrote:
> > >
> > > Author: emaste
> > > Date: Wed Jan 22 18:40:19 2020
> > > New Revision: 356990
> > > URL: https://svnweb.freebsd.org/changeset/base/356990
> > >
> > > Log:
> > >   Tag NLS aliases with package=runtime
> > 
> > This commit message does not match the change, it should be
> > 'package=utilities'. The symlink is tagged 'package=utilities'
> > matching the NLS data in /usr/share/locale/...
> > 
>
> Revert and recommit?  Note that this email message well not
> be found by anyone looking at svn logs trying to find stuff.
>
> IMHO any commit message that does not match the actual commit
> should be reverted and recommitted with the correct message.

+1. It helps those who follow to inform them before deciding whether to dig 
into the code or not.


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

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


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


svn commit: r357061 - head/sys/netpfil/pf

2020-01-23 Thread Kristof Provost
Author: kp
Date: Thu Jan 23 22:13:41 2020
New Revision: 357061
URL: https://svnweb.freebsd.org/changeset/base/357061

Log:
  pf: Apply kif flags to new group members
  
  If we have a 'set skip on ' rule this flag it set on the group
  kif, but must also be set on all members. pfctl does this when the rules
  are set, but if groups are added afterwards we must also apply the flags
  to the new member. If not, new group members will not be skipped until
  the rules are reloaded.
  
  Reported by:  dvl@
  Reviewed by:  glebius@
  Differential Revision:https://reviews.freebsd.org/D23254

Modified:
  head/sys/netpfil/pf/pf_if.c

Modified: head/sys/netpfil/pf/pf_if.c
==
--- head/sys/netpfil/pf/pf_if.c Thu Jan 23 21:46:33 2020(r357060)
+++ head/sys/netpfil/pf/pf_if.c Thu Jan 23 22:13:41 2020(r357061)
@@ -477,7 +477,9 @@ static void
 pfi_kif_update(struct pfi_kif *kif)
 {
struct ifg_list *ifgl;
+   struct ifg_member   *ifgm;
struct pfi_dynaddr  *p;
+   struct pfi_kif  *tmpkif;
 
NET_EPOCH_ASSERT();
PF_RULES_WASSERT();
@@ -485,6 +487,18 @@ pfi_kif_update(struct pfi_kif *kif)
/* update all dynaddr */
TAILQ_FOREACH(p, &kif->pfik_dynaddrs, entry)
pfi_dynaddr_update(p);
+
+   /* Apply group flags to new members. */
+   if (kif->pfik_group != NULL) {
+   CK_STAILQ_FOREACH(ifgm, &kif->pfik_group->ifg_members,
+   ifgm_next) {
+   tmpkif = (struct pfi_kif *)ifgm->ifgm_ifp->if_pf_kif;
+   if (tmpkif == NULL)
+   continue;
+
+   tmpkif->pfik_flags |= kif->pfik_flags;
+   }
+   }
 
/* again for all groups kif is member of */
if (kif->pfik_ifp != NULL) {
___
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: 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-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: r357051 - head/sys/dev/bge

2020-01-23 Thread Ian Lepore
On Thu, 2020-01-23 at 15:05 -0800, Gleb Smirnoff wrote:
> 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.
> 

That sounds every bit as horrible and out-of-place as the recent hack
(and it does feel very much like a horrible hack) that put network-
specific code into the guts of interrupt dispatching.

-- Ian


___
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: 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-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: r357062 - head/share/man/man9

2020-01-23 Thread John Baldwin
Author: jhb
Date: Thu Jan 23 23:36:58 2020
New Revision: 357062
URL: https://svnweb.freebsd.org/changeset/base/357062

Log:
  Correct the return types of fueword*().
  
  MFC after:1 week
  Sponsored by: DARPA

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

Modified: head/share/man/man9/fetch.9
==
--- head/share/man/man9/fetch.9 Thu Jan 23 22:13:41 2020(r357061)
+++ head/share/man/man9/fetch.9 Thu Jan 23 23:36:58 2020(r357062)
@@ -34,7 +34,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd April 17, 2018
+.Dd January 23, 2020
 .Dt FETCH 9
 .Os
 .Sh NAME
@@ -61,11 +61,11 @@
 .Fn fuword32 "volatile const void *base"
 .Ft int64_t
 .Fn fuword64 "volatile const void *base"
-.Ft long
+.Ft int
 .Fn fueword "volatile const void *base" "long *val"
-.Ft int32_t
+.Ft int
 .Fn fueword32 "volatile const void *base" "int32_t *val"
-.Ft int64_t
+.Ft int
 .Fn fueword64 "volatile const void *base" "int64_t *val"
 .In sys/resourcevar.h
 .Sh DESCRIPTION
___
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: r357063 - head/sys/x86/cpufreq

2020-01-23 Thread Conrad Meyer
Author: cem
Date: Thu Jan 23 23:52:57 2020
New Revision: 357063
URL: https://svnweb.freebsd.org/changeset/base/357063

Log:
  cpufreq(4): Fix missing MODULE_DEPEND on hwpstate_intel
  
  DRIVER_MODULE does not actually define a MODULE_VERSION, which is required
  to satisfy a MODULE_DEPENDency.  Declare one explicitly in
  hwpstate_intel(4).
  
  Reported by:  flo
  X-MFC-With:   r357002

Modified:
  head/sys/x86/cpufreq/hwpstate_intel.c

Modified: head/sys/x86/cpufreq/hwpstate_intel.c
==
--- head/sys/x86/cpufreq/hwpstate_intel.c   Thu Jan 23 23:36:58 2020
(r357062)
+++ head/sys/x86/cpufreq/hwpstate_intel.c   Thu Jan 23 23:52:57 2020
(r357063)
@@ -106,6 +106,7 @@ static driver_t hwpstate_intel_driver = {
 
 DRIVER_MODULE(hwpstate_intel, cpu, hwpstate_intel_driver,
 hwpstate_intel_devclass, NULL, NULL);
+MODULE_VERSION(hwpstate_intel, 1);
 
 static int
 intel_hwp_dump_sysctl_handler(SYSCTL_HANDLER_ARGS)
___
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: r357051 - head/sys/dev/bge

2020-01-23 Thread Ryan Stone
On Thu, Jan 23, 2020 at 6:05 PM Gleb Smirnoff  wrote:
>
> 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.

Why on earth is it done that way rather than putting the network epoch
enter/exit in ether_input?  I'm with Ian; this sounds like a huge
layering violation.
___
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: 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-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: 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-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: r357065 - head/lib/libc/stdlib

2020-01-23 Thread Conrad Meyer
Author: cem
Date: Fri Jan 24 01:32:16 2020
New Revision: 357065
URL: https://svnweb.freebsd.org/changeset/base/357065

Log:
  random(3): Abstract state into a single context object
  
  No functional change.
  
  Reviewed by:  kevans, markm
  Differential Revision:https://reviews.freebsd.org/D23288

Modified:
  head/lib/libc/stdlib/random.c

Modified: head/lib/libc/stdlib/random.c
==
--- head/lib/libc/stdlib/random.c   Fri Jan 24 01:00:28 2020
(r357064)
+++ head/lib/libc/stdlib/random.c   Fri Jan 24 01:32:16 2020
(r357065)
@@ -144,6 +144,19 @@ __FBSDID("$FreeBSD$");
 static const int degrees[MAX_TYPES] =  { DEG_0, DEG_1, DEG_2, DEG_3, DEG_4 };
 static const int seps [MAX_TYPES] ={ SEP_0, SEP_1, SEP_2, SEP_3, SEP_4 };
 
+/* A full instance of the random(3) generator. */
+struct random_state {
+   uint32_t*rst_fptr;
+   uint32_t*rst_rptr;
+   uint32_t*rst_state;
+   int rst_type;
+   int rst_deg;
+   int rst_sep;
+   uint32_t*rst_end_ptr;
+   /* Flexible array member must be last. */
+   uint32_trst_randtbl[];
+};
+
 /*
  * Initially, everything is set up as if from:
  *
@@ -157,52 +170,58 @@ static const int seps [MAX_TYPES] =   { SEP_0, SEP_1, 
SE
  *
  * MAX_TYPES * (rptr - state) + TYPE_3 == TYPE_3.
  */
+static struct random_state implicit = {
+   .rst_randtbl = {
+   TYPE_3,
+   0x2cf41758, 0x27bb3711, 0x4916d4d1, 0x7b02f59f, 0x9b8e28eb, 
0xc0e80269,
+   0x696f5c16, 0x878f1ff5, 0x52d9c07f, 0x916a06cd, 0xb50b3a20, 
0x2776970a,
+   0xee4eb2a6, 0xe94640ec, 0xb1d65612, 0x9d1ed968, 0x1043f6b7, 
0xa3432a76,
+   0x17eacbb9, 0x3c09e2eb, 0x4f8c2b3,  0x708a1f57, 0xee341814, 
0x95d0e4d2,
+   0xb06f216c, 0x8bd2e72e, 0x8f7c38d7, 0xcfc6a8fc, 0x2a59495,  
0xa20d2a69,
+   0xe29d12d1
+   },
 
-static uint32_t randtbl[DEG_3 + 1] = {
-   TYPE_3,
-   0x2cf41758, 0x27bb3711, 0x4916d4d1, 0x7b02f59f, 0x9b8e28eb, 0xc0e80269,
-   0x696f5c16, 0x878f1ff5, 0x52d9c07f, 0x916a06cd, 0xb50b3a20, 0x2776970a,
-   0xee4eb2a6, 0xe94640ec, 0xb1d65612, 0x9d1ed968, 0x1043f6b7, 0xa3432a76,
-   0x17eacbb9, 0x3c09e2eb, 0x4f8c2b3,  0x708a1f57, 0xee341814, 0x95d0e4d2,
-   0xb06f216c, 0x8bd2e72e, 0x8f7c38d7, 0xcfc6a8fc, 0x2a59495,  0xa20d2a69,
-   0xe29d12d1
+   /*
+* fptr and rptr are two pointers into the state info, a front and a 
rear
+* pointer.  These two pointers are always rand_sep places aparts, as 
they
+* cycle cyclically through the state information.  (Yes, this does 
mean we
+* could get away with just one pointer, but the code for random() is 
more
+* efficient this way).  The pointers are left positioned as they would 
be
+* from the call
+*
+*  initstate(1, randtbl, 128);
+*
+* (The position of the rear pointer, rptr, is really 0 (as explained 
above
+* in the initialization of randtbl) because the state table pointer is 
set
+* to point to randtbl[1] (as explained below).
+*/
+   .rst_fptr = &implicit.rst_randtbl[SEP_3 + 1],
+   .rst_rptr = &implicit.rst_randtbl[1],
+
+   /*
+* The following things are the pointer to the state information table, 
the
+* type of the current generator, the degree of the current polynomial 
being
+* used, and the separation between the two pointers.  Note that for 
efficiency
+* of random(), we remember the first location of the state 
information, not
+* the zeroeth.  Hence it is valid to access state[-1], which is used to
+* store the type of the R.N.G.  Also, we remember the last location, 
since
+* this is more efficient than indexing every time to find the address 
of
+* the last element to see if the front and rear pointers have wrapped.
+*/
+   .rst_state = &implicit.rst_randtbl[1],
+   .rst_type = TYPE_3,
+   .rst_deg = DEG_3,
+   .rst_sep = SEP_3,
+   .rst_end_ptr = &implicit.rst_randtbl[DEG_3 + 1],
 };
 
 /*
- * fptr and rptr are two pointers into the state info, a front and a rear
- * pointer.  These two pointers are always rand_sep places aparts, as they
- * cycle cyclically through the state information.  (Yes, this does mean we
- * could get away with just one pointer, but the code for random() is more
- * efficient this way).  The pointers are left positioned as they would be
- * from the call
- *
- * initstate(1, randtbl, 128);
- *
- * (The position of the rear pointer, rptr, is really 0 (as explained above
- * in the initialization of randtbl) because the state table pointer is set
- * to point to randtbl[1] (as explained below).
+ * This is the same low quality PRNG used in rand(3) in FreeBSD 12 and prior.
+ * It may be

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

2020-01-23 Thread Ryan Stone
On Thu, Jan 23, 2020 at 8:25 PM Gleb Smirnoff  wrote:
> 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.

Epoch is a synchronization primitive, but the net_epoch is absolutely
a part of the networking layer.  If we need better batching then the
correct solution is to introduce a batched interface for drivers to
push packets up the stack, not to mess around at the interrupt layer.

Note that the only reason why this works for mlx4/mlx5 is that
linuxkpi *always* requests a INTR_TYPE_NET no matter what driver is
running.  This means that all drm graphics driver interrupts are now
running under the net_epoch:

https://svnweb.freebsd.org/base/head/sys/compat/linuxkpi/common/include/linux/interrupt.h?revision=352205&view=markup#l103
___
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: r357066 - head/lib/libc/stdlib

2020-01-23 Thread Conrad Meyer
Author: cem
Date: Fri Jan 24 01:39:29 2020
New Revision: 357066
URL: https://svnweb.freebsd.org/changeset/base/357066

Log:
  random(3): Abstract routines into _r versions on explicit state
  
  The existing APIs simply pass the implicit global state to the _r variants.
  
  No functional change.
  
  Note that these routines are not exported from libc and are not intended to be
  exported.  If someone wished to export them from libc (which I would
  discourage), they should first be modified to match the inconsistent parameter
  type / order of the glibc public interfaces of the same names.
  
  I know Ravi will ask, so: the eventual goal of this series is to replace
  rand(3) with the implementation from random(3) (D23290).  However, I'd like to
  wait a bit longer on that one to see if more feedback emerges.
  
  Reviewed by:  kevans, markm
  Differential Revision:https://reviews.freebsd.org/D23289

Added:
  head/lib/libc/stdlib/random.h   (contents, props changed)
Modified:
  head/lib/libc/stdlib/random.c

Modified: head/lib/libc/stdlib/random.c
==
--- head/lib/libc/stdlib/random.c   Fri Jan 24 01:32:16 2020
(r357065)
+++ head/lib/libc/stdlib/random.c   Fri Jan 24 01:39:29 2020
(r357066)
@@ -38,10 +38,13 @@ __FBSDID("$FreeBSD$");
 #include "namespace.h"
 #include 
 #include 
+#include 
 #include 
 #include 
 #include "un-namespace.h"
 
+#include "random.h"
+
 /*
  * random.c:
  *
@@ -144,19 +147,6 @@ __FBSDID("$FreeBSD$");
 static const int degrees[MAX_TYPES] =  { DEG_0, DEG_1, DEG_2, DEG_3, DEG_4 };
 static const int seps [MAX_TYPES] ={ SEP_0, SEP_1, SEP_2, SEP_3, SEP_4 };
 
-/* A full instance of the random(3) generator. */
-struct random_state {
-   uint32_t*rst_fptr;
-   uint32_t*rst_rptr;
-   uint32_t*rst_state;
-   int rst_type;
-   int rst_deg;
-   int rst_sep;
-   uint32_t*rst_end_ptr;
-   /* Flexible array member must be last. */
-   uint32_trst_randtbl[];
-};
-
 /*
  * Initially, everything is set up as if from:
  *
@@ -170,7 +160,7 @@ struct random_state {
  *
  * MAX_TYPES * (rptr - state) + TYPE_3 == TYPE_3.
  */
-static struct random_state implicit = {
+static struct __random_state implicit = {
.rst_randtbl = {
TYPE_3,
0x2cf41758, 0x27bb3711, 0x4916d4d1, 0x7b02f59f, 0x9b8e28eb, 
0xc0e80269,
@@ -257,25 +247,31 @@ parkmiller32(uint32_t ctx)
  * for default usage relies on values produced by this routine.
  */
 void
-srandom(unsigned int x)
+srandom_r(struct __random_state *estate, unsigned x)
 {
int i, lim;
 
-   implicit.rst_state[0] = (uint32_t)x;
-   if (implicit.rst_type == TYPE_0)
+   estate->rst_state[0] = (uint32_t)x;
+   if (estate->rst_type == TYPE_0)
lim = NSHUFF;
else {
-   for (i = 1; i < implicit.rst_deg; i++)
-   implicit.rst_state[i] =
-   parkmiller32(implicit.rst_state[i - 1]);
-   implicit.rst_fptr = &implicit.rst_state[implicit.rst_sep];
-   implicit.rst_rptr = &implicit.rst_state[0];
-   lim = 10 * implicit.rst_deg;
+   for (i = 1; i < estate->rst_deg; i++)
+   estate->rst_state[i] =
+   parkmiller32(estate->rst_state[i - 1]);
+   estate->rst_fptr = &estate->rst_state[estate->rst_sep];
+   estate->rst_rptr = &estate->rst_state[0];
+   lim = 10 * estate->rst_deg;
}
for (i = 0; i < lim; i++)
-   (void)random();
+   (void)random_r(estate);
 }
 
+void
+srandom(unsigned x)
+{
+   srandom_r(&implicit, x);
+}
+
 /*
  * srandomdev:
  *
@@ -289,20 +285,20 @@ srandom(unsigned int x)
  * derived from the LC algorithm applied to a fixed seed.
  */
 void
-srandomdev(void)
+srandomdev_r(struct __random_state *estate)
 {
int mib[2];
size_t expected, len;
 
-   if (implicit.rst_type == TYPE_0)
-   len = sizeof(implicit.rst_state[0]);
+   if (estate->rst_type == TYPE_0)
+   len = sizeof(estate->rst_state[0]);
else
-   len = implicit.rst_deg * sizeof(implicit.rst_state[0]);
+   len = estate->rst_deg * sizeof(estate->rst_state[0]);
expected = len;
 
mib[0] = CTL_KERN;
mib[1] = KERN_ARND;
-   if (sysctl(mib, 2, implicit.rst_state, &len, NULL, 0) == -1 ||
+   if (sysctl(mib, 2, estate->rst_state, &len, NULL, 0) == -1 ||
len != expected) {
/*
 * The sysctl cannot fail. If it does fail on some FreeBSD
@@ -313,14 +309,20 @@ srandomdev(void)
abort();
}
 
-   if (implicit.rst_type != TYPE_0) {
-   implicit.rst_fptr = &implicit.rst_state[implicit.rst_sep];
-  

svn commit: r357067 - in head: lib/libbe lib/libbe/tests sbin/bectl

2020-01-23 Thread Kyle Evans
Author: kevans
Date: Fri Jan 24 02:18:09 2020
New Revision: 357067
URL: https://svnweb.freebsd.org/changeset/base/357067

Log:
  Drop "All Rights Reserved" from all libbe/bectl files
  
  I sent out an e-mail on 2020/01/21 with a plan to do this to Kyle, Rob, and
  Wes; all parties have responded in the affirmative that it's OK to drop it
  from these files.

Modified:
  head/lib/libbe/be.c
  head/lib/libbe/be.h
  head/lib/libbe/be_access.c
  head/lib/libbe/be_error.c
  head/lib/libbe/be_impl.h
  head/lib/libbe/be_info.c
  head/lib/libbe/libbe.3
  head/lib/libbe/tests/target_prog.c
  head/sbin/bectl/bectl.8
  head/sbin/bectl/bectl.c

Modified: head/lib/libbe/be.c
==
--- head/lib/libbe/be.c Fri Jan 24 01:39:29 2020(r357066)
+++ head/lib/libbe/be.c Fri Jan 24 02:18:09 2020(r357067)
@@ -2,7 +2,6 @@
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
  *
  * Copyright (c) 2017 Kyle J. Kneitinger 
- * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions

Modified: head/lib/libbe/be.h
==
--- head/lib/libbe/be.h Fri Jan 24 01:39:29 2020(r357066)
+++ head/lib/libbe/be.h Fri Jan 24 02:18:09 2020(r357067)
@@ -2,7 +2,6 @@
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
  *
  * Copyright (c) 2017 Kyle J. Kneitinger 
- * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions

Modified: head/lib/libbe/be_access.c
==
--- head/lib/libbe/be_access.c  Fri Jan 24 01:39:29 2020(r357066)
+++ head/lib/libbe/be_access.c  Fri Jan 24 02:18:09 2020(r357067)
@@ -4,7 +4,6 @@
  * Copyright (c) 2017 Kyle J. Kneitinger 
  * Copyright (c) 2018 Kyle Evans 
  * Copyright (c) 2019 Wes Maag 
- * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions

Modified: head/lib/libbe/be_error.c
==
--- head/lib/libbe/be_error.c   Fri Jan 24 01:39:29 2020(r357066)
+++ head/lib/libbe/be_error.c   Fri Jan 24 02:18:09 2020(r357067)
@@ -2,7 +2,6 @@
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
  *
  * Copyright (c) 2017 Kyle J. Kneitinger 
- * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions

Modified: head/lib/libbe/be_impl.h
==
--- head/lib/libbe/be_impl.hFri Jan 24 01:39:29 2020(r357066)
+++ head/lib/libbe/be_impl.hFri Jan 24 02:18:09 2020(r357067)
@@ -2,7 +2,6 @@
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
  *
  * Copyright (c) 2017 Kyle J. Kneitinger 
- * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions

Modified: head/lib/libbe/be_info.c
==
--- head/lib/libbe/be_info.cFri Jan 24 01:39:29 2020(r357066)
+++ head/lib/libbe/be_info.cFri Jan 24 02:18:09 2020(r357067)
@@ -3,7 +3,6 @@
  *
  * Copyright (c) 2017 Kyle J. Kneitinger 
  * Copyright (c) 2018 Kyle Evans 
- * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions

Modified: head/lib/libbe/libbe.3
==
--- head/lib/libbe/libbe.3  Fri Jan 24 01:39:29 2020(r357066)
+++ head/lib/libbe/libbe.3  Fri Jan 24 02:18:09 2020(r357067)
@@ -2,7 +2,6 @@
 .\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD
 .\"
 .\" Copyright (c) 2017 Kyle Kneitinger
-.\" All rights reserved.
 .\" Copyright (c) 2018 Kyle Evans 
 .\"
 .\" Redistribution and use in source and binary forms, with or without

Modified: head/lib/libbe/tests/target_prog.c
==
--- head/lib/libbe/tests/target_prog.c  Fri Jan 24 01:39:29 2020
(r357066)
+++ head/lib/libbe/tests/target_prog.c  Fri Jan 24 02:18:09 2020
(r357067)
@@ -2,7 +2,6 @@
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
  *
  * Copyright (c) 2019 Rob Wing
- * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions

Modified: head/sbin/bectl/bectl.8
=

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&view=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-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: r357051 - head/sys/dev/bge

2020-01-23 Thread Jeff Roberson

On Thu, 23 Jan 2020, Gleb Smirnoff wrote:


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&view=markup#l103


The historical reason is that linuxkpi was originally made to support ofed 
and there was no real way to get this information from the driver.




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.


While we don't have a policy strictly requiring reviews it is the norm to 
have substantial changes socialized and reviewed.  I appreciate the work 
that you are doing but it likely should've been discussed somewhere 
more publicly.  I apologized if I missed it but I don't see reference to 
anything.


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


Thanks,
Jeff



--
Gleb Smirnoff


___
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: 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-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: r357051 - head/sys/dev/bge

2020-01-23 Thread Jeff Roberson

On Thu, 23 Jan 2020, Gleb Smirnoff wrote:


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


Ok thank you.  Can you tag commits so people can see the discussion?  Was 
it in one I missed?  When I'm committing a long patch series I include the 
link in all of them.


Ryan, are you subscribed to @networking?



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.


I am often surprised at how much cpu time I see on linux spent in RCU free 
processing.  Many of these things are written in such a way that 
everything is cache cold by the time you swing back around.  So the 
callout walk is a giant cold linked list.


Thanks,
Jeff



--
Gleb Smirnoff


___
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: 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-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: r357028 - head/sys/vm

2020-01-23 Thread Alexey Dokuchaev
On Wed, Jan 22, 2020 at 07:33:00PM -1000, Jeff Roberson wrote:
> You may be asking yourself, why did jeff just squish a bunch of code
> around with little functional change.  I could not justify adding more
> complexity to a 900 line function with a handful of gotos.  It is ~300
> lines now.  I tested the whole set together.  I apologize if there are
> bugs.

I'm quite certain folks do appreciate the good work Jeff.  "Reviewed by:
dougm, kib, markj" lines leave very little room for doubt. :-)

./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: r357068 - head/usr.sbin/ntp/libntpevent

2020-01-23 Thread Adrian Chadd
Author: adrian
Date: Fri Jan 24 06:24:40 2020
New Revision: 357068
URL: https://svnweb.freebsd.org/changeset/base/357068

Log:
  [ntp] Don't compile in the ssl routines into libevent if MK_OPENSSL is no
  
  Most of ntpd still handles MK_OPENSSL ok, but the libevent import brought
  in the SSL bufferevent routines without checking MK_OPENSSL.
  
  This doesn't completely fix WITHOUT_CRYPTO=YES building, but hey, it's one
  less broken thing.

Modified:
  head/usr.sbin/ntp/libntpevent/Makefile

Modified: head/usr.sbin/ntp/libntpevent/Makefile
==
--- head/usr.sbin/ntp/libntpevent/Makefile  Fri Jan 24 02:18:09 2020
(r357067)
+++ head/usr.sbin/ntp/libntpevent/Makefile  Fri Jan 24 06:24:40 2020
(r357068)
@@ -1,15 +1,21 @@
 # $FreeBSD$
 
+.include 
+
 .PATH: ${SRCTOP}/contrib/libevent
 
 LIB= ntpevent
 INTERNALLIB=
 
-SRCS=  buffer.c bufferevent.c bufferevent_filter.c bufferevent_openssl.c \
+SRCS=  buffer.c bufferevent.c bufferevent_filter.c \
bufferevent_pair.c epoll.c evdns.c event.c event_tagging.c \
evmap.c evport.c evrpc.c evthread.c evthread_pthread.c evutil.c \
evutil_rand.c evutil_time.c http.c kqueue.c listener.c log.c poll.c \
select.c signal.c strlcpy.c
+
+.if ${MK_OPENSSL} != "no"
+SRCS+= bufferevent_openssl.c
+.endif
 
 .if ${MACHINE_ARCH} == "i386"
 NTP_ATOMIC=x86_32
___
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: r357069 - head/sys/kern

2020-01-23 Thread Mateusz Guzik
Author: mjg
Date: Fri Jan 24 07:42:57 2020
New Revision: 357069
URL: https://svnweb.freebsd.org/changeset/base/357069

Log:
  lockmgr: don't touch the lock past unlock
  
  This evens it up with other locking primitives.
  
  Note lock profiling still touches the lock, which again is in line with the
  rest.
  
  Reviewed by:  jeff
  Differential Revision:https://reviews.freebsd.org/D23343

Modified:
  head/sys/kern/kern_lock.c

Modified: head/sys/kern/kern_lock.c
==
--- head/sys/kern/kern_lock.c   Fri Jan 24 06:24:40 2020(r357068)
+++ head/sys/kern/kern_lock.c   Fri Jan 24 07:42:57 2020(r357069)
@@ -209,7 +209,6 @@ static void
 lockmgr_note_shared_release(struct lock *lk, const char *file, int line)
 {
 
-   LOCKSTAT_PROFILE_RELEASE_RWLOCK(lockmgr__release, lk, LOCKSTAT_READER);
WITNESS_UNLOCK(&lk->lock_object, 0, file, line);
LOCK_LOG_LOCK("SUNLOCK", &lk->lock_object, 0, 0, file, line);
TD_LOCKS_DEC(curthread);
@@ -234,11 +233,12 @@ static void
 lockmgr_note_exclusive_release(struct lock *lk, const char *file, int line)
 {
 
-   LOCKSTAT_PROFILE_RELEASE_RWLOCK(lockmgr__release, lk, LOCKSTAT_WRITER);
+   if (LK_HOLDER(lk->lk_lock) != LK_KERNPROC) {
+   WITNESS_UNLOCK(&lk->lock_object, LOP_EXCLUSIVE, file, line);
+   TD_LOCKS_DEC(curthread);
+   }
LOCK_LOG_LOCK("XUNLOCK", &lk->lock_object, 0, lk->lk_recurse, file,
line);
-   WITNESS_UNLOCK(&lk->lock_object, LOP_EXCLUSIVE, file, line);
-   TD_LOCKS_DEC(curthread);
 }
 
 static __inline struct thread *
@@ -388,7 +388,7 @@ retry_sleepq:
break;
}
 
-   lockmgr_note_shared_release(lk, file, line);
+   LOCKSTAT_PROFILE_RELEASE_RWLOCK(lockmgr__release, lk, LOCKSTAT_READER);
return (wakeup_swapper);
 }
 
@@ -924,6 +924,7 @@ lockmgr_upgrade(struct lock *lk, u_int flags, struct l
 * We have been unable to succeed in upgrading, so just
 * give up the shared lock.
 */
+   lockmgr_note_shared_release(lk, file, line);
wakeup_swapper |= wakeupshlk(lk, file, line);
error = lockmgr_xlock_hard(lk, flags, ilk, file, line, lwa);
flags &= ~LK_INTERLOCK;
@@ -1034,11 +1035,6 @@ lockmgr_xunlock_hard(struct lock *lk, uintptr_t x, u_i
 */
if (LK_HOLDER(x) == LK_KERNPROC)
tid = LK_KERNPROC;
-   else {
-   WITNESS_UNLOCK(&lk->lock_object, LOP_EXCLUSIVE, file, line);
-   TD_LOCKS_DEC(curthread);
-   }
-   LOCK_LOG_LOCK("XUNLOCK", &lk->lock_object, 0, lk->lk_recurse, file, 
line);
 
/*
 * The lock is held in exclusive mode.
@@ -1135,16 +1131,18 @@ lockmgr_unlock_fast_path(struct lock *lk, u_int flags,
_lockmgr_assert(lk, KA_LOCKED, file, line);
x = lk->lk_lock;
if (__predict_true(x & LK_SHARE) != 0) {
+   lockmgr_note_shared_release(lk, file, line);
if (lockmgr_sunlock_try(lk, &x)) {
-   lockmgr_note_shared_release(lk, file, line);
+   LOCKSTAT_PROFILE_RELEASE_RWLOCK(lockmgr__release, lk, 
LOCKSTAT_READER);
} else {
return (lockmgr_sunlock_hard(lk, x, flags, ilk, file, 
line));
}
} else {
tid = (uintptr_t)curthread;
+   lockmgr_note_exclusive_release(lk, file, line);
if (!lockmgr_recursed(lk) &&
atomic_cmpset_rel_ptr(&lk->lk_lock, tid, LK_UNLOCKED)) {
-   lockmgr_note_exclusive_release(lk, file, line);
+   LOCKSTAT_PROFILE_RELEASE_RWLOCK(lockmgr__release, lk, 
LOCKSTAT_WRITER);
} else {
return (lockmgr_xunlock_hard(lk, x, flags, ilk, file, 
line));
}
@@ -1221,16 +1219,18 @@ lockmgr_unlock(struct lock *lk)
_lockmgr_assert(lk, KA_LOCKED, file, line);
x = lk->lk_lock;
if (__predict_true(x & LK_SHARE) != 0) {
+   lockmgr_note_shared_release(lk, file, line);
if (lockmgr_sunlock_try(lk, &x)) {
-   lockmgr_note_shared_release(lk, file, line);
+   LOCKSTAT_PROFILE_RELEASE_RWLOCK(lockmgr__release, lk, 
LOCKSTAT_READER);
} else {
return (lockmgr_sunlock_hard(lk, x, LK_RELEASE, NULL, 
file, line));
}
} else {
tid = (uintptr_t)curthread;
+   lockmgr_note_exclusive_release(lk, file, line);
if (!lockmgr_recursed(lk) &&
atomic_cmpset_rel_ptr(&lk->lk_lock, tid, LK_UNLOCKED)) {
-   lockmgr_note_exclusive_release(lk, file, line);
+   LOCKSTAT_PROFILE_RELEASE_RWLOCK(lockmgr__release, lk, 
LOCKSTAT_WRITER);
} else {
return (lockmgr_xunlock_

svn commit: r357070 - head/sys/kern

2020-01-23 Thread Mateusz Guzik
Author: mjg
Date: Fri Jan 24 07:44:25 2020
New Revision: 357070
URL: https://svnweb.freebsd.org/changeset/base/357070

Log:
  vfs: stop unlocking the vnode upfront in vput
  
  Doing so runs into races with filesystems which make half-constructed vnodes
  visible to other users, while depending on the chain vput -> vinactive ->
  vrecycle to be executed without dropping the vnode lock.
  
  Impediments for making this work got cleared up (notably vop_unlock_post now
  does not do anything and lockmgr stops touching the lock after the final
  write). Stacked filesystems keep vhold/vdrop across unlock, which arguably can
  now be eliminated.
  
  Reviewed by:  jeff
  Differential Revision:https://reviews.freebsd.org/D23344

Modified:
  head/sys/kern/vfs_subr.c

Modified: head/sys/kern/vfs_subr.c
==
--- head/sys/kern/vfs_subr.cFri Jan 24 07:42:57 2020(r357069)
+++ head/sys/kern/vfs_subr.cFri Jan 24 07:44:25 2020(r357070)
@@ -3088,6 +3088,11 @@ enum vputx_op { VPUTX_VRELE, VPUTX_VPUT, VPUTX_VUNREF 
  * Decrement the use and hold counts for a vnode.
  *
  * See an explanation near vget() as to why atomic operation is safe.
+ *
+ * XXX Some filesystems pass in an exclusively locked vnode and strongly depend
+ * on the lock being held all the way until VOP_INACTIVE. This in particular
+ * happens with UFS which adds half-constructed vnodes to the hash, where they
+ * can be found by other code.
  */
 static void
 vputx(struct vnode *vp, enum vputx_op func)
@@ -3097,6 +3102,8 @@ vputx(struct vnode *vp, enum vputx_op func)
KASSERT(vp != NULL, ("vputx: null vp"));
if (func == VPUTX_VUNREF)
ASSERT_VOP_LOCKED(vp, "vunref");
+   else if (func == VPUTX_VPUT)
+   ASSERT_VOP_LOCKED(vp, "vput");
ASSERT_VI_UNLOCKED(vp, __func__);
VNASSERT(vp->v_holdcnt > 0 && vp->v_usecount > 0, vp,
("%s: wrong ref counts", __func__));
@@ -3112,22 +3119,19 @@ vputx(struct vnode *vp, enum vputx_op func)
 * count which provides liveness of the vnode, in which case we
 * have to vdrop.
 */
-   if (!refcount_release(&vp->v_usecount))
+   if (!refcount_release(&vp->v_usecount)) {
+   if (func == VPUTX_VPUT)
+   VOP_UNLOCK(vp);
return;
+   }
VI_LOCK(vp);
v_decr_devcount(vp);
/*
 * By the time we got here someone else might have transitioned
 * the count back to > 0.
 */
-   if (vp->v_usecount > 0) {
-   vdropl(vp);
-   return;
-   }
-   if (vp->v_iflag & VI_DOINGINACT) {
-   vdropl(vp);
-   return;
-   }
+   if (vp->v_usecount > 0 || vp->v_iflag & VI_DOINGINACT)
+   goto out;
 
/*
 * Check if the fs wants to perform inactive processing. Note we
@@ -3137,10 +3141,8 @@ vputx(struct vnode *vp, enum vputx_op func)
 * here but to drop our hold count.
 */
if (__predict_false(VN_IS_DOOMED(vp)) ||
-   VOP_NEED_INACTIVE(vp) == 0) {
-   vdropl(vp);
-   return;
-   }
+   VOP_NEED_INACTIVE(vp) == 0)
+   goto out;
 
/*
 * We must call VOP_INACTIVE with the node locked. Mark
@@ -3153,8 +3155,12 @@ vputx(struct vnode *vp, enum vputx_op func)
VI_LOCK(vp);
break;
case VPUTX_VPUT:
-   error = VOP_LOCK(vp, LK_EXCLUSIVE | LK_INTERLOCK | LK_NOWAIT);
-   VI_LOCK(vp);
+   error = 0;
+   if (VOP_ISLOCKED(vp) != LK_EXCLUSIVE) {
+   error = VOP_LOCK(vp, LK_UPGRADE | LK_INTERLOCK |
+   LK_NOWAIT);
+   VI_LOCK(vp);
+   }
break;
case VPUTX_VUNREF:
error = 0;
@@ -3177,6 +3183,11 @@ vputx(struct vnode *vp, enum vputx_op func)
} else {
vdropl(vp);
}
+   return;
+out:
+   if (func == VPUTX_VPUT)
+   VOP_UNLOCK(vp);
+   vdropl(vp);
 }
 
 /*
@@ -3194,21 +3205,11 @@ vrele(struct vnode *vp)
  * Release an already locked vnode.  This give the same effects as
  * unlock+vrele(), but takes less time and avoids releasing and
  * re-aquiring the lock (as vrele() acquires the lock internally.)
- *
- * It is an invariant that all VOP_* calls operate on a held vnode.
- * We may be only having an implicit hold stemming from our usecount,
- * which we are about to release. If we unlock the vnode afterwards we
- * open a time window where someone else dropped the last usecount and
- * proceeded to free the vnode before our unlock finished. For this
- * reason we unlock the vnode early. This is a little bit wasteful as
- * it may be the vnode is exclusively locked and inactive processing is
- * needed, in which case we are adding work.
  */

svn commit: r357071 - in head/sys: kern ufs/ffs

2020-01-23 Thread Mateusz Guzik
Author: mjg
Date: Fri Jan 24 07:45:59 2020
New Revision: 357071
URL: https://svnweb.freebsd.org/changeset/base/357071

Log:
  vfs: stop handling VI_OWEINACT in vget
  
  vget is almost always called with LK_SHARED, meaning the flag (if present) is
  almost guaranteed to get cleared. Stop handling it in the first place and
  instead let the thread which wanted to do inactive handle the bumepd usecount.
  
  Reviewed by:  jeff
  Tested by:pho
  Differential Revision:https://reviews.freebsd.org/D23184

Modified:
  head/sys/kern/vfs_subr.c
  head/sys/ufs/ffs/ffs_snapshot.c

Modified: head/sys/kern/vfs_subr.c
==
--- head/sys/kern/vfs_subr.cFri Jan 24 07:44:25 2020(r357070)
+++ head/sys/kern/vfs_subr.cFri Jan 24 07:45:59 2020(r357071)
@@ -2860,7 +2860,7 @@ vget(struct vnode *vp, int flags, struct thread *td)
 int
 vget_finish(struct vnode *vp, int flags, enum vgetstate vs)
 {
-   int error, oweinact;
+   int error;
 
VNASSERT((flags & LK_TYPE_MASK) != 0, vp,
("%s: invalid lock operation", __func__));
@@ -2887,8 +2887,6 @@ vget_finish(struct vnode *vp, int flags, enum vgetstat
}
 
if (vs == VGET_USECOUNT) {
-   VNASSERT((vp->v_iflag & VI_OWEINACT) == 0, vp,
-   ("%s: vnode with usecount and VI_OWEINACT set", __func__));
return (0);
}
 
@@ -2904,9 +2902,6 @@ vget_finish(struct vnode *vp, int flags, enum vgetstat
 #else
refcount_release(&vp->v_holdcnt);
 #endif
-   VNODE_REFCOUNT_FENCE_ACQ();
-   VNASSERT((vp->v_iflag & VI_OWEINACT) == 0, vp,
-   ("%s: vnode with usecount and VI_OWEINACT set", __func__));
return (0);
}
 
@@ -2930,25 +2925,11 @@ vget_finish(struct vnode *vp, int flags, enum vgetstat
 #else
refcount_release(&vp->v_holdcnt);
 #endif
-   VNODE_REFCOUNT_FENCE_ACQ();
-   VNASSERT((vp->v_iflag & VI_OWEINACT) == 0, vp,
-   ("%s: vnode with usecount and VI_OWEINACT set",
-   __func__));
VI_UNLOCK(vp);
return (0);
}
-   if ((vp->v_iflag & VI_OWEINACT) == 0) {
-   oweinact = 0;
-   } else {
-   oweinact = 1;
-   vp->v_iflag &= ~VI_OWEINACT;
-   VNODE_REFCOUNT_FENCE_REL();
-   }
v_incr_devcount(vp);
refcount_acquire(&vp->v_usecount);
-   if (oweinact && VOP_ISLOCKED(vp) == LK_EXCLUSIVE &&
-   (flags & LK_NOWAIT) == 0)
-   vinactive(vp);
VI_UNLOCK(vp);
return (0);
 }
@@ -2967,8 +2948,6 @@ vref(struct vnode *vp)
VNODE_REFCOUNT_FENCE_ACQ();
VNASSERT(vp->v_holdcnt > 0, vp,
("%s: active vnode not held", __func__));
-   VNASSERT((vp->v_iflag & VI_OWEINACT) == 0, vp,
-   ("%s: vnode with usecount and VI_OWEINACT set", __func__));
return;
}
VI_LOCK(vp);
@@ -2986,15 +2965,9 @@ vrefl(struct vnode *vp)
VNODE_REFCOUNT_FENCE_ACQ();
VNASSERT(vp->v_holdcnt > 0, vp,
("%s: active vnode not held", __func__));
-   VNASSERT((vp->v_iflag & VI_OWEINACT) == 0, vp,
-   ("%s: vnode with usecount and VI_OWEINACT set", __func__));
return;
}
vholdl(vp);
-   if ((vp->v_iflag & VI_OWEINACT) != 0) {
-   vp->v_iflag &= ~VI_OWEINACT;
-   VNODE_REFCOUNT_FENCE_REL();
-   }
v_incr_devcount(vp);
refcount_acquire(&vp->v_usecount);
 }
@@ -3052,8 +3025,8 @@ vdefer_inactive(struct vnode *vp)
 {
 
ASSERT_VI_LOCKED(vp, __func__);
-   VNASSERT(vp->v_iflag & VI_OWEINACT, vp,
-   ("%s: vnode without VI_OWEINACT", __func__));
+   VNASSERT(vp->v_holdcnt > 0, vp,
+   ("%s: vnode without hold count", __func__));
if (VN_IS_DOOMED(vp)) {
vdropl(vp);
return;
@@ -3063,6 +3036,11 @@ vdefer_inactive(struct vnode *vp)
vdropl(vp);
return;
}
+   if (vp->v_usecount > 0) {
+   vp->v_iflag &= ~VI_OWEINACT;
+   vdropl(vp);
+   return;
+   }
vlazy(vp);
vp->v_iflag |= VI_DEFINACT;
VI_UNLOCK(vp);
@@ -3070,11 +3048,10 @@ vdefer_inactive(struct vnode *vp)
 }
 
 static void
-vdefer_inactive_cond(struct vnode *vp)
+vdefer_inactive_unlocked(struct vnode *vp)
 {
 
VI_LOCK(vp);
-   VNASSERT(vp->v_holdcnt > 0, vp, ("vnode without hold count"));
if ((vp->v_iflag & VI_OWEINACT) == 0) {
vdropl(vp);
return;
@@ -3173,15 +3150,12 @@ vputx(struct vnode *vp, enum vputx_op func)
VNASSERT(vp->v_usecount == 0 || (vp->v_iflag & VI_OWEINACT) == 0, vp,
("vnode with usecount an

svn commit: r357072 - head/sys/kern

2020-01-23 Thread Mateusz Guzik
Author: mjg
Date: Fri Jan 24 07:47:44 2020
New Revision: 357072
URL: https://svnweb.freebsd.org/changeset/base/357072

Log:
  vfs: allow v_usecount to transition 0->1 without the interlock
  
  There is nothing to do but to bump the count even during said transition.
  There are 2 places which can do it:
  - vget only does this after locking the vnode, meaning there is no change in
contract versus inactive or reclamantion
  - vref only ever did it with the interlock held which did not protect against
either (that is, it would always succeed)
  
  VCHR vnodes retain special casing due to the need to maintain dev use count.
  
  Reviewed by:  jeff, kib
  Tested by:pho (previous version)
  Differential Revision:https://reviews.freebsd.org/D23185

Modified:
  head/sys/kern/vfs_subr.c

Modified: head/sys/kern/vfs_subr.c
==
--- head/sys/kern/vfs_subr.cFri Jan 24 07:45:59 2020(r357071)
+++ head/sys/kern/vfs_subr.cFri Jan 24 07:47:44 2020(r357072)
@@ -2826,11 +2826,10 @@ v_decr_devcount(struct vnode *vp)
  * see doomed vnodes.  If inactive processing was delayed in
  * vput try to do it here.
  *
- * usecount is manipulated using atomics without holding any locks,
- * except when transitioning 0->1 in which case the interlock is held.
-
- * holdcnt is manipulated using atomics without holding any locks,
- * except when transitioning 1->0 in which case the interlock is held.
+ * usecount is manipulated using atomics without holding any locks.
+ *
+ * holdcnt can be manipulated using atomics without holding any locks,
+ * except when transitioning 1<->0, in which case the interlock is held.
  */
 enum vgetstate
 vget_prep(struct vnode *vp)
@@ -2857,10 +2856,46 @@ vget(struct vnode *vp, int flags, struct thread *td)
return (vget_finish(vp, flags, vs));
 }
 
+static int __noinline
+vget_finish_vchr(struct vnode *vp)
+{
+
+   VNASSERT(vp->v_type == VCHR, vp, ("type != VCHR)"));
+
+   /*
+* See the comment in vget_finish before usecount bump.
+*/
+   if (refcount_acquire_if_not_zero(&vp->v_usecount)) {
+#ifdef INVARIANTS
+   int old = atomic_fetchadd_int(&vp->v_holdcnt, -1);
+   VNASSERT(old > 0, vp, ("%s: wrong hold count %d", __func__, 
old));
+#else
+   refcount_release(&vp->v_holdcnt);
+#endif
+   return (0);
+   }
+
+   VI_LOCK(vp);
+   if (refcount_acquire_if_not_zero(&vp->v_usecount)) {
+#ifdef INVARIANTS
+   int old = atomic_fetchadd_int(&vp->v_holdcnt, -1);
+   VNASSERT(old > 1, vp, ("%s: wrong hold count %d", __func__, 
old));
+#else
+   refcount_release(&vp->v_holdcnt);
+#endif
+   VI_UNLOCK(vp);
+   return (0);
+   }
+   v_incr_devcount(vp);
+   refcount_acquire(&vp->v_usecount);
+   VI_UNLOCK(vp);
+   return (0);
+}
+
 int
 vget_finish(struct vnode *vp, int flags, enum vgetstate vs)
 {
-   int error;
+   int error, old;
 
VNASSERT((flags & LK_TYPE_MASK) != 0, vp,
("%s: invalid lock operation", __func__));
@@ -2890,69 +2925,106 @@ vget_finish(struct vnode *vp, int flags, enum vgetstat
return (0);
}
 
+   if (__predict_false(vp->v_type == VCHR))
+   return (vget_finish_vchr(vp));
+
/*
 * We hold the vnode. If the usecount is 0 it will be utilized to keep
 * the vnode around. Otherwise someone else lended their hold count and
 * we have to drop ours.
 */
-   if (refcount_acquire_if_not_zero(&vp->v_usecount)) {
+   old = atomic_fetchadd_int(&vp->v_usecount, 1);
+   VNASSERT(old >= 0, vp, ("%s: wrong use count %d", __func__, old));
+   if (old != 0) {
 #ifdef INVARIANTS
-   int old = atomic_fetchadd_int(&vp->v_holdcnt, -1);
+   old = atomic_fetchadd_int(&vp->v_holdcnt, -1);
VNASSERT(old > 1, vp, ("%s: wrong hold count %d", __func__, 
old));
 #else
refcount_release(&vp->v_holdcnt);
 #endif
-   return (0);
}
+   return (0);
+}
 
+/*
+ * Increase the reference (use) and hold count of a vnode.
+ * This will also remove the vnode from the free list if it is presently free.
+ */
+static void __noinline
+vref_vchr(struct vnode *vp, bool interlock)
+{
+
/*
-* We don't guarantee that any particular close will
-* trigger inactive processing so just make a best effort
-* here at preventing a reference to a removed file.  If
-* we don't succeed no harm is done.
-*
-* Upgrade our holdcnt to a usecount.
+* See the comment in vget_finish before usecount bump.
 */
-   VI_LOCK(vp);
-   /*
-* See the previous section. By the time we get here we may find
-* ourselves in the same spot.
-*/
+   if (!interlock) {
+   if (refc

svn commit: r357073 - head/sys/vm

2020-01-23 Thread Doug Moore
Author: dougm
Date: Fri Jan 24 07:48:11 2020
New Revision: 357073
URL: https://svnweb.freebsd.org/changeset/base/357073

Log:
  Most uses of vm_map_clip_start follow a call to vm_map_lookup. Define
  an inline function vm_map_lookup_clip_start that invokes them both and
  use it in places that invoke both. Drop a couple of local variables
  made unnecessary by this function.
  
  Reviewed by:  markj
  Tested by:pho
  Differential Revision:https://reviews.freebsd.org/D22987

Modified:
  head/sys/vm/vm_map.c

Modified: head/sys/vm/vm_map.c
==
--- head/sys/vm/vm_map.cFri Jan 24 07:47:44 2020(r357072)
+++ head/sys/vm/vm_map.cFri Jan 24 07:48:11 2020(r357073)
@@ -2387,7 +2387,7 @@ vm_map_entry_clone(vm_map_t map, vm_map_entry_t entry)
  * This routine is called only when it is known that
  * the entry must be split.
  */
-static void
+static inline void
 _vm_map_clip_start(vm_map_t map, vm_map_entry_t entry, vm_offset_t start)
 {
vm_map_entry_t new_entry;
@@ -2407,6 +2407,28 @@ _vm_map_clip_start(vm_map_t map, vm_map_entry_t entry,
 }
 
 /*
+ * vm_map_lookup_clip_start:
+ *
+ * Find the entry at or just after 'start', and clip it if 'start' is in
+ * the interior of the entry.  Return entry after 'start', and in
+ * prev_entry set the entry before 'start'.
+ */
+static inline vm_map_entry_t
+vm_map_lookup_clip_start(vm_map_t map, vm_offset_t start,
+vm_map_entry_t *prev_entry)
+{
+   vm_map_entry_t entry;
+
+   if (vm_map_lookup_entry(map, start, prev_entry)) {
+   entry = *prev_entry;
+   vm_map_clip_start(map, entry, start);
+   *prev_entry = vm_map_entry_pred(entry);
+   } else
+   entry = vm_map_entry_succ(*prev_entry);
+   return (entry);
+}
+
+/*
  * vm_map_clip_end:[ internal use only ]
  *
  * Asserts that the given entry ends at or before
@@ -2423,7 +2445,7 @@ _vm_map_clip_start(vm_map_t map, vm_map_entry_t entry,
  * This routine is called only when it is known that
  * the entry must be split.
  */
-static void
+static inline void
 _vm_map_clip_end(vm_map_t map, vm_map_entry_t entry, vm_offset_t end)
 {
vm_map_entry_t new_entry;
@@ -2835,15 +2857,6 @@ vm_map_madvise(
 */
VM_MAP_RANGE_CHECK(map, start, end);
 
-   if (vm_map_lookup_entry(map, start, &entry)) {
-   if (modify_map)
-   vm_map_clip_start(map, entry, start);
-   prev_entry = vm_map_entry_pred(entry);
-   } else {
-   prev_entry = entry;
-   entry = vm_map_entry_succ(entry);
-   }
-
if (modify_map) {
/*
 * madvise behaviors that are implemented in the vm_map_entry.
@@ -2851,8 +2864,9 @@ vm_map_madvise(
 * We clip the vm_map_entry so that behavioral changes are
 * limited to the specified address range.
 */
-   for (; entry->start < end;
-prev_entry = entry, entry = vm_map_entry_succ(entry)) {
+   for (entry = vm_map_lookup_clip_start(map, start, &prev_entry);
+   entry->start < end;
+   prev_entry = entry, entry = vm_map_entry_succ(entry)) {
if ((entry->eflags & MAP_ENTRY_IS_SUB_MAP) != 0)
continue;
 
@@ -2900,6 +2914,8 @@ vm_map_madvise(
 * Since we don't clip the vm_map_entry, we have to clip
 * the vm_object pindex and count.
 */
+   if (!vm_map_lookup_entry(map, start, &entry))
+   entry = vm_map_entry_succ(entry);
for (; entry->start < end;
entry = vm_map_entry_succ(entry)) {
vm_offset_t useEnd, useStart;
@@ -3003,13 +3019,8 @@ vm_map_inherit(vm_map_t map, vm_offset_t start, vm_off
return (KERN_SUCCESS);
vm_map_lock(map);
VM_MAP_RANGE_CHECK(map, start, end);
-   if (vm_map_lookup_entry(map, start, &prev_entry)) {
-   entry = prev_entry;
-   vm_map_clip_start(map, entry, start);
-   prev_entry = vm_map_entry_pred(entry);
-   } else
-   entry = vm_map_entry_succ(prev_entry);
-   for (; entry->start < end;
+   for (entry = vm_map_lookup_clip_start(map, start, &prev_entry);
+   entry->start < end;
prev_entry = entry, entry = vm_map_entry_succ(entry)) {
vm_map_clip_end(map, entry, end);
if ((entry->eflags & MAP_ENTRY_GUARD) == 0 ||
@@ -3732,29 +3743,18 @@ vm_map_entry_delete(vm_map_t map, vm_map_entry_t entry
 int
 vm_map_delete(vm_map_t map, vm_offset_t start, vm_offset_t end)
 {
-   vm_map_entry_t entry;
-   vm_map_entry_t first_entry;
+   vm_map_entry_t entry, next_entry;
 
VM_