slab.c
inline void
__slab_move_to_front(kmem_cache_t cp, kmem_slab_t slab) {
    if (cp->slabs == slab) return;

    __slab_remove(cp, slab);
    
    // check if there is any slab in the cache
    if (cp->slabs == NULL) { 
        slab->prev = slab;
        slab->next = slab;

        cp->slabs_back = slab;
    }
    else {
        slab->prev = cp->slabs;
        cp->slabs->next = slab;

        slab->next = cp->slabs_back;
        cp->slabs_back->prev = slab;
    }
    cp->slabs = slab;
}
/* Internal auxiliary to move slab to the front of freelist

    @cp cache pointer
    @slab slab pointer
*/
Internal auxiliary to move slab to the front of freelist
Internal auxiliary to move slab to the front of freelist
inline void
__slab_move_to_front(kmem_cache_t cp, kmem_slab_t slab) {
    if (cp->slabs == slab) return;
    __slab_remove(cp, slab);
    if (cp->slabs == NULL) { 
        slab->prev = slab;
        slab->next = slab;
        cp->slabs_back = slab;
    }
    else {
        slab->prev = cp->slabs;
        cp->slabs->next = slab;
        slab->next = cp->slabs_back;
        cp->slabs_back->prev = slab;
    }
    cp->slabs = slab;
}
inline void __slab_move_to_front ( kmem_cache_t cp , kmem_slab_t slab ) { if ( cp -> slabs == slab ) return ; __slab_remove ( cp , slab ) ; if ( cp -> slabs == NULL ) { slab -> prev = slab ; slab -> next = slab ; cp -> slabs_back = slab ; } else { slab -> prev = cp -> slabs ; cp -> slabs -> next = slab ; slab -> next = cp -> slabs_back ; cp -> slabs_back -> prev = slab ; } cp -> slabs = slab ; }
Internal auxiliary to move slab to the front of freelist
Internal auxiliary to move slab to the front of freelist
// check if there is any slab in the cache