summaryrefslogtreecommitdiffstats
path: root/freebsd/sys/vm
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-12-20 11:12:40 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-12-20 13:36:34 +0100
commit2b2563da953978f63e3e707f758fd600dcd19a32 (patch)
treea207b096c10788192b56025e8187f14d1b5a978d /freebsd/sys/vm
parentfreebsd/if_cpsw: Port. (diff)
downloadrtems-libbsd-2b2563da953978f63e3e707f758fd600dcd19a32.tar.bz2
Update to FreeBSD head 2018-12-20
Git mirror commit 19a6ceb89dbacf74697d493e48c388767126d418. It includes an update of wpa_supplicant to version 2.7. It includes an update of the OpenSSL baseline to version 1.1.1a. Update #3472.
Diffstat (limited to '')
-rw-r--r--freebsd/sys/vm/uma_core.c72
-rw-r--r--freebsd/sys/vm/uma_int.h12
2 files changed, 40 insertions, 44 deletions
diff --git a/freebsd/sys/vm/uma_core.c b/freebsd/sys/vm/uma_core.c
index db624654..ade3328a 100644
--- a/freebsd/sys/vm/uma_core.c
+++ b/freebsd/sys/vm/uma_core.c
@@ -1537,7 +1537,7 @@ keg_small_init(uma_keg_t keg)
if (keg->uk_flags & UMA_ZONE_OFFPAGE)
shsize = 0;
else
- shsize = sizeof(struct uma_slab);
+ shsize = SIZEOF_UMA_SLAB;
if (rsize <= slabsize - shsize)
keg->uk_ipers = (slabsize - shsize) / rsize;
@@ -1607,7 +1607,6 @@ keg_small_init(uma_keg_t keg)
static void
keg_large_init(uma_keg_t keg)
{
- u_int shsize;
KASSERT(keg != NULL, ("Keg is null in keg_large_init"));
KASSERT((keg->uk_flags & UMA_ZFLAG_CACHEONLY) == 0,
@@ -1620,23 +1619,17 @@ keg_large_init(uma_keg_t keg)
keg->uk_rsize = keg->uk_size;
/* Check whether we have enough space to not do OFFPAGE. */
- if ((keg->uk_flags & UMA_ZONE_OFFPAGE) == 0) {
- shsize = sizeof(struct uma_slab);
- if (shsize & UMA_ALIGN_PTR)
- shsize = (shsize & ~UMA_ALIGN_PTR) +
- (UMA_ALIGN_PTR + 1);
-
- if (PAGE_SIZE * keg->uk_ppera - keg->uk_rsize < shsize) {
- /*
- * We can't do OFFPAGE if we're internal, in which case
- * we need an extra page per allocation to contain the
- * slab header.
- */
- if ((keg->uk_flags & UMA_ZFLAG_INTERNAL) == 0)
- keg->uk_flags |= UMA_ZONE_OFFPAGE;
- else
- keg->uk_ppera++;
- }
+ if ((keg->uk_flags & UMA_ZONE_OFFPAGE) == 0 &&
+ PAGE_SIZE * keg->uk_ppera - keg->uk_rsize < SIZEOF_UMA_SLAB) {
+ /*
+ * We can't do OFFPAGE if we're internal, in which case
+ * we need an extra page per allocation to contain the
+ * slab header.
+ */
+ if ((keg->uk_flags & UMA_ZFLAG_INTERNAL) == 0)
+ keg->uk_flags |= UMA_ZONE_OFFPAGE;
+ else
+ keg->uk_ppera++;
}
if ((keg->uk_flags & UMA_ZONE_OFFPAGE) &&
@@ -1783,20 +1776,11 @@ keg_ctor(void *mem, int size, void *udata, int flags)
/*
* If we're putting the slab header in the actual page we need to
- * figure out where in each page it goes. This calculates a right
- * justified offset into the memory on an ALIGN_PTR boundary.
+ * figure out where in each page it goes. See SIZEOF_UMA_SLAB
+ * macro definition.
*/
if (!(keg->uk_flags & UMA_ZONE_OFFPAGE)) {
- u_int totsize;
-
- /* Size of the slab struct and free list */
- totsize = sizeof(struct uma_slab);
-
- if (totsize & UMA_ALIGN_PTR)
- totsize = (totsize & ~UMA_ALIGN_PTR) +
- (UMA_ALIGN_PTR + 1);
- keg->uk_pgoff = (PAGE_SIZE * keg->uk_ppera) - totsize;
-
+ keg->uk_pgoff = (PAGE_SIZE * keg->uk_ppera) - SIZEOF_UMA_SLAB;
/*
* The only way the following is possible is if with our
* UMA_ALIGN_PTR adjustments we are now bigger than
@@ -1804,13 +1788,10 @@ keg_ctor(void *mem, int size, void *udata, int flags)
* mathematically possible for all cases, so we make
* sure here anyway.
*/
- totsize = keg->uk_pgoff + sizeof(struct uma_slab);
- if (totsize > PAGE_SIZE * keg->uk_ppera) {
- printf("zone %s ipers %d rsize %d size %d\n",
- zone->uz_name, keg->uk_ipers, keg->uk_rsize,
- keg->uk_size);
- panic("UMA slab won't fit.");
- }
+ KASSERT(keg->uk_pgoff + sizeof(struct uma_slab) <=
+ PAGE_SIZE * keg->uk_ppera,
+ ("zone %s ipers %d rsize %d size %d slab won't fit",
+ zone->uz_name, keg->uk_ipers, keg->uk_rsize, keg->uk_size));
}
if (keg->uk_flags & UMA_ZONE_HASH)
@@ -2105,10 +2086,17 @@ uma_startup_count(int vm_zones)
#endif
/* Memory for the rest of startup zones, UMA and VM, ... */
- 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)
+ if (zsize > UMA_SLAB_SPACE) {
+ /* See keg_large_init(). */
+ u_int ppera;
+
+ ppera = howmany(roundup2(zsize, UMA_BOOT_ALIGN), PAGE_SIZE);
+ if (PAGE_SIZE * ppera - roundup2(zsize, UMA_BOOT_ALIGN) <
+ SIZEOF_UMA_SLAB)
+ ppera++;
+ pages += (zones + vm_zones) * ppera;
+ } else if (roundup2(zsize, UMA_BOOT_ALIGN) > UMA_SLAB_SPACE)
+ /* See keg_small_init() special case for uk_ppera = 1. */
pages += zones;
else
pages += howmany(zones,
diff --git a/freebsd/sys/vm/uma_int.h b/freebsd/sys/vm/uma_int.h
index 0fbc0512..0429bac6 100644
--- a/freebsd/sys/vm/uma_int.h
+++ b/freebsd/sys/vm/uma_int.h
@@ -139,9 +139,17 @@
#define UMA_MAX_WASTE 10
/*
- * Size of memory in a not offpage slab available for actual items.
+ * Actual size of uma_slab when it is placed at an end of a page
+ * with pointer sized alignment requirement.
*/
-#define UMA_SLAB_SPACE (UMA_SLAB_SIZE - sizeof(struct uma_slab))
+#define SIZEOF_UMA_SLAB ((sizeof(struct uma_slab) & UMA_ALIGN_PTR) ? \
+ (sizeof(struct uma_slab) & ~UMA_ALIGN_PTR) + \
+ (UMA_ALIGN_PTR + 1) : sizeof(struct uma_slab))
+
+/*
+ * Size of memory in a not offpage single page slab available for actual items.
+ */
+#define UMA_SLAB_SPACE (PAGE_SIZE - SIZEOF_UMA_SLAB)
/*
* I doubt there will be many cases where this is exceeded. This is the initial