Lines Matching refs:slab

698 alloc_from_slab(gc_slab *slab, uint32_t bucket)  in alloc_from_slab()  argument
702 if (slab->freelist) { in alloc_from_slab()
706 header = slab->freelist; in alloc_from_slab()
707 slab->freelist = get_gc_freelist_next(slab->freelist); in alloc_from_slab()
708 } else if (slab->next_available + size <= ((char *) slab) + SLAB_SIZE) { in alloc_from_slab()
709 header = (gc_block_header *) slab->next_available; in alloc_from_slab()
710 header->slab_offset = (char *) header - (char *) slab; in alloc_from_slab()
712 slab->next_available += size; in alloc_from_slab()
717 slab->num_allocated++; in alloc_from_slab()
718 slab->num_free--; in alloc_from_slab()
719 if (!slab->num_free) in alloc_from_slab()
720 list_del(&slab->free_link); in alloc_from_slab()
725 free_slab(gc_slab *slab) in free_slab() argument
727 if (list_is_linked(&slab->free_link)) in free_slab()
728 list_del(&slab->free_link); in free_slab()
729 list_del(&slab->link); in free_slab()
730 ralloc_free(slab); in free_slab()
736 gc_slab *slab = get_gc_slab(header); in free_from_slab() local
738 if (slab->num_allocated == 1 && !(keep_empty_slabs && list_is_singular(&slab->free_link))) { in free_from_slab()
740 free_slab(slab); in free_from_slab()
742 } else if (slab->num_free == 0) { in free_from_slab()
743 list_add(&slab->free_link, &slab->ctx->slabs[header->bucket].free_slabs); in free_from_slab()
749 while (slab->free_link.next != &slab->ctx->slabs[header->bucket].free_slabs && in free_from_slab()
750 slab->num_free > list_entry(slab->free_link.next, gc_slab, free_link)->num_free) { in free_from_slab()
751 gc_slab *next = list_entry(slab->free_link.next, gc_slab, free_link); in free_from_slab()
754 list_move_to(&slab->free_link, &next->free_link); in free_from_slab()
758 set_gc_freelist_next(header, slab->freelist); in free_from_slab()
759 slab->freelist = header; in free_from_slab()
761 slab->num_allocated--; in free_from_slab()
762 slab->num_free++; in free_from_slab()
779 gc_slab *slab = ralloc_size(ctx, get_slab_size(bucket)); in create_slab() local
780 if (unlikely(!slab)) in create_slab()
783 slab->ctx = ctx; in create_slab()
784 slab->freelist = NULL; in create_slab()
785 slab->next_available = (char*)(slab + 1); in create_slab()
786 slab->num_allocated = 0; in create_slab()
787 slab->num_free = gc_bucket_num_objs(bucket); in create_slab()
789 list_addtail(&slab->link, &ctx->slabs[bucket].slabs); in create_slab()
790 list_addtail(&slab->free_link, &ctx->slabs[bucket].free_slabs); in create_slab()
792 return slab; in create_slab()
820 gc_slab *slab = list_first_entry(&ctx->slabs[bucket].free_slabs, gc_slab, free_link); in gc_alloc_size() local
821 header = alloc_from_slab(slab, bucket); in gc_alloc_size()
905 list_for_each_entry_safe(gc_slab, slab, &ctx->slabs[i].slabs, link) { in gc_sweep_end()
906 if (!slab->num_allocated) { in gc_sweep_end()
907 free_slab(slab); in gc_sweep_end()
911 for (char *ptr = (char*)(slab + 1); ptr != slab->next_available; ptr += obj_size) { in gc_sweep_end()
918 bool last = slab->num_allocated == 1; in gc_sweep_end()
930 list_for_each_entry(gc_slab, slab, &ctx->slabs[i].slabs, link) { in gc_sweep_end()
931 assert(slab->num_allocated > 0); /* free_from_slab() should free it otherwise */ in gc_sweep_end()
932 ralloc_steal(ctx, slab); in gc_sweep_end()