Subversion Repositories HelenOS-historic

Rev

Rev 1428 | Rev 1677 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1428 Rev 1554
Line 46... Line 46...
46
 *
46
 *
47
 * The slab allocator supports per-CPU caches ('magazines') to facilitate
47
 * The slab allocator supports per-CPU caches ('magazines') to facilitate
48
 * good SMP scaling.
48
 * good SMP scaling.
49
 *
49
 *
50
 * When a new object is being allocated, it is first checked, if it is
50
 * When a new object is being allocated, it is first checked, if it is
51
 * available in CPU-bound magazine. If it is not found there, it is
51
 * available in a CPU-bound magazine. If it is not found there, it is
52
 * allocated from CPU-shared slab - if partial full is found, it is used,
52
 * allocated from a CPU-shared slab - if a partially full one is found,
53
 * otherwise a new one is allocated.
53
 * it is used, otherwise a new one is allocated.
54
 *
54
 *
55
 * When an object is being deallocated, it is put to CPU-bound magazine.
55
 * When an object is being deallocated, it is put to a CPU-bound magazine.
56
 * If there is no such magazine, new one is allocated (if it fails,
56
 * If there is no such magazine, a new one is allocated (if this fails,
57
 * the object is deallocated into slab). If the magazine is full, it is
57
 * the object is deallocated into slab). If the magazine is full, it is
58
 * put into cpu-shared list of magazines and new one is allocated.
58
 * put into cpu-shared list of magazines and a new one is allocated.
59
 *
59
 *
60
 * The CPU-bound magazine is actually a pair of magazine to avoid
60
 * The CPU-bound magazine is actually a pair of magazines in order to avoid
61
 * thrashing when somebody is allocating/deallocating 1 item at the magazine
61
 * thrashing when somebody is allocating/deallocating 1 item at the magazine
62
 * size boundary. LIFO order is enforced, which should avoid fragmentation
62
 * size boundary. LIFO order is enforced, which should avoid fragmentation
63
 * as much as possible.
63
 * as much as possible.
64
 *  
64
 *  
65
 * Every cache contains list of full slabs and list of partialy full slabs.
65
 * Every cache contains list of full slabs and list of partially full slabs.
66
 * Empty slabs are immediately freed (thrashing will be avoided because
66
 * Empty slabs are immediately freed (thrashing will be avoided because
67
 * of magazines).
67
 * of magazines).
68
 *
68
 *
69
 * The slab information structure is kept inside the data area, if possible.
69
 * The slab information structure is kept inside the data area, if possible.
70
 * The cache can be marked that it should not use magazines. This is used
70
 * The cache can be marked that it should not use magazines. This is used
71
 * only for slab related caches to avoid deadlocks and infinite recursion
71
 * only for slab related caches to avoid deadlocks and infinite recursion
72
 * (the slab allocator uses itself for allocating all it's control structures).
72
 * (the slab allocator uses itself for allocating all it's control structures).
73
 *
73
 *
74
 * The slab allocator allocates lot of space and does not free it. When
74
 * The slab allocator allocates a lot of space and does not free it. When
75
 * frame allocator fails to allocate the frame, it calls slab_reclaim().
75
 * the frame allocator fails to allocate a frame, it calls slab_reclaim().
76
 * It tries 'light reclaim' first, then brutal reclaim. The light reclaim
76
 * It tries 'light reclaim' first, then brutal reclaim. The light reclaim
77
 * releases slabs from cpu-shared magazine-list, until at least 1 slab
77
 * releases slabs from cpu-shared magazine-list, until at least 1 slab
78
 * is deallocated in each cache (this algorithm should probably change).
78
 * is deallocated in each cache (this algorithm should probably change).
79
 * The brutal reclaim removes all cached objects, even from CPU-bound
79
 * The brutal reclaim removes all cached objects, even from CPU-bound
80
 * magazines.
80
 * magazines.