Changeset 9179d0a in mainline for generic/src/mm/slab.c
- Timestamp:
- 2006-04-27T17:13:49Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 040e4e9
- Parents:
- eaa202a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
generic/src/mm/slab.c
reaa202a r9179d0a 27 27 */ 28 28 29 /* 30 * The SLAB allocator is closely modelled after OpenSolaris SLAB allocator 31 * http://www.usenix.org/events/usenix01/full_papers/bonwick/bonwick_html/ 29 /** 30 * @file slab.c 31 * @brief Slab allocator. 32 * 33 * The slab allocator is closely modelled after OpenSolaris slab allocator. 34 * @see http://www.usenix.org/events/usenix01/full_papers/bonwick/bonwick_html/ 32 35 * 33 36 * with the following exceptions: 34 * - empty SLABSare deallocated immediately37 * @li empty slabs are deallocated immediately 35 38 * (in Linux they are kept in linked list, in Solaris ???) 36 * -empty magazines are deallocated when not needed39 * @li empty magazines are deallocated when not needed 37 40 * (in Solaris they are held in linked list in slab cache) 38 41 * 39 * 40 * -cache coloring41 * -dynamic magazine growing (different magazine sizes are already42 * Following features are not currently supported but would be easy to do: 43 * @li cache coloring 44 * @li dynamic magazine growing (different magazine sizes are already 42 45 * supported, but we would need to adjust allocation strategy) 43 46 * 44 * The SLABallocator supports per-CPU caches ('magazines') to facilitate47 * The slab allocator supports per-CPU caches ('magazines') to facilitate 45 48 * good SMP scaling. 46 49 * 47 50 * When a new object is being allocated, it is first checked, if it is 48 51 * available in CPU-bound magazine. If it is not found there, it is 49 * allocated from CPU-shared SLAB- if partial full is found, it is used,52 * allocated from CPU-shared slab - if partial full is found, it is used, 50 53 * otherwise a new one is allocated. 51 54 * 52 55 * When an object is being deallocated, it is put to CPU-bound magazine. 53 56 * If there is no such magazine, new one is allocated (if it fails, 54 * the object is deallocated into SLAB). If the magazine is full, it is57 * the object is deallocated into slab). If the magazine is full, it is 55 58 * put into cpu-shared list of magazines and new one is allocated. 56 59 * … … 61 64 * 62 65 * Every cache contains list of full slabs and list of partialy full slabs. 63 * Empty SLABSare immediately freed (thrashing will be avoided because66 * Empty slabs are immediately freed (thrashing will be avoided because 64 67 * of magazines). 65 68 * 66 * The SLABinformation structure is kept inside the data area, if possible.69 * The slab information structure is kept inside the data area, if possible. 67 70 * The cache can be marked that it should not use magazines. This is used 68 * only for SLABrelated caches to avoid deadlocks and infinite recursion69 * (the SLABallocator uses itself for allocating all it's control structures).70 * 71 * The SLABallocator allocates lot of space and does not free it. When71 * only for slab related caches to avoid deadlocks and infinite recursion 72 * (the slab allocator uses itself for allocating all it's control structures). 73 * 74 * The slab allocator allocates lot of space and does not free it. When 72 75 * frame allocator fails to allocate the frame, it calls slab_reclaim(). 73 76 * It tries 'light reclaim' first, then brutal reclaim. The light reclaim … … 77 80 * magazines. 78 81 * 79 * TODO: For better CPU-scaling the magazine allocation strategy should 82 * TODO:@n 83 * For better CPU-scaling the magazine allocation strategy should 80 84 * be extended. Currently, if the cache does not have magazine, it asks 81 85 * for non-cpu cached magazine cache to provide one. It might be feasible … … 86 90 * magazine cache. 87 91 * 88 * - it might be good to add granularity of locks even to slab level, 89 * we could then try_spinlock over all partial slabs and thus improve 90 * scalability even on slab level 91 */ 92 92 * @li it might be good to add granularity of locks even to slab level, 93 * we could then try_spinlock over all partial slabs and thus improve 94 * scalability even on slab level 95 */ 93 96 94 97 #include <synch/spinlock.h> … … 114 117 /** Cache for external slab descriptors 115 118 * This time we want per-cpu cache, so do not make it static 116 * - using SLAB for internal SLABstructures will not deadlock,119 * - using slab for internal slab structures will not deadlock, 117 120 * as all slab structures are 'small' - control structures of 118 121 * their caches do not require further allocation … … 142 145 143 146 /**************************************/ 144 /* S LABallocation functions */147 /* Slab allocation functions */ 145 148 146 149 /** … … 191 194 192 195 /** 193 * Deallocate space associated with SLAB196 * Deallocate space associated with slab 194 197 * 195 198 * @return number of freed frames … … 213 216 214 217 /**************************************/ 215 /* S LABfunctions */218 /* Slab functions */ 216 219 217 220 … … 274 277 if (list_empty(&cache->partial_slabs)) { 275 278 /* Allow recursion and reclaiming 276 * - this should work, as the SLABcontrol structures279 * - this should work, as the slab control structures 277 280 * are small and do not need to allocte with anything 278 281 * other ten frame_alloc when they are allocating, … … 510 513 511 514 /**************************************/ 512 /* S LAB CACHEfunctions */515 /* Slab cache functions */ 513 516 514 517 /** Return number of objects that fit in certain cache size */ … … 790 793 ipl = interrupts_disable(); 791 794 spinlock_lock(&slab_cache_lock); 792 printf(" SLABname\t Osize\t Pages\t Obj/pg\t Slabs\t Cached\tAllocobjs\tCtl\n");795 printf("slab name\t Osize\t Pages\t Obj/pg\t Slabs\t Cached\tAllocobjs\tCtl\n"); 793 796 for (cur = slab_cache_list.next;cur!=&slab_cache_list; cur=cur->next) { 794 797 cache = list_get_instance(cur, slab_cache_t, link);
Note:
See TracChangeset
for help on using the changeset viewer.