Changeset 18 for trunk/kernel/mm/kcm.c


Ignore:
Timestamp:
Jun 3, 2017, 4:42:49 PM (5 years ago)
Author:
max@…
Message:

cosmetic, and a few typos

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/mm/kcm.c

    r14 r18  
    11/*
    22 * kcm.c - Per cluster & per type Kernel Cache Manager access functions
    3  * 
     3 *
    44 * Author  Ghassan Almaless (2008,2009,2010,2011,2012)
    55 *         Alain Greiner    (2016)
     
    5050
    5151    // get first block available
    52         int32_t index = bitmap_ffs( page->bitmap , kcm->blocks_nr ); 
     52        int32_t index = bitmap_ffs( page->bitmap , kcm->blocks_nr );
    5353
    5454    assert( (index != -1) , __FUNCTION__ , "kcm page should not be full" );
    55  
     55
    5656    // allocate block
    5757        bitmap_clear( page->bitmap , index );
     
    8787{
    8888        kcm_page_t * page;
    89     uint32_t     index; 
    90  
     89    uint32_t     index;
     90
    9191        page = (kcm_page_t*)((intptr_t)ptr & CONFIG_PPM_PAGE_MASK);
    9292        index = ((uint8_t*)ptr - page->base) / kcm->block_size;
    93  
     93
    9494        bitmap_set( page->bitmap , index );
    9595        page->refcount --;
    96  
     96
    9797    // change the page to active if it was busy
    9898        if( page->busy )
     
    121121/////////////////////////////////////////////////////////////////////////////////////
    122122// This static function allocates one page from PPM. It initializes
    123 // the KCM-page descriptor, and introduces the new page into freelist. 
     123// the KCM-page descriptor, and introduces the new page into freelist.
    124124/////////////////////////////////////////////////////////////////////////////////////
    125125static error_t freelist_populate( kcm_t * kcm )
     
    134134    req.flags = AF_KERNEL;
    135135    page = kmem_alloc( &req );
    136  
     136
    137137        if( page == NULL )
    138138        {
    139                 printk("\n[ERROR] in %s : failed to allocate page in cluster %d\n", 
     139                printk("\n[ERROR] in %s : failed to allocate page in cluster %d\n",
    140140               __FUNCTION__ , local_cxy );
    141141        return ENOMEM;
     
    158158        list_add_first( &kcm->free_root , &ptr->list );
    159159        kcm->free_pages_nr ++;
    160  
     160
    161161        return 0;
    162162
     
    179179        }
    180180
    181     // get first KCM page from freelist and change its status to active 
     181    // get first KCM page from freelist and change its status to active
    182182        page = LIST_FIRST( &kcm->free_root, kcm_page_t , list );
    183183        list_unlink( &page->list );
     
    200200        spinlock_init( &kcm->lock );
    201201
    202     // initialize KCM type 
     202    // initialize KCM type
    203203        kcm->type = type;
    204204
     
    219219        kcm->blocks_nr  = blocks_nr;
    220220        kcm->block_size = block_size;
    221      
     221
    222222    kcm_dmsg("\n[INFO] %s : KCM %s initialised / block_size = %d / blocks_nr = %d\n",
    223223             __FUNCTION__ , kmem_type_str( type ) , block_size , blocks_nr );
     
    230230        kcm_page_t   * page;
    231231        list_entry_t * iter;
    232  
     232
    233233    // get KCM lock
    234234        spinlock_lock( &kcm->lock );
     
    274274    // get lock
    275275        spinlock_lock( &kcm->lock );
    276    
     276
    277277    // get an active page
    278278    if( list_is_empty( &kcm->active_root ) )  // no active page => get one
     
    303303    ptr  = kcm_get_block( kcm , page );
    304304
    305     // release lock 
     305    // release lock
    306306        spinlock_unlock(&kcm->lock);
    307307
     
    318318        kcm_page_t * page;
    319319        kcm_t      * kcm;
    320  
     320
    321321        if( ptr == NULL ) return;
    322        
     322
    323323        page = (kcm_page_t *)((intptr_t)ptr & CONFIG_PPM_PAGE_MASK);
    324324        kcm  = page->kcm;
     
    330330        kcm_put_block( kcm , ptr );
    331331
    332     // release lock 
     332    // release lock
    333333        spinlock_unlock( &kcm->lock );
    334334}
     
    338338{
    339339        printk("*** KCM type = %s / free_pages = %d / busy_pages = %d / active_pages = %d\n",
    340            kmem_type_str( kcm->type ) , 
    341            kcm->free_pages_nr , 
     340           kmem_type_str( kcm->type ) ,
     341           kcm->free_pages_nr ,
    342342           kcm->busy_pages_nr ,
    343343           kcm->active_pages_nr );
Note: See TracChangeset for help on using the changeset viewer.