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


Ignore:
Timestamp:
Jun 26, 2019, 11:42:37 AM (5 years ago)
Author:
alain
Message:

This version is a major evolution: The physical memory allocators,
defined in the kmem.c, ppm.c, and kcm.c files have been modified
to support remote accesses. The RPCs that were previously user
to allocate physical memory in a remote cluster have been removed.
This has been done to cure a dead-lock in case of concurrent page-faults.

This version 2.2 has been tested on a (4 clusters / 2 cores per cluster)
TSAR architecture, for both the "sort" and the "fft" applications.

File:
1 edited

Legend:

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

    r634 r635  
    4949#include <hal_exception.h>
    5050
    51 //////////////////////////////////////////////////////////////////////////////////
     51////////////////////////////////////////////////////////////////////////////////////////////
    5252//   Extern global variables
    53 //////////////////////////////////////////////////////////////////////////////////
     53////////////////////////////////////////////////////////////////////////////////////////////
    5454
    5555extern  process_t  process_zero;      // allocated in cluster.c
     
    286286}  // end vmm_detach_from_vsl()
    287287
    288 
    289 
    290 
    291288////////////////////////////////////////////
    292289error_t vmm_user_init( process_t * process )
    293290{
    294     vseg_t  * vseg_args;
    295     vseg_t  * vseg_envs;
    296     intptr_t  base;
    297     intptr_t  size;
    298291    uint32_t  i;
    299292
     
    319312"STACK zone too small\n");
    320313
     314    // initialize the lock protecting the VSL
     315        remote_rwlock_init( XPTR( local_cxy , &vmm->vsl_lock ) , LOCK_VMM_VSL );
     316
     317
     318/*
    321319    // register "args" vseg in VSL
    322320    base = CONFIG_VMM_UTILS_BASE << CONFIG_PPM_PAGE_SHIFT;
     
    358356
    359357    vmm->envs_vpn_base = base;
    360 
     358*/
    361359    // initialize STACK allocator
    362360    vmm->stack_mgr.bitmap   = 0;
     
    375373
    376374    // initialize instrumentation counters
    377         vmm->pgfault_nr = 0;
     375        vmm->false_pgfault_nr    = 0;
     376        vmm->local_pgfault_nr    = 0;
     377        vmm->global_pgfault_nr   = 0;
     378        vmm->false_pgfault_cost  = 0;
     379        vmm->local_pgfault_cost  = 0;
     380        vmm->global_pgfault_cost = 0;
    378381
    379382    hal_fence();
     
    398401
    399402#if DEBUG_VMM_USER_RESET
    400 uint32_t cycle = (uint32_t)hal_get_cycles();
     403uint32_t   cycle;
    401404thread_t * this = CURRENT_THREAD;
     405#endif
     406
     407#if (DEBUG_VMM_USER_RESET & 1 )
     408cycle = (uint32_t)hal_get_cycles();
    402409if( DEBUG_VMM_USER_RESET < cycle )
    403410printk("\n[%s] thread[%x,%x] enter for process %x in cluster %x / cycle %d\n",
     
    407414#if (DEBUG_VMM_USER_RESET & 1 )
    408415if( DEBUG_VMM_USER_RESET < cycle )
    409 hal_vmm_display( process , true );
     416hal_vmm_display( XPTR( local_cxy , process ) , true );
    410417#endif
    411418
     
    478485#endif
    479486
     487#if (DEBUG_VMM_USER_RESET & 1 )
     488if( DEBUG_VMM_USER_RESET < cycle )
     489hal_vmm_display( XPTR( local_cxy , process ) , true );
     490#endif
     491
    480492}  // end vmm_user_reset()
    481493
     
    503515thread_t * this = CURRENT_THREAD;
    504516if( DEBUG_VMM_UPDATE_PTE < cycle )
    505 printk("\n[%s] thread[%x,%x] enter for process %x / vpn %x / cycle %d\n",
    506 __FUNCTION__, this->process->pid, this->trdid, process->pid , vpn , cycle );
    507 #endif
    508 
    509 // check cluster is reference
    510 assert( (GET_CXY( process->ref_xp ) == local_cxy) , "not called in reference cluster\n");
     517printk("\n[%s] thread[%x,%x] enter for process %x / vpn %x / attr %x / ppn %x / ycle %d\n",
     518__FUNCTION__, this->process->pid, this->trdid, process->pid, vpn, attr, ppn, cycle );
     519#endif
    511520
    512521    // get extended pointer on root of process copies xlist in owner cluster
     
    517526    process_root_xp  = XPTR( owner_cxy , process_root_ptr );
    518527
     528// check local cluster is owner cluster
     529assert( (owner_cxy == local_cxy) , "must be called in owner cluster\n");
     530
    519531    // loop on destination process copies
    520532    XLIST_FOREACH( process_root_xp , process_iter_xp )
     
    525537        remote_process_cxy = GET_CXY( remote_process_xp );
    526538
    527 #if (DEBUG_VMM_UPDATE_PTE & 0x1)
     539#if (DEBUG_VMM_UPDATE_PTE & 1)
    528540if( DEBUG_VMM_UPDATE_PTE < cycle )
    529 printk("\n[%s] threadr[%x,%x] handling vpn %x for process %x in cluster %x\n",
     541printk("\n[%s] thread[%x,%x] handling vpn %x for process %x in cluster %x\n",
    530542__FUNCTION__, this->process->pid, this->trdid, vpn, process->pid, remote_process_cxy );
    531543#endif
     
    545557#endif
    546558
     559#if (DEBUG_VMM_UPDATE_PTE & 1)
     560hal_vmm_display( process , true );
     561#endif
     562
    547563}  // end vmm_global_update_pte()
    548564
     
    570586    cxy_t           owner_cxy;
    571587    lpid_t          owner_lpid;
     588
     589    // get target process PID
     590    pid = process->pid;
    572591
    573592#if DEBUG_VMM_SET_COW
     
    576595if( DEBUG_VMM_SET_COW < cycle )
    577596printk("\n[%s] thread[%x,%x] enter for process %x / cycle %d\n",
    578 __FUNCTION__, this->process->pid, this->trdid, process->pid , cycle );
     597__FUNCTION__, this->process->pid, this->trdid, pid , cycle );
     598#endif
     599
     600#if (DEBUG_VMM_SET_COW & 1)
     601if( DEBUG_VMM_SET_COW < cycle )
     602hal_vmm_display( process , true );
    579603#endif
    580604
    581605// check cluster is reference
    582 assert( (GET_CXY( process->ref_xp ) == local_cxy) ,
    583 "local cluster is not process reference cluster\n");
     606assert( (XPTR( local_cxy , process ) == process->ref_xp),
     607"local cluster must be process reference cluster\n");
    584608
    585609    // get pointer on reference VMM
     
    587611
    588612    // get extended pointer on root of process copies xlist in owner cluster
    589     pid              = process->pid;
    590613    owner_cxy        = CXY_FROM_PID( pid );
    591614    owner_lpid       = LPID_FROM_PID( pid );
     
    596619    vseg_root_xp  = XPTR( local_cxy , &vmm->vsegs_root );
    597620
    598     // loop on destination process copies
     621    // loop on target process copies
    599622    XLIST_FOREACH( process_root_xp , process_iter_xp )
    600623    {
    601         // get cluster and local pointer on remote process
     624        // get cluster and local pointer on remote process copy
    602625        remote_process_xp  = XLIST_ELEMENT( process_iter_xp , process_t , copies_list );
    603626        remote_process_ptr = GET_PTR( remote_process_xp );
     
    606629#if (DEBUG_VMM_SET_COW & 1)
    607630if( DEBUG_VMM_SET_COW < cycle )
    608 printk("\n[%s] thread[%x,%x] handling process %x in cluster %x\n",
    609 __FUNCTION__, this->process->pid, this->trdid, process->pid , remote_process_cxy );
     631printk("\n[%s] thread[%x,%x] (%x) handles process %x in cluster %x\n",
     632__FUNCTION__, this->process->pid, this->trdid, this, pid, remote_process_cxy );
    610633#endif
    611634
     
    620643            vseg     = GET_PTR( vseg_xp );
    621644
    622 assert( (GET_CXY( vseg_xp ) == local_cxy) ,
    623 "all vsegs in reference VSL must be local\n" );
    624 
    625645            // get vseg type, base and size
    626646            uint32_t type     = vseg->type;
     
    630650#if (DEBUG_VMM_SET_COW & 1)
    631651if( DEBUG_VMM_SET_COW < cycle )
    632 printk("\n[%s] thread[%x,%x] handling vseg %s / vpn_base = %x / vpn_size = %x\n",
     652printk("\n[%s] thread[%x,%x] found vseg %s / vpn_base = %x / vpn_size = %x\n",
    633653__FUNCTION__, this->process->pid, this->trdid, vseg_type_str(type), vpn_base, vpn_size );
    634654#endif
     
    653673
    654674                // atomically increment pending forks counter in physical pages,
    655                 // for all vseg pages that are mapped in reference cluster
     675                // this is only done once, when handling the reference copy
    656676                if( remote_process_cxy == local_cxy )
    657677                {
     678
     679#if (DEBUG_VMM_SET_COW & 1)
     680if( DEBUG_VMM_SET_COW < cycle )
     681printk("\n[%s] thread[%x,%x] handles vseg %s / vpn_base = %x / vpn_size = %x\n",
     682__FUNCTION__, this->process->pid, this->trdid, vseg_type_str(type), vpn_base, vpn_size );
     683#endif
    658684                    // scan all pages in vseg
    659685                    for( vpn = vpn_base ; vpn < (vpn_base + vpn_size) ; vpn++ )
     
    684710                        }
    685711                    }   // end loop on vpn
     712
     713#if (DEBUG_VMM_SET_COW & 1)
     714if( DEBUG_VMM_SET_COW < cycle )
     715printk("\n[%s] thread[%x,%x] completes vseg %s / vpn_base = %x / vpn_size = %x\n",
     716__FUNCTION__, this->process->pid, this->trdid, vseg_type_str(type), vpn_base, vpn_size );
     717#endif
    686718                }   // end if local
    687719            }   // end if vseg type
     
    713745    vseg_t    * child_vseg;
    714746    uint32_t    type;
    715     bool_t      cow;
    716747    vpn_t       vpn;           
    717748    vpn_t       vpn_base;
    718749    vpn_t       vpn_size;
    719     xptr_t      page_xp;        // extended pointer on page descriptor
    720     page_t    * page_ptr;
    721     cxy_t       page_cxy;
    722     xptr_t      forks_xp;       // extended pointer on forks counter in page descriptor
    723750    xptr_t      parent_root_xp;
    724751    bool_t      mapped;
     
    740767    parent_vmm = &parent_process->vmm;
    741768    child_vmm  = &child_process->vmm;
    742 
    743     // initialize the lock protecting the child VSL
    744         remote_rwlock_init( XPTR( local_cxy , &child_vmm->vsl_lock ) , LOCK_VMM_VSL );
    745 
    746     // initialize the child VSL as empty
    747     xlist_root_init( XPTR( local_cxy, &child_vmm->vsegs_root ) );
    748     child_vmm->vsegs_nr = 0;
    749 
    750     // create an empty child GPT
    751     error = hal_gpt_create( &child_vmm->gpt );
    752     if( error )
    753     {
    754         printk("\n[ERROR] in %s : cannot create GPT\n", __FUNCTION__ );
    755         return -1;
    756     }
    757769
    758770    // build extended pointer on parent VSL root and lock
     
    820832            {
    821833                // activate the COW for DATA, ANON, REMOTE vsegs only
    822                 cow = ( type != VSEG_TYPE_FILE );
     834                // cow = ( type != VSEG_TYPE_FILE );
    823835
    824836                vpn_base = child_vseg->vpn_base;
     
    832844                                              XPTR( parent_cxy , &parent_vmm->gpt ),
    833845                                              vpn,
    834                                               cow,
    835                                               &ppn,
    836                                               &mapped );
     846                                              false,      // does not handle COW flag
     847                                              &ppn,       // unused
     848                                              &mapped );  // unused
    837849                    if( error )
    838850                    {
     
    842854                    }
    843855
    844                     // increment pending forks counter in page if mapped
    845                     if( mapped )
    846                     {
    847                         // get pointers and cluster on page descriptor
    848                         page_xp  = ppm_ppn2page( ppn );
    849                         page_cxy = GET_CXY( page_xp );
    850                         page_ptr = GET_PTR( page_xp );
    851 
    852                         // get extended pointers on "forks" and "lock"
    853                         forks_xp = XPTR( page_cxy , &page_ptr->forks );
    854                         lock_xp  = XPTR( page_cxy , &page_ptr->lock );
    855 
    856                         // get lock protecting "forks" counter
    857                         remote_busylock_acquire( lock_xp );
    858 
    859                         // increment "forks"
    860                         hal_remote_atomic_add( forks_xp , 1 );
    861 
    862                         // release lock protecting "forks" counter
    863                         remote_busylock_release( lock_xp );
    864 
    865856#if DEBUG_VMM_FORK_COPY
    866857cycle = (uint32_t)hal_get_cycles();
     
    869860__FUNCTION__ , this->process->pid, this->trdid , vpn , cycle );
    870861#endif
    871                     }
    872862                }
    873863            }   // end if no code & no stack
     
    877867    // release the parent VSL lock in read mode
    878868    remote_rwlock_rd_release( parent_lock_xp );
    879 
    880     // update child VMM with kernel vsegs
    881     error = hal_vmm_kernel_update( child_process );
    882 
    883     if( error )
    884     {
    885         printk("\n[ERROR] in %s : cannot update child VMM\n", __FUNCTION__ );
    886         return -1;
    887     }
    888869
    889870    // initialize the child VMM STACK allocator
     
    902883
    903884    // initialize instrumentation counters
    904         child_vmm->pgfault_nr    = 0;
     885        child_vmm->false_pgfault_nr    = 0;
     886        child_vmm->local_pgfault_nr    = 0;
     887        child_vmm->global_pgfault_nr   = 0;
     888        child_vmm->false_pgfault_cost  = 0;
     889        child_vmm->local_pgfault_cost  = 0;
     890        child_vmm->global_pgfault_cost = 0;
    905891
    906892    // copy base addresses from parent VMM to child VMM
     
    933919
    934920#if DEBUG_VMM_DESTROY
    935 uint32_t cycle = (uint32_t)hal_get_cycles();
    936 thread_t * this = CURRENT_THREAD;
     921uint32_t   cycle = (uint32_t)hal_get_cycles();
     922thread_t * this  = CURRENT_THREAD;
    937923if( DEBUG_VMM_DESTROY < cycle )
    938924printk("\n[%s] thread[%x,%x] enter for process %x in cluster %x / cycle %d\n",
     
    942928#if (DEBUG_VMM_DESTROY & 1 )
    943929if( DEBUG_VMM_DESTROY < cycle )
    944 hal_vmm_display( process , true );
     930hal_vmm_display( XPTR( local_cxy, process ) , true );
    945931#endif
    946932
     
    10621048vseg_t * vmm_create_vseg( process_t   * process,
    10631049                              vseg_type_t   type,
    1064                           intptr_t      base,
     1050                          intptr_t      base,         // ltid for VSEG_TYPE_STACK
    10651051                              uint32_t      size,
    10661052                          uint32_t      file_offset,
     
    10741060        error_t      error;
    10751061
    1076 #if DEBUG_VMM_CREATE_VSEG
     1062#if (DEBUG_VMM_CREATE_VSEG & 1)
    10771063thread_t * this  = CURRENT_THREAD;
    10781064uint32_t   cycle = (uint32_t)hal_get_cycles();
    10791065if( DEBUG_VMM_CREATE_VSEG < cycle )
    1080 printk("\n[%s] thread[%x,%x] enter for process %x / %s / cxy %x / cycle %d\n",
    1081 __FUNCTION__, this->process->pid, this->trdid, process->pid, vseg_type_str(type), cxy, cycle );
     1066printk("\n[%s] thread[%x,%x] enter / process %x / %s / base %x / cxy %x / cycle %d\n",
     1067__FUNCTION__, this->process->pid, this->trdid,
     1068process->pid, vseg_type_str(type), base, cxy, cycle );
    10821069#endif
    10831070
     
    11711158        }
    11721159
    1173 #if DEBUG_VMM_CREATE_VSEG
     1160#if (DEBUG_VMM_CREATE_VSEG & 1)
    11741161if( DEBUG_VMM_CREATE_VSEG < cycle )
    11751162printk("\n[%s] thread[%x,%x] : base %x / size %x / vpn_base %x / vpn_size %x\n",
     
    12041191cycle = (uint32_t)hal_get_cycles();
    12051192if( DEBUG_VMM_CREATE_VSEG < cycle )
    1206 printk("\n[%s] thread[%x,%x] exit / %s / cxy %x / cycle %d\n",
    1207 __FUNCTION__, this->process->pid, this->trdid, vseg_type_str(type), cxy, cycle );
     1193printk("\n[%s] thread[%x,%x] exit / process %x / %s / base %x / cxy %x / cycle %d\n",
     1194__FUNCTION__, this->process->pid, this->trdid,
     1195process->pid, vseg_type_str(type), base, cxy, cycle );
    12081196#endif
    12091197
     
    16851673    xptr_t       page_xp;
    16861674    cxy_t        page_cxy;
     1675    page_t     * page_ptr;
    16871676    uint32_t     index;
    16881677
     
    17111700    }
    17121701
    1713     // allocate a 4 Kbytes physical page from target cluster
    1714     page_xp = ppm_remote_alloc_pages( page_cxy , 0 );
     1702    // allocate one small physical page from target cluster
     1703    page_ptr = ppm_remote_alloc_pages( page_cxy , 0 );
     1704
     1705    page_xp = XPTR( page_cxy , page_ptr );
    17151706
    17161707#if DEBUG_VMM_PAGE_ALLOCATE
    17171708cycle = (uint32_t)hal_get_cycles();
    17181709if( DEBUG_VMM_PAGE_ALLOCATE < cycle )
    1719 printk("\n[%s] thread[%x,%x] exit for vpn %x / ppn %x / cluster %x / cycle %d\n",
    1720 __FUNCTION__ , this->process->pid, this->trdid, vpn, ppm_page2ppn(page_xp), page_cxy, cycle );
     1710printk("\n[%s] thread[%x,%x] exit for vpn %x / ppn %x / cycle %d\n",
     1711__FUNCTION__ , this->process->pid, this->trdid, vpn, ppm_page2ppn(page_xp), cycle );
    17211712#endif
    17221713
     
    17411732uint32_t   cycle = (uint32_t)hal_get_cycles();
    17421733thread_t * this  = CURRENT_THREAD;
    1743 // if( DEBUG_VMM_GET_ONE_PPN < cycle )
    1744 if( vpn == 0x40B )
     1734if( (DEBUG_VMM_GET_ONE_PPN < cycle) && (vpn == 0x40b) )
    17451735printk("\n[%s] thread[%x,%x] enter for vpn %x / type %s / page_id  %d / cycle %d\n",
    17461736__FUNCTION__, this->process->pid, this->trdid, vpn, vseg_type_str(type), page_id, cycle );
     
    17691759        page_xp = vmm_page_allocate( vseg , vpn );
    17701760
    1771         if( page_xp == XPTR_NULL ) return ENOMEM;
     1761        if( page_xp == XPTR_NULL ) return -1;
    17721762
    17731763        // initialise missing page from .elf file mapper for DATA and CODE types
     
    17881778
    17891779#if (DEBUG_VMM_GET_ONE_PPN & 0x1)
    1790 // if( DEBUG_VMM_GET_ONE_PPN < cycle )
    1791 if( vpn == 0x40B )
     1780if( (DEBUG_VMM_GET_ONE_PPN < cycle) && (vpn == 0x40b) )
    17921781printk("\n[%s] thread[%x,%x] for vpn = %x / elf_offset = %x\n",
    17931782__FUNCTION__, this->process->pid, this->trdid, vpn, elf_offset );
     
    18031792
    18041793#if (DEBUG_VMM_GET_ONE_PPN & 0x1)
    1805 // if( DEBUG_VMM_GET_ONE_PPN < cycle )
    1806 if( vpn == 0x40B )
     1794if( (DEBUG_VMM_GET_ONE_PPN < cycle) && (vpn == 0x40b) )
    18071795printk("\n[%s] thread[%x,%x] for vpn  %x / fully in BSS\n",
    18081796__FUNCTION__, this->process->pid, this->trdid, vpn );
     
    18211809
    18221810#if (DEBUG_VMM_GET_ONE_PPN & 0x1)
    1823 // if( DEBUG_VMM_GET_ONE_PPN < cycle )
    1824 if( vpn == 0x40B )
     1811if( (DEBUG_VMM_GET_ONE_PPN < cycle) && (vpn == 0x40b) )
    18251812printk("\n[%s] thread[%x,%x] for vpn  %x / fully in mapper\n",
    18261813__FUNCTION__, this->process->pid, this->trdid, vpn );
     
    18391826
    18401827#if (DEBUG_VMM_GET_ONE_PPN & 0x1)
    1841 // if( DEBUG_VMM_GET_ONE_PPN < cycle )
    1842 if( vpn == 0x40B )
     1828if( (DEBUG_VMM_GET_ONE_PPN < cycle) && (vpn == 0x40b) )
    18431829printk("\n[%s] thread[%x,%x] for vpn  %x / both mapper & BSS\n"
    18441830"      %d bytes from mapper / %d bytes from BSS\n",
     
    18741860#if DEBUG_VMM_GET_ONE_PPN
    18751861cycle = (uint32_t)hal_get_cycles();
    1876 // if( DEBUG_VMM_GET_ONE_PPN < cycle )
    1877 if( vpn == 0x40B )
    1878 printk("\n[%s] thread[%x,%x] exit for vpn %x / ppn %x / cycle\n",
     1862if( (DEBUG_VMM_GET_ONE_PPN < cycle) && (vpn == 0x40b) )
     1863printk("\n[%s] thread[%x,%x] exit for vpn %x / ppn %x / cycle %d\n",
    18791864__FUNCTION__ , this->process->pid, this->trdid , vpn , *ppn, cycle );
    18801865#endif
     
    19061891
    19071892#if DEBUG_VMM_HANDLE_PAGE_FAULT
    1908 if( (start_cycle > DEBUG_VMM_HANDLE_PAGE_FAULT) && (vpn == vpn) )
     1893if( (start_cycle > DEBUG_VMM_HANDLE_PAGE_FAULT) && (vpn > 0) )
    19091894printk("\n[%s] thread[%x,%x] enter for vpn %x / cycle %d\n",
    19101895__FUNCTION__, this->process->pid, this->trdid, vpn, start_cycle );
     
    19121897
    19131898#if (DEBUG_VMM_HANDLE_PAGE_FAULT & 1)
    1914 if( (start_cycle > DEBUG_VMM_HANDLE_PAGE_FAULT) && (vpn == vpn) )
    1915 hal_vmm_display( this->process , false );
     1899if( (start_cycle > DEBUG_VMM_HANDLE_PAGE_FAULT) && (vpn > 0) )
     1900hal_vmm_display( this->process , true );
    19161901#endif
    19171902
     
    19281913    }
    19291914
    1930 #if DEBUG_VMM_HANDLE_PAGE_FAULT
    1931 if( (start_cycle > DEBUG_VMM_HANDLE_PAGE_FAULT) && (vpn == vpn) )
     1915#if (DEBUG_VMM_HANDLE_PAGE_FAULT & 1)
     1916if( (start_cycle > DEBUG_VMM_HANDLE_PAGE_FAULT) && (vpn > 0) )
    19321917printk("\n[%s] thread[%x,%x] found vseg %s\n",
    19331918__FUNCTION__, this->process->pid, this->trdid, vseg_type_str(vseg->type) );
     
    19501935    }
    19511936
    1952 #if DEBUG_VMM_HANDLE_PAGE_FAULT
    1953 if( (start_cycle > DEBUG_VMM_HANDLE_PAGE_FAULT) && (vpn == vpn) )
    1954 printk("\n[%s] thread[%x,%x] locked vpn %x in cluster %x / cycle %d\n",
     1937#if (DEBUG_VMM_HANDLE_PAGE_FAULT & 1)
     1938if( (start_cycle > DEBUG_VMM_HANDLE_PAGE_FAULT) && (vpn > 0) )
     1939printk("\n[%s] thread[%x,%x] locked vpn %x in cluster %x\n",
    19551940__FUNCTION__, this->process->pid, this->trdid, vpn, local_cxy );
    19561941#endif
     
    19701955        {
    19711956
    1972 #if DEBUG_VMM_HANDLE_PAGE_FAULT
    1973 if( (start_cycle > DEBUG_VMM_HANDLE_PAGE_FAULT) && (vpn == vpn) )
    1974 printk("\n[%s] thread[%x,%x] access local gpt : cxy %x / ref_cxy %x / type %s\n",
    1975 __FUNCTION__, this->process->pid, this->trdid, local_cxy, ref_cxy, vseg_type_str(vseg->type) );
     1957#if (DEBUG_VMM_HANDLE_PAGE_FAULT & 1)
     1958if( (start_cycle > DEBUG_VMM_HANDLE_PAGE_FAULT) && (vpn > 0) )
     1959printk("\n[%s] thread[%x,%x] access local gpt : cxy %x / ref_cxy %x / type %s / cycle %d\n",
     1960__FUNCTION__, this->process->pid, this->trdid,
     1961local_cxy, ref_cxy, vseg_type_str(vseg->type), (uint32_t)hal_get_cycles() );
    19761962#endif
    19771963            // allocate and initialise a physical page
     
    20081994
    20091995#if DEBUG_VMM_HANDLE_PAGE_FAULT
    2010 if( (end_cycle > DEBUG_VMM_HANDLE_PAGE_FAULT) && (vpn == vpn) )
     1996if( (end_cycle > DEBUG_VMM_HANDLE_PAGE_FAULT) && (vpn > 0) )
    20111997printk("\n[%s] thread[%x,%x] handled local pgfault / ppn %x / attr %x / cycle %d\n",
    20121998__FUNCTION__, this->process->pid, this->trdid, ppn, attr, end_cycle );
     
    20262012        {
    20272013
    2028 #if DEBUG_VMM_HANDLE_PAGE_FAULT
    2029 if( (start_cycle > DEBUG_VMM_HANDLE_PAGE_FAULT) && (vpn == vpn) )
    2030 printk("\n[%s] thread[%x,%x] access ref gpt : cxy %x / ref_cxy %x / type %s\n",
    2031 __FUNCTION__, this->process->pid, this->trdid, local_cxy, ref_cxy, vseg_type_str(vseg->type) );
     2014#if (DEBUG_VMM_HANDLE_PAGE_FAULT & 1)
     2015if( (start_cycle > DEBUG_VMM_HANDLE_PAGE_FAULT) && (vpn > 0) )
     2016printk("\n[%s] thread[%x,%x] access ref gpt : cxy %x / ref_cxy %x / type %s / cycle %d\n",
     2017__FUNCTION__, this->process->pid, this->trdid,
     2018local_cxy, ref_cxy, vseg_type_str(vseg->type), (uint32_t)hal_get_cycles() );
    20322019#endif
    20332020            // build extended pointer on reference GPT
     
    20502037            }
    20512038
    2052 #if DEBUG_VMM_HANDLE_PAGE_FAULT
    2053 if( (start_cycle > DEBUG_VMM_HANDLE_PAGE_FAULT) && (vpn == vpn) )
     2039#if (DEBUG_VMM_HANDLE_PAGE_FAULT & 1)
     2040if( (start_cycle > DEBUG_VMM_HANDLE_PAGE_FAULT) && (vpn > 0) )
    20542041printk("\n[%s] thread[%x,%x] get pte from ref gpt / attr %x / ppn %x\n",
    20552042__FUNCTION__, this->process->pid, this->trdid, ref_attr, ref_ppn );
     
    20652052                                 ref_ppn );
    20662053
    2067 #if DEBUG_VMM_HANDLE_PAGE_FAULT
    2068 if( (start_cycle > DEBUG_VMM_HANDLE_PAGE_FAULT) && (vpn == vpn) )
     2054#if (DEBUG_VMM_HANDLE_PAGE_FAULT & 1)
     2055if( (start_cycle > DEBUG_VMM_HANDLE_PAGE_FAULT) && (vpn > 0) )
    20692056printk("\n[%s] thread[%x,%x] updated local gpt for a false pgfault\n",
    20702057__FUNCTION__, this->process->pid, this->trdid );
     
    20742061                hal_gpt_unlock_pte( ref_gpt_xp, vpn );
    20752062                             
    2076 #if DEBUG_VMM_HANDLE_PAGE_FAULT
    2077 if( (start_cycle > DEBUG_VMM_HANDLE_PAGE_FAULT) && (vpn == vpn) )
     2063#if (DEBUG_VMM_HANDLE_PAGE_FAULT &1)
     2064if( (start_cycle > DEBUG_VMM_HANDLE_PAGE_FAULT) && (vpn > 0) )
    20782065printk("\n[%s] thread[%x,%x] unlock the ref gpt after a false pgfault\n",
    20792066__FUNCTION__, this->process->pid, this->trdid );
     
    20852072
    20862073#if DEBUG_VMM_HANDLE_PAGE_FAULT
    2087 if( (end_cycle > DEBUG_VMM_HANDLE_PAGE_FAULT) && (vpn == vpn) )
     2074if( (end_cycle > DEBUG_VMM_HANDLE_PAGE_FAULT) && (vpn > 0) )
    20882075printk("\n[%s] thread[%x,%x] handled false pgfault / ppn %x / attr %x / cycle %d\n",
    20892076__FUNCTION__, this->process->pid, this->trdid, ref_ppn, ref_attr, end_cycle );
     
    21202107                if( vseg->flags & VSEG_CACHE ) attr |= GPT_CACHABLE;
    21212108
    2122 #if DEBUG_VMM_HANDLE_PAGE_FAULT
    2123 if( (start_cycle > DEBUG_VMM_HANDLE_PAGE_FAULT) && (vpn == vpn) )
     2109#if (DEBUG_VMM_HANDLE_PAGE_FAULT & 1)
     2110if( (start_cycle > DEBUG_VMM_HANDLE_PAGE_FAULT) && (vpn > 0) )
    21242111printk("\n[%s] thread[%x,%x] build a new PTE for a true pgfault\n",
    21252112__FUNCTION__, this->process->pid, this->trdid );
     
    21322119                                 ppn );
    21332120
    2134 #if DEBUG_VMM_HANDLE_PAGE_FAULT
    2135 if( (start_cycle > DEBUG_VMM_HANDLE_PAGE_FAULT) && (vpn == vpn) )
     2121#if (DEBUG_VMM_HANDLE_PAGE_FAULT & 1)
     2122if( (start_cycle > DEBUG_VMM_HANDLE_PAGE_FAULT) && (vpn > 0) )
    21362123printk("\n[%s] thread[%x,%x] set new PTE in ref gpt for a true page fault\n",
    21372124__FUNCTION__, this->process->pid, this->trdid );
     
    21502137
    21512138#if DEBUG_VMM_HANDLE_PAGE_FAULT
    2152 if( (end_cycle > DEBUG_VMM_HANDLE_PAGE_FAULT) && (vpn == vpn) )
     2139if( (end_cycle > DEBUG_VMM_HANDLE_PAGE_FAULT) && (vpn > 0) )
    21532140printk("\n[%s] thread[%x,%x] handled global pgfault / ppn %x / attr %x / cycle %d\n",
    21542141__FUNCTION__, this->process->pid, this->trdid, ppn, attr, end_cycle );
     
    21732160
    21742161#if DEBUG_VMM_HANDLE_PAGE_FAULT
    2175 if( (end_cycle > DEBUG_VMM_HANDLE_PAGE_FAULT) && (vpn == vpn) )
     2162if( (end_cycle > DEBUG_VMM_HANDLE_PAGE_FAULT) && (vpn > 0) )
    21762163printk("\n[%s] handled by another thread / vpn %x / ppn %x / attr %x / cycle %d\n",
    21772164__FUNCTION__, vpn, ppn, attr, end_cycle );
     
    22122199#endif
    22132200
    2214 #if (DEBUG_VMM_HANDLE_PAGE_FAULT & 1)
     2201#if ((DEBUG_VMM_HANDLE_COW & 3) == 3 )
    22152202hal_vmm_display( process , true );
    22162203#endif
     
    23522339#if(DEBUG_VMM_HANDLE_COW & 1)
    23532340if( DEBUG_VMM_HANDLE_COW < cycle )
    2354 printk("\n[%s] thread[%x,%x]  no pending forks / keep existing PPN %x\n",
     2341printk("\n[%s] thread[%x,%x] no pending forks / keep existing PPN %x\n",
    23552342__FUNCTION__, this->process->pid, this->trdid, old_ppn );
    23562343#endif
     
    23602347    // build new_attr : set WRITABLE, reset COW, reset LOCKED
    23612348    new_attr = (((old_attr | GPT_WRITABLE) & (~GPT_COW)) & (~GPT_LOCKED));
     2349
     2350#if(DEBUG_VMM_HANDLE_COW & 1)
     2351if( DEBUG_VMM_HANDLE_COW < cycle )
     2352printk("\n[%s] thread[%x,%x] new_attr %x / new_ppn %x\n",
     2353__FUNCTION__, this->process->pid, this->trdid, new_attr, new_ppn );
     2354#endif
    23622355
    23632356    // update the relevant GPT(s)
     
    23662359    if( (vseg->type == VSEG_TYPE_STACK) || (vseg->type == VSEG_TYPE_CODE) )
    23672360    {
    2368         // set the new PTE2
     2361        // set new PTE in local gpt
    23692362        hal_gpt_set_pte( gpt_xp,
    23702363                         vpn,
     
    23982391#endif
    23992392
     2393#if ((DEBUG_VMM_HANDLE_COW & 3) == 3)
     2394hal_vmm_display( process , true );
     2395#endif
     2396
    24002397     return EXCP_NON_FATAL;
    24012398
Note: See TracChangeset for help on using the changeset viewer.