Changes in kernel/generic/src/mm/slab.c [4ed41b3:5a6cc679] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/mm/slab.c
r4ed41b3 r5a6cc679 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;130 127 131 128 /** Cache for external slab descriptors … … 592 589 assert(_slab_initialized >= 2); 593 590 594 cache->mag_cache = slab_alloc(&slab_mag_cache, FRAME_ATOMIC); 591 cache->mag_cache = malloc(sizeof(slab_mag_cache_t) * config.cpu_count, 592 FRAME_ATOMIC); 595 593 if (!cache->mag_cache) 596 594 return false; … … 725 723 } 726 724 727 /** Return object to cache, use slab if known728 *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 742 725 /** Check that there are no slabs and remove cache from system 743 726 * … … 768 751 panic("Destroying cache that is not empty."); 769 752 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 } 753 if (!(cache->flags & SLAB_CACHE_NOMAGAZINE)) 754 free(cache->mag_cache); 774 755 775 756 slab_free(&slab_cache_cache, cache); … … 798 779 799 780 return result; 781 } 782 783 /** Return object to cache, use slab if known 784 * 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); 800 796 } 801 797 … … 935 931 #endif 936 932 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 941 933 irq_spinlock_lock(&slab_cache_lock, false); 942 934
Note:
See TracChangeset
for help on using the changeset viewer.