Re: svn commit: r347402 - head/sys/modules/ipsec

2019-05-10 Thread Andrey V. Elsukov
On 09.05.2019 22:13, Kyle Evans wrote:
>> there is two IPsec related interfaces that have problem with automatic
>> loading - if_enc and if_ipsec. So, if you add both to the mapping list,
>> this will be useful. CAM enc driver has conflicting name and prevents to
>> automatic loading of if_enc(4). It is probably always build in the
>> kernel, but renaming it into "ses" may break some third-party device
>> drivers.
>>
> 
> I think you want something like [0] to add both of these to the map
> and stop ifconfig(8) from bailing on loading if_enc because 'enc' is
> loaded. This is safe at least for the set of modules currently mapped.
> 
> Thanks,
> 
> Kyle Evans
> 
> [0] https://people.freebsd.org/~kevans/ipsec.diff

It looks good to me.

-- 
WBR, Andrey V. Elsukov



signature.asc
Description: OpenPGP digital signature


svn commit: r347425 - head/tests/sys/sys

2019-05-10 Thread Edward Tomasz Napierala
Author: trasz
Date: Fri May 10 07:46:14 2019
New Revision: 347425
URL: https://svnweb.freebsd.org/changeset/base/347425

Log:
  Add simple regression tests for tree(3).  Those are ATF-ified versions
  of OpenBSD's regress/sys/sys/tree/.
  
  Reviewed by:  ngie
  MFC after:2 weeks
  Sponsored by: Klara Inc.
  Differential Revision:https://reviews.freebsd.org/D20186

Added:
  head/tests/sys/sys/rb_test.c   (contents, props changed)
  head/tests/sys/sys/splay_test.c   (contents, props changed)
Modified:
  head/tests/sys/sys/Makefile

Modified: head/tests/sys/sys/Makefile
==
--- head/tests/sys/sys/Makefile Fri May 10 07:28:58 2019(r347424)
+++ head/tests/sys/sys/Makefile Fri May 10 07:46:14 2019(r347425)
@@ -2,7 +2,7 @@
 
 TESTSDIR=  ${TESTSBASE}/sys/sys
 
-ATF_TESTS_C=   bitstring_test
+ATF_TESTS_C=   bitstring_test rb_test splay_test
 
 WARNS?=5
 

Added: head/tests/sys/sys/rb_test.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tests/sys/sys/rb_test.cFri May 10 07:46:14 2019
(r347425)
@@ -0,0 +1,108 @@
+/* $OpenBSD: rb-test.c,v 1.4 2008/04/13 00:22:17 djm Exp $ */
+/*
+ * Copyright 2002 Niels Provos 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#include 
+
+#include 
+#include 
+
+#include 
+
+struct node {
+   RB_ENTRY(node) node;
+   int key;
+};
+
+RB_HEAD(tree, node) root;
+
+static int
+compare(struct node *a, struct node *b)
+{
+   if (a->key < b->key) return (-1);
+   else if (a->key > b->key) return (1);
+   return (0);
+}
+
+RB_PROTOTYPE(tree, node, node, compare);
+
+RB_GENERATE(tree, node, node, compare);
+
+#define ITER 150
+#define MIN 5
+#define MAX 5000
+
+ATF_TC_WITHOUT_HEAD(rb_test);
+ATF_TC_BODY(rb_test, tc)
+{
+   struct node *tmp, *ins;
+   int i, max, min;
+
+   RB_INIT(&root);
+
+   for (i = 0; i < ITER; i++) {
+   tmp = malloc(sizeof(struct node));
+   ATF_CHECK_MSG(tmp != NULL, "malloc failed");
+   do {
+   tmp->key = arc4random_uniform(MAX-MIN);
+   tmp->key += MIN;
+   } while (RB_FIND(tree, &root, tmp) != NULL);
+   if (i == 0)
+   max = min = tmp->key;
+   else {
+   if (tmp->key > max)
+   max = tmp->key;
+   if (tmp->key < min)
+   min = tmp->key;
+   }
+   ATF_CHECK_EQ(NULL, RB_INSERT(tree, &root, tmp));
+   }
+
+   ins = RB_MIN(tree, &root);
+   ATF_CHECK_EQ(min, ins->key);
+   tmp = ins;
+   ins = RB_MAX(tree, &root);
+   ATF_CHECK_EQ(max, ins->key);
+
+   ATF_CHECK_EQ(tmp, RB_REMOVE(tree, &root, tmp));
+
+   for (i = 0; i < ITER - 1; i++) {
+   tmp = RB_ROOT(&root);
+   ATF_CHECK_MSG(tmp != NULL, "RB_ROOT error");
+   ATF_CHECK_EQ(tmp, RB_REMOVE(tree, &root, tmp));
+   free(tmp);
+   }
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+   ATF_TP_ADD_TC(tp, rb_test);
+
+   return (atf_no_error());
+}

Added: head/tests/sys/sys/splay_test.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tests/sys/sys/splay_test.c Fri May 10 07:46:14 2019
(r347425)
@@ -0,0 +1,1

svn commit: r347426 - head/tests/sys/sys

2019-05-10 Thread Edward Tomasz Napierala
Author: trasz
Date: Fri May 10 08:16:29 2019
New Revision: 347426
URL: https://svnweb.freebsd.org/changeset/base/347426

Log:
  Try to unbreak the build after r347425.
  
  MFC after:2 weeks

Modified:
  head/tests/sys/sys/rb_test.c
  head/tests/sys/sys/splay_test.c

Modified: head/tests/sys/sys/rb_test.c
==
--- head/tests/sys/sys/rb_test.cFri May 10 07:46:14 2019
(r347425)
+++ head/tests/sys/sys/rb_test.cFri May 10 08:16:29 2019
(r347426)
@@ -63,6 +63,8 @@ ATF_TC_BODY(rb_test, tc)
struct node *tmp, *ins;
int i, max, min;
 
+   max = min = 42; /* pacify gcc */
+
RB_INIT(&root);
 
for (i = 0; i < ITER; i++) {

Modified: head/tests/sys/sys/splay_test.c
==
--- head/tests/sys/sys/splay_test.c Fri May 10 07:46:14 2019
(r347425)
+++ head/tests/sys/sys/splay_test.c Fri May 10 08:16:29 2019
(r347426)
@@ -65,6 +65,8 @@ ATF_TC_BODY(splay_test, tc)
 
SPLAY_INIT(&root);
 
+   max = min = 42; /* pacify gcc */
+
for (i = 0; i < ITER; i++) {
tmp = malloc(sizeof(struct node));
ATF_CHECK_MSG(tmp != NULL, "malloc failed");
___
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: r347410 - in head: . sys/amd64/conf sys/arm/conf sys/arm64/conf sys/i386/conf sys/powerpc/conf sys/riscv/conf sys/sparc64/conf

2019-05-10 Thread Alexey Dokuchaev
On Thu, May 09, 2019 at 10:38:15PM +, Andrew Gallatin wrote:
> Author: gallatin
> Date: Thu May  9 22:38:15 2019
> New Revision: 347410
> URL: https://svnweb.freebsd.org/changeset/base/347410
> 
> Log:
>   Remove IPSEC from GENERIC due to performance issues
>   
> @@ -30,7 +30,6 @@ options PREEMPTION  # Enable ...
>  options  VIMAGE  # Subsystem virtualization, e.g. VNET
>  options  INET# InterNETworking
>  options  INET6   # IPv6 communications protocols
> -options  IPSEC   # IP (v4/v6) security
>  options  IPSEC_SUPPORT   # Allow kldload of ipsec and tcpmd5

I've asked this question some two years ago, but no one could answer it
back then, so I'll try again.

What is the reason behind having IPSEC_SUPPORT option instead of no special
option at all?  If I grep for SUPPORT in conf/GENERIC, I see things like
INVARIANT_SUPPORT or IEEE80211_SUPPORT_MESH (with meaningful explanations)
but IPSEC_SUPPORT which, per the comment, "allows to kldload of ipsec and
tcpmd5", is totally beyond me.  Lots of kernel features are/can be loaded
as modules, but we don't have things like SOUND_SUPPORT or USB_SUPPORT.

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


Re: svn commit: r347410 - in head: . sys/amd64/conf sys/arm/conf sys/arm64/conf sys/i386/conf sys/powerpc/conf sys/riscv/conf sys/sparc64/conf

2019-05-10 Thread Andrey V. Elsukov
On 10.05.2019 11:46, Alexey Dokuchaev wrote:
> On Thu, May 09, 2019 at 10:38:15PM +, Andrew Gallatin wrote:
>> Author: gallatin
>> Date: Thu May  9 22:38:15 2019
>> New Revision: 347410
>> URL: https://svnweb.freebsd.org/changeset/base/347410
>>
>> Log:
>>   Remove IPSEC from GENERIC due to performance issues
>>   
>> @@ -30,7 +30,6 @@ optionsPREEMPTION  # Enable ...
>>  options VIMAGE  # Subsystem virtualization, e.g. VNET
>>  options INET# InterNETworking
>>  options INET6   # IPv6 communications protocols
>> -options IPSEC   # IP (v4/v6) security
>>  options IPSEC_SUPPORT   # Allow kldload of ipsec and tcpmd5
> 
> I've asked this question some two years ago, but no one could answer it
> back then, so I'll try again.
> 
> What is the reason behind having IPSEC_SUPPORT option instead of no special
> option at all?  If I grep for SUPPORT in conf/GENERIC, I see things like
> INVARIANT_SUPPORT or IEEE80211_SUPPORT_MESH (with meaningful explanations)
> but IPSEC_SUPPORT which, per the comment, "allows to kldload of ipsec and
> tcpmd5", is totally beyond me.  Lots of kernel features are/can be loaded
> as modules, but we don't have things like SOUND_SUPPORT or USB_SUPPORT.

IPSEC_SUPPORT builds into the kernel PF_KEY domain protocol, that is
required by IPsec implementation to interact with userlevel. Currently
the kernel does not support unregistering of protocol domains. This is
mostly why option IPSEC_SUPPORT was introduced. The second cause -
reduce overhead that IPSEC produces even when it is not used.

-- 
WBR, Andrey V. Elsukov



signature.asc
Description: OpenPGP digital signature


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

2019-05-10 Thread Ruslan Bukin
Author: br
Date: Fri May 10 11:21:57 2019
New Revision: 347427
URL: https://svnweb.freebsd.org/changeset/base/347427

Log:
  RISC-V ISA does not specify how to manage physical memory attributes (PMA).
  So do nothing in pmap_page_set_memattr() and don't panic.
  
  Reviewed by:  markj
  Sponsored by: DARPA, AFRL
  Differential Revision:https://reviews.freebsd.org/D20209

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

Modified: head/sys/riscv/riscv/pmap.c
==
--- head/sys/riscv/riscv/pmap.c Fri May 10 08:16:29 2019(r347426)
+++ head/sys/riscv/riscv/pmap.c Fri May 10 11:21:57 2019(r347427)
@@ -4200,16 +4200,6 @@ pmap_page_set_memattr(vm_page_t m, vm_memattr_t ma)
 {
 
m->md.pv_memattr = ma;
-
-   /*
-* RISCVTODO: Implement the below (from the amd64 pmap)
-* If "m" is a normal page, update its direct mapping.  This update
-* can be relied upon to perform any cache operations that are
-* required for data coherence.
-*/
-   if ((m->flags & PG_FICTITIOUS) == 0 &&
-   PHYS_IN_DMAP(VM_PAGE_TO_PHYS(m)))
-   panic("RISCVTODO: pmap_page_set_memattr");
 }
 
 /*
___
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: r347410 - in head: . sys/amd64/conf sys/arm/conf sys/arm64/conf sys/i386/conf sys/powerpc/conf sys/riscv/conf sys/sparc64/conf

2019-05-10 Thread Slawa Olhovchenkov
On Thu, May 09, 2019 at 10:38:15PM +, Andrew Gallatin wrote:

> Author: gallatin
> Date: Thu May  9 22:38:15 2019
> New Revision: 347410
> URL: https://svnweb.freebsd.org/changeset/base/347410
> 
> Log:
>   Remove IPSEC from GENERIC due to performance issues
>   
>   Having IPSEC compiled into the kernel imposes a non-trivial
>   performance penalty on multi-threaded workloads due to IPSEC
>   refcounting. In my benchmarks of multi-threaded UDP
>   transmit (connected sockets), I've seen a roughly 20% performance
>   penalty when the IPSEC option is included in the kernel (16.8Mpps
>   vs 13.8Mpps with 32 senders on a 14 core / 28 HTT Xeon
>   2697v3)). This is largely due to key_addref() incrementing and
>   decrementing an atomic reference count on the default
>   policy. This cause all CPUs to stall on the same cacheline, as it
>   bounces between different CPUs.
>   
>   Given that relatively few users use ipsec, and that it can be
>   loaded as a module, it seems reasonable to ask those users to
>   load the ipsec module so as to avoid imposing this penalty on the
>   GENERIC kernel. Its my hope that this will make FreeBSD look
>   better in "out of the box" benchmark comparisons with other
>   operating systems.
>   
>   Many thanks to ae for fixing auto-loading of ipsec.ko when
>   ifconfig tries to configure ipsec, and to cy for volunteering
>   to ensure the the racoon ports will load the ipsec.ko module
>   
>   Reviewed by:cem, cy, delphij, gnn, jhb, jpaetzel
>   Differential Revision:  https://reviews.freebsd.org/D20163

pf have ifdef for IPSEC, but don't have support IPSEC_SUPPORT
(netpfil/pf/if_pfsync.c).
___
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: r347429 - head/sbin/ifconfig

2019-05-10 Thread Kyle Evans
Author: kevans
Date: Fri May 10 13:18:22 2019
New Revision: 347429
URL: https://svnweb.freebsd.org/changeset/base/347429

Log:
  ifconfig(8): Add kld mappings for ipsec/enc
  
  Additionally, providing mappings makes the comparison for already loaded
  modules a little more strict. This should have been done at initial
  introduction, but there was no real reason- however, it proves necessary for
  enc which has a standard enc -> if_enc mapping but there also exists an
  'enc' module that's actually CAM. The mapping lets us unambiguously
  determine the correct module.
  
  Discussed with:   ae
  MFC after:4 days

Modified:
  head/sbin/ifconfig/ifconfig.c

Modified: head/sbin/ifconfig/ifconfig.c
==
--- head/sbin/ifconfig/ifconfig.c   Fri May 10 12:33:42 2019
(r347428)
+++ head/sbin/ifconfig/ifconfig.c   Fri May 10 13:18:22 2019
(r347429)
@@ -71,6 +71,7 @@ static const char rcsid[] =
 #ifdef JAIL
 #include 
 #endif
+#include 
 #include 
 #include 
 #include 
@@ -146,6 +147,20 @@ static struct module_map_entry {
.ifname = "vmnet",
.kldname = "if_tuntap",
},
+   {
+   .ifname = "ipsec",
+   .kldname = "ipsec",
+   },
+   {
+   /*
+* This mapping exists because there is a conflicting enc module
+* in CAM.  ifconfig's guessing behavior will attempt to match
+* the ifname to a module as well as if_${ifname} and clash with
+* CAM enc.  This is an assertion of the correct module to load.
+*/
+   .ifname = "enc",
+   .kldname = "if_enc",
+   },
 };
 
 
