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


Ignore:
Timestamp:
Feb 12, 2019, 1:15:47 PM (5 years ago)
Author:
alain
Message:

1) Fix a bug in KSH : after the "load" command,

the [ksh] prompt is now printed after completion
of the loaded application.

2) Fix a bug in vmm_handle_cow() : the copy-on-write

use now a hal_remote_memcpy() to replicate the page content.


File:
1 edited

Legend:

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

    r567 r619  
    33 *
    44 * Author  Ghassan Almaless (2008,2009,2010,2011,2012)
    5  *         Alain Greiner    (2016,2017,2018)
     5 *         Alain Greiner    (2016,2017,2018,2019)
    66 *
    77 * Copyright (c) UPMC Sorbonne Universites
     
    5151
    5252#if DEBUG_KCM
     53thread_t * this = CURRENT_THREAD;
    5354uint32_t cycle = (uint32_t)hal_get_cycles();
    5455if( DEBUG_KCM < cycle )
    55 printk("\n[DBG] %s : thread %x enters for %s / page %x / count %d / active %d\n",
    56 __FUNCTION__ , CURRENT_THREAD , kmem_type_str( kcm->type ) ,
     56printk("\n[%s] thread[%x,%x] enters for %s / page %x / count %d / active %d\n",
     57__FUNCTION__, this->process->pid, this->trdid, kmem_type_str(kcm->type),
    5758(intptr_t)kcm_page , kcm_page->count , kcm_page->active );
    5859#endif
    5960
    60         assert( kcm_page->active , "kcm_page should be active" );
     61assert( kcm_page->active , "kcm_page should be active" );
    6162
    6263        // get first block available
    6364        int32_t index = bitmap_ffs( kcm_page->bitmap , kcm->blocks_nr );
    6465
    65         assert( (index != -1) , "kcm_page should not be full" );
     66assert( (index != -1) , "kcm_page should not be full" );
    6667
    6768        // allocate block
     
    9091cycle = (uint32_t)hal_get_cycles();
    9192if( DEBUG_KCM < cycle )
    92 printk("\n[DBG] %s : thread %x exit / type %s / ptr %x / page %x / count %d\n",
    93        __FUNCTION__ , CURRENT_THREAD , kmem_type_str( kcm->type ) , (intptr_t)ptr ,
    94 (intptr_t)kcm_page , kcm_page->count );
     93printk("\n[%s] thread[%x,%x] exit for %s / ptr %x / page %x / count %d\n",
     94__FUNCTION__, this->process->pid, this->trdid, kmem_type_str(kcm->type),
     95(intptr_t)ptr, (intptr_t)kcm_page, kcm_page->count );
    9596#endif
    9697
     
    115116        index = ((uint8_t *)ptr - (uint8_t *)kcm_page - CONFIG_KCM_SLOT_SIZE) / kcm->block_size;
    116117
    117         assert( !bitmap_state( kcm_page->bitmap , index ) , "page already freed" );
    118         assert( (kcm_page->count > 0) , "count already zero" );
     118assert( !bitmap_state( kcm_page->bitmap , index ) , "page already freed" );
     119
     120assert( (kcm_page->count > 0) , "count already zero" );
    119121
    120122        bitmap_set( kcm_page->bitmap , index );
     
    163165        if( page == NULL )
    164166        {
    165                 printk("\n[ERROR] in %s : failed to allocate page in cluster %d\n",
    166                        __FUNCTION__ , local_cxy );
     167                printk("\n[ERROR] in %s : failed to allocate page in cluster %x\n",
     168            __FUNCTION__ , local_cxy );
    167169                return ENOMEM;
    168170        }
     
    216218                   uint32_t   type )
    217219{
    218         // the kcm_page descriptor mut fit in the KCM slot
    219         assert( (sizeof(kcm_page_t) <= CONFIG_KCM_SLOT_SIZE) ,
    220                 "KCM slot too small\n" );
     220
     221// the kcm_page descriptor must fit in the KCM slot
     222assert( (sizeof(kcm_page_t) <= CONFIG_KCM_SLOT_SIZE) , "KCM slot too small\n" );
     223
     224// the allocated object must fit in one single page
     225assert( (kmem_type_size(type) <= (CONFIG_PPM_PAGE_SIZE - CONFIG_KCM_SLOT_SIZE)),
     226"allocated object requires more than one single page\n" );
    221227
    222228        // initialize lock
     
    241247        uint32_t  blocks_nr = (CONFIG_PPM_PAGE_SIZE - CONFIG_KCM_SLOT_SIZE) / block_size;
    242248        kcm->blocks_nr = blocks_nr;
     249
     250#if DEBUG_KCM
     251thread_t * this  = CURRENT_THREAD;
     252uint32_t   cycle = (uint32_t)hal_get_cycles();
     253if( DEBUG_KCM < cycle )
     254printk("\n[%s] thread[%x,%x] initialised KCM %s : block_size %d / blocks_nr %d\n",
     255__FUNCTION__, this->process->pid, this->trdid,
     256kmem_type_str( kcm->type ), block_size, blocks_nr );
     257#endif
     258
    243259}
    244260
     
    331347        kcm_t      * kcm;
    332348
    333         assert( (ptr != NULL) , "pointer cannot be NULL" );
     349// check argument
     350assert( (ptr != NULL) , "pointer cannot be NULL" );
    334351
    335352        kcm_page = (kcm_page_t *)((intptr_t)ptr & ~CONFIG_PPM_PAGE_MASK);
Note: See TracChangeset for help on using the changeset viewer.