Changeset f3272e98 in mainline
- Timestamp:
- 2006-10-22T17:42:49Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2191541
- Parents:
- 78595d6
- Location:
- kernel
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/doc/mm
r78595d6 rf3272e98 81 81 does not have to check the return value. 82 82 83 3) The maximum size that can be allocated using malloc is 128K83 3) The maximum size that can be allocated using malloc is 256K 84 84 85 85 Rules 1) and 2) apply to slab_alloc as well. Using SLAB allocator -
kernel/generic/include/mm/slab.h
r78595d6 rf3272e98 69 69 count_t size; /**< Number of slots in magazine */ 70 70 void *objs[0]; /**< Slots in magazine */ 71 } slab_magazine_t;71 } slab_magazine_t; 72 72 73 73 typedef struct { … … 75 75 slab_magazine_t *last; 76 76 SPINLOCK_DECLARE(lock); 77 } slab_mag_cache_t;77 } slab_mag_cache_t; 78 78 79 79 … … 83 83 link_t link; 84 84 /* Configuration */ 85 size_t size; 85 size_t size; /**< Size of slab position - align_up(sizeof(obj)) */ 86 86 int (*constructor)(void *obj, int kmflag); 87 87 int (*destructor)(void *obj); 88 int flags; 88 int flags; /**< Flags changing behaviour of cache */ 89 89 90 90 /* Computed values */ 91 uint8_t order; 92 int objects; 91 uint8_t order; /**< Order of frames to be allocated */ 92 int objects; /**< Number of objects that fit in */ 93 93 94 94 /* Statistics */ … … 99 99 100 100 /* Slabs */ 101 link_t full_slabs; 102 link_t partial_slabs; 101 link_t full_slabs; /**< List of full slabs */ 102 link_t partial_slabs; /**< List of partial slabs */ 103 103 SPINLOCK_DECLARE(slablock); 104 104 /* Magazines */ 105 link_t magazines ;/**< List o full magazines */105 link_t magazines /**< List o full magazines */ 106 106 SPINLOCK_DECLARE(maglock); 107 107 108 108 /** CPU cache */ 109 109 slab_mag_cache_t *mag_cache; 110 } slab_cache_t;110 } slab_cache_t; 111 111 112 112 extern slab_cache_t * slab_cache_create(char *name, -
kernel/generic/src/mm/slab.c
r78595d6 rf3272e98 138 138 /** Slab descriptor */ 139 139 typedef struct { 140 slab_cache_t *cache; /**< Pointer to parent cache*/141 link_t link; /* List of full/partial slabs*/142 void *start; /**< Start address of first available item*/143 count_t available; /**< Count of available items in this slab*/144 index_t nextavail; /**< The index of next available item*/140 slab_cache_t *cache; /**< Pointer to parent cache. */ 141 link_t link; /**< List of full/partial slabs. */ 142 void *start; /**< Start address of first available item. */ 143 count_t available; /**< Count of available items in this slab. */ 144 index_t nextavail; /**< The index of next available item. */ 145 145 }slab_t; 146 146 … … 290 290 spinlock_lock(&cache->slablock); 291 291 } else { 292 slab = list_get_instance(cache->partial_slabs.next, 293 slab_t, 294 link); 292 slab = list_get_instance(cache->partial_slabs.next, slab_t, link); 295 293 list_remove(&slab->link); 296 294 } … … 299 297 slab->available--; 300 298 301 if (! 299 if (!slab->available) 302 300 list_prepend(&slab->link, &cache->full_slabs); 303 301 else … … 900 898 slab_t *slab; 901 899 902 if (!obj) return; 900 if (!obj) 901 return; 903 902 904 903 slab = obj2slab(obj);
Note:
See TracChangeset
for help on using the changeset viewer.