@@ -1436,6 +1451,7 @@ ifmaybeload(const char *name)
char ifkind[IFNAMSIZ + MOD_PREFIX_LEN], ifname[IFNAMSIZ], *dp;
const char *cp;
struct module_map_entry *mme;
+   bool found;
 
/* loading suppressed by the user */
if (noload)
@@ -1451,16 +1467,18 @@ ifmaybeload(const char *name)
 
/* Either derive it from the map or guess otherwise */
*ifkind = '\0';
+   found = false;
for (i = 0; i < nitems(module_map); ++i) {
mme = &module_map[i];
if (strcmp(mme->ifname, ifname) == 0) {
strlcpy(ifkind, mme->kldname, sizeof(ifkind));
+   found = true;
break;
}
}
 
/* We didn't have an alias for it... we'll guess. */
-   if (*ifkind == '\0') {
+   if (!found) {
/* turn interface and unit into module name */
strlcpy(ifkind, "if_", sizeof(ifkind));
strlcat(ifkind, ifname, sizeof(ifkind));
@@ -1480,8 +1498,12 @@ ifmaybeload(const char *name)
} else {
cp = mstat.name;
}
-   /* already loaded? */
-   if (strcmp(ifname, cp) == 0 ||
+   /*
+* Is it already loaded?  Don't compare with ifname if
+* we were specifically told which kld to use.  Doing
+* so could lead to conflicts not trivially solved.
+*/
+   if ((!found && strcmp(ifname, cp) == 0) ||
strcmp(ifkind, cp) == 0)
return;
}
___
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: r347430 - in head/sys: kern netinet sys

2019-05-10 Thread Andrew Gallatin
Author: gallatin
Date: Fri May 10 13:41:19 2019
New Revision: 347430
URL: https://svnweb.freebsd.org/changeset/base/347430

Log:
  Bind TCP HPTS (pacer) threads to NUMA domains
  
  Bind the TCP pacer threads to NUMA domains and build per-domain
  pacer-thread lookup tables. These tables allow us to use the
  inpcb's NUMA domain information to match an inpcb with a pacer
  thread on the same domain.
  
  The motivation for this is to keep the TCP connection local to a
  NUMA domain as much as possible.
  
  Thanks to jhb for pre-reviewing an earlier version of the patch.
  
  Reviewed by:  rrs
  Sponsored by: Netflix
  Differential Revision:https://reviews.freebsd.org/D20134

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

Modified: head/sys/kern/kern_intr.c
==
--- head/sys/kern/kern_intr.c   Fri May 10 13:18:22 2019(r347429)
+++ head/sys/kern/kern_intr.c   Fri May 10 13:41:19 2019(r347430)
@@ -380,6 +380,25 @@ intr_event_bind_ithread(struct intr_event *ie, int cpu
return (_intr_event_bind(ie, cpu, false, true));
 }
 
+/*
+ * Bind an interrupt event's ithread to the specified cpuset.
+ */
+int
+intr_event_bind_ithread_cpuset(struct intr_event *ie, cpuset_t *cs)
+{
+   lwpid_t id;
+
+   mtx_lock(&ie->ie_lock);
+   if (ie->ie_thread != NULL) {
+   id = ie->ie_thread->it_thread->td_tid;
+   mtx_unlock(&ie->ie_lock);
+   return (cpuset_setthread(id, cs));
+   } else {
+   mtx_unlock(&ie->ie_lock);
+   }
+   return (ENODEV);
+}
+
 static struct intr_event *
 intr_lookup(int irq)
 {

Modified: head/sys/netinet/tcp_hpts.c
==
--- head/sys/netinet/tcp_hpts.c Fri May 10 13:18:22 2019(r347429)
+++ head/sys/netinet/tcp_hpts.c Fri May 10 13:41:19 2019(r347430)
@@ -131,6 +131,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
+#include 
 
 #include 
 #include 
@@ -171,7 +172,7 @@ MALLOC_DEFINE(M_TCPHPTS, "tcp_hpts", "TCP hpts");
 #include 
 static int tcp_bind_threads = 1;
 #else
-static int tcp_bind_threads = 0;
+static int tcp_bind_threads = 2;
 #endif
 TUNABLE_INT("net.inet.tcp.bind_hptss", &tcp_bind_threads);
 
@@ -207,6 +208,13 @@ static int32_t logging_on = 0;
 static int32_t hpts_sleep_max = (NUM_OF_HPTSI_SLOTS - 2);
 static int32_t tcp_hpts_precision = 120;
 
+struct hpts_domain_info {
+   int count;
+   int cpu[MAXCPU];
+};
+
+struct hpts_domain_info hpts_domains[MAXMEMDOM];
+
 SYSCTL_INT(_net_inet_tcp_hpts, OID_AUTO, precision, CTLFLAG_RW,
 &tcp_hpts_precision, 120,
 "Value for PRE() precision of callout");
@@ -1079,8 +1087,10 @@ hpts_random_cpu(struct inpcb *inp){
 static uint16_t
 hpts_cpuid(struct inpcb *inp){
u_int cpuid;
+#ifdef NUMA
+   struct hpts_domain_info *di;
+#endif
 
-
/*
 * If one has been set use it i.e. we want both in and out on the
 * same hpts.
@@ -1103,11 +1113,21 @@ hpts_cpuid(struct inpcb *inp){
 * unknown cpuids to curcpu.  Not the best, but apparently better
 * than defaulting to swi 0.
 */
-   if (inp->inp_flowtype != M_HASHTYPE_NONE) {
+   
+   if (inp->inp_flowtype == M_HASHTYPE_NONE)
+   return (hpts_random_cpu(inp));
+   /*
+* Hash to a thread based on the flowid.  If we are using numa,
+* then restrict the hash to the numa domain where the inp lives.
+*/
+#ifdef NUMA
+   if (tcp_bind_threads == 2 && inp->inp_numa_domain != M_NODOM) {
+   di = &hpts_domains[inp->inp_numa_domain];
+   cpuid = di->cpu[inp->inp_flowid % di->count];
+   } else
+#endif
cpuid = inp->inp_flowid % mp_ncpus;
-   return (cpuid);
-   }
-   cpuid = hpts_random_cpu(inp);
+
return (cpuid);
 #endif
 }
@@ -1781,8 +1801,11 @@ tcp_init_hptsi(void *st)
struct timeval tv;
sbintime_t sb;
struct tcp_hpts_entry *hpts;
+   struct pcpu *pc;
+   cpuset_t cs;
char unit[16];
uint32_t ncpus = mp_ncpus ? mp_ncpus : MAXCPU;
+   int count, domain;
 
tcp_pace.rp_proc = NULL;
tcp_pace.rp_num_hptss = ncpus;
@@ -1861,6 +1884,11 @@ tcp_init_hptsi(void *st)
}
callout_init(&hpts->co, 1);
}
+
+   /* Don't try to bind to NUMA domains if we don't have any */
+   if (vm_ndomains == 1 && tcp_bind_threads == 2)
+   tcp_bind_threads = 0;
+
/*
 * Now lets start ithreads to handle the hptss.
 */
@@ -1875,9 +1903,20 @@ tcp_init_hptsi(void *st)
hpts, i, error);
}
created++;
-   if (tcp_bind_threads) {
+   if (tcp_bind_threads == 1) {
if (intr_event_bind(hpts->ie, i) == 0)

Re: svn commit: r347410 - in head: . sys/amd64/conf sys/arm/conf sys/arm64/conf sys/i386/conf sys/powerpc/conf sys/riscv/conf sys/sparc64/conf

2019-05-10 Thread Andrew Gallatin

On 2019-05-10 08:44, Slawa Olhovchenkov wrote:


pf have ifdef for IPSEC, but don't have support IPSEC_SUPPORT
(netpfil/pf/if_pfsync.c).



Thanks for pointing this out.  It seems like IPSEC_SUPPORT would work 
for this.  I've made a patch, and it compiles and the pf module loads.

However, I have no knowledge of how to test it.  Is this something
that you use, and which you can test?

Thanks,

Drew

diff --git a/sys/netpfil/pf/if_pfsync.c b/sys/netpfil/pf/if_pfsync.c
index 45b1e090f95c..cc06637b862e 100644
--- a/sys/netpfil/pf/if_pfsync.c
+++ b/sys/netpfil/pf/if_pfsync.c
@@ -308,7 +308,7 @@ static void	pfsync_bulk_update(void *);
 static void	pfsync_bulk_fail(void *);
 
 static void	pfsync_detach_ifnet(struct ifnet *);
-#ifdef IPSEC
+#ifdef IPSEC_SUPPORT
 static void	pfsync_update_net_tdb(struct pfsync_tdb *);
 #endif
 static struct pfsync_bucket	*pfsync_get_bucket(struct pfsync_softc *,
@@ -1228,7 +1228,7 @@ pfsync_in_tdb(struct pfsync_pkt *pkt, struct mbuf *m, int offset, int count)
 {
 	int len = count * sizeof(struct pfsync_tdb);
 
-#if defined(IPSEC)
+#if defined(IPSEC_SUPPORT)
 	struct pfsync_tdb *tp;
 	struct mbuf *mp;
 	int offp;
@@ -1249,7 +1249,7 @@ pfsync_in_tdb(struct pfsync_pkt *pkt, struct mbuf *m, int offset, int count)
 	return (len);
 }
 
-#if defined(IPSEC)
+#if defined(IPSEC_SUPPORT)
 /* Update an in-kernel tdb. Silently fail if no tdb is found. */
 static void
 pfsync_update_net_tdb(struct pfsync_tdb *pt)
___
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: r347410 - in head: . sys/amd64/conf sys/arm/conf sys/arm64/conf sys/i386/conf sys/powerpc/conf sys/riscv/conf sys/sparc64/conf

2019-05-10 Thread Kristof Provost

On 10 May 2019, at 8:31, Andrew Gallatin wrote:

On 2019-05-10 08:44, Slawa Olhovchenkov wrote:


pf have ifdef for IPSEC, but don't have support IPSEC_SUPPORT
(netpfil/pf/if_pfsync.c).



Thanks for pointing this out.  It seems like IPSEC_SUPPORT would work 
for this.  I've made a patch, and it compiles and the pf module loads.

However, I have no knowledge of how to test it.  Is this something
that you use, and which you can test?


I suspect this code has not actually been enabled for a long time.
gettdb() doesn’t actually appear to be defined anywhere, so I 
wouldn’t expect it to ever compile.


gettdb() does exist in OpenBSD, so my current guess is that this is just 
an import artefact, and we should `#ifdef OPENBSD` it or something, or 
just remove it completely.


For completeness, and because I never shut up about this: to test pf 
`kldload pfsync`, `cd /usr/tests/sys/netpfil/pf` and `sudo kyua test`


There’s more information in the current edition of the FreeBSD 
journal.


Regards,
Kristof
___
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: r347433 - head/sys/sys

2019-05-10 Thread Doug Moore
Author: dougm
Date: Fri May 10 16:01:25 2019
New Revision: 347433
URL: https://svnweb.freebsd.org/changeset/base/347433

Log:
  A major change to subr_blist.c failed to update all the comments about
  changes to struct fields. Update those now.
  
  Approved by: markj (mentor)
  Differential Revision: https://reviews.freebsd.org/D20227

Modified:
  head/sys/sys/blist.h

Modified: head/sys/sys/blist.h
==
--- head/sys/sys/blist.hFri May 10 15:55:30 2019(r347432)
+++ head/sys/sys/blist.hFri May 10 16:01:25 2019(r347433)
@@ -69,17 +69,17 @@ typedef uint64_tu_daddr_t;  /* unsigned 
disk address *
 #define SWAPBLK_NONE   ((daddr_t)((u_daddr_t)SWAPBLK_MASK + 1))/* flag */
 
 /*
- * Both blmeta and bmu_bitmap MUST be a power of 2 in size.
+ * Both blmeta and bm_bitmap MUST be a power of 2 in size.
  */
 
 typedef struct blmeta {
-   u_daddr_t   bm_bitmap;  /* bitmap if we are a leaf  */
+   u_daddr_t   bm_bitmap;  /* marking unfilled block sets  */
daddr_t bm_bighint; /* biggest contiguous block hint*/
 } blmeta_t;
 
 typedef struct blist {
daddr_t bl_blocks;  /* area of coverage */
-   daddr_t bl_avail;   /* # available blocks */
+   daddr_t bl_avail;   /* # available blocks   */
u_daddr_t   bl_radix;   /* coverage radix   */
daddr_t bl_cursor;  /* next-fit search starts at*/
blmeta_tbl_root[1]; /* root of radix tree   */
___
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: r347440 - head/sys/dev/ahci

2019-05-10 Thread Emmanuel Vadot
Author: manu
Date: Fri May 10 16:43:53 2019
New Revision: 347440
URL: https://svnweb.freebsd.org/changeset/base/347440

Log:
  ahci: Check if bus is cache-coherent
  
  We do this for FDT systems but not for ACPI ones.
  Check the presence of the _CCA attribute.
  
  Sponsored by: Ampere Computing, LLC
  Reviewed by:  andrew
  Differential Revision:https://reviews.freebsd.org/D20144

Modified:
  head/sys/dev/ahci/ahci_generic.c

Modified: head/sys/dev/ahci/ahci_generic.c
==
--- head/sys/dev/ahci/ahci_generic.cFri May 10 16:43:47 2019
(r347439)
+++ head/sys/dev/ahci/ahci_generic.cFri May 10 16:43:53 2019
(r347440)
@@ -89,6 +89,7 @@ ahci_fdt_probe(device_t dev)
 static int
 ahci_acpi_probe(device_t dev)
 {
+   struct ahci_controller *ctlr = device_get_softc(dev);
ACPI_HANDLE h;
 
if ((h = acpi_get_handle(dev)) == NULL)
@@ -98,6 +99,12 @@ ahci_acpi_probe(device_t dev)
pci_get_subclass(dev) == PCIS_STORAGE_SATA &&
pci_get_progif(dev) == PCIP_STORAGE_SATA_AHCI_1_0) {
device_set_desc_copy(dev, "AHCI SATA controller");
+   if (ACPI_FAILURE(acpi_GetInteger(h, "_CCA",
+ &ctlr->dma_coherent)))
+   ctlr->dma_coherent = 0;
+   if (bootverbose)
+   device_printf(dev, "Bus is%s cache-coherent\n",
+ ctlr->dma_coherent ? "" : " not");
return (BUS_PROBE_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: r347439 - head/lib/libnetgraph

2019-05-10 Thread Mark Johnston
Author: markj
Date: Fri May 10 16:43:47 2019
New Revision: 347439
URL: https://svnweb.freebsd.org/changeset/base/347439

Log:
  Atomically update the global gMsgId in libnetgraph.
  
  Otherwise concurrently running threads may inadvertently use the same
  token for different messages.
  
  Preserve the behaviour of disallowing negative message tokens, but allow
  a message token value of zero since this simplifies the code a bit and
  tokens are documented to be non-negative.
  
  PR:   234442
  Reported and tested by:   eugen
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/lib/libnetgraph/msg.c

Modified: head/lib/libnetgraph/msg.c
==
--- head/lib/libnetgraph/msg.c  Fri May 10 16:41:33 2019(r347438)
+++ head/lib/libnetgraph/msg.c  Fri May 10 16:43:47 2019(r347439)
@@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -51,7 +52,7 @@ __FBSDID("$FreeBSD$");
 #include "internal.h"
 
 /* Next message token value */
-static int gMsgId;
+static _Atomic(unsigned int) gMsgId;
 
 /* For delivering both messages and replies */
 static int NgDeliverMsg(int cs, const char *path,
@@ -72,9 +73,7 @@ NgSendMsg(int cs, const char *path,
memset(&msg, 0, sizeof(msg));
msg.header.version = NG_VERSION;
msg.header.typecookie = cookie;
-   if (++gMsgId < 0)
-   gMsgId = 1;
-   msg.header.token = gMsgId;
+   msg.header.token = atomic_fetch_add(&gMsgId, 1) & INT_MAX;
msg.header.flags = NGF_ORIG;
msg.header.cmd = cmd;
snprintf((char *)msg.header.cmdstr, NG_CMDSTRSIZ, "cmd%d", cmd);
@@ -143,9 +142,7 @@ NgSendAsciiMsg(int cs, const char *path, const char *f
 
/* Now send binary version */
binary = (struct ng_mesg *)reply->data;
-   if (++gMsgId < 0)
-   gMsgId = 1;
-   binary->header.token = gMsgId;
+   binary->header.token = atomic_fetch_add(&gMsgId, 1) & INT_MAX;
binary->header.version = NG_VERSION;
if (NgDeliverMsg(cs,
path, binary, binary->data, binary->header.arglen) < 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: r347441 - head/usr.sbin/efibootmgr

2019-05-10 Thread Emmanuel Vadot
Author: manu
Date: Fri May 10 16:44:35 2019
New Revision: 347441
URL: https://svnweb.freebsd.org/changeset/base/347441

Log:
  efibootmgr: Do not add the new boot entry in dry-run is specified
  
  While here fix a typo.
  
  Sponsored-by: Ampere Computing, LLC
  Reviewed by:  imp
  Differential Revision:https://reviews.freebsd.org/D20212

Modified:
  head/usr.sbin/efibootmgr/efibootmgr.c

Modified: head/usr.sbin/efibootmgr/efibootmgr.c
==
--- head/usr.sbin/efibootmgr/efibootmgr.c   Fri May 10 16:43:53 2019
(r347440)
+++ head/usr.sbin/efibootmgr/efibootmgr.c   Fri May 10 16:44:35 2019
(r347441)
@@ -679,7 +679,7 @@ make_boot_var(const char *label, const char *loader, c
lopt_size = create_loadopt(load_opt_buf, MAX_LOADOPT_LEN, load_attrs,
dp, llen + klen, label, env, env ? strlen(env) + 1 : 0);
if (lopt_size == BAD_LENGTH)
-   errx(1, "Can't crate loadopt");
+   errx(1, "Can't create loadopt");
 
ret = 0;
if (!dry_run) {
@@ -690,7 +690,8 @@ make_boot_var(const char *label, const char *loader, c
if (ret)
err(1, "efi_set_variable");
 
-   add_to_boot_order(bootvar); /* first, still not active */
+   if (!dry_run)
+   add_to_boot_order(bootvar); /* first, still not active */
new_ent = malloc(sizeof(struct entry));
if (new_ent == NULL)
err(1, "malloc");
___
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: r347442 - head/sys/arm64/rockchip/clk

2019-05-10 Thread Emmanuel Vadot
Author: manu
Date: Fri May 10 16:45:17 2019
New Revision: 347442
URL: https://svnweb.freebsd.org/changeset/base/347442

Log:
  arm64: rockchip: Don't always put PLL to normal mode
  
  We used to put every PLL in normal mode (meaning that the output would
  be the result of the PLL configuration) instead of slow mode (the output
  is equal to the external oscillator frequency, 24-26Mhz) but this doesn't
  work for most of the PLLs as when we put them into normal mode the registers
  configuring the output frequency haven't been set.
  Add a normal_mode member in clk_pll_def/clk_pll_sc struct and if it's true
  we then set the PLL to normal mode.
  For now only set it to the LPLL and BPLL (Little cluster PLL and Big cluster
  PLL respectively).
  
  Reviewed by:  ganbold
  Differential Revision:https://reviews.freebsd.org/D20174

Modified:
  head/sys/arm64/rockchip/clk/rk3399_cru.c
  head/sys/arm64/rockchip/clk/rk_clk_pll.c
  head/sys/arm64/rockchip/clk/rk_clk_pll.h

Modified: head/sys/arm64/rockchip/clk/rk3399_cru.c
==
--- head/sys/arm64/rockchip/clk/rk3399_cru.cFri May 10 16:44:35 2019
(r347441)
+++ head/sys/arm64/rockchip/clk/rk3399_cru.cFri May 10 16:45:17 2019
(r347442)
@@ -764,6 +764,7 @@ static struct rk_clk_pll_def lpll = {
.gate_shift = 0,
.flags = RK_CLK_PLL_HAVE_GATE,
.rates = rk3399_pll_rates,
+   .normal_mode = true,
 };
 
 static struct rk_clk_pll_def bpll = {
@@ -778,6 +779,7 @@ static struct rk_clk_pll_def bpll = {
.gate_shift = 1,
.flags = RK_CLK_PLL_HAVE_GATE,
.rates = rk3399_pll_rates,
+   .normal_mode = true,
 };
 
 static struct rk_clk_pll_def dpll = {

Modified: head/sys/arm64/rockchip/clk/rk_clk_pll.c
==
--- head/sys/arm64/rockchip/clk/rk_clk_pll.cFri May 10 16:44:35 2019
(r347441)
+++ head/sys/arm64/rockchip/clk/rk_clk_pll.cFri May 10 16:45:17 2019
(r347442)
@@ -54,6 +54,8 @@ struct rk_clk_pll_sc {
 
struct rk_clk_pll_rate  *rates;
struct rk_clk_pll_rate  *frac_rates;
+
+   boolnormal_mode;
 };
 
 #defineWRITE4(_clk, off, val)  \
@@ -344,11 +346,13 @@ rk3399_clk_pll_init(struct clknode *clk, device_t dev)
 
sc = clknode_get_softc(clk);
 
-   /* Setting to normal mode */
-   reg = RK3399_CLK_PLL_MODE_NORMAL << RK3399_CLK_PLL_MODE_SHIFT;
-   reg |= RK3399_CLK_PLL_MODE_MASK << RK_CLK_PLL_MASK_SHIFT;
-   WRITE4(clk, sc->base_offset + RK3399_CLK_PLL_MODE_OFFSET,
-   reg | RK3399_CLK_PLL_WRITE_MASK);
+   if (sc->normal_mode) {
+   /* Setting to normal mode */
+   reg = RK3399_CLK_PLL_MODE_NORMAL << RK3399_CLK_PLL_MODE_SHIFT;
+   reg |= RK3399_CLK_PLL_MODE_MASK << RK_CLK_PLL_MASK_SHIFT;
+   WRITE4(clk, sc->base_offset + RK3399_CLK_PLL_MODE_OFFSET,
+   reg | RK3399_CLK_PLL_WRITE_MASK);
+   }
 
clknode_init_parent_idx(clk, 0);
 
@@ -521,6 +525,7 @@ rk3399_clk_pll_register(struct clkdom *clkdom, struct 
sc->flags = clkdef->flags;
sc->rates = clkdef->rates;
sc->frac_rates = clkdef->frac_rates;
+   sc->normal_mode = clkdef->normal_mode;
 
clknode_register(clkdom, clk);
 

Modified: head/sys/arm64/rockchip/clk/rk_clk_pll.h
==
--- head/sys/arm64/rockchip/clk/rk_clk_pll.hFri May 10 16:44:35 2019
(r347441)
+++ head/sys/arm64/rockchip/clk/rk_clk_pll.hFri May 10 16:45:17 2019
(r347442)
@@ -57,6 +57,8 @@ struct rk_clk_pll_def {
 
struct rk_clk_pll_rate  *rates;
struct rk_clk_pll_rate  *frac_rates;
+
+   boolnormal_mode;
 };
 
 #defineRK_CLK_PLL_HAVE_GATE0x1
___
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: r347445 - head/usr.bin/dtc

2019-05-10 Thread Leandro Lupori
Author: luporl
Date: Fri May 10 17:05:40 2019
New Revision: 347445
URL: https://svnweb.freebsd.org/changeset/base/347445

Log:
  Fix build issue with clang 8.0.1
  
  The algorithm header is needed to use std::remove_if

Modified:
  head/usr.bin/dtc/fdt.hh

Modified: head/usr.bin/dtc/fdt.hh
==
--- head/usr.bin/dtc/fdt.hh Fri May 10 16:58:05 2019(r347444)
+++ head/usr.bin/dtc/fdt.hh Fri May 10 17:05:40 2019(r347445)
@@ -34,6 +34,7 @@
 
 #ifndef _FDT_HH_
 #define _FDT_HH_
+#include 
 #include 
 #include 
 #include 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r347458 - head/sys/conf

2019-05-10 Thread Bryan Drewery
Author: bdrewery
Date: Fri May 10 18:09:27 2019
New Revision: 347458
URL: https://svnweb.freebsd.org/changeset/base/347458

Log:
  Fix build race with machine links and genoffset.o.
  
  Generate the ilinks for all dependency objects not just the ones
  in the CLEAN list.
  
  Possibly related to r345351
  
  Reported by:  kmoore
  MFC after:2 weeks
  X-MFC-with:   r345351
  Sponsored by: Dell EMC Isilon

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

Modified: head/sys/conf/kern.post.mk
==
--- head/sys/conf/kern.post.mk  Fri May 10 17:31:50 2019(r347457)
+++ head/sys/conf/kern.post.mk  Fri May 10 18:09:27 2019(r347458)
@@ -357,7 +357,7 @@ _ILINKS+= x86
 # Ensure that debug info references the path in the source tree.
 .for _link in ${_ILINKS}
 .if !exists(${.OBJDIR}/${_link})
-${SRCS} ${CLEAN:M*.o}: ${_link}
+${SRCS} ${DEPENDOBJS}: ${_link}
 .endif
 .if defined(_MAP_DEBUG_PREFIX)
 .if ${_link} == "machine"
___
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: r347402 - head/sys/modules/ipsec

2019-05-10 Thread Kyle Evans
On Fri, May 10, 2019 at 2:46 AM Andrey V. Elsukov  wrote:
>
> On 09.05.2019 22:13, Kyle Evans wrote:
> >> there is two IPsec related interfaces that have problem with automatic
> >> loading - if_enc and if_ipsec. So, if you add both to the mapping list,
> >> this will be useful. CAM enc driver has conflicting name and prevents to
> >> automatic loading of if_enc(4). It is probably always build in the
> >> kernel, but renaming it into "ses" may break some third-party device
> >> drivers.
> >>
> >
> > I think you want something like [0] to add both of these to the map
> > and stop ifconfig(8) from bailing on loading if_enc because 'enc' is
> > loaded. This is safe at least for the set of modules currently mapped.
> >
> > Thanks,
> >
> > Kyle Evans
> >
> > [0] https://people.freebsd.org/~kevans/ipsec.diff
>
> It looks good to me.
>
> --
> WBR, Andrey V. Elsukov
>

Committed as r347429 -- any objection to reverting this link created
in r347402 now?

Thanks!

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


svn commit: r347461 - head/sys/kern

2019-05-10 Thread Doug Moore
Author: dougm
Date: Fri May 10 18:22:40 2019
New Revision: 347461
URL: https://svnweb.freebsd.org/changeset/base/347461

Log:
  Replace panic() with KASSERT() and provide more useful information when 
failure happens.
  
  Approved by: kib (mentor)
  Differential Revision: https://reviews.freebsd.org/D20226

Modified:
  head/sys/kern/subr_blist.c

Modified: head/sys/kern/subr_blist.c
==
--- head/sys/kern/subr_blist.c  Fri May 10 18:18:41 2019(r347460)
+++ head/sys/kern/subr_blist.c  Fri May 10 18:22:40 2019(r347461)
@@ -109,6 +109,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -120,11 +121,10 @@ __FBSDID("$FreeBSD$");
 #define malloc(a,b,c)  calloc(a, 1)
 #define free(a,b)  free(a)
 #define ummin(a,b) ((a) < (b) ? (a) : (b))
+#define KASSERT(a,b)   assert(a)
 
 #include 
 
-void panic(const char *ctl, ...);
-
 #endif
 
 /*
@@ -235,8 +235,7 @@ blist_create(daddr_t blocks, int flags)
blist_t bl;
u_daddr_t nodes, radix;
 
-   if (blocks == 0)
-   panic("invalid block count");
+   KASSERT(blocks > 0, ("invalid block count"));
 
/*
 * Calculate the radix and node count used for scanning.
@@ -288,8 +287,8 @@ blist_alloc(blist_t bl, daddr_t count)
 {
daddr_t blk, cursor;
 
-   if (count > BLIST_MAX_ALLOC)
-   panic("allocation too large");
+   KASSERT(count <= BLIST_MAX_ALLOC,
+   ("allocation too large: %d", (int)count));
 
/*
 * This loop iterates at most twice.  An allocation failure in the
@@ -325,15 +324,15 @@ blist_avail(blist_t bl)
 
 /*
  * blist_free() -  free up space in the block bitmap.  Return the base
- * of a contiguous region.  Panic if an inconsistancy is
- * found.
+ * of a contiguous region.
  */
 void
 blist_free(blist_t bl, daddr_t blkno, daddr_t count)
 {
 
-   if (blkno < 0 || blkno + count > bl->bl_blocks)
-   panic("freeing invalid range");
+   KASSERT(blkno >= 0 && blkno + count <= bl->bl_blocks,
+   ("freeing invalid range: blkno %jx, count %d, blocks %jd",
+   (uintmax_t)blkno, (int)count, (uintmax_t)bl->bl_blocks));
blst_meta_free(bl->bl_root, blkno, count, bl->bl_radix);
bl->bl_avail += count;
 }
@@ -349,8 +348,9 @@ blist_fill(blist_t bl, daddr_t blkno, daddr_t count)
 {
daddr_t filled;
 
-   if (blkno < 0 || blkno + count > bl->bl_blocks)
-   panic("filling invalid range");
+   KASSERT(blkno >= 0 && blkno + count <= bl->bl_blocks,
+   ("filling invalid range: blkno %jx, count %d, blocks %jd",
+   (uintmax_t)blkno, (int)count, (uintmax_t)bl->bl_blocks));
filled = blst_meta_fill(bl->bl_root, blkno, count, bl->bl_radix);
bl->bl_avail -= filled;
return (filled);
@@ -840,8 +840,9 @@ blst_leaf_free(blmeta_t *scan, daddr_t blk, int count)
 *  count   n
 */
mask = bitrange(blk & BLIST_BMAP_MASK, count);
-   if (scan->bm_bitmap & mask)
-   panic("freeing free block");
+   KASSERT((scan->bm_bitmap & mask) == 0,
+   ("freeing free block: %jx, size %d, mask %jx",
+   (uintmax_t)blk, count, (uintmax_t)scan->bm_bitmap & mask));
scan->bm_bitmap |= mask;
 }
 
@@ -1142,19 +1143,7 @@ main(int ac, char **av)
break;
}
}
-   return(0);
-}
-
-void
-panic(const char *ctl, ...)
-{
-   va_list va;
-
-   va_start(va, ctl);
-   vfprintf(stderr, ctl, va);
-   fprintf(stderr, "\n");
-   va_end(va);
-   exit(1);
+   return (0);
 }
 
 #endif
___
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: r347462 - head/sys/kern

2019-05-10 Thread Doug Moore
Author: dougm
Date: Fri May 10 18:25:06 2019
New Revision: 347462
URL: https://svnweb.freebsd.org/changeset/base/347462

Log:
  blist_next_leaf_alloc walks over all the meta-nodes between one leaf
  and the next one, and if blocks are allocated from the next leaf, it
  walks back toward where it started, as long as there are interleaving
  meta-nodes to be updated on account of the last free blocks under
  those meta-nodes being allocated. Only if the walk goes all the way
  back to the starting point must we calculate the position of the
  meta-node that is the least-comment parent of one leaf and the next,
  and update a bit in that meta-node to indicate the allocation of its
  last free block.
  
  There's no need to start calculating the position of that least-common
  parent until the walk back reaches the original starting point, and
  there's no need for a calculation that updates 'radius' to tell us
  when we've walked back to the beginning, since comparing scan to next
  suffices for that.
  
  Approved by: kib (mentor)
  Differential Revision: https://reviews.freebsd.org/D20229

Modified:
  head/sys/kern/subr_blist.c

Modified: head/sys/kern/subr_blist.c
==
--- head/sys/kern/subr_blist.c  Fri May 10 18:22:40 2019(r347461)
+++ head/sys/kern/subr_blist.c  Fri May 10 18:25:06 2019(r347462)
@@ -607,7 +607,6 @@ static int
 blst_next_leaf_alloc(blmeta_t *scan, daddr_t blk, int count)
 {
blmeta_t *next;
-   daddr_t skip;
u_daddr_t radix;
int digit;
 
@@ -632,13 +631,14 @@ blst_next_leaf_alloc(blmeta_t *scan, daddr_t blk, int 
/*
 * Update bitmaps of next-ancestors, up to least common ancestor.
 */
-   skip = radix_to_skip(radix);
-   while (radix != BLIST_BMAP_RADIX && next->bm_bitmap == 0) {
-   (--next)->bm_bitmap ^= 1;
-   radix /= BLIST_META_RADIX;
-   }
-   if (next->bm_bitmap == 0)
-   scan[-digit * skip].bm_bitmap ^= (u_daddr_t)1 << digit;
+   while (next->bm_bitmap == 0) {
+   if (--next == scan) {
+   scan[-digit * radix_to_skip(radix)].bm_bitmap ^=
+   (u_daddr_t)1 << digit;
+   break;
+   }
+   next->bm_bitmap ^= 1;
+   }
return (0);
 }
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r347410 - in head: . sys/amd64/conf sys/arm/conf sys/arm64/conf sys/i386/conf sys/powerpc/conf sys/riscv/conf sys/sparc64/conf

2019-05-10 Thread Andrey V. Elsukov
On 10.05.2019 18:31, Andrew Gallatin wrote:
> On 2019-05-10 08:44, Slawa Olhovchenkov wrote:
> 
>> pf have ifdef for IPSEC, but don't have support IPSEC_SUPPORT
>> (netpfil/pf/if_pfsync.c).
>>
> 
> Thanks for pointing this out.  It seems like IPSEC_SUPPORT would work
> for this.  I've made a patch, and it compiles and the pf module loads.
> However, I have no knowledge of how to test it.  Is this something
> that you use, and which you can test?
>

I think you need to include opt_ipsec.h to have chance compile it. But
as Kristof said, it wont work.

-- 
WBR, Andrey V. Elsukov



signature.asc
Description: OpenPGP digital signature


Re: svn commit: r347410 - in head: . sys/amd64/conf sys/arm/conf sys/arm64/conf sys/i386/conf sys/powerpc/conf sys/riscv/conf sys/sparc64/conf

2019-05-10 Thread Andrey V. Elsukov
On 10.05.2019 21:39, Alexey Dokuchaev wrote:
>> The second cause -- reduce overhead that IPSEC produces even when it
>> is not used.
> 
> So does it mean that if I don't plan to use IPSEC, I can safely remove
> IPSEC_SUPPORT from my config and also get slight performance boost?

Yes, currently each call to IPsec has check like
`if (ipsec_enabled) {...}`, when you build the kernel without
IPSEC/IPSEC_SUPPORT, this check will be removed too, this can add some
performance boost :-)

-- 
WBR, Andrey V. Elsukov



signature.asc
Description: OpenPGP digital signature


Re: svn commit: r347410 - in head: . sys/amd64/conf sys/arm/conf sys/arm64/conf sys/i386/conf sys/powerpc/conf sys/riscv/conf sys/sparc64/conf

2019-05-10 Thread Alexey Dokuchaev
On Fri, May 10, 2019 at 12:11:47PM +0300, Andrey V. Elsukov wrote:
> On 10.05.2019 11:46, Alexey Dokuchaev wrote:
> > ...
> > What is the reason behind having IPSEC_SUPPORT option instead of no
> > special option at all?
> 
> IPSEC_SUPPORT builds into the kernel PF_KEY domain protocol, that is
> required by IPsec implementation to interact with userlevel. Currently
> the kernel does not support unregistering of protocol domains. This is
> mostly why option IPSEC_SUPPORT was introduced.

Okay, I see, thank you Andrey for explanation.

> The second cause -- reduce overhead that IPSEC produces even when it
> is not used.

So does it mean that if I don't plan to use IPSEC, I can safely remove
IPSEC_SUPPORT from my config and also get slight performance boost?

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


Re: svn commit: r347410 - in head: . sys/amd64/conf sys/arm/conf sys/arm64/conf sys/i386/conf sys/powerpc/conf sys/riscv/conf sys/sparc64/conf

2019-05-10 Thread Alexey Dokuchaev
On Fri, May 10, 2019 at 09:44:58PM +0300, Andrey V. Elsukov wrote:
> On 10.05.2019 21:39, Alexey Dokuchaev wrote:
> >> The second cause -- reduce overhead that IPSEC produces even when it
> >> is not used.
> > 
> > So does it mean that if I don't plan to use IPSEC, I can safely remove
> > IPSEC_SUPPORT from my config and also get slight performance boost?
> 
> Yes, currently each call to IPsec has check like
> `if (ipsec_enabled) {...}`, when you build the kernel without
> IPSEC/IPSEC_SUPPORT, this check will be removed too, this can add some
> performance boost :-)

Got it. :-)  Thanks for the fast response (and proper quoting).

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


Re: svn commit: r347410 - in head: . sys/amd64/conf sys/arm/conf sys/arm64/conf sys/i386/conf sys/powerpc/conf sys/riscv/conf sys/sparc64/conf

2019-05-10 Thread Slawa Olhovchenkov
On Fri, May 10, 2019 at 11:31:21AM -0400, Andrew Gallatin wrote:

> On 2019-05-10 08:44, Slawa Olhovchenkov wrote:
> 
> > pf have ifdef for IPSEC, but don't have support IPSEC_SUPPORT
> > (netpfil/pf/if_pfsync.c).
> > 
> 
> Thanks for pointing this out.  It seems like IPSEC_SUPPORT would work 
> for this.  I've made a patch, and it compiles and the pf module loads.
> However, I have no knowledge of how to test it.  Is this something
> that you use, and which you can test?

I am don't use pf, I am just explore kernel for ame reasson (IPSEC
performance penalty) and see mostly IPSEC code ifdef to

#if defined(IPSEC) || defined(IPSEC_SUPPORT)

and only netpfil/pf/if_pfsync.c ifdef to

#if defined(IPSEC)


> Thanks,
> 
> Drew
> 

> diff --git a/sys/netpfil/pf/if_pfsync.c b/sys/netpfil/pf/if_pfsync.c
> index 45b1e090f95c..cc06637b862e 100644
> --- a/sys/netpfil/pf/if_pfsync.c
> +++ b/sys/netpfil/pf/if_pfsync.c
> @@ -308,7 +308,7 @@ static void   pfsync_bulk_update(void *);
>  static void  pfsync_bulk_fail(void *);
>  
>  static void  pfsync_detach_ifnet(struct ifnet *);
> -#ifdef IPSEC
> +#ifdef IPSEC_SUPPORT
>  static void  pfsync_update_net_tdb(struct pfsync_tdb *);
>  #endif
>  static struct pfsync_bucket  *pfsync_get_bucket(struct pfsync_softc *,
> @@ -1228,7 +1228,7 @@ pfsync_in_tdb(struct pfsync_pkt *pkt, struct mbuf *m, 
> int offset, int count)
>  {
>   int len = count * sizeof(struct pfsync_tdb);
>  
> -#if defined(IPSEC)
> +#if defined(IPSEC_SUPPORT)
>   struct pfsync_tdb *tp;
>   struct mbuf *mp;
>   int offp;
> @@ -1249,7 +1249,7 @@ pfsync_in_tdb(struct pfsync_pkt *pkt, struct mbuf *m, 
> int offset, int count)
>   return (len);
>  }
>  
> -#if defined(IPSEC)
> +#if defined(IPSEC_SUPPORT)
>  /* Update an in-kernel tdb. Silently fail if no tdb is found. */
>  static void
>  pfsync_update_net_tdb(struct pfsync_tdb *pt)

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

___
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: r347463 - head/sys/powerpc/aim

2019-05-10 Thread Justin Hibbits
Author: jhibbits
Date: Fri May 10 19:36:14 2019
New Revision: 347463
URL: https://svnweb.freebsd.org/changeset/base/347463

Log:
  powerpc: Initialize the Hardware Interrupt Offset Register (HIOR) earlier for 
ppc970
  
  Since we now have a much larger KVA on powerpc64, it's possible to get SLB
  traps earlier in boot, possibly even before the HIOR is properly configured
  for us.  Move the HIOR setup to immediately after reset, so that we use our
  exception handlers instead of Open Firmware's.
  
  PR:   233863
  Submitted by: Mark Millard (partial)
  Reported by:  Mark Millard
  MFC after:2 weeks

Modified:
  head/sys/powerpc/aim/mp_cpudep.c

Modified: head/sys/powerpc/aim/mp_cpudep.c
==
--- head/sys/powerpc/aim/mp_cpudep.cFri May 10 18:25:06 2019
(r347462)
+++ head/sys/powerpc/aim/mp_cpudep.cFri May 10 19:36:14 2019
(r347463)
@@ -68,6 +68,10 @@ cpudep_ap_early_bootstrap(void)
case IBM970:
case IBM970FX:
case IBM970MP:
+   /* Set HIOR to 0 */
+   __asm __volatile("mtspr 311,%0" :: "r"(0));
+   powerpc_sync();
+
/* Restore HID4 and HID5, which are necessary for the MMU */
 
 #ifdef __powerpc64__
@@ -314,10 +318,6 @@ cpudep_ap_setup()
case IBM970:
case IBM970FX:
case IBM970MP:
-   /* Set HIOR to 0 */
-   __asm __volatile("mtspr 311,%0" :: "r"(0));
-   powerpc_sync();
-
/*
 * The 970 has strange rules about how to update HID registers.
 * See Table 2-3, 970MP manual
___
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: r347464 - head/sys/kern

2019-05-10 Thread Doug Moore
Author: dougm
Date: Fri May 10 19:55:29 2019
New Revision: 347464
URL: https://svnweb.freebsd.org/changeset/base/347464

Log:
  Replace the expression "-mask & ~mask" with a function call that does
  the same thing, but is commented so that it might be better
  understood.
  
  Approved by: kib (mentor)
  Differential Revision: https://reviews.freebsd.org/D20231

Modified:
  head/sys/kern/subr_blist.c

Modified: head/sys/kern/subr_blist.c
==
--- head/sys/kern/subr_blist.c  Fri May 10 19:36:14 2019(r347463)
+++ head/sys/kern/subr_blist.c  Fri May 10 19:55:29 2019(r347464)
@@ -643,6 +643,19 @@ blst_next_leaf_alloc(blmeta_t *scan, daddr_t blk, int 
 }
 
 /*
+ * Given a bitmask, flip all the bits from the least-significant 1-bit to the
+ * most significant bit.  If the result is non-zero, then the least-significant
+ * 1-bit of the result is in the same position as the least-signification 0-bit
+ * in mask that is followed by a 1-bit.
+ */
+static inline u_daddr_t
+flip_hibits(u_daddr_t mask)
+{
+
+   return (-mask & ~mask);
+}
+
+/*
  * BLST_LEAF_ALLOC() - allocate at a leaf in the radix tree (a bitmap).
  *
  * This function is the core of the allocator.  Its execution time is
@@ -659,7 +672,7 @@ blst_leaf_alloc(blmeta_t *scan, daddr_t blk, int count
count1 = count - 1;
num_shifts = fls(count1);
mask = scan->bm_bitmap;
-   while ((-mask & ~mask) != 0 && num_shifts > 0) {
+   while (flip_hibits(mask) != 0 && num_shifts > 0) {
/*
 * If bit i is set in mask, then bits in [i, i+range1] are set
 * in scan->bm_bitmap.  The value of range1 is equal to count1
___
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: r347465 - head/sys/netinet6

2019-05-10 Thread John Baldwin
Author: jhb
Date: Fri May 10 20:15:40 2019
New Revision: 347465
URL: https://svnweb.freebsd.org/changeset/base/347465

Log:
  Apply r280991 to ip6_fragment.
  
  This uses m_dup_pkthdr() to copy all of the metadata about a packet to
  each of its fragments including VLAN tags, mbuf tags, etc. instead of
  hand-copying a few fields.
  
  Reviewed by:  bz
  MFC after:1 month
  Sponsored by: Netflix
  Differential Revision:https://reviews.freebsd.org/D20117

Modified:
  head/sys/netinet6/ip6_output.c

Modified: head/sys/netinet6/ip6_output.c
==
--- head/sys/netinet6/ip6_output.c  Fri May 10 19:55:29 2019
(r347464)
+++ head/sys/netinet6/ip6_output.c  Fri May 10 20:15:40 2019
(r347465)
@@ -228,7 +228,20 @@ ip6_fragment(struct ifnet *ifp, struct mbuf *m0, int h
IP6STAT_INC(ip6s_odropped);
return (ENOBUFS);
}
-   m->m_flags = m0->m_flags & M_COPYFLAGS;
+
+   /*
+* Make sure the complete packet header gets copied
+* from the originating mbuf to the newly created
+* mbuf. This also ensures that existing firewall
+* classification(s), VLAN tags and so on get copied
+* to the resulting fragmented packet(s):
+*/
+   if (m_dup_pkthdr(m, m0, M_NOWAIT) == 0) {
+   m_free(m);
+   IP6STAT_INC(ip6s_odropped);
+   return (ENOBUFS);
+   }
+
*mnext = m;
mnext = &m->m_nextpkt;
m->m_data += max_linkhdr;
@@ -253,8 +266,6 @@ ip6_fragment(struct ifnet *ifp, struct mbuf *m0, int h
}
m_cat(m, m_frgpart);
m->m_pkthdr.len = fraglen + hlen + sizeof(*ip6f);
-   m->m_pkthdr.fibnum = m0->m_pkthdr.fibnum;
-   m->m_pkthdr.rcvif = NULL;
ip6f->ip6f_reserved = 0;
ip6f->ip6f_ident = id;
ip6f->ip6f_nxt = nextproto;
___
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: r347466 - head/sys/netinet

2019-05-10 Thread Gleb Smirnoff
Author: glebius
Date: Fri May 10 21:51:17 2019
New Revision: 347466
URL: https://svnweb.freebsd.org/changeset/base/347466

Log:
  Fix regression from r347375: do not panic when sending an IP multicast
  packet from an interface that doesn't have IPv4 address.
  
  Reported by:  Michael Butler 

Modified:
  head/sys/netinet/ip_output.c

Modified: head/sys/netinet/ip_output.c
==
--- head/sys/netinet/ip_output.cFri May 10 20:15:40 2019
(r347465)
+++ head/sys/netinet/ip_output.cFri May 10 21:51:17 2019
(r347466)
@@ -361,7 +361,11 @@ again:
mtu = ifp->if_mtu;
IFP_TO_IA(ifp, ia, &in_ifa_tracker);
isbroadcast = 0;/* fool gcc */
-   src = IA_SIN(ia)->sin_addr;
+   /* Interface may have no addresses. */
+   if (ia != NULL)
+   src = IA_SIN(ia)->sin_addr;
+   else
+   src.s_addr = INADDR_ANY;
} else if (ro != NULL) {
if (ro->ro_rt == 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"


svn commit: r347467 - head/sys/netinet/netdump

2019-05-10 Thread Conrad Meyer
Author: cem
Date: Fri May 10 21:55:11 2019
New Revision: 347467
URL: https://svnweb.freebsd.org/changeset/base/347467

Log:
  netdump: Don't store sensitive key data we don't need
  
  Prior to this revision, struct diocskerneldump_arg (and struct netdump_conf
  with embedded diocskerneldump_arg before r347192), were copied in their
  entirety to the global 'nd_conf' variable.  Also prior to this revision,
  de-configuring netdump would *not* remove the the key material from global
  nd_conf.
  
  As part of Encrypted Kernel Crash Dumps (EKCD), which was developed
  contemporaneously with netdump but happened to land first, the
  diocskerneldump_arg structure will contain sensitive key material
  (kda_key[]) when encrypted dumps are configured.
  
  Netdump doesn't have any use for the key data -- encryption is handled in
  the core dumper code -- so in this revision, we no longer store it.
  
  Unfortunately, I think this leak dates to the initial import of netdump in
  r333283; so it's present in FreeBSD 12.0.
  
  Fortunately, the impact *seems* relatively minor.  Any new *netdump*
  configuration would overwrite the key material; for active encrypted netdump
  configurations, the key data stored was just a duplicate of the key material
  already in the core dumper code; and no user interface (other than
  /dev/kmem) actually exposed the leaked material to userspace.
  
  Reviewed by:  markj, rpokala (earlier commit message)
  MFC after:2 weeks
  Security: yes (minor)
  Sponsored by: Dell EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D20233

Modified:
  head/sys/netinet/netdump/netdump_client.c

Modified: head/sys/netinet/netdump/netdump_client.c
==
--- head/sys/netinet/netdump/netdump_client.c   Fri May 10 21:51:17 2019
(r347466)
+++ head/sys/netinet/netdump/netdump_client.c   Fri May 10 21:55:11 2019
(r347467)
@@ -119,10 +119,16 @@ static uint64_t rcvd_acks;
 CTASSERT(sizeof(rcvd_acks) * NBBY == NETDUMP_MAX_IN_FLIGHT);
 
 /* Configuration parameters. */
-static struct diocskerneldump_arg nd_conf;
-#definend_server   nd_conf.kda_server.in4
-#definend_client   nd_conf.kda_client.in4
-#definend_gateway  nd_conf.kda_gateway.in4
+static struct {
+   char ndc_iface[IFNAMSIZ];
+   union kd_ip  ndc_server;
+   union kd_ip  ndc_client;
+   union kd_ip  ndc_gateway;
+   uint8_t  ndc_af;
+} nd_conf;
+#definend_server   nd_conf.ndc_server.in4
+#definend_client   nd_conf.ndc_client.in4
+#definend_gateway  nd_conf.ndc_gateway.in4
 
 /* General dynamic settings. */
 static struct ether_addr nd_gw_mac;
@@ -1087,8 +1093,20 @@ netdump_configure(struct diocskerneldump_arg *conf, st
return (ENODEV);
 
nd_ifp = ifp;
+
netdump_reinit(ifp);
-   memcpy(&nd_conf, conf, sizeof(nd_conf));
+#define COPY_SIZED(elm) do {   \
+   _Static_assert(sizeof(nd_conf.ndc_ ## elm) ==   \
+   sizeof(conf->kda_ ## elm), "elm " __XSTRING(elm) " mismatch"); \
+   memcpy(&nd_conf.ndc_ ## elm, &conf->kda_ ## elm,\
+   sizeof(nd_conf.ndc_ ## elm));   \
+} while (0)
+   COPY_SIZED(iface);
+   COPY_SIZED(server);
+   COPY_SIZED(client);
+   COPY_SIZED(gateway);
+   COPY_SIZED(af);
+#undef COPY_SIZED
nd_enabled = 1;
return (0);
 }
@@ -1193,7 +1211,7 @@ netdump_ioctl(struct cdev *dev __unused, u_long cmd, c
error = ENXIO;
break;
}
-   if (nd_conf.kda_af != AF_INET) {
+   if (nd_conf.ndc_af != AF_INET) {
error = EOPNOTSUPP;
break;
}
@@ -1225,7 +1243,7 @@ netdump_ioctl(struct cdev *dev __unused, u_long cmd, c
memcpy(&conf->kda_server, &nd_server, sizeof(nd_server));
memcpy(&conf->kda_client, &nd_client, sizeof(nd_client));
memcpy(&conf->kda_gateway, &nd_gateway, sizeof(nd_gateway));
-   conf->kda_af = nd_conf.kda_af;
+   conf->kda_af = nd_conf.ndc_af;
conf = NULL;
break;
 
@@ -1397,7 +1415,7 @@ netdump_modevent(module_t mod __unused, int what, void
 
bzero(&kda, sizeof(kda));
kda.kda_index = KDA_REMOVE_DEV;
-   (void)dumper_remove(nd_conf.kda_iface, &kda);
+   (void)dumper_remove(nd_conf.ndc_iface, &kda);
 
netdump_mbuf_drain();
nd_enabled = 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: r347468 - head/sys/kern

2019-05-10 Thread Doug Moore
Author: dougm
Date: Fri May 10 22:02:29 2019
New Revision: 347468
URL: https://svnweb.freebsd.org/changeset/base/347468

Log:
  Add a (q)uit option to the subr_blist test program.
  
  Approved by: kib (mentor)
  Differential Revision: https://reviews.freebsd.org/D20234

Modified:
  head/sys/kern/subr_blist.c

Modified: head/sys/kern/subr_blist.c
==
--- head/sys/kern/subr_blist.c  Fri May 10 21:55:11 2019(r347467)
+++ head/sys/kern/subr_blist.c  Fri May 10 22:02:29 2019(r347468)
@@ -1148,13 +1148,18 @@ main(int ac, char **av)
"f %x %d-free\n"
"l %x %d-fill\n"
"r %d   -resize\n"
-   "h/?-help"
+   "h/?-help\n"
+   "q  -quit"
);
break;
+   case 'q':
+   break;
default:
printf("?\n");
break;
}
+   if (buf[0] == 'q')
+   break;
}
return (0);
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r347469 - head/sys/kern

2019-05-10 Thread Doug Moore
Author: dougm
Date: Fri May 10 22:49:01 2019
New Revision: 347469
URL: https://svnweb.freebsd.org/changeset/base/347469

Log:
  When bitpos can't be implemented with an inline ffs* instruction,
  change the binary search so that it does not depend on a single bit
  only being set in the bitmask. Use bitpos more generally, and avoid
  some clearing of bits to accommodate its current behavior.
  
  Approved by: kib (mentor)
  Differential Revision: https://reviews.freebsd.org/D20232

Modified:
  head/sys/kern/subr_blist.c

Modified: head/sys/kern/subr_blist.c
==
--- head/sys/kern/subr_blist.c  Fri May 10 22:02:29 2019(r347468)
+++ head/sys/kern/subr_blist.c  Fri May 10 22:49:01 2019(r347469)
@@ -192,31 +192,41 @@ bitrange(int n, int count)
 
 
 /*
- * Use binary search, or a faster method, to find the 1 bit in a u_daddr_t.
- * Assumes that the argument has only one bit set.
+ * Find the first bit set in a u_daddr_t.
  */
 static inline int
-bitpos(u_daddr_t mask)
+generic_bitpos(u_daddr_t mask)
 {
int hi, lo, mid;
 
-   switch (sizeof(mask)) {
+   lo = 0;
+   hi = BLIST_BMAP_RADIX;
+   while (lo + 1 < hi) {
+   mid = (lo + hi) >> 1;
+   if (mask & bitrange(0, mid))
+   hi = mid;
+   else
+   lo = mid;
+   }
+   return (lo);
+}
+
+static inline int
+bitpos(u_daddr_t mask)
+{
+
+   return (_Generic(mask,
 #ifdef HAVE_INLINE_FFSLL
-   case sizeof(long long):
-   return (ffsll(mask) - 1);
+   long long: ffsll(mask) - 1,
 #endif
-   default:
-   lo = 0;
-   hi = BLIST_BMAP_RADIX;
-   while (lo + 1 < hi) {
-   mid = (lo + hi) >> 1;
-   if ((mask >> mid) != 0)
-   lo = mid;
-   else
-   hi = mid;
-   }
-   return (lo);
-   }
+#ifdef HAVE_INLINE_FFSL
+   long: ffsl(mask) - 1,
+#endif
+#ifdef HAVE_INLINE_FFS
+   int: ffs(mask) - 1,
+#endif
+   default: generic_bitpos(mask)
+   ));
 }
 
 /*
@@ -532,7 +542,8 @@ blist_stats(blist_t bl, struct sbuf *s)
struct gap_stats gstats;
struct gap_stats *stats = &gstats;
daddr_t i, nodes, radix;
-   u_daddr_t bit, diff, mask;
+   u_daddr_t diff, mask;
+   int digit;
 
init_gap_stats(stats);
nodes = 0;
@@ -570,9 +581,9 @@ blist_stats(blist_t bl, struct sbuf *s)
if (gap_stats_counting(stats))
diff ^= 1;
while (diff != 0) {
-   bit = diff & -diff;
-   update_gap_stats(stats, i + bitpos(bit));
-   diff ^= bit;
+   digit = bitpos(diff);
+   update_gap_stats(stats, i + digit);
+   diff ^= bitrange(digit, 1);
}
}
nodes += radix_to_skip(radix);
@@ -776,7 +787,7 @@ static daddr_t
 blst_meta_alloc(blmeta_t *scan, daddr_t cursor, daddr_t count, u_daddr_t radix)
 {
daddr_t blk, i, r, skip;
-   u_daddr_t bit, mask;
+   u_daddr_t mask;
bool scan_from_start;
int digit;
 
@@ -808,8 +819,7 @@ blst_meta_alloc(blmeta_t *scan, daddr_t cursor, daddr_
 * Examine the nonempty subtree associated with each bit set in mask.
 */
do {
-   bit = mask & -mask;
-   digit = bitpos(bit);
+   digit = bitpos(mask);
i = 1 + digit * skip;
if (count <= scan[i].bm_bighint) {
/*
@@ -819,12 +829,12 @@ blst_meta_alloc(blmeta_t *scan, daddr_t cursor, daddr_
count, radix);
if (r != SWAPBLK_NONE) {
if (scan[i].bm_bitmap == 0)
-   scan->bm_bitmap ^= bit;
+   scan->bm_bitmap ^= bitrange(digit, 1);
return (r);
}
}
cursor = blk;
-   } while ((mask ^= bit) != 0);
+   } while ((mask ^= bitrange(digit, 1)) != 0);
 
/*
 * We couldn't allocate count in this subtree.  If the whole tree was
@@ -1019,7 +1029,7 @@ static void
 blst_radix_print(blmeta_t *scan, daddr_t blk, daddr_t radix, int tab)
 {
daddr_t skip;
-   u_daddr_t bit, mask;
+   u_daddr_t mask;
int digit;
 
if (radix == BLIST_BMAP_RADIX) {
@@ -1051,11 +1061,10 @@ blst_radix_print(blmeta_t *scan, daddr_t blk, daddr_t 
mask = scan->bm_bitmap;
/* Examine the nonempty subtree associated with each bit set in mask */
do {
-   

svn commit: r347470 - in head/sys/compat/linuxkpi/common: include/linux src

2019-05-10 Thread Johannes Lundberg
Author: johalun
Date: Fri May 10 23:10:22 2019
New Revision: 347470
URL: https://svnweb.freebsd.org/changeset/base/347470

Log:
  Implement linux_pci_unregister_drm_driver in linuxkpi so that drm drivers
  can be unloaded.
  
  This patch is a part of D19565.
  
  Reviewed by:  hps
  Approved by:  imp (mentor), hps
  MFC after:1 week

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

Modified: head/sys/compat/linuxkpi/common/include/linux/pci.h
==
--- head/sys/compat/linuxkpi/common/include/linux/pci.h Fri May 10 22:49:01 
2019(r347469)
+++ head/sys/compat/linuxkpi/common/include/linux/pci.h Fri May 10 23:10:22 
2019(r347470)
@@ -532,6 +532,7 @@ pci_write_config_dword(struct pci_dev *pdev, int where
 intlinux_pci_register_driver(struct pci_driver *pdrv);
 intlinux_pci_register_drm_driver(struct pci_driver *pdrv);
 void   linux_pci_unregister_driver(struct pci_driver *pdrv);
+void   linux_pci_unregister_drm_driver(struct pci_driver *pdrv);
 
 #definepci_register_driver(pdrv)   linux_pci_register_driver(pdrv)
 #definepci_unregister_driver(pdrv) 
linux_pci_unregister_driver(pdrv)

Modified: head/sys/compat/linuxkpi/common/src/linux_pci.c
==
--- head/sys/compat/linuxkpi/common/src/linux_pci.c Fri May 10 22:49:01 
2019(r347469)
+++ head/sys/compat/linuxkpi/common/src/linux_pci.c Fri May 10 23:10:22 
2019(r347470)
@@ -417,6 +417,22 @@ linux_pci_unregister_driver(struct pci_driver *pdrv)
mtx_unlock(&Giant);
 }
 
+void
+linux_pci_unregister_drm_driver(struct pci_driver *pdrv)
+{
+   devclass_t bus;
+
+   bus = devclass_find("vgapci");
+
+   spin_lock(&pci_lock);
+   list_del(&pdrv->links);
+   spin_unlock(&pci_lock);
+   mtx_lock(&Giant);
+   if (bus != NULL)
+   devclass_delete_driver(bus, &pdrv->bsddriver);
+   mtx_unlock(&Giant);
+}
+
 CTASSERT(sizeof(dma_addr_t) <= sizeof(uint64_t));
 
 struct linux_dma_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: r347471 - head/sys/netinet/netdump

2019-05-10 Thread Conrad Meyer
Author: cem
Date: Fri May 10 23:10:22 2019
New Revision: 347471
URL: https://svnweb.freebsd.org/changeset/base/347471

Log:
  netdump: Fix boot-time configuration typo
  
  Boot-time netdump configuration is much more useful if one can configure the
  client and gateway addresses.  Fix trivial typo.
  
  (Long-standing bug, I believe it dates to the original netdump commit.)
  
  Spotted by:   one of vangyzen@ or markj@
  Sponsored by: Dell EMC Isilon

Modified:
  head/sys/netinet/netdump/netdump_client.c

Modified: head/sys/netinet/netdump/netdump_client.c
==
--- head/sys/netinet/netdump/netdump_client.c   Fri May 10 23:10:22 2019
(r347470)
+++ head/sys/netinet/netdump/netdump_client.c   Fri May 10 23:10:22 2019
(r347471)
@@ -1394,11 +1394,11 @@ netdump_modevent(module_t mod __unused, int what, void
freeenv(arg);
}
if ((arg = kern_getenv("net.dump.client")) != NULL) {
-   inet_aton(arg, &conf.kda_server.in4);
+   inet_aton(arg, &conf.kda_client.in4);
freeenv(arg);
}
if ((arg = kern_getenv("net.dump.gateway")) != NULL) {
-   inet_aton(arg, &conf.kda_server.in4);
+   inet_aton(arg, &conf.kda_gateway.in4);
freeenv(arg);
}
conf.kda_af = AF_INET;
___
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: r347472 - head/sys/kern

2019-05-10 Thread Doug Moore
Author: dougm
Date: Fri May 10 23:12:37 2019
New Revision: 347472
URL: https://svnweb.freebsd.org/changeset/base/347472

Log:
  Don't use _Generic, as many systems don't know about it.  Go back to a 
lo-tech switch statement.
  
  Approved by: kib (mentor)
  Differential Revision: https://reviews.freebsd.org/D20235

Modified:
  head/sys/kern/subr_blist.c

Modified: head/sys/kern/subr_blist.c
==
--- head/sys/kern/subr_blist.c  Fri May 10 23:10:22 2019(r347471)
+++ head/sys/kern/subr_blist.c  Fri May 10 23:12:37 2019(r347472)
@@ -215,18 +215,18 @@ static inline int
 bitpos(u_daddr_t mask)
 {
 
-   return (_Generic(mask,
+  switch (sizeof(mask)) {
 #ifdef HAVE_INLINE_FFSLL
-   long long: ffsll(mask) - 1,
+  case sizeof(long long):
+ return (ffsll(mask) - 1);
 #endif
-#ifdef HAVE_INLINE_FFSL
-   long: ffsl(mask) - 1,
-#endif
 #ifdef HAVE_INLINE_FFS
-   int: ffs(mask) - 1,
+  case sizeof(int):
+ return (ffs(mask) - 1);
 #endif
-   default: generic_bitpos(mask)
-   ));
+  default:
+ return (generic_bitpos(mask));
+  }
 }
 
 /*
___
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: r347473 - head/sys/netinet/netdump

2019-05-10 Thread Conrad Meyer
Author: cem
Date: Fri May 10 23:12:59 2019
New Revision: 347473
URL: https://svnweb.freebsd.org/changeset/base/347473

Log:
  netdump: Ref the interface we're attached to
  
  Serialize netdump configuration / deconfiguration, and discard our
  configuration when the affiliated interface goes away by monitoring
  ifnet_departure_event.
  
  Reviewed by:  markj, with input from vangyzen@ (earlier version)
  Sponsored by: Dell EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D20206

Modified:
  head/sys/netinet/netdump/netdump_client.c

Modified: head/sys/netinet/netdump/netdump_client.c
==
--- head/sys/netinet/netdump/netdump_client.c   Fri May 10 23:12:37 2019
(r347472)
+++ head/sys/netinet/netdump/netdump_client.c   Fri May 10 23:12:59 2019
(r347473)
@@ -93,6 +93,8 @@ static int netdump_configure(struct diocskerneldump_a
struct thread *);
 static int  netdump_dumper(void *priv __unused, void *virtual,
vm_offset_t physical __unused, off_t offset, size_t length);
+static bool netdump_enabled(void);
+static int  netdump_enabled_sysctl(SYSCTL_HANDLER_ARGS);
 static int  netdump_ether_output(struct mbuf *m, struct ifnet *ifp,
struct ether_addr dst, u_short etype);
 static void netdump_handle_arp(struct mbuf **mb);
@@ -102,11 +104,13 @@ static int netdump_ioctl(struct cdev *dev 
__unused, u
 static int  netdump_modevent(module_t mod, int type, void *priv);
 static void netdump_network_poll(void);
 static void netdump_pkt_in(struct ifnet *ifp, struct mbuf *m);
+static void netdump_reinit_internal(struct ifnet *ifp);
 static int  netdump_send(uint32_t type, off_t offset, unsigned char *data,
uint32_t datalen);
 static int  netdump_send_arp(in_addr_t dst);
 static int  netdump_start(struct dumperinfo *di);
 static int  netdump_udp_output(struct mbuf *m);
+static void netdump_unconfigure(void);
 
 /* Must be at least as big as the chunks dumpsys() gives us. */
 static unsigned char nd_buf[MAXDUMPPGS * PAGE_SIZE];
@@ -131,8 +135,17 @@ static struct {
 #definend_gateway  nd_conf.ndc_gateway.in4
 
 /* General dynamic settings. */
+static struct sx nd_conf_lk;
+SX_SYSINIT(nd_conf, &nd_conf_lk, "netdump configuration lock");
+#define NETDUMP_WLOCK()sx_xlock(&nd_conf_lk)
+#define NETDUMP_WUNLOCK()  sx_xunlock(&nd_conf_lk)
+#define NETDUMP_RLOCK()sx_slock(&nd_conf_lk)
+#define NETDUMP_RUNLOCK()  sx_sunlock(&nd_conf_lk)
+#define NETDUMP_ASSERT_WLOCKED()   sx_assert(&nd_conf_lk, SA_XLOCKED)
+#define NETDUMP_ASSERT_LOCKED()sx_assert(&nd_conf_lk, 
SA_LOCKED)
 static struct ether_addr nd_gw_mac;
 static struct ifnet *nd_ifp;
+static eventhandler_tag nd_detach_cookie;
 static uint16_t nd_server_port = NETDUMP_PORT;
 
 FEATURE(netdump, "Netdump client support");
@@ -144,10 +157,8 @@ static int nd_debug;
 SYSCTL_INT(_net_netdump, OID_AUTO, debug, CTLFLAG_RWTUN,
 &nd_debug, 0,
 "Debug message verbosity");
-static int nd_enabled;
-SYSCTL_INT(_net_netdump, OID_AUTO, enabled, CTLFLAG_RD,
-&nd_enabled, 0,
-"netdump configuration status");
+SYSCTL_PROC(_net_netdump, OID_AUTO, enabled, CTLFLAG_RD | CTLTYPE_INT,
+&nd_ifp, 0, netdump_enabled_sysctl, "I", "netdump configuration status");
 static char nd_path[MAXPATHLEN];
 SYSCTL_STRING(_net_netdump, OID_AUTO, path, CTLFLAG_RW,
 nd_path, sizeof(nd_path),
@@ -165,6 +176,29 @@ SYSCTL_INT(_net_netdump, OID_AUTO, arp_retries, CTLFLA
 &nd_arp_retries, 0,
 "Number of ARP attempts before giving up");
 
+static bool
+netdump_enabled(void)
+{
+
+   NETDUMP_ASSERT_LOCKED();
+   return (nd_ifp != NULL);
+}
+
+static int
+netdump_enabled_sysctl(SYSCTL_HANDLER_ARGS)
+{
+   int en, error;
+
+   NETDUMP_RLOCK();
+   en = netdump_enabled();
+   NETDUMP_RUNLOCK();
+
+   error = SYSCTL_OUT(req, &en, sizeof(en));
+   if (error != 0 || req->newptr == NULL)
+   return (error);
+   return (EPERM);
+}
+
 /*
  * Checks for netdump support on a network interface
  *
@@ -248,7 +282,7 @@ netdump_udp_output(struct mbuf *m)
struct udpiphdr *ui;
struct ip *ip;
 
-   MPASS(nd_ifp != NULL);
+   MPASS(netdump_enabled());
 
M_PREPEND(m, sizeof(struct udpiphdr), M_NOWAIT);
if (m == NULL) {
@@ -306,7 +340,7 @@ netdump_send_arp(in_addr_t dst)
struct arphdr *ah;
int pktlen;
 
-   MPASS(nd_ifp != NULL);
+   MPASS(netdump_enabled());
 
/* Fill-up a broadcast address. */
memset(&bcast, 0xFF, ETHER_ADDR_LEN);
@@ -409,7 +443,7 @@ netdump_send(uint32_t type, off_t offset, unsigned cha
rcvd_acks = 0;
retries = 0;
 
-   MPASS(nd_ifp != NULL);
+   MPASS(netdump_enabled());
 
 retransmit:
/

svn commit: r347476 - head/usr.sbin/mountd

2019-05-10 Thread Rick Macklem
Author: rmacklem
Date: Fri May 10 23:52:17 2019
New Revision: 347476
URL: https://svnweb.freebsd.org/changeset/base/347476

Log:
  Factor out some exportlist list operations into separate functions.
  
  This patch moves the code that removes and frees all exportlist elements
  out into a separate function called free_exports().
  It does the same for the insertion of a new exportlist entry into a list.
  It also adds a second argument to ex_search() for the list to use.
  None of these changes have any semantic effect. They are being done to
  prepare the code for future patches that convert the single linked list
  for the exportlist to a hash table of lists and a patch that will do
  incremental changes of exports in the kernel.
  And it fixes the argument for SLIST_HEAD_INITIALIZER() to be a pointer,
  which doesn't really matter, since SLIST_HEAD_INITIALIZER() doesn't use
  the argument.
  
  MFC after:1 month

Modified:
  head/usr.sbin/mountd/mountd.c

Modified: head/usr.sbin/mountd/mountd.c
==
--- head/usr.sbin/mountd/mountd.c   Fri May 10 23:46:42 2019
(r347475)
+++ head/usr.sbin/mountd/mountd.c   Fri May 10 23:52:17 2019
(r347476)
@@ -128,6 +128,8 @@ struct exportlist {
 /* ex_flag bits */
 #defineEX_LINKED   0x1
 
+SLIST_HEAD(exportlisthead, exportlist);
+
 struct netmsk {
struct sockaddr_storage nt_net;
struct sockaddr_storage nt_mask;
@@ -189,13 +191,15 @@ static intdo_mount(struct exportlist *, struct 
groupl
struct xucred *, char *, int, struct statfs *);
 static int do_opt(char **, char **, struct exportlist *,
struct grouplist *, int *, int *, struct xucred *);
-static struct exportlist   *ex_search(fsid_t *);
+static struct exportlist   *ex_search(fsid_t *, struct exportlisthead *);
 static struct exportlist   *get_exp(void);
 static voidfree_dir(struct dirlist *);
 static voidfree_exp(struct exportlist *);
 static voidfree_grp(struct grouplist *);
 static voidfree_host(struct hostlist *);
 static voidget_exportlist(void);
+static voidinsert_exports(struct exportlist *, struct exportlisthead *);
+static voidfree_exports(struct exportlisthead *);
 static int get_host(char *, struct grouplist *, struct grouplist *);
 static struct hostlist *get_ht(void);
 static int get_line(void);
@@ -227,8 +231,8 @@ static int  xdr_fhs(XDR *, caddr_t);
 static int xdr_mlist(XDR *, caddr_t);
 static voidterminate(int);
 
-static SLIST_HEAD(, exportlist) exphead = SLIST_HEAD_INITIALIZER(exphead);
-static SLIST_HEAD(, mountlist) mlhead = SLIST_HEAD_INITIALIZER(mlhead);
+static struct exportlisthead exphead = SLIST_HEAD_INITIALIZER(&exphead);
+static SLIST_HEAD(, mountlist) mlhead = SLIST_HEAD_INITIALIZER(&mlhead);
 static struct grouplist *grphead;
 static char *exnames_default[2] = { _PATH_EXPORTS, NULL };
 static char **exnames;
@@ -1087,7 +1091,7 @@ mntsrv(struct svc_req *rqstp, SVCXPRT *transp)
if (bad)
ep = NULL;
else
-   ep = ex_search(&fsb.f_fsid);
+   ep = ex_search(&fsb.f_fsid, &exphead);
hostset = defset = 0;
if (ep && (chk_host(ep->ex_defdir, saddr, &defset, &hostset,
&numsecflavors, &secflavorsp) ||
@@ -1540,7 +1544,7 @@ get_exportlist_one(void)
 * See if this directory is already
 * in the list.
 */
-   ep = ex_search(&fsb.f_fsid);
+   ep = ex_search(&fsb.f_fsid, &exphead);
if (ep == (struct exportlist *)NULL) {
ep = get_exp();
ep->ex_fs = fsb.f_fsid;
@@ -1695,7 +1699,7 @@ get_exportlist_one(void)
}
dirhead = (struct dirlist *)NULL;
if ((ep->ex_flag & EX_LINKED) == 0) {
-   SLIST_INSERT_HEAD(&exphead, ep, entries);
+   insert_exports(ep, &exphead);
 
ep->ex_flag |= EX_LINKED;
}
@@ -1714,7 +1718,6 @@ nextline:
 static void
 get_exportlist(void)
 {
-   struct exportlist *ep, *ep2;
struct grouplist *grp, *tgrp;
struct export_args export;
struct iovec *iov;
@@ -1738,10 +1741,7 @@ get_exportlist(void)
/*
 * First, get rid of the old list
 */
-   SLIST_FOREACH_SAFE(ep, &exphead, entries, ep2) {
-   SLIST_REMOVE(&exphead, ep, exportlist, entries);
-   free_exp(ep);
-   }
+   free_exports(&exphead);
 
grp = grphead;
while (grp) {
@@ -1869,6 +1869,31 @@ get_exportlist(void)
 }
 
 /*

svn commit: r347477 - head/sys/kern

2019-05-10 Thread Doug Moore
Author: dougm
Date: Sat May 11 02:13:52 2019
New Revision: 347477
URL: https://svnweb.freebsd.org/changeset/base/347477

Log:
  Revert r347469.
  
  Approved by: kib (mentor)

Modified:
  head/sys/kern/subr_blist.c

Modified: head/sys/kern/subr_blist.c
==
--- head/sys/kern/subr_blist.c  Fri May 10 23:52:17 2019(r347476)
+++ head/sys/kern/subr_blist.c  Sat May 11 02:13:52 2019(r347477)
@@ -192,41 +192,31 @@ bitrange(int n, int count)
 
 
 /*
- * Find the first bit set in a u_daddr_t.
+ * Use binary search, or a faster method, to find the 1 bit in a u_daddr_t.
+ * Assumes that the argument has only one bit set.
  */
 static inline int
-generic_bitpos(u_daddr_t mask)
+bitpos(u_daddr_t mask)
 {
int hi, lo, mid;
 
-   lo = 0;
-   hi = BLIST_BMAP_RADIX;
-   while (lo + 1 < hi) {
-   mid = (lo + hi) >> 1;
-   if (mask & bitrange(0, mid))
-   hi = mid;
-   else
-   lo = mid;
-   }
-   return (lo);
-}
-
-static inline int
-bitpos(u_daddr_t mask)
-{
-
-  switch (sizeof(mask)) {
+   switch (sizeof(mask)) {
 #ifdef HAVE_INLINE_FFSLL
-  case sizeof(long long):
- return (ffsll(mask) - 1);
+   case sizeof(long long):
+   return (ffsll(mask) - 1);
 #endif
-#ifdef HAVE_INLINE_FFS
-  case sizeof(int):
- return (ffs(mask) - 1);
-#endif
-  default:
- return (generic_bitpos(mask));
-  }
+   default:
+   lo = 0;
+   hi = BLIST_BMAP_RADIX;
+   while (lo + 1 < hi) {
+   mid = (lo + hi) >> 1;
+   if ((mask >> mid) != 0)
+   lo = mid;
+   else
+   hi = mid;
+   }
+   return (lo);
+   }
 }
 
 /*
@@ -542,8 +532,7 @@ blist_stats(blist_t bl, struct sbuf *s)
struct gap_stats gstats;
struct gap_stats *stats = &gstats;
daddr_t i, nodes, radix;
-   u_daddr_t diff, mask;
-   int digit;
+   u_daddr_t bit, diff, mask;
 
init_gap_stats(stats);
nodes = 0;
@@ -581,9 +570,9 @@ blist_stats(blist_t bl, struct sbuf *s)
if (gap_stats_counting(stats))
diff ^= 1;
while (diff != 0) {
-   digit = bitpos(diff);
-   update_gap_stats(stats, i + digit);
-   diff ^= bitrange(digit, 1);
+   bit = diff & -diff;
+   update_gap_stats(stats, i + bitpos(bit));
+   diff ^= bit;
}
}
nodes += radix_to_skip(radix);
@@ -787,7 +776,7 @@ static daddr_t
 blst_meta_alloc(blmeta_t *scan, daddr_t cursor, daddr_t count, u_daddr_t radix)
 {
daddr_t blk, i, r, skip;
-   u_daddr_t mask;
+   u_daddr_t bit, mask;
bool scan_from_start;
int digit;
 
@@ -819,7 +808,8 @@ blst_meta_alloc(blmeta_t *scan, daddr_t cursor, daddr_
 * Examine the nonempty subtree associated with each bit set in mask.
 */
do {
-   digit = bitpos(mask);
+   bit = mask & -mask;
+   digit = bitpos(bit);
i = 1 + digit * skip;
if (count <= scan[i].bm_bighint) {
/*
@@ -829,12 +819,12 @@ blst_meta_alloc(blmeta_t *scan, daddr_t cursor, daddr_
count, radix);
if (r != SWAPBLK_NONE) {
if (scan[i].bm_bitmap == 0)
-   scan->bm_bitmap ^= bitrange(digit, 1);
+   scan->bm_bitmap ^= bit;
return (r);
}
}
cursor = blk;
-   } while ((mask ^= bitrange(digit, 1)) != 0);
+   } while ((mask ^= bit) != 0);
 
/*
 * We couldn't allocate count in this subtree.  If the whole tree was
@@ -1029,7 +1019,7 @@ static void
 blst_radix_print(blmeta_t *scan, daddr_t blk, daddr_t radix, int tab)
 {
daddr_t skip;
-   u_daddr_t mask;
+   u_daddr_t bit, mask;
int digit;
 
if (radix == BLIST_BMAP_RADIX) {
@@ -1061,10 +1051,11 @@ blst_radix_print(blmeta_t *scan, daddr_t blk, daddr_t 
mask = scan->bm_bitmap;
/* Examine the nonempty subtree associated with each bit set in mask */
do {
-   digit = bitpos(mask);
+   bit = mask & -mask;
+   digit = bitpos(bit);
blst_radix_print(&scan[1 + digit * skip], blk + digit * radix,
radix, tab);
-   } while ((mask ^= bitrange(digit, 1)) != 0);
+   } while ((mask ^= bit) != 0);
tab -= 4;
 
printf

svn commit: r347483 - head/sys/net

2019-05-10 Thread Kyle Evans
Author: kevans
Date: Sat May 11 04:18:06 2019
New Revision: 347483
URL: https://svnweb.freebsd.org/changeset/base/347483

Log:
  tuntap: Improve style
  
  No functional change.
  
  tun_flags of the tuntap_driver was renamed to ident_flags to reflect the
  fact that it's a subset of the tun_flags that identifies a tuntap device.
  This maps more easily (visually) to the TUN_DRIVER_IDENT_MASK that masks off
  the bits of tun_flags that are applicable to tuntap driver ident. This is a
  purely cosmetic change.

Modified:
  head/sys/net/if_tuntap.c

Modified: head/sys/net/if_tuntap.c
==
--- head/sys/net/if_tuntap.cSat May 11 03:41:58 2019(r347482)
+++ head/sys/net/if_tuntap.cSat May 11 04:18:06 2019(r347483)
@@ -104,9 +104,9 @@ struct tuntap_driver;
  * static for the duration of a tunnel interface.
  */
 struct tuntap_softc {
-   TAILQ_ENTRY(tuntap_softc)   tun_list;
-   struct cdev *tun_dev;
-   u_short tun_flags;  /* misc flags */
+   TAILQ_ENTRY(tuntap_softc)tun_list;
+   struct cdev *tun_dev;
+   u_short  tun_flags; /* misc flags */
 #defineTUN_OPEN0x0001
 #defineTUN_INITED  0x0002
 #defineTUN_RCOLL   0x0004
@@ -120,20 +120,21 @@ struct tuntap_softc {
 #defineTUN_L2  0x0400
 #defineTUN_VMNET   0x0800
 
-#define TUN_READY   (TUN_OPEN | TUN_INITED)
+#defineTUN_DRIVER_IDENT_MASK   (TUN_L2 | TUN_VMNET)
+#defineTUN_READY   (TUN_OPEN | TUN_INITED)
 
-   pid_t   tun_pid;/* owning pid */
-   struct  ifnet *tun_ifp; /* the interface */
-   struct  sigio *tun_sigio;   /* information for async I/O */
-   struct  tuntap_driver *tun_drv; /* appropriate driver */
-   struct  selinfo tun_rsel;   /* read select */
-   struct mtx  tun_mtx;/* protect mutable softc fields */
-   struct cv   tun_cv; /* protect against ref'd dev destroy */
-   struct ether_addr   tun_ether;  /* remote address */
+   pid_ttun_pid;   /* owning pid */
+   struct ifnet*tun_ifp;   /* the interface */
+   struct sigio*tun_sigio; /* async I/O info */
+   struct tuntap_driver*tun_drv;   /* appropriate driver */
+   struct selinfo   tun_rsel;  /* read select */
+   struct mtx   tun_mtx;   /* softc field mutex */
+   struct cvtun_cv;/* for ref'd dev destroy */
+   struct ether_addrtun_ether; /* remote address */
 };
-#define TUN2IFP(sc)((sc)->tun_ifp)
+#defineTUN2IFP(sc) ((sc)->tun_ifp)
 
-#define TUNDEBUG   if (tundebug) if_printf
+#defineTUNDEBUGif (tundebug) if_printf
 
 #defineTUN_LOCK(tp)mtx_lock(&(tp)->tun_mtx)
 #defineTUN_UNLOCK(tp)  mtx_unlock(&(tp)->tun_mtx)
@@ -153,8 +154,8 @@ static const char vmnetname[] = "vmnet";
 static MALLOC_DEFINE(M_TUN, tunname, "Tunnel Interface");
 static int tundebug = 0;
 static int tundclone = 1;
-static int tap_allow_uopen = 0;/* allow user open() */
-static int tapuponopen = 0;/* IFF_UP on open() */
+static int tap_allow_uopen = 0;/* allow user open() */
+static int tapuponopen = 0;/* IFF_UP on open() */
 static int tapdclone = 1;  /* enable devfs cloning */
 
 static TAILQ_HEAD(,tuntap_softc)   tunhead = 
TAILQ_HEAD_INITIALIZER(tunhead);
@@ -174,11 +175,11 @@ SYSCTL_INT(_net_link_tun, OID_AUTO, devfs_cloning, CTL
 static SYSCTL_NODE(_net_link, OID_AUTO, tap, CTLFLAG_RW, 0,
 "Ethernet tunnel software network interface");
 SYSCTL_INT(_net_link_tap, OID_AUTO, user_open, CTLFLAG_RW, &tap_allow_uopen, 0,
-   "Allow user to open /dev/tap (based on node permissions)");
+"Allow user to open /dev/tap (based on node permissions)");
 SYSCTL_INT(_net_link_tap, OID_AUTO, up_on_open, CTLFLAG_RW, &tapuponopen, 0,
-   "Bring interface up when /dev/tap is opened");
+"Bring interface up when /dev/tap is opened");
 SYSCTL_INT(_net_link_tap, OID_AUTO, devfs_cloning, CTLFLAG_RWTUN, &tapdclone, 
0,
-   "Enable legacy devfs interface creation");
+"Enable legacy devfs interface creation");
 SYSCTL_INT(_net_link_tap, OID_AUTO, debug, CTLFLAG_RW, &tundebug, 0, "");
 
 static int tuntap_name2info(const char *name, int *unit, int *flags);
@@ -226,19 +227,17 @@ static struct filterops tun_write_filterops = {
.f_event =  tunkqwrite,
 };
 
-#defineTUN_DRIVER_IDENT_MASK   (TUN_L2 | TUN_VMNET)
-
 static struct tuntap_driver {
-   int  tun_flags;
-   struct unrhdr   *unrhdr;
struct cdevswcdevsw;
+   int  ident_flags;
+   struct unrhdr   *unrhdr;
struct clonedevs  

Re: svn commit: r347477 - head/sys/kern

2019-05-10 Thread Cy Schubert
In message <201905110213.x4b2dq9u088...@repo.freebsd.org>, Doug Moore 
writes:
> Author: dougm
> Date: Sat May 11 02:13:52 2019
> New Revision: 347477
> URL: https://svnweb.freebsd.org/changeset/base/347477
>
> Log:
>   Revert r347469.

Why?

>   
>   Approved by: kib (mentor)
>
> Modified:
>   head/sys/kern/subr_blist.c
>


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


Re: svn commit: r347477 - head/sys/kern

2019-05-10 Thread Doug Moore
With mentor approval, I commit r347469.  I start getting email about
jenkins failure to build for several architectures on account of the
_Generic() construct I introduced in that change.

I whip up a patch to undo that part of r347469, and ask for mentor
approval.  Meanwhile, mentor authorizes me in email to revert r347469.

I try apply applying the fix-patch, and get email that it was rejected
for lack of reviewer.  In retrospect, it seems to have been committed
anyway as r347472.

Thinking that things are still broken, I do what my mentor pre-approved
earlier and revert back to before r347469.  A patch to redo r347469,
without _Generic(), awaits mentor approval.

I realize that breaking the build and then committing without mentor
approval in my first week as committer isn't a good beginning.   Sorry
about that.

At least I have no social media presence, so there's that.

Doug Moore


On 5/10/19 11:47 PM, Cy Schubert wrote:
> In message <201905110213.x4b2dq9u088...@repo.freebsd.org>, Doug Moore 
> writes:
>> Author: dougm
>> Date: Sat May 11 02:13:52 2019
>> New Revision: 347477
>> URL: https://svnweb.freebsd.org/changeset/base/347477
>>
>> Log:
>>   Revert r347469.
> Why?
>
>>   
>>   Approved by: kib (mentor)
>>
>> Modified:
>>   head/sys/kern/subr_blist.c
>>
>

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