Rev 782 | Rev 785 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 782 | Rev 783 | ||
---|---|---|---|
Line 250... | Line 250... | ||
250 | 250 | ||
251 | } else if (slab->available == 1) { |
251 | } else if (slab->available == 1) { |
252 | /* It was in full, move to partial */ |
252 | /* It was in full, move to partial */ |
253 | list_remove(&slab->link); |
253 | list_remove(&slab->link); |
254 | list_prepend(&slab->link, &cache->partial_slabs); |
254 | list_prepend(&slab->link, &cache->partial_slabs); |
255 | spinlock_unlock(&cache->slablock); |
- | |
256 | } |
255 | } |
- | 256 | spinlock_unlock(&cache->slablock); |
|
257 | return 0; |
257 | return 0; |
258 | } |
258 | } |
259 | 259 | ||
260 | /** |
260 | /** |
261 | * Take new object from slab or create new if needed |
261 | * Take new object from slab or create new if needed |
Line 534... | Line 534... | ||
534 | void (*destructor)(void *obj), |
534 | void (*destructor)(void *obj), |
535 | int flags) |
535 | int flags) |
536 | { |
536 | { |
537 | int i; |
537 | int i; |
538 | int pages; |
538 | int pages; |
- | 539 | ipl_t ipl; |
|
539 | 540 | ||
540 | memsetb((__address)cache, sizeof(*cache), 0); |
541 | memsetb((__address)cache, sizeof(*cache), 0); |
541 | cache->name = name; |
542 | cache->name = name; |
542 | 543 | ||
543 | if (align < sizeof(__native)) |
544 | if (align < sizeof(__native)) |
Line 578... | Line 579... | ||
578 | cache->objects = comp_objects(cache); |
579 | cache->objects = comp_objects(cache); |
579 | /* If info fits in, put it inside */ |
580 | /* If info fits in, put it inside */ |
580 | if (badness(cache) > sizeof(slab_t)) |
581 | if (badness(cache) > sizeof(slab_t)) |
581 | cache->flags |= SLAB_CACHE_SLINSIDE; |
582 | cache->flags |= SLAB_CACHE_SLINSIDE; |
582 | 583 | ||
- | 584 | /* Add cache to cache list */ |
|
- | 585 | ipl = interrupts_disable(); |
|
583 | spinlock_lock(&slab_cache_lock); |
586 | spinlock_lock(&slab_cache_lock); |
584 | 587 | ||
585 | list_append(&cache->link, &slab_cache_list); |
588 | list_append(&cache->link, &slab_cache_list); |
586 | 589 | ||
587 | spinlock_unlock(&slab_cache_lock); |
590 | spinlock_unlock(&slab_cache_lock); |
- | 591 | interrupts_restore(ipl); |
|
588 | } |
592 | } |
589 | 593 | ||
590 | /** Create slab cache */ |
594 | /** Create slab cache */ |
591 | slab_cache_t * slab_cache_create(char *name, |
595 | slab_cache_t * slab_cache_create(char *name, |
592 | size_t size, |
596 | size_t size, |
Line 756... | Line 760... | ||
756 | /* Print list of slabs */ |
760 | /* Print list of slabs */ |
757 | void slab_print_list(void) |
761 | void slab_print_list(void) |
758 | { |
762 | { |
759 | slab_cache_t *cache; |
763 | slab_cache_t *cache; |
760 | link_t *cur; |
764 | link_t *cur; |
- | 765 | ipl_t ipl; |
|
761 | 766 | ||
- | 767 | ipl = interrupts_disable(); |
|
762 | spinlock_lock(&slab_cache_lock); |
768 | spinlock_lock(&slab_cache_lock); |
763 | printf("SLAB name\tOsize\tPages\tObj/pg\tSlabs\tCached\tAllocobjs\tCtl\n"); |
769 | printf("SLAB name\tOsize\tPages\tObj/pg\tSlabs\tCached\tAllocobjs\tCtl\n"); |
764 | for (cur = slab_cache_list.next;cur!=&slab_cache_list; cur=cur->next) { |
770 | for (cur = slab_cache_list.next;cur!=&slab_cache_list; cur=cur->next) { |
765 | cache = list_get_instance(cur, slab_cache_t, link); |
771 | cache = list_get_instance(cur, slab_cache_t, link); |
766 | printf("%s\t%d\t%d\t%d\t%d\t%d\t%d\t\t%s\n", cache->name, cache->size, |
772 | printf("%s\t%d\t%d\t%d\t%d\t%d\t%d\t\t%s\n", cache->name, cache->size, |
Line 769... | Line 775... | ||
769 | atomic_get(&cache->cached_objs), |
775 | atomic_get(&cache->cached_objs), |
770 | atomic_get(&cache->allocated_objs), |
776 | atomic_get(&cache->allocated_objs), |
771 | cache->flags & SLAB_CACHE_SLINSIDE ? "In" : "Out"); |
777 | cache->flags & SLAB_CACHE_SLINSIDE ? "In" : "Out"); |
772 | } |
778 | } |
773 | spinlock_unlock(&slab_cache_lock); |
779 | spinlock_unlock(&slab_cache_lock); |
- | 780 | interrupts_restore(ipl); |
|
774 | } |
781 | } |
775 | 782 | ||
776 | #ifdef CONFIG_DEBUG |
783 | #ifdef CONFIG_DEBUG |
777 | static int _slab_initialized = 0; |
784 | static int _slab_initialized = 0; |
778 | #endif |
785 | #endif |