Home | History | Annotate | Download | only in nouveau

Lines Matching defs:slab

46 mm_slab_alloc(struct mm_slab *slab)
50 if (slab->free == 0)
53 for (i = 0; i < (slab->count + 31) / 32; ++i) {
54 b = ffs(slab->bits[i]) - 1;
57 assert(n < slab->count);
58 slab->free--;
59 slab->bits[i] &= ~(1 << b);
67 mm_slab_free(struct mm_slab *slab, int i)
69 assert(i < slab->count);
70 slab->bits[i / 32] |= 1 << (i % 32);
71 slab->free++;
72 assert(slab->free <= slab->count);
99 /* size of bo allocation for slab with chunks of (1 << chunk_order) bytes */
116 struct mm_slab *slab;
123 slab = MALLOC(sizeof(struct mm_slab) + words * 4);
124 if (!slab)
127 memset(&slab->bits[0], ~0, words * 4);
129 slab->bo = NULL;
132 &slab->bo);
134 FREE(slab);
138 LIST_INITHEAD(&slab->head);
140 slab->cache = cache;
141 slab->order = chunk_order;
142 slab->count = slab->free = size >> chunk_order;
144 LIST_ADD(&slab->head, &mm_bucket_by_order(cache, chunk_order)->free);
149 debug_printf("MM: new slab, total memory = %"PRIu64" KiB\n",
155 /* @return token to identify slab or NULL if we just allocated a new bo */
161 struct mm_slab *slab;
178 slab = LIST_ENTRY(struct mm_slab, bucket->used.next, head);
183 slab = LIST_ENTRY(struct mm_slab, bucket->free.next, head);
185 LIST_DEL(&slab->head);
186 LIST_ADD(&slab->head, &bucket->used);
189 *offset = mm_slab_alloc(slab) << slab->order;
195 nouveau_bo_ref(slab->bo, bo);
197 if (slab->free == 0) {
198 LIST_DEL(&slab->head);
199 LIST_ADD(&slab->head, &bucket->full);
204 alloc->priv = (void *)slab;
212 struct mm_slab *slab = (struct mm_slab *)alloc->priv;
213 struct mm_bucket *bucket = mm_bucket_by_order(slab->cache, slab->order);
215 mm_slab_free(slab, alloc->offset >> slab->order);
217 if (slab->free == slab->count) {
218 LIST_DEL(&slab->head);
219 LIST_ADDTAIL(&slab->head, &bucket->free);
221 if (slab->free == 1) {
222 LIST_DEL(&slab->head);
223 LIST_ADDTAIL(&slab->head, &bucket->used);
262 struct mm_slab *slab, *next;
264 LIST_FOR_EACH_ENTRY_SAFE(slab, next, head, head) {
265 LIST_DEL(&slab->head);
266 nouveau_bo_ref(NULL, &slab->bo);
267 FREE(slab);