Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 436a0a5 in mainline for kernel/generic/src/mm/slab.c


Ignore:
Timestamp:
2018-11-09T22:04:01Z (3 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master
Children:
95d45482
Parents:
88e43bc (diff), abf6c01 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

(merge) Reduce the number of blocking allocations in the kernel

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/mm/slab.c

    r88e43bc r436a0a5  
    667667    size_t (*destructor)(void *obj), unsigned int flags)
    668668{
    669         slab_cache_t *cache = slab_alloc(&slab_cache_cache, 0);
     669        slab_cache_t *cache = slab_alloc(&slab_cache_cache, FRAME_ATOMIC);
     670        if (!cache)
     671                panic("Not enough memory to allocate slab cache %s.", name);
     672
    670673        _slab_cache_create(cache, name, size, align, constructor, destructor,
    671674            flags);
     
    730733NO_TRACE static void _slab_free(slab_cache_t *cache, void *obj, slab_t *slab)
    731734{
     735        if (!obj)
     736                return;
     737
    732738        ipl_t ipl = interrupts_disable();
    733739
     
    954960}
    955961
    956 static void *_malloc(size_t size, unsigned int flags)
     962void *malloc(size_t size)
    957963{
    958964        assert(_slab_initialized);
     
    964970        uint8_t idx = fnzb(size - 1) - SLAB_MIN_MALLOC_W + 1;
    965971
    966         return slab_alloc(malloc_caches[idx], flags);
    967 }
    968 
    969 void *malloc(size_t size)
    970 {
    971         return _malloc(size, FRAME_ATOMIC);
    972 }
    973 
    974 /** Non-failing malloc.
    975  *  Never returns NULL, but may block forever if no memory is available.
    976  */
    977 void *nfmalloc(size_t size)
    978 {
    979         return _malloc(size, 0);
    980 }
    981 
    982 static void *_realloc(void *ptr, size_t size, unsigned int flags)
     972        return slab_alloc(malloc_caches[idx], FRAME_ATOMIC);
     973}
     974
     975void *realloc(void *ptr, size_t size)
    983976{
    984977        assert(_slab_initialized);
     
    992985                uint8_t idx = fnzb(size - 1) - SLAB_MIN_MALLOC_W + 1;
    993986
    994                 new_ptr = slab_alloc(malloc_caches[idx], flags);
     987                new_ptr = slab_alloc(malloc_caches[idx], FRAME_ATOMIC);
    995988        } else
    996989                new_ptr = NULL;
     
    10071000}
    10081001
    1009 void *realloc(void *ptr, size_t size)
    1010 {
    1011         return _realloc(ptr, size, FRAME_ATOMIC);
    1012 }
    1013 
    10141002void free(void *ptr)
    10151003{
Note: See TracChangeset for help on using the changeset viewer.