Re: svn commit: r331732 - head/sys/vm

2018-04-01 Thread Tijl Coosemans
On Sat, 31 Mar 2018 18:54:32 -0400 Mark Johnston  wrote:
> On Sat, Mar 31, 2018 at 08:21:18PM +0200, Tijl Coosemans wrote:
> > On Thu, 29 Mar 2018 14:27:40 + (UTC) Mark Johnston  
> > wrote:  
> > > Author: markj
> > > Date: Thu Mar 29 14:27:40 2018
> > > New Revision: 331732
> > > URL: https://svnweb.freebsd.org/changeset/base/331732
> > > 
> > > Log:
> > >   Fix the background laundering mechanism after r329882.
> > >   
> > >   Rather than using the number of inactive queue scans as a metric for
> > >   how many clean pages are being freed by the page daemon, have the
> > >   page daemon keep a running counter of the number of pages it has freed,
> > >   and have the laundry thread use that when computing the background
> > >   laundering threshold.
> > > [...]  
> > 
> > I'm seeing big processes being killed with an "out of swap space" message
> > even though there's still plenty of swap available.  It seems to be fixed
> > by making this division round upwards:
> > 
> > if (target == 0 && ndirty * isqrt((nfreed +
> > (vmd->vmd_free_target - vmd->vmd_free_min) - 1) /
> > (vmd->vmd_free_target - vmd->vmd_free_min)) >= nclean) {
> > 
> > I don't know where this formula comes from, so I don't know if this
> > change is correct.  
> 
> Hm, that's somewhat surprising. This code shouldn't be executing in
> situations where the OOM kill logic is invoked (i.e., memory pressure
> plus a shortage of clean pages in the inactive queue).
> 
> How much RAM does the system have? Could you collect "sysctl vm" output
> around the time of an OOM kill?

1GiB RAM.  I've sampled sysctl vm every 5s from the moment the process
starts swapping until it is killed and uploaded that to
https://people.freebsd.org/~tijl/sysctl/

> I'm wondering if the higher inactive queue scan frequency after r329882
> might be responsible: OOM kills are performed after vm.pageout_oom_seq
> back-to-back scans fail to reclaim any pages. Does your problem persist
> if you increase the value of that sysctl, say to 60?

This didn't help.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r331732 - head/sys/vm

2018-04-01 Thread Mark Johnston
On Sun, Apr 01, 2018 at 05:20:21PM +0200, Tijl Coosemans wrote:
> On Sat, 31 Mar 2018 18:54:32 -0400 Mark Johnston  wrote:
> > On Sat, Mar 31, 2018 at 08:21:18PM +0200, Tijl Coosemans wrote:
> > > On Thu, 29 Mar 2018 14:27:40 + (UTC) Mark Johnston 
> > >  wrote:  
> > > > Author: markj
> > > > Date: Thu Mar 29 14:27:40 2018
> > > > New Revision: 331732
> > > > URL: https://svnweb.freebsd.org/changeset/base/331732
> > > > 
> > > > Log:
> > > >   Fix the background laundering mechanism after r329882.
> > > >   
> > > >   Rather than using the number of inactive queue scans as a metric for
> > > >   how many clean pages are being freed by the page daemon, have the
> > > >   page daemon keep a running counter of the number of pages it has 
> > > > freed,
> > > >   and have the laundry thread use that when computing the background
> > > >   laundering threshold.
> > > > [...]  
> > > 
> > > I'm seeing big processes being killed with an "out of swap space" message
> > > even though there's still plenty of swap available.  It seems to be fixed
> > > by making this division round upwards:
> > > 
> > >   if (target == 0 && ndirty * isqrt((nfreed +
> > >   (vmd->vmd_free_target - vmd->vmd_free_min) - 1) /
> > >   (vmd->vmd_free_target - vmd->vmd_free_min)) >= nclean) {
> > > 
> > > I don't know where this formula comes from, so I don't know if this
> > > change is correct.  
> > 
> > Hm, that's somewhat surprising. This code shouldn't be executing in
> > situations where the OOM kill logic is invoked (i.e., memory pressure
> > plus a shortage of clean pages in the inactive queue).
> > 
> > How much RAM does the system have? Could you collect "sysctl vm" output
> > around the time of an OOM kill?
> 
> 1GiB RAM.  I've sampled sysctl vm every 5s from the moment the process
> starts swapping until it is killed and uploaded that to
> https://people.freebsd.org/~tijl/sysctl/

Thank you. Now I agree with your change. Would you like to commit it?
I can take care of it if you prefer.

There is still a deeper problem here after r329882 in that the shortfall
laundering mechanism is not kicking in before the OOM killer. The
problem is that the PID controller may produce a positive output even
when the error is negative; this is seen in 22.txt, the last capture
before the OOM kill. Because the error is negative (i.e.,
v_free_count > v_free_target), we will not attempt to launder pages in
shortfall mode. The positive output means that the page daemon is
repeatedly scanning the (completely depleted) inactive queue, but since
the laundering mechanism is failing to produce clean pages, there is
nothing to reclaim and so we eventually invoke the OOM killer.

I'm not yet sure how best to address this, but your change is probably
sufficient to mitigate the problem in general and also corrects an
unintentional behaviour change in my commit.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2018-04-01 Thread Mark Johnston
On Sat, Mar 31, 2018 at 11:33:48AM +0200, Harry Schmalzbauer wrote:
>  Bezüglich Sean Bruno's Nachricht vom 11.10.2017 00:21 (localtime):
> > Author: sbruno
> > Date: Tue Oct 10 22:21:05 2017
> > New Revision: 324508
> > URL: https://svnweb.freebsd.org/changeset/base/324508
> >
> > Log:
> >   match sendfile() error handling to send().
> >   
> >   Sendfile() should match the error checking order of send() which
> >   is currently:
> >   
> >   SBS_CANTSENDMORE
> >   so_error
> >   SS_ISCONNECTED
> >   
> >   Submitted by: Jason Eggleston 
> >   Reviewed by:  glebius
> >   MFC after:2 weeks
> >   Sponsored by: Limelight Networks
> >   Differential Revision:https://reviews.freebsd.org/D12633
> >
> > Modified:
> >   head/sys/kern/kern_sendfile.c
> >
> 
> I'm still applying this one locally to stable/11.
> Is it going to be MFCd before 11.2?
> 
> There are a view more candidates:
> https://svnweb.freebsd.org/base?view=revision=324601 along with
> r324448
> https://svnweb.freebsd.org/base?view=revision=327596
> https://svnweb.freebsd.org/base?view=revision=328977
> These were flagged for MFC with expired defer time.
> And tomorrow this one was supposed to be MFCd also:
> https://svnweb.freebsd.org/base?view=revision=331130

I think r324446 and r324448 need to be MFCed before most of these can go
in. I MFCed the other commits (r317567, r324508) that you asked about in
other threads.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r331732 - head/sys/vm

2018-04-01 Thread Tijl Coosemans
On Sun, 1 Apr 2018 12:27:03 -0400 Mark Johnston  wrote:
> On Sun, Apr 01, 2018 at 05:20:21PM +0200, Tijl Coosemans wrote:
>> On Sat, 31 Mar 2018 18:54:32 -0400 Mark Johnston  wrote:  
>>> On Sat, Mar 31, 2018 at 08:21:18PM +0200, Tijl Coosemans wrote:  
 On Thu, 29 Mar 2018 14:27:40 + (UTC) Mark Johnston  
 wrote:
> Author: markj
> Date: Thu Mar 29 14:27:40 2018
> New Revision: 331732
> URL: https://svnweb.freebsd.org/changeset/base/331732
> 
> Log:
>   Fix the background laundering mechanism after r329882.
>   
>   Rather than using the number of inactive queue scans as a metric for
>   how many clean pages are being freed by the page daemon, have the
>   page daemon keep a running counter of the number of pages it has freed,
>   and have the laundry thread use that when computing the background
>   laundering threshold.
> [...]
 
 I'm seeing big processes being killed with an "out of swap space" message
 even though there's still plenty of swap available.  It seems to be fixed
 by making this division round upwards:
 
if (target == 0 && ndirty * isqrt((nfreed +
(vmd->vmd_free_target - vmd->vmd_free_min) - 1) /
(vmd->vmd_free_target - vmd->vmd_free_min)) >= nclean) {
 
 I don't know where this formula comes from, so I don't know if this
 change is correct.
>>> 
>>> Hm, that's somewhat surprising. This code shouldn't be executing in
>>> situations where the OOM kill logic is invoked (i.e., memory pressure
>>> plus a shortage of clean pages in the inactive queue).
>>> 
>>> How much RAM does the system have? Could you collect "sysctl vm" output
>>> around the time of an OOM kill?  
>> 
>> 1GiB RAM.  I've sampled sysctl vm every 5s from the moment the process
>> starts swapping until it is killed and uploaded that to
>> https://people.freebsd.org/~tijl/sysctl/  
> 
> Thank you. Now I agree with your change. Would you like to commit it?
> I can take care of it if you prefer.

Please go ahead.  You can probably write a better commit log.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r331866 - stable/11/sys/x86/x86

2018-04-01 Thread Mark Johnston
Author: markj
Date: Sun Apr  1 16:42:13 2018
New Revision: 331866
URL: https://svnweb.freebsd.org/changeset/base/331866

Log:
  MFC r317567 (by cem):
  x86 MCA: Fix a deadlock in MCA exception processing

Modified:
  stable/11/sys/x86/x86/mca.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/x86/x86/mca.c
==
--- stable/11/sys/x86/x86/mca.c Sun Apr  1 07:49:48 2018(r331865)
+++ stable/11/sys/x86/x86/mca.c Sun Apr  1 16:42:13 2018(r331866)
@@ -653,7 +653,7 @@ amd_thresholding_update(enum scan_mode mode, int bank,
  * count of the number of valid MC records found.
  */
 static int
-mca_scan(enum scan_mode mode)
+mca_scan(enum scan_mode mode, int *recoverablep)
 {
struct mca_record rec;
uint64_t mcg_cap, ucmask;
@@ -704,7 +704,9 @@ mca_scan(enum scan_mode mode)
}
if (mode == POLLED)
mca_fill_freelist();
-   return (mode == MCE ? recoverable : count);
+   if (recoverablep != NULL)
+   *recoverablep = recoverable;
+   return (count);
 }
 
 /*
@@ -726,7 +728,7 @@ mca_scan_cpus(void *context, int pending)
CPU_FOREACH(cpu) {
sched_bind(td, cpu);
thread_unlock(td);
-   count += mca_scan(POLLED);
+   count += mca_scan(POLLED, NULL);
thread_lock(td);
sched_unbind(td);
}
@@ -1150,7 +1152,7 @@ void
 mca_intr(void)
 {
uint64_t mcg_status;
-   int old_count, recoverable;
+   int recoverable, count;
 
if (!(cpu_feature & CPUID_MCA)) {
/*
@@ -1164,20 +1166,18 @@ mca_intr(void)
}
 
/* Scan the banks and check for any non-recoverable errors. */
-   old_count = mca_count;
-   recoverable = mca_scan(MCE);
+   count = mca_scan(MCE, );
mcg_status = rdmsr(MSR_MCG_STATUS);
if (!(mcg_status & MCG_STATUS_RIPV))
recoverable = 0;
 
if (!recoverable) {
/*
-* Wait for at least one error to be logged before
-* panic'ing.  Some errors will assert a machine check
-* on all CPUs, but only certain CPUs will find a valid
-* bank to log.
+* Only panic if the error was detected local to this CPU.
+* Some errors will assert a machine check on all CPUs, but
+* only certain CPUs will find a valid bank to log.
 */
-   while (mca_count == old_count)
+   while (count == 0)
cpu_spinwait();
 
panic("Unrecoverable machine check exception");
@@ -1199,7 +1199,7 @@ cmc_intr(void)
 * Serialize MCA bank scanning to prevent collisions from
 * sibling threads.
 */
-   count = mca_scan(CMCI);
+   count = mca_scan(CMCI, NULL);
 
/* If we found anything, log them to the console. */
if (count != 0) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r331867 - stable/11/sys/netsmb

2018-04-01 Thread Mark Johnston
Author: markj
Date: Sun Apr  1 16:43:30 2018
New Revision: 331867
URL: https://svnweb.freebsd.org/changeset/base/331867

Log:
  MFC r324102 (by cem):
  netsmb: Fix buggy/racy smb_strdupin()
  
  PR:   222687

Modified:
  stable/11/sys/netsmb/smb_subr.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/netsmb/smb_subr.c
==
--- stable/11/sys/netsmb/smb_subr.c Sun Apr  1 16:42:13 2018
(r331866)
+++ stable/11/sys/netsmb/smb_subr.c Sun Apr  1 16:43:30 2018
(r331867)
@@ -110,22 +110,11 @@ smb_strdup(const char *s)
 char *
 smb_strdupin(char *s, size_t maxlen)
 {
-   char *p, bt;
+   char *p;
int error;
-   size_t len;
 
-   len = 0;
-   for (p = s; ;p++) {
-   if (copyin(p, , 1))
-   return NULL;
-   len++;
-   if (maxlen && len > maxlen)
-   return NULL;
-   if (bt == 0)
-   break;
-   }
-   p = malloc(len, M_SMBSTR, M_WAITOK);
-   error = copyin(s, p, len);
+   p = malloc(maxlen + 1, M_SMBSTR, M_WAITOK);
+   error = copyinstr(s, p, maxlen + 1, NULL);
if (error) {
free(p, M_SMBSTR);
return (NULL);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r331862 - head/sys/vm

2018-04-01 Thread Jeff Roberson
Author: jeff
Date: Sun Apr  1 04:47:05 2018
New Revision: 331862
URL: https://svnweb.freebsd.org/changeset/base/331862

Log:
  Add the flag ZONE_NOBUCKETCACHE.  This flag instructions UMA not to keep
  a cache of fully populated buckets.  This will be used in a follow-on
  commit.
  
  The flag idea was originally from markj.
  
  Reviewed by:  markj, kib
  Tested by:pho
  Sponsored by: Netflix, Dell/EMC Isilon

Modified:
  head/sys/vm/uma.h
  head/sys/vm/uma_core.c

Modified: head/sys/vm/uma.h
==
--- head/sys/vm/uma.h   Sun Apr  1 04:11:38 2018(r331861)
+++ head/sys/vm/uma.h   Sun Apr  1 04:47:05 2018(r331862)
@@ -286,6 +286,10 @@ uma_zone_t uma_zcache_create(char *name, int size, uma
 * NUMA aware Zone.  Implements a best
 * effort first-touch policy.
 */
+#defineUMA_ZONE_NOBUCKETCACHE  0x2 /*
+* Don't cache full buckets.  Limit
+* UMA to per-cpu state.
+*/
 
 /*
  * These flags are shared between the keg and zone.  In zones wishing to add

Modified: head/sys/vm/uma_core.c
==
--- head/sys/vm/uma_core.c  Sun Apr  1 04:11:38 2018(r331861)
+++ head/sys/vm/uma_core.c  Sun Apr  1 04:47:05 2018(r331862)
@@ -2965,7 +2965,13 @@ zfree_start:
/* ub_cnt is pointing to the last free item */
KASSERT(bucket->ub_cnt != 0,
("uma_zfree: Attempting to insert an empty bucket onto the 
full list.\n"));
-   LIST_INSERT_HEAD(>uzd_buckets, bucket, ub_link);
+   if ((zone->uz_flags & UMA_ZONE_NOBUCKETCACHE) != 0) {
+   ZONE_UNLOCK(zone);
+   bucket_drain(zone, bucket);
+   bucket_free(zone, bucket, udata);
+   goto zfree_restart;
+   } else
+   LIST_INSERT_HEAD(>uzd_buckets, bucket, ub_link);
}
 
/*
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r331863 - head/sys/vm

2018-04-01 Thread Jeff Roberson
Author: jeff
Date: Sun Apr  1 04:50:05 2018
New Revision: 331863
URL: https://svnweb.freebsd.org/changeset/base/331863

Log:
  Add a uma cache of free pages in the DEFAULT freepool.  This gives us
  per-cpu alloc and free of pages.  The cache is filled with as few trips
  to the phys allocator as possible by the use of a new
  vm_phys_alloc_npages() function which allocates as many as N pages.
  
  This code was originally by markj with the import function rewritten by
  me.
  
  Reviewed by:  markj, kib
  Tested by:pho
  Sponsored by: Netflix, Dell/EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D14905

Modified:
  head/sys/vm/vm_page.c
  head/sys/vm/vm_pagequeue.h
  head/sys/vm/vm_phys.c
  head/sys/vm/vm_phys.h

Modified: head/sys/vm/vm_page.c
==
--- head/sys/vm/vm_page.c   Sun Apr  1 04:47:05 2018(r331862)
+++ head/sys/vm/vm_page.c   Sun Apr  1 04:50:05 2018(r331863)
@@ -186,6 +186,9 @@ static int vm_page_reclaim_run(int req_class, int doma
 vm_page_t m_run, vm_paddr_t high);
 static int vm_domain_alloc_fail(struct vm_domain *vmd, vm_object_t object,
 int req);
+static int vm_page_import(void *arg, void **store, int cnt, int domain,
+int flags);
+static void vm_page_release(void *arg, void **store, int cnt);
 
 SYSINIT(vm_page, SI_SUB_VM, SI_ORDER_SECOND, vm_page_init, NULL);
 
@@ -199,6 +202,32 @@ vm_page_init(void *dummy)
VM_ALLOC_NORMAL | VM_ALLOC_WIRED);
 }
 
+/*
+ * The cache page zone is initialized later since we need to be able to 
allocate
+ * pages before UMA is fully initialized.
+ */
+static void
+vm_page_init_cache_zones(void *dummy __unused)
+{
+   struct vm_domain *vmd;
+   int i;
+
+   for (i = 0; i < vm_ndomains; i++) {
+   vmd = VM_DOMAIN(i);
+   /*
+* Don't allow the page cache to take up more than .25% of
+* memory.
+*/
+   if (vmd->vmd_page_count / 400 < 256 * mp_ncpus)
+   continue;
+   vmd->vmd_pgcache = uma_zcache_create("vm pgcache",
+   sizeof(struct vm_page), NULL, NULL, NULL, NULL,
+   vm_page_import, vm_page_release, vmd,
+   UMA_ZONE_NOBUCKETCACHE | UMA_ZONE_MAXBUCKET | UMA_ZONE_VM);
+   }
+}
+SYSINIT(vm_page2, SI_SUB_VM_CONF, SI_ORDER_ANY, vm_page_init_cache_zones, 
NULL);
+
 /* Make sure that u_long is at least 64 bits when PAGE_SIZE is 32K. */
 #if PAGE_SIZE == 32768
 #ifdef CTASSERT
@@ -1753,6 +1782,11 @@ again:
}
 #endif
vmd = VM_DOMAIN(domain);
+   if (object != NULL && vmd->vmd_pgcache != NULL) {
+   m = uma_zalloc(vmd->vmd_pgcache, M_NOWAIT);
+   if (m != NULL)
+   goto found;
+   }
if (vm_domain_allocate(vmd, req, 1)) {
/*
 * If not, allocate it from the free page queues.
@@ -1783,9 +1817,7 @@ again:
 */
KASSERT(m != NULL, ("missing page"));
 
-#if VM_NRESERVLEVEL > 0
 found:
-#endif
vm_page_alloc_check(m);
 
/*
@@ -2150,6 +2182,52 @@ again:
return (m);
 }
 
+static int
+vm_page_import(void *arg, void **store, int cnt, int domain, int flags)
+{
+   struct vm_domain *vmd;
+   vm_page_t m;
+   int i, j, n;
+
+   vmd = arg;
+   /* Only import if we can bring in a full bucket. */
+   if (cnt == 1 || !vm_domain_allocate(vmd, VM_ALLOC_NORMAL, cnt))
+   return (0);
+   domain = vmd->vmd_domain;
+   n = 64; /* Starting stride, arbitrary. */
+   vm_domain_free_lock(vmd);
+   for (i = 0; i < cnt; i+=n) {
+   n = vm_phys_alloc_npages(domain, VM_FREELIST_DEFAULT, ,
+   MIN(n, cnt-i));
+   if (n == 0)
+   break;
+   for (j = 0; j < n; j++)
+   store[i+j] = m++;
+   }
+   vm_domain_free_unlock(vmd);
+   if (cnt != i)
+   vm_domain_freecnt_inc(vmd, cnt - i);
+
+   return (i);
+}
+
+static void
+vm_page_release(void *arg, void **store, int cnt)
+{
+   struct vm_domain *vmd;
+   vm_page_t m;
+   int i;
+
+   vmd = arg;
+   vm_domain_free_lock(vmd);
+   for (i = 0; i < cnt; i++) {
+   m = (vm_page_t)store[i];
+   vm_phys_free_pages(m, 0);
+   }
+   vm_domain_free_unlock(vmd);
+   vm_domain_freecnt_inc(vmd, cnt);
+}
+
 #defineVPSC_ANY0   /* No restrictions. */
 #defineVPSC_NORESERV   1   /* Skip reservations; implies 
VPSC_NOSUPER. */
 #defineVPSC_NOSUPER2   /* Skip superpages. */
@@ -3222,7 +3300,12 @@ vm_page_free_toq(vm_page_t m)
 
if (!vm_page_free_prep(m, false))
return;
+
vmd = vm_pagequeue_domain(m);
+   if (m->pool == VM_FREEPOOL_DEFAULT && vmd->vmd_pgcache != NULL) {
+   

Re: svn commit: r327954 - in head/sys: amd64/conf conf dev/acpica vm x86/acpica

2018-04-01 Thread Ian Lepore
On Sun, 2018-01-14 at 03:36 +, Jeff Roberson wrote:
> Author: jeff
> Date: Sun Jan 14 03:36:03 2018
> New Revision: 327954
> URL: https://svnweb.freebsd.org/changeset/base/327954
> 
> Log:
>   Move VM_NUMA_ALLOC and DEVICE_NUMA under the single global config
> option NUMA.
>   
>   Sponsored by:   Netflix, Dell/EMC Isilon
>   Discussed with: jhb

It turns out this breaks building powerpc lint kernels. It shakes out
like this... makeLINT.mk copies sys/conf/NOTES into the generated LINT
config (I guess on the theory that things documented in NOTES are
supported by all arches). So option NUMA is present on powerpc, but the
powerpc vmparam.h doesn't define VM_LEVEL_0_ORDER so the build fails.
(Mips also doesn't define that, but it has no lint kernel build at all
right now.)

It could be fixed in vm_domainset.c with:

-#ifdef NUMA
+#if defined(NUMA) && defined(VM_LEVEL_0_ORDER)

but there may be some better way to fix it, I don't know that much
about this stuff.

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


svn commit: r331869 - head/sys/dev/nxge

2018-04-01 Thread Ian Lepore
Author: ian
Date: Sun Apr  1 18:53:27 2018
New Revision: 331869
URL: https://svnweb.freebsd.org/changeset/base/331869

Log:
  Fix the build on arches with default unsigned char.  Capture the fubyte()
  return value in an int as well as the char, and test the full int value
  for fubyte() failure.

Modified:
  head/sys/dev/nxge/if_nxge.c

Modified: head/sys/dev/nxge/if_nxge.c
==
--- head/sys/dev/nxge/if_nxge.c Sun Apr  1 18:22:24 2018(r331868)
+++ head/sys/dev/nxge/if_nxge.c Sun Apr  1 18:53:27 2018(r331869)
@@ -1366,12 +1366,13 @@ xge_ioctl_stats(xge_lldev_t *lldev, struct ifreq *ifre
xge_hal_status_e status = XGE_HAL_OK;
char cmd, mode;
void *info = NULL;
-   int retValue = EINVAL;
+   int retValue;
 
-   cmd = fubyte(ifr_data_get_ptr(ifreqp));
-   if (cmd == -1)
+   cmd = retValue = fubyte(ifr_data_get_ptr(ifreqp));
+   if (retValue == -1)
return (EFAULT);
 
+   retValue = EINVAL;
switch(cmd) {
case XGE_QUERY_STATS:
mtx_lock(>mtx_drv);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r331868 - in head/sys/modules: i2c/iicbus i2c/isl spi/at45d spi/mx25l spi/spibus

2018-04-01 Thread Ian Lepore
Author: ian
Date: Sun Apr  1 18:22:24 2018
New Revision: 331868
URL: https://svnweb.freebsd.org/changeset/base/331868

Log:
  Add opt_platform.h for several modules that have #ifdef FDT in the source.
  
  Submitted by: Andre Albsmeier 

Modified:
  head/sys/modules/i2c/iicbus/Makefile
  head/sys/modules/i2c/isl/Makefile
  head/sys/modules/spi/at45d/Makefile
  head/sys/modules/spi/mx25l/Makefile
  head/sys/modules/spi/spibus/Makefile

Modified: head/sys/modules/i2c/iicbus/Makefile
==
--- head/sys/modules/i2c/iicbus/MakefileSun Apr  1 16:43:30 2018
(r331867)
+++ head/sys/modules/i2c/iicbus/MakefileSun Apr  1 18:22:24 2018
(r331868)
@@ -13,6 +13,7 @@ SRCS= \
iicbus_if.h \
iiconf.c \
iiconf.h \
+   opt_platform.h \
 
 .if !empty(OPT_FDT)
 SRCS+= ofw_iicbus.c ofw_bus_if.h

Modified: head/sys/modules/i2c/isl/Makefile
==
--- head/sys/modules/i2c/isl/Makefile   Sun Apr  1 16:43:30 2018
(r331867)
+++ head/sys/modules/i2c/isl/Makefile   Sun Apr  1 18:22:24 2018
(r331868)
@@ -2,6 +2,6 @@
 
 .PATH: ${SRCTOP}/sys/dev/isl
 KMOD   = isl
-SRCS   = isl.c device_if.h bus_if.h iicbus_if.h
+SRCS   = isl.c device_if.h bus_if.h iicbus_if.h opt_platform.h
 
 .include 

Modified: head/sys/modules/spi/at45d/Makefile
==
--- head/sys/modules/spi/at45d/Makefile Sun Apr  1 16:43:30 2018
(r331867)
+++ head/sys/modules/spi/at45d/Makefile Sun Apr  1 18:22:24 2018
(r331868)
@@ -9,6 +9,7 @@ SRCS=   at45d.c
 SRCS+= \
bus_if.h \
device_if.h \
+   opt_platform.h \
spibus_if.h \
 
 .if !empty(OPT_FDT)

Modified: head/sys/modules/spi/mx25l/Makefile
==
--- head/sys/modules/spi/mx25l/Makefile Sun Apr  1 16:43:30 2018
(r331867)
+++ head/sys/modules/spi/mx25l/Makefile Sun Apr  1 18:22:24 2018
(r331868)
@@ -9,6 +9,7 @@ SRCS=   mx25l.c
 SRCS+= \
bus_if.h \
device_if.h \
+   opt_platform.h \
spibus_if.h \
 
 .if !empty(OPT_FDT)

Modified: head/sys/modules/spi/spibus/Makefile
==
--- head/sys/modules/spi/spibus/MakefileSun Apr  1 16:43:30 2018
(r331867)
+++ head/sys/modules/spi/spibus/MakefileSun Apr  1 18:22:24 2018
(r331868)
@@ -13,6 +13,7 @@ SRCS+=ofw_spibus.c ofw_bus_if.h
 SRCS+= \
bus_if.h \
device_if.h \
+   opt_platform.h \
spibus_if.c \
spibus_if.h \
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r331871 - head/sys/vm

2018-04-01 Thread Gleb Smirnoff
Author: glebius
Date: Mon Apr  2 05:11:59 2018
New Revision: 331871
URL: https://svnweb.freebsd.org/changeset/base/331871

Log:
  Handle a special case when a slab can fit only one allocation,
  and zone has a large alignment. With alignment taken into
  account uk_rsize will be greater than space in a slab. However,
  since we have only one item per slab, it is always naturally
  aligned.
  
  Code that will panic before this change with 4k page:
  
z = uma_zcreate("test", 3984, NULL, NULL, NULL, NULL, 31, 0);
uma_zalloc(z, M_WAITOK);
  
  A practical scenario to hit the panic is a machine with 56 CPUs
  and 2 NUMA domains, which yields in zone size of 3984.
  
  PR:   227116
  MFC after:2 weeks

Modified:
  head/sys/vm/uma_core.c

Modified: head/sys/vm/uma_core.c
==
--- head/sys/vm/uma_core.c  Sun Apr  1 22:59:53 2018(r331870)
+++ head/sys/vm/uma_core.c  Mon Apr  2 05:11:59 2018(r331871)
@@ -1290,7 +1290,15 @@ keg_small_init(uma_keg_t keg)
else 
shsize = sizeof(struct uma_slab);
 
-   keg->uk_ipers = (slabsize - shsize) / rsize;
+   if (rsize <= slabsize - shsize)
+   keg->uk_ipers = (slabsize - shsize) / rsize;
+   else {
+   /* Handle special case when we have 1 item per slab, so
+* alignment requirement can be relaxed. */
+   KASSERT(keg->uk_size <= slabsize - shsize,
+   ("%s: size %u greater than slab", __func__, keg->uk_size));
+   keg->uk_ipers = 1;
+   }
KASSERT(keg->uk_ipers > 0 && keg->uk_ipers <= SLAB_SETSIZE,
("%s: keg->uk_ipers %u", __func__, keg->uk_ipers));
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r331872 - head/sys/vm

2018-04-01 Thread Gleb Smirnoff
Author: glebius
Date: Mon Apr  2 05:14:31 2018
New Revision: 331872
URL: https://svnweb.freebsd.org/changeset/base/331872

Log:
  In uma_startup_count() handle special case when zone will fit into
  single slab, but with alignment adjustment it won't. Again, when
  there is only one item in a slab alignment can be ignored. See
  previous revision of this file for more info.
  
  PR:   227116

Modified:
  head/sys/vm/uma_core.c

Modified: head/sys/vm/uma_core.c
==
--- head/sys/vm/uma_core.c  Mon Apr  2 05:11:59 2018(r331871)
+++ head/sys/vm/uma_core.c  Mon Apr  2 05:14:31 2018(r331872)
@@ -1828,9 +1828,11 @@ uma_startup_count(int vm_zones)
 #endif
 
/* Memory for the rest of startup zones, UMA and VM, ... */
-   if (zsize > UMA_SLAB_SIZE)
+   if (zsize > UMA_SLAB_SPACE)
pages += (zones + vm_zones) *
howmany(roundup2(zsize, UMA_BOOT_ALIGN), UMA_SLAB_SIZE);
+   else if (roundup2(zsize, UMA_BOOT_ALIGN) > UMA_SLAB_SPACE)
+   pages += zones;
else
pages += howmany(zones,
UMA_SLAB_SPACE / roundup2(zsize, UMA_BOOT_ALIGN));
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r331873 - head/sys/vm

2018-04-01 Thread Gleb Smirnoff
Author: glebius
Date: Mon Apr  2 05:15:25 2018
New Revision: 331873
URL: https://svnweb.freebsd.org/changeset/base/331873

Log:
  Use UMA_SLAB_SPACE macro. No functional change here.

Modified:
  head/sys/vm/uma_core.c

Modified: head/sys/vm/uma_core.c
==
--- head/sys/vm/uma_core.c  Mon Apr  2 05:14:31 2018(r331872)
+++ head/sys/vm/uma_core.c  Mon Apr  2 05:15:25 2018(r331873)
@@ -1481,7 +1481,7 @@ keg_ctor(void *mem, int size, void *udata, int flags)
if (keg->uk_flags & UMA_ZONE_CACHESPREAD) {
keg_cachespread_init(keg);
} else {
-   if (keg->uk_size > (UMA_SLAB_SIZE - sizeof(struct uma_slab)))
+   if (keg->uk_size > UMA_SLAB_SPACE)
keg_large_init(keg);
else
keg_small_init(keg);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r331870 - stable/11/sys/dev/ispfw

2018-04-01 Thread Alexander Motin
Author: mav
Date: Sun Apr  1 22:59:53 2018
New Revision: 331870
URL: https://svnweb.freebsd.org/changeset/base/331870

Log:
  MFC r330292: Update QLogic ISP 24xx/25xx chips firmware to 8.07.00.

Modified:
  stable/11/sys/dev/ispfw/asm_2400.h
  stable/11/sys/dev/ispfw/asm_2500.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/ispfw/asm_2400.h
==
--- stable/11/sys/dev/ispfw/asm_2400.h  Sun Apr  1 18:53:27 2018
(r331869)
+++ stable/11/sys/dev/ispfw/asm_2400.h  Sun Apr  1 22:59:53 2018
(r331870)
@@ -25,23 +25,23 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */ 
 /*
- * Firmware Version 7.03.00 (Apr 14, 2014)
+ * Firmware Version 8.07.00 (2017)
  */
 #ifdef ISP_2400
 static const uint32_t isp_2400_risc_code[] = {
-   0x0401f195, 0x00112000, 0x0010, 0xc798,
-   0x0007, 0x0003, 0x, 0x9496,
+   0x0401f1be, 0x00112000, 0x0010, 0xc79b,
+   0x0008, 0x0007, 0x, 0x9496,
0x0003, 0x, 0x20434f50, 0x59524947,
-   0x48542032, 0x30303720, 0x514c4f47, 0x49432043,
+   0x48542032, 0x30313720, 0x514c4f47, 0x49432043,
0x4f52504f, 0x52415449, 0x4f4e2020, 0x20495350,
0x32347878, 0x20466972, 0x6d776172, 0x65202020,
-   0x56657273, 0x696f6e20, 0x2020372e, 0x30332e30,
+   0x56657273, 0x696f6e20, 0x2020382e, 0x30372e30,
0x30202024, 0x, 0x, 0x,
0x, 0x, 0x, 0x,
0x, 0x, 0x, 0x,
0x, 0x, 0x, 0x,
0x, 0x, 0x, 0x,
-   0x42001800, 0x0010014c, 0x42002000, 0x0010e36f,
+   0x42001800, 0x0010014c, 0x42002000, 0x0010e377,
0x500c0800, 0x800c1800, 0x500c1000, 0x800c1800,
0x54042000, 0x80102000, 0x80040800, 0x80081040,
0x040207fc, 0x500c0800, 0x800409c0, 0x040207f6,
@@ -124,759 +124,771 @@ static const uint32_t isp_2400_risc_code[] = {
0x6150, 0x0010, 0x6170, 0x0010,
0x6190, 0x0010, 0x61b0, 0x0010,
0x, 0x, 0x, 0x,
-   0x, 0x0010, 0x0010, 0xc798,
-   0x, 0x00112004, 0x0002, 0x0c50,
-   0x, 0x00112c54, 0x0010fd00, 0x1b58,
-   0x, 0x001147ac, 0xc000, 0x08b1,
-   0x00ff, 0x0011505d, 0x8000, 0x0696,
+   0x, 0x0010, 0x0010, 0xc79b,
+   0x, 0x00112004, 0x0002, 0x1083,
+   0x, 0x00113087, 0x0010fd00, 0x1b72,
+   0x, 0x00114bf9, 0xc000, 0x08e2,
+   0x00ff, 0x001154db, 0x8000, 0x069e,
0x00ff, 0x, 0x, 0x,
-   0x, 0x4203f000, 0x00021fff, 0x4000,
-   0x4203e000, 0x9100, 0x4000, 0x42000800,
-   0x00020c51, 0x4202f000, 0x, 0x4200,
-   0x7023, 0x5000, 0x8c000500, 0x04020003,
-   0x42000800, 0x0002, 0x45780800, 0x80040800,
-   0x82040580, 0x00022000, 0x040207fc, 0x4178a000,
-   0x4200a800, 0x0010c798, 0x42000800, 0x0010fd00,
-   0x4054, 0x8004b480, 0x0201f800, 0x0010c5e6,
-   0x0401fade, 0x0401fa0a, 0x4803c856, 0x4200,
-   0x1000, 0x5000, 0x82000480, 0x24320002,
-   0x0402000d, 0x0201f800, 0x0010c62d, 0x0408,
-   0x42000800, 0x7a17, 0x5004, 0x8c00050e,
-   0x04020003, 0x8400054e, 0x44000800, 0x4a03,
-   0x, 0x4a03c020, 0x0004, 0x4203e000,
-   0x600f, 0x4a0370e8, 0x0003, 0x4a0378e8,
-   0x0003, 0x59e00023, 0x8c000500, 0x04020027,
-   0x42002800, 0x0010017d, 0x58140800, 0x4817c857,
-   0x4807c857, 0x800409c0, 0x040b, 0x58142002,
-   0x4813c857, 0x58141003, 0x4c14, 0x0401faaa,
-   0x5c002800, 0x0402002a, 0x82142c00, 0x0004,
-   0x0401f7f2, 0x42002800, 0x0010017d, 0x5814a000,
-   0x4817c857, 0x4853c857, 0x8050a1c0, 0x040f,
-   0x4c14, 0x5814a801, 0x4857c857, 0x4050,
-   0x80540480, 0x0405, 0x5814b002, 0x485bc857,
-   0x0201f800, 0x0010c5dd, 0x5c002800, 0x82142c00,
-   0x0004, 0x0401f7ee, 0x42002800, 0x0010017d,
-   0x58140801, 0x4817c857, 0x4807c857, 0x800409c0,
-   0x0418, 0x58142002, 0x4813c857, 0x58141003,
-   0x4c14, 0x0401fa84, 0x04020005, 0x5c002800,
-   0x82142c00, 0x0004, 0x0401f7f2, 0x4803c856,
-   0x4a03c020, 0x4010, 0x4a03c011, 0x40100011,
-   0x04006000, 0x4203e000, 0x4000, 0x4a03c017,
-   0x, 0x4203e000, 0x3001, 0x0401f000,
-   0x4803c856, 0x0201f800, 0x0010fd04, 0x0401fb0b,
-   0x4a03c014, 0x001c001c, 0x42002000, 0x00111858,
-   0x0201f800, 0x0010c5ee, 0x4200, 0x1000,
-   0x5000, 0x82000480, 0x24220001, 0x04000908,
+