Changes in kernel/generic/src/mm/slab.c [5a6cc679:4ed41b3] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/mm/slab.c
r5a6cc679 r4ed41b3 125 125 /** Cache for cache descriptors */ 126 126 static slab_cache_t slab_cache_cache; 127 128 /** Cache for per-CPU magazines of caches */ 129 static slab_cache_t slab_mag_cache; 127 130 128 131 /** Cache for external slab descriptors … … 589 592 assert(_slab_initialized >= 2); 590 593 591 cache->mag_cache = malloc(sizeof(slab_mag_cache_t) * config.cpu_count, 592 FRAME_ATOMIC); 594 cache->mag_cache = slab_alloc(&slab_mag_cache, FRAME_ATOMIC); 593 595 if (!cache->mag_cache) 594 596 return false; … … 723 725 } 724 726 727 /** Return object to cache, use slab if known 728 * 729 */ 730 NO_TRACE static void _slab_free(slab_cache_t *cache, void *obj, slab_t *slab) 731 { 732 ipl_t ipl = interrupts_disable(); 733 734 if ((cache->flags & SLAB_CACHE_NOMAGAZINE) || 735 (magazine_obj_put(cache, obj))) 736 slab_obj_destroy(cache, obj, slab); 737 738 interrupts_restore(ipl); 739 atomic_dec(&cache->allocated_objs); 740 } 741 725 742 /** Check that there are no slabs and remove cache from system 726 743 * … … 751 768 panic("Destroying cache that is not empty."); 752 769 753 if (!(cache->flags & SLAB_CACHE_NOMAGAZINE)) 754 free(cache->mag_cache); 770 if (!(cache->flags & SLAB_CACHE_NOMAGAZINE)) { 771 slab_t *mag_slab = obj2slab(cache->mag_cache); 772 _slab_free(mag_slab->cache, cache->mag_cache, mag_slab); 773 } 755 774 756 775 slab_free(&slab_cache_cache, cache); … … 779 798 780 799 return result; 781 }782 783 /** Return object to cache, use slab if known784 *785 */786 NO_TRACE static void _slab_free(slab_cache_t *cache, void *obj, slab_t *slab)787 {788 ipl_t ipl = interrupts_disable();789 790 if ((cache->flags & SLAB_CACHE_NOMAGAZINE) ||791 (magazine_obj_put(cache, obj)))792 slab_obj_destroy(cache, obj, slab);793 794 interrupts_restore(ipl);795 atomic_dec(&cache->allocated_objs);796 800 } 797 801 … … 931 935 #endif 932 936 937 _slab_cache_create(&slab_mag_cache, "slab_mag_cache", 938 sizeof(slab_mag_cache_t) * config.cpu_count, sizeof(uintptr_t), 939 NULL, NULL, SLAB_CACHE_NOMAGAZINE | SLAB_CACHE_SLINSIDE); 940 933 941 irq_spinlock_lock(&slab_cache_lock, false); 934 942
Note:
See TracChangeset
for help on using the changeset viewer.