Changeset 614 for trunk/kernel/mm/vmm.c


Ignore:
Timestamp:
Jan 15, 2019, 1:59:32 PM (6 years ago)
Author:
alain
Message:

1) introduce a dev_ioc_sync_write() function in IOC API,

to improve the DEVFS synchronous update.

2) fix a big bug in both the user_dir_create() and user_dir_destroy()

functions: add an extended pointer on the reference client process
in the function's arguments.

File:
1 edited

Legend:

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

    r611 r614  
    6464    intptr_t  base;
    6565    intptr_t  size;
     66    uint32_t  i;
    6667
    6768#if DEBUG_VMM_INIT
     
    6970uint32_t cycle = (uint32_t)hal_get_cycles();
    7071if( DEBUG_VMM_INIT )
    71 printk("\n[%s] thread[%x,%x] enter for process %x / cycle %d\n",
    72 __FUNCTION__ , this->process->pid, this->trdid, process->pid , cycle );
     72printk("\n[%s] thread[%x,%x] enter for process %x in cluster %x / cycle %d\n",
     73__FUNCTION__ , this->process->pid, this->trdid, process->pid, local_cxy, cycle );
    7374#endif
    7475
     
    183184    vmm->mmap_mgr.first_free_vpn  = CONFIG_VMM_HEAP_BASE;
    184185    busylock_init( &vmm->mmap_mgr.lock , LOCK_VMM_MMAP );
    185 
    186     uint32_t i;
    187186    for( i = 0 ; i < 32 ; i++ ) list_root_init( &vmm->mmap_mgr.zombi_list[i] );
    188187
     
    195194cycle = (uint32_t)hal_get_cycles();
    196195if( DEBUG_VMM_INIT )
    197 printk("\n[%s] thread[%x,%x] exit / process %x / entry_point %x / cycle %d\n",
    198 __FUNCTION__, this->process->pid, this->trdid, process->pid, process->vmm.entry_point, cycle );
     196printk("\n[%s] thread[%x,%x] exit for process %x in cluster %x / cycle %d\n",
     197__FUNCTION__, this->process->pid, this->trdid, process->pid, local_cxy, cycle );
    199198#endif
    200199
     
    944943    vpn_t      free;
    945944
    946     // mmap vseg size must be power of 2
     945#if DEBUG_VMM_MMAP_ALLOC
     946thread_t * this = CURRENT_THREAD;
     947uint32_t cycle = (uint32_t)hal_get_cycles();
     948if( DEBUG_VMM_MMAP_ALLOC < cycle )
     949printk("\n[%s] thread[%x,%x] enter / cycle %d\n",
     950__FUNCTION__, this->process->pid, this->trdid, cycle );
     951#endif
     952
     953    // vseg size must be power of 2
    947954    // compute actual size and index in zombi_list array
    948955    size  = POW2_ROUNDUP( npages );
     
    952959    mmap_mgr_t * mgr = &vmm->mmap_mgr;
    953960
     961printk("\n@@@ in %s : size = %d / index = %d / first = %d / empty = %d\n",
     962__FUNCTION__, size, index, mgr->vpn_size, list_is_empty(&mgr->zombi_list[index]) );
     963
    954964    // get lock on mmap allocator
    955965    busylock_acquire( &mgr->lock );
     
    958968    if( list_is_empty( &mgr->zombi_list[index] ) )     // from mmap zone
    959969    {
     970
     971printk("\n@@@ from mmap zone\n" );
     972
    960973        // check overflow
    961974        free = mgr->first_free_vpn;
    962         if( (free + size) > mgr->vpn_size ) return ENOMEM;
    963 
    964         // update STACK allocator
     975        if( (free + size) > mgr->vpn_size ) return -1;
     976
     977        // update MMAP allocator
    965978        mgr->first_free_vpn += size;
    966979
     
    970983    else                                             // from zombi_list
    971984    {
     985
     986printk("\n@@@ from zombi_list\n" );
     987
    972988        // get pointer on zombi vseg from zombi_list
    973989        vseg = LIST_FIRST( &mgr->zombi_list[index] , vseg_t , zlist );
     
    982998    // release lock on mmap allocator
    983999    busylock_release( &mgr->lock );
     1000
     1001#if DEBUG_VMM_MMAP_ALLOC
     1002cycle = (uint32_t)hal_get_cycles();
     1003if( DEBUG_VMM_DESTROY < cycle )
     1004printk("\n[%s] thread[%x,%x] exit / vpn_base %x / vpn_size %x / cycle %d\n",
     1005__FUNCTION__, this->process->pid, this->trdid, base, size, cycle );
     1006#endif
    9841007
    9851008    // returns vpn_base, vpn_size
     
    10091032uint32_t   cycle = (uint32_t)hal_get_cycles();
    10101033if( DEBUG_VMM_CREATE_VSEG < cycle )
    1011 printk("\n[%s] thread[%x,%x] enter / %s / cxy %x / cycle %d\n",
    1012 __FUNCTION__, this->process->pid, this->trdid, vseg_type_str(type), cxy, cycle );
     1034printk("\n[%s] thread[%x,%x] enter for process %x / %s / cxy %x / cycle %d\n",
     1035__FUNCTION__, this->process->pid, this->trdid, process->pid, vseg_type_str(type), cxy, cycle );
    10131036#endif
    10141037
     
    10921115    if( vseg != NULL )
    10931116    {
    1094         printk("\n[ERROR] in %s for process %x : new vseg [vpn_base = %x / vpn_size = %x]\n"
    1095                "  overlap existing vseg [vpn_base = %x / vpn_size = %x]\n",
     1117        printk("\n[ERROR] in %s for process %x : new vseg [vpn_base %x / vpn_size %x]\n"
     1118               "  overlap existing vseg [vpn_base %x / vpn_size %x]\n",
    10961119        __FUNCTION__ , process->pid, vpn_base, vpn_size, vseg->vpn_base, vseg->vpn_size );
    10971120        return NULL;
     
    11061129        return NULL;
    11071130        }
     1131
     1132#if DEBUG_VMM_CREATE_VSEG
     1133if( DEBUG_VMM_CREATE_VSEG < cycle )
     1134printk("\n[%s] thread[%x,%x] : base %x / size %x / vpn_base %x / vpn_size %x\n",
     1135__FUNCTION__, this->process->pid, this->trdid, base, size, vpn_base, vpn_size );
     1136#endif
    11081137
    11091138    // initialize vseg descriptor
Note: See TracChangeset for help on using the changeset viewer.