[rtems-libbsd commit] ZONE(9): Fix slab flag handling
Sebastian Huber
sebh at rtems.org
Fri Sep 11 09:56:19 UTC 2015
Module: rtems-libbsd
Branch: 4.11
Commit: 662f7ece731228a0edccf6354c8b26df2b2d31c1
Changeset: http://git.rtems.org/rtems-libbsd/commit/?id=662f7ece731228a0edccf6354c8b26df2b2d31c1
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Fri Sep 11 11:49:47 2015 +0200
ZONE(9): Fix slab flag handling
Disable unused slab flags.
---
freebsd/sys/kern/kern_mbuf.c | 2 +-
freebsd/sys/vm/uma.h | 4 ++++
freebsd/sys/vm/uma_core.c | 10 ++++++++--
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/freebsd/sys/kern/kern_mbuf.c b/freebsd/sys/kern/kern_mbuf.c
index 74e7aa1..03a0e1f 100644
--- a/freebsd/sys/kern/kern_mbuf.c
+++ b/freebsd/sys/kern/kern_mbuf.c
@@ -425,9 +425,9 @@ static void *
mbuf_jumbo_alloc(uma_zone_t zone, int bytes, uint8_t *flags, int wait)
{
+#ifndef __rtems__
/* Inform UMA that this allocator uses kernel_map/object. */
*flags = UMA_SLAB_KERNEL;
-#ifndef __rtems__
return ((void *)kmem_alloc_contig(kernel_map, bytes, wait,
(vm_paddr_t)0, ~(vm_paddr_t)0, 1, 0, VM_MEMATTR_DEFAULT));
#else /* __rtems__ */
diff --git a/freebsd/sys/vm/uma.h b/freebsd/sys/vm/uma.h
index 53344c0..dbe3c48 100644
--- a/freebsd/sys/vm/uma.h
+++ b/freebsd/sys/vm/uma.h
@@ -542,13 +542,17 @@ void uma_zone_set_freef(uma_zone_t zone, uma_free freef);
/*
* These flags are setable in the allocf and visible in the freef.
*/
+#ifndef __rtems__
#define UMA_SLAB_BOOT 0x01 /* Slab alloced from boot pages */
#define UMA_SLAB_KMEM 0x02 /* Slab alloced from kmem_map */
+#endif /* __rtems__ */
#define UMA_SLAB_KERNEL 0x04 /* Slab alloced from kernel_map */
+#ifndef __rtems__
#define UMA_SLAB_PRIV 0x08 /* Slab alloced from priv allocator */
#define UMA_SLAB_OFFP 0x10 /* Slab is managed separately */
#define UMA_SLAB_MALLOC 0x20 /* Slab is a large malloc slab */
/* 0x40 and 0x80 are available */
+#endif /* __rtems__ */
/*
* Used to pre-fill a zone with some number of items
diff --git a/freebsd/sys/vm/uma_core.c b/freebsd/sys/vm/uma_core.c
index 593e7f3..845c433 100644
--- a/freebsd/sys/vm/uma_core.c
+++ b/freebsd/sys/vm/uma_core.c
@@ -722,11 +722,13 @@ keg_drain(uma_keg_t keg)
while (slab) {
n = LIST_NEXT(slab, us_link);
+#ifndef __rtems__
/* We have no where to free these to */
if (slab->us_flags & UMA_SLAB_BOOT) {
slab = n;
continue;
}
+#endif /* __rtems__ */
LIST_REMOVE(slab, us_link);
keg->uk_pages -= keg->uk_ppera;
@@ -1023,10 +1025,11 @@ page_alloc(uma_zone_t zone, int bytes, u_int8_t *pflag, int wait)
{
void *p; /* Returned page */
- *pflag = UMA_SLAB_KMEM;
#ifndef __rtems__
+ *pflag = UMA_SLAB_KMEM;
p = (void *) kmem_malloc(kmem_map, bytes, wait);
#else /* __rtems__ */
+ *pflag = 0;
p = rtems_bsd_page_alloc(bytes, wait);
#endif /* __rtems__ */
@@ -1121,7 +1124,10 @@ page_free(void *mem, int size, u_int8_t flags)
kmem_free(map, (vm_offset_t)mem, size);
#else /* __rtems__ */
- rtems_bsd_page_free(mem);
+ if (flags & UMA_SLAB_KERNEL)
+ free(mem, M_TEMP);
+ else
+ rtems_bsd_page_free(mem);
#endif /* __rtems__ */
}
More information about the vc
mailing list