mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-10-14 10:27:12 +08:00
ZONE(9): Use page allocator
This commit is contained in:
@@ -90,9 +90,6 @@ __FBSDID("$FreeBSD$");
|
|||||||
|
|
||||||
#include <ddb/ddb.h>
|
#include <ddb/ddb.h>
|
||||||
|
|
||||||
#ifdef __rtems__
|
|
||||||
rtems_bsd_chunk_control rtems_bsd_uma_chunks;
|
|
||||||
#endif /* __rtems__ */
|
|
||||||
/*
|
/*
|
||||||
* This is the zone and keg from which all zones are spawned. The idea is that
|
* This is the zone and keg from which all zones are spawned. The idea is that
|
||||||
* even the zone & keg heads are allocated from the allocator, so we use the
|
* even the zone & keg heads are allocated from the allocator, so we use the
|
||||||
@@ -880,12 +877,8 @@ keg_alloc_slab(uma_keg_t keg, uma_zone_t zone, int wait)
|
|||||||
slab = (uma_slab_t )(mem + keg->uk_pgoff);
|
slab = (uma_slab_t )(mem + keg->uk_pgoff);
|
||||||
|
|
||||||
if (keg->uk_flags & UMA_ZONE_VTOSLAB)
|
if (keg->uk_flags & UMA_ZONE_VTOSLAB)
|
||||||
#ifndef __rtems__
|
|
||||||
for (i = 0; i < keg->uk_ppera; i++)
|
for (i = 0; i < keg->uk_ppera; i++)
|
||||||
vsetslab((vm_offset_t)mem + (i * PAGE_SIZE), slab);
|
vsetslab((vm_offset_t)mem + (i * PAGE_SIZE), slab);
|
||||||
#else /* __rtems__ */
|
|
||||||
vsetslab((vm_offset_t)mem, slab);
|
|
||||||
#endif /* __rtems__ */
|
|
||||||
|
|
||||||
slab->us_keg = keg;
|
slab->us_keg = keg;
|
||||||
slab->us_data = mem;
|
slab->us_data = mem;
|
||||||
@@ -1027,7 +1020,7 @@ page_alloc(uma_zone_t zone, int bytes, u_int8_t *pflag, int wait)
|
|||||||
#ifndef __rtems__
|
#ifndef __rtems__
|
||||||
p = (void *) kmem_malloc(kmem_map, bytes, wait);
|
p = (void *) kmem_malloc(kmem_map, bytes, wait);
|
||||||
#else /* __rtems__ */
|
#else /* __rtems__ */
|
||||||
p = rtems_bsd_chunk_alloc(&rtems_bsd_uma_chunks, bytes);
|
p = rtems_bsd_page_alloc(bytes, wait);
|
||||||
#endif /* __rtems__ */
|
#endif /* __rtems__ */
|
||||||
|
|
||||||
return (p);
|
return (p);
|
||||||
@@ -1121,7 +1114,7 @@ page_free(void *mem, int size, u_int8_t flags)
|
|||||||
|
|
||||||
kmem_free(map, (vm_offset_t)mem, size);
|
kmem_free(map, (vm_offset_t)mem, size);
|
||||||
#else /* __rtems__ */
|
#else /* __rtems__ */
|
||||||
rtems_bsd_chunk_free(&rtems_bsd_uma_chunks, mem);
|
rtems_bsd_page_free(mem);
|
||||||
#endif /* __rtems__ */
|
#endif /* __rtems__ */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1644,16 +1637,6 @@ zone_foreach(void (*zfunc)(uma_zone_t))
|
|||||||
mtx_unlock(&uma_mtx);
|
mtx_unlock(&uma_mtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __rtems__
|
|
||||||
static void
|
|
||||||
rtems_bsd_uma_chunk_info_ctor(rtems_bsd_chunk_control *self,
|
|
||||||
rtems_bsd_chunk_info *info)
|
|
||||||
{
|
|
||||||
rtems_bsd_uma_chunk_info *uci = (rtems_bsd_uma_chunk_info *) info;
|
|
||||||
|
|
||||||
uci->slab = NULL;
|
|
||||||
}
|
|
||||||
#endif /* __rtems__ */
|
|
||||||
/* Public functions */
|
/* Public functions */
|
||||||
/* See uma.h */
|
/* See uma.h */
|
||||||
void
|
void
|
||||||
@@ -1672,11 +1655,6 @@ uma_startup(void *bootmem, int boot_pages)
|
|||||||
#ifdef UMA_DEBUG
|
#ifdef UMA_DEBUG
|
||||||
printf("Creating uma keg headers zone and keg.\n");
|
printf("Creating uma keg headers zone and keg.\n");
|
||||||
#endif
|
#endif
|
||||||
#ifdef __rtems__
|
|
||||||
rtems_bsd_chunk_init(&rtems_bsd_uma_chunks,
|
|
||||||
sizeof(rtems_bsd_uma_chunk_info), rtems_bsd_uma_chunk_info_ctor,
|
|
||||||
rtems_bsd_chunk_info_dtor_default);
|
|
||||||
#endif /* __rtems__ */
|
|
||||||
mtx_init(&uma_mtx, "UMA lock", NULL, MTX_DEF);
|
mtx_init(&uma_mtx, "UMA lock", NULL, MTX_DEF);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1848,7 +1826,7 @@ rtems_bsd_uma_startup(void *unused)
|
|||||||
uma_startup(NULL, 0);
|
uma_startup(NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SYSINIT(rtems_bsd_uma_startup, SI_SUB_VM, SI_ORDER_FIRST,
|
SYSINIT(rtems_bsd_uma_startup, SI_SUB_VM, SI_ORDER_SECOND,
|
||||||
rtems_bsd_uma_startup, NULL);
|
rtems_bsd_uma_startup, NULL);
|
||||||
#endif /* __rtems__ */
|
#endif /* __rtems__ */
|
||||||
|
|
||||||
@@ -2829,11 +2807,7 @@ zone_free_item(uma_zone_t zone, void *item, void *udata,
|
|||||||
zone->uz_frees++;
|
zone->uz_frees++;
|
||||||
|
|
||||||
if (!(zone->uz_flags & UMA_ZONE_VTOSLAB)) {
|
if (!(zone->uz_flags & UMA_ZONE_VTOSLAB)) {
|
||||||
#ifndef __rtems__
|
|
||||||
mem = (u_int8_t *)((unsigned long)item & (~UMA_SLAB_MASK));
|
mem = (u_int8_t *)((unsigned long)item & (~UMA_SLAB_MASK));
|
||||||
#else /* __rtems__ */
|
|
||||||
mem = rtems_bsd_chunk_get_begin(&rtems_bsd_uma_chunks, item);
|
|
||||||
#endif /* __rtems__ */
|
|
||||||
keg = zone_first_keg(zone); /* Must only be one. */
|
keg = zone_first_keg(zone); /* Must only be one. */
|
||||||
if (zone->uz_flags & UMA_ZONE_HASH) {
|
if (zone->uz_flags & UMA_ZONE_HASH) {
|
||||||
slab = hash_sfind(&keg->uk_hash, mem);
|
slab = hash_sfind(&keg->uk_hash, mem);
|
||||||
@@ -3105,12 +3079,8 @@ uma_find_refcnt(uma_zone_t zone, void *item)
|
|||||||
u_int32_t *refcnt;
|
u_int32_t *refcnt;
|
||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
#ifndef __rtems__
|
|
||||||
slabref = (uma_slabrefcnt_t)vtoslab((vm_offset_t)item &
|
slabref = (uma_slabrefcnt_t)vtoslab((vm_offset_t)item &
|
||||||
(~UMA_SLAB_MASK));
|
(~UMA_SLAB_MASK));
|
||||||
#else /* __rtems__ */
|
|
||||||
slabref = (uma_slabrefcnt_t)vtoslab((vm_offset_t)item);
|
|
||||||
#endif /* __rtems__ */
|
|
||||||
keg = slabref->us_keg;
|
keg = slabref->us_keg;
|
||||||
KASSERT(slabref != NULL && slabref->us_keg->uk_flags & UMA_ZONE_REFCNT,
|
KASSERT(slabref != NULL && slabref->us_keg->uk_flags & UMA_ZONE_REFCNT,
|
||||||
("uma_find_refcnt(): zone possibly not UMA_ZONE_REFCNT"));
|
("uma_find_refcnt(): zone possibly not UMA_ZONE_REFCNT"));
|
||||||
|
@@ -405,14 +405,7 @@ hash_sfind(struct uma_hash *hash, u_int8_t *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __rtems__
|
#ifdef __rtems__
|
||||||
#include <machine/rtems-bsd-chunk.h>
|
#include <machine/rtems-bsd-page.h>
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
rtems_bsd_chunk_info chunk_info;
|
|
||||||
uma_slab_t slab;
|
|
||||||
} rtems_bsd_uma_chunk_info;
|
|
||||||
|
|
||||||
extern rtems_bsd_chunk_control rtems_bsd_uma_chunks;
|
|
||||||
#endif /* __rtems__ */
|
#endif /* __rtems__ */
|
||||||
static __inline uma_slab_t
|
static __inline uma_slab_t
|
||||||
vtoslab(vm_offset_t va)
|
vtoslab(vm_offset_t va)
|
||||||
@@ -429,10 +422,7 @@ vtoslab(vm_offset_t va)
|
|||||||
else
|
else
|
||||||
return (NULL);
|
return (NULL);
|
||||||
#else /* __rtems__ */
|
#else /* __rtems__ */
|
||||||
rtems_bsd_uma_chunk_info *uci = (rtems_bsd_uma_chunk_info *)
|
return (rtems_bsd_page_get_object((void *)va));
|
||||||
rtems_bsd_chunk_get_info(&rtems_bsd_uma_chunks, (void *) va);
|
|
||||||
|
|
||||||
return uci->slab;
|
|
||||||
#endif /* __rtems__ */
|
#endif /* __rtems__ */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -446,10 +436,7 @@ vsetslab(vm_offset_t va, uma_slab_t slab)
|
|||||||
p->object = (vm_object_t)slab;
|
p->object = (vm_object_t)slab;
|
||||||
p->flags |= PG_SLAB;
|
p->flags |= PG_SLAB;
|
||||||
#else /* __rtems__ */
|
#else /* __rtems__ */
|
||||||
rtems_bsd_uma_chunk_info *uci = (rtems_bsd_uma_chunk_info *)
|
rtems_bsd_page_set_object((void *)va, slab);
|
||||||
rtems_bsd_chunk_get_info(&rtems_bsd_uma_chunks, (void *) va);
|
|
||||||
|
|
||||||
uci->slab = slab;
|
|
||||||
#endif /* __rtems__ */
|
#endif /* __rtems__ */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user