From db2078e4f1802434f791f4f1c333725c42fe172b Mon Sep 17 00:00:00 2001 From: Richard Braun Date: Sat, 17 Dec 2011 15:24:05 +0000 Subject: Adjust the kernel to use the slab allocator * device/dev_lookup.c: Replace zalloc header, types and function calls with their slab counterparts. * device/dev_pager.c: Likewise. * device/ds_routines.c: Likewise. * device/io_req.h: Likewise. * device/net_io.c: Likewise. * i386/i386/fpu.c: Likewise. * i386/i386/io_perm.c: Likewise. * i386/i386/machine_task.c: Likewise. * i386/i386/pcb.c: Likewise. * i386/i386/task.h: Likewise. * i386/intel/pmap.c: Likewise. * i386/intel/pmap.h: Remove #include . * include/mach_debug/mach_debug.defs (host_zone_info): Replace routine declaration with skip directive. (host_slab_info): New routine declaration. * include/mach_debug/mach_debug_types.defs (zone_name_t) (zone_name_array_t, zone_info_t, zone_info_array_t): Remove types. (cache_info_t, cache_info_array_t): New types. * include/mach_debug/mach_debug_types.h: Replace #include with . * ipc/ipc_entry.c: Replace zalloc header, types and function calls with their slab counterparts. * ipc/ipc_entry.h: Likewise. * ipc/ipc_init.c: Likewise. * ipc/ipc_marequest.c: Likewise. * ipc/ipc_object.c: Likewise. * ipc/ipc_object.h: Likewise. * ipc/ipc_space.c: Likewise. * ipc/ipc_space.h: Likewise. * ipc/ipc_table.c (kalloc_map): Remove extern declaration. * kern/act.c: Replace zalloc header, types and function calls with their slab counterparts. * kern/kalloc.h: Add #include . (MINSIZE): Remove definition. (kalloc_map): Add extern declaration. (kget): Remove prototype. * kern/mach_clock.c: Adjust comment. * kern/processor.c: Replace zalloc header, types and function calls with their slab counterparts. * kern/startup.c: Remove #include . * kern/task.c: Replace zalloc header, types and function calls with their slab counterparts. * kern/thread.c: Likewise. * vm/memory_object_proxy.c: Likewise. * vm/vm_external.c: Likewise. * vm/vm_fault.c: Likewise. * vm/vm_init.c: Likewise. * vm/vm_map.c: Likewise. * vm/vm_object.c: Likewise. * vm/vm_page.h: Remove #include . * vm/vm_pageout.c: Replace zalloc header, types and function calls with their slab counterparts. * vm/vm_resident.c: Likewise. (zdata, zdata_size): Remove declarations. (vm_page_bootstrap): Don't steal memory for the zone system. --- ipc/ipc_entry.c | 4 ++-- ipc/ipc_entry.h | 8 ++++---- ipc/ipc_init.c | 34 ++++++++++++---------------------- ipc/ipc_marequest.c | 15 ++++++--------- ipc/ipc_object.c | 3 ++- ipc/ipc_object.h | 10 +++++----- ipc/ipc_space.c | 4 ++-- ipc/ipc_space.h | 7 ++++--- ipc/ipc_table.c | 7 ------- 9 files changed, 37 insertions(+), 55 deletions(-) (limited to 'ipc') diff --git a/ipc/ipc_entry.c b/ipc/ipc_entry.c index 42e8dd8..3a06244 100644 --- a/ipc/ipc_entry.c +++ b/ipc/ipc_entry.c @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include #include #include @@ -51,7 +51,7 @@ #include #include -zone_t ipc_tree_entry_zone; +struct kmem_cache ipc_tree_entry_cache; /* * Routine: ipc_entry_tree_collision diff --git a/ipc/ipc_entry.h b/ipc/ipc_entry.h index a577cf0..6afa4f6 100644 --- a/ipc/ipc_entry.h +++ b/ipc/ipc_entry.h @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include #include #include @@ -129,10 +129,10 @@ typedef struct ipc_tree_entry { #define ite_request ite_entry.ie_request #define ite_next ite_entry.hash.tree -extern zone_t ipc_tree_entry_zone; +extern struct kmem_cache ipc_tree_entry_cache; -#define ite_alloc() ((ipc_tree_entry_t) zalloc(ipc_tree_entry_zone)) -#define ite_free(ite) zfree(ipc_tree_entry_zone, (vm_offset_t) (ite)) +#define ite_alloc() ((ipc_tree_entry_t) kmem_cache_alloc(&ipc_tree_entry_cache)) +#define ite_free(ite) kmem_cache_free(&ipc_tree_entry_cache, (vm_offset_t) (ite)) extern ipc_entry_t diff --git a/ipc/ipc_init.c b/ipc/ipc_init.c index e9ca64d..9b7e126 100644 --- a/ipc/ipc_init.c +++ b/ipc/ipc_init.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -77,28 +78,17 @@ ipc_bootstrap(void) ipc_port_timestamp_lock_init(); ipc_port_timestamp_data = 0; - ipc_space_zone = zinit(sizeof(struct ipc_space), 0, - ipc_space_max * sizeof(struct ipc_space), - sizeof(struct ipc_space), - 0, "ipc spaces"); - - ipc_tree_entry_zone = - zinit(sizeof(struct ipc_tree_entry), 0, - ipc_tree_entry_max * sizeof(struct ipc_tree_entry), - sizeof(struct ipc_tree_entry), - IPC_ZONE_TYPE, "ipc tree entries"); - - ipc_object_zones[IOT_PORT] = - zinit(sizeof(struct ipc_port), 0, - ipc_port_max * sizeof(struct ipc_port), - sizeof(struct ipc_port), - 0, "ipc ports"); - - ipc_object_zones[IOT_PORT_SET] = - zinit(sizeof(struct ipc_pset), 0, - ipc_pset_max * sizeof(struct ipc_pset), - sizeof(struct ipc_pset), - IPC_ZONE_TYPE, "ipc port sets"); + kmem_cache_init(&ipc_space_cache, "ipc_space", + sizeof(struct ipc_space), 0, NULL, NULL, NULL, 0); + + kmem_cache_init(&ipc_tree_entry_cache, "ipc_tree_entry", + sizeof(struct ipc_tree_entry), 0, NULL, NULL, NULL, 0); + + kmem_cache_init(&ipc_object_caches[IOT_PORT], "ipc_port", + sizeof(struct ipc_port), 0, NULL, NULL, NULL, 0); + + kmem_cache_init(&ipc_object_caches[IOT_PORT_SET], "ipc_pset", + sizeof(struct ipc_pset), 0, NULL, NULL, NULL, 0); /* create special spaces */ diff --git a/ipc/ipc_marequest.c b/ipc/ipc_marequest.c index 540382a..2087c67 100644 --- a/ipc/ipc_marequest.c +++ b/ipc/ipc_marequest.c @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include #include @@ -58,11 +58,11 @@ #endif -zone_t ipc_marequest_zone; +struct kmem_cache ipc_marequest_cache; int ipc_marequest_max = IMAR_MAX; -#define imar_alloc() ((ipc_marequest_t) zalloc(ipc_marequest_zone)) -#define imar_free(imar) zfree(ipc_marequest_zone, (vm_offset_t) (imar)) +#define imar_alloc() ((ipc_marequest_t) kmem_cache_alloc(&ipc_marequest_cache)) +#define imar_free(imar) kmem_cache_free(&ipc_marequest_cache, (vm_offset_t) (imar)) typedef unsigned int ipc_marequest_index_t; @@ -142,11 +142,8 @@ ipc_marequest_init(void) bucket->imarb_head = IMAR_NULL; } - ipc_marequest_zone = - zinit(sizeof(struct ipc_marequest), 0, - ipc_marequest_max * sizeof(struct ipc_marequest), - sizeof(struct ipc_marequest), - IPC_ZONE_TYPE, "ipc msg-accepted requests"); + kmem_cache_init(&ipc_marequest_cache, "ipc_marequest", + sizeof(struct ipc_marequest), 0, NULL, NULL, NULL, 0); } /* diff --git a/ipc/ipc_object.c b/ipc/ipc_object.c index a7a7ddb..4850fb1 100644 --- a/ipc/ipc_object.c +++ b/ipc/ipc_object.c @@ -47,8 +47,9 @@ #include #include #include +#include -zone_t ipc_object_zones[IOT_NUMBER]; +struct kmem_cache ipc_object_caches[IOT_NUMBER]; diff --git a/ipc/ipc_object.h b/ipc/ipc_object.h index 2bbf8bd..adf5bca 100644 --- a/ipc/ipc_object.h +++ b/ipc/ipc_object.h @@ -39,7 +39,7 @@ #include #include #include -#include +#include typedef unsigned int ipc_object_refs_t; typedef unsigned int ipc_object_bits_t; @@ -57,7 +57,7 @@ typedef struct ipc_object { #define IO_VALID(io) (((io) != IO_NULL) && ((io) != IO_DEAD)) #define IO_BITS_KOTYPE 0x0000ffff /* used by the object */ -#define IO_BITS_OTYPE 0x7fff0000 /* determines a zone */ +#define IO_BITS_OTYPE 0x7fff0000 /* determines a cache */ #define IO_BITS_ACTIVE 0x80000000U /* is object alive? */ #define io_active(io) ((int)(io)->io_bits < 0) /* hack */ @@ -75,13 +75,13 @@ typedef struct ipc_object { #define IOT_PORT_SET 1 #define IOT_NUMBER 2 /* number of types used */ -extern zone_t ipc_object_zones[IOT_NUMBER]; +extern struct kmem_cache ipc_object_caches[IOT_NUMBER]; #define io_alloc(otype) \ - ((ipc_object_t) zalloc(ipc_object_zones[(otype)])) + ((ipc_object_t) kmem_cache_alloc(&ipc_object_caches[(otype)])) #define io_free(otype, io) \ - zfree(ipc_object_zones[(otype)], (vm_offset_t) (io)) + kmem_cache_free(&ipc_object_caches[(otype)], (vm_offset_t) (io)) #define io_lock_init(io) simple_lock_init(&(io)->io_lock_data) #define io_lock(io) simple_lock(&(io)->io_lock_data) diff --git a/ipc/ipc_space.c b/ipc/ipc_space.c index 0f50f15..ab55e83 100644 --- a/ipc/ipc_space.c +++ b/ipc/ipc_space.c @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include #include #include @@ -55,7 +55,7 @@ -zone_t ipc_space_zone; +struct kmem_cache ipc_space_cache; ipc_space_t ipc_space_kernel; ipc_space_t ipc_space_reply; diff --git a/ipc/ipc_space.h b/ipc/ipc_space.h index d030bf7..c4683d2 100644 --- a/ipc/ipc_space.h +++ b/ipc/ipc_space.h @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -82,10 +83,10 @@ struct ipc_space { #define IS_NULL ((ipc_space_t) 0) -extern zone_t ipc_space_zone; +extern struct kmem_cache ipc_space_cache; -#define is_alloc() ((ipc_space_t) zalloc(ipc_space_zone)) -#define is_free(is) zfree(ipc_space_zone, (vm_offset_t) (is)) +#define is_alloc() ((ipc_space_t) kmem_cache_alloc(&ipc_space_cache)) +#define is_free(is) kmem_cache_free(&ipc_space_cache, (vm_offset_t) (is)) extern struct ipc_space *ipc_space_kernel; extern struct ipc_space *ipc_space_reply; diff --git a/ipc/ipc_table.c b/ipc/ipc_table.c index e572358..d5b7904 100644 --- a/ipc/ipc_table.c +++ b/ipc/ipc_table.c @@ -50,13 +50,6 @@ void ipc_table_fill( unsigned int min, vm_size_t elemsize); -/* - * We borrow the kalloc map, rather than creating - * yet another submap of the kernel map. - */ - -extern vm_map_t kalloc_map; - ipc_table_size_t ipc_table_entries; unsigned int ipc_table_entries_size = 512; -- cgit v1.2.3