39#define SLAB_HEADER ((sizeof(struct slab) + 15) & ~(size_t) 15)
40#define SLAB_PAGES (ARCH_SLAB_SIZE / PAGE_SIZE)
53 while (((
size_t)
SLAB_MIN <<
class) < size)
87 return (
struct slab *) vaddr;
128 (*list)->prev =
slab;
144 int class = slab_class(size);
159 void **obj = (
void **) ((
char *)
slab + off);
219 }
else if (was_full) {
struct vm_page * mm_page_alloc(void)
Allocates a free page of physical memory.
void mm_page_dealloc(paddr_t paddr)
Frees a page of physical memory, back to the zone it came from.
void slab_free(void *ptr)
Frees an object of a slab.
int slab_owns(void *ptr)
Says whether an object is a slab's, for kfree().
void * slab_alloc(size_t size, struct malloc_type *type)
Allocates a small object, from a slab of its malloc type and size class, making a new slab if none ha...
int pmap_add(struct pmap *pmap, vaddr_t va, paddr_t pa, uint32_t flags)
Maps a page in an address space, replacing what was mapped there.
paddr_t arch_page_get_mapping(struct pmap *pmap, vaddr_t vaddr)
Finds the page mapped at a virtual address of an address space.
void pmap_remove(struct pmap *pmap, vaddr_t sva, vaddr_t eva)
Unmaps the pages of a range of an address space, and flushes them from the TLBs that may have them.
static void slab_unlink(struct slab **list, struct slab *slab)
Takes slab off a list of slabs with free objects.
static int slab_class(size_t size)
Returns the size class for objects of size bytes: the smallest power of two from SLAB_MIN that holds ...
static void slab_link(struct slab **list, struct slab *slab)
Puts slab at the head of a list of slabs with free objects.
static void slab_page_free(struct slab *slab)
Unmaps a slab's page, and gives it back to the buddy allocator.
static size_t slab_first_free
static struct slab * slab_page_alloc(void)
Maps a page of memory at a free page of the slab region, for a new slab.
static uint8_t slab_map[SLAB_PAGES/8]
A list: its first and last nodes, and how many there are.
A malloc type: what an allocation is for, which /proc/kvmem counts by.
struct slab * slabs[SLAB_CLASSES]
A slab's header, at the start of its page.
struct malloc_type * type
A page of physical memory (pages[] has one for every page of RAM).
paddr_t paddr
its physical address
struct pmap * pmap
its page tables (the architecture's)
struct vm_space kvm_space
#define VM_KRW
kernel read/write