Ignore:
Timestamp:
Jun 26, 2019, 11:42:37 AM (17 months 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/kern/thread.c

    r633 r635  
    7878static thread_t * thread_alloc( void )
    7979{
    80         page_t       * page;   // pointer on page descriptor containing thread descriptor
    8180        kmem_req_t     req;    // kmem request
    8281
    8382        // allocates memory for thread descriptor + kernel stack
    84         req.type  = KMEM_PAGE;
    85         req.size = CONFIG_THREAD_DESC_ORDER;
     83        req.type  = KMEM_PPM;
     84        req.order = CONFIG_THREAD_DESC_ORDER;
    8685        req.flags = AF_KERNEL | AF_ZERO;
    87         page      = kmem_alloc( &req );
    88 
    89         if( page == NULL ) return NULL;
    90 
    91     // return pointer on new thread descriptor
    92     xptr_t base_xp = ppm_page2base( XPTR(local_cxy , page ) );
    93     return GET_PTR( base_xp );
     86
     87    return kmem_alloc( &req );
    9488
    9589}  // end thread_alloc()
     
    125119{
    126120
    127 // check type and trdid fields initialized
     121// check type and trdid fields are initialized
    128122assert( (thread->type == type)   , "bad type argument" );
    129123assert( (thread->trdid == trdid) , "bad trdid argument" );
     
    133127thread_t * this  = CURRENT_THREAD;
    134128if( DEBUG_THREAD_INIT < cycle )
    135 printk("\n[%s] thread[%x,%x] enter for thread %x in process %x / cycle %d\n",
    136 __FUNCTION__, this->process->pid, this->trdid, thread->trdid, process->pid , cycle );
     129printk("\n[%s] thread[%x,%x] enter for thread[%x,%x] / cycle %d\n",
     130__FUNCTION__, this->process->pid, this->trdid, process->pid, thread->trdid, cycle );
    137131#endif
    138132
     
    192186cycle = (uint32_t)hal_get_cycles();
    193187if( DEBUG_THREAD_INIT < cycle )
    194 printk("\n[%s] thread[%x,%x] exit for thread %x in process %x / cycle %d\n",
    195 __FUNCTION__, this->process->pid, this->trdid, thread, process->pid, cycle );
     188printk("\n[%s] thread[%x,%x] exit for thread[%x,%x] / cycle %d\n",
     189__FUNCTION__, this->process->pid, this->trdid, process->pid, thread->trdid, cycle );
    196190#endif
    197191
     
    580574    vpn_t  parent_vpn_size = hal_remote_l32( XPTR( parent_cxy, &parent_us_vseg->vpn_size ) );
    581575    vpn_t  child_vpn_base  = child_us_vseg->vpn_base;
     576
    582577    for( parent_vpn = parent_vpn_base , child_vpn = child_vpn_base ;
    583578         parent_vpn < (parent_vpn_base + parent_vpn_size) ;
     
    625620#if (DEBUG_THREAD_USER_FORK & 1)
    626621if( DEBUG_THREAD_USER_FORK < cycle )
    627 printk("\n[%s] thread[%x,%x] copied all stack vseg PTEs to child GPT\n",
     622printk("\n[%s] thread[%x,%x] copied STACK vseg PTEs & set COW in child GPT\n",
    628623__FUNCTION__, this->process->pid, this->trdid );
    629624#endif
     
    636631#if (DEBUG_THREAD_USER_FORK & 1)
    637632if( DEBUG_THREAD_USER_FORK < cycle )
    638 printk("\n[%s] thread[%x,%x] set the COW flag for stack vseg in parent GPT\n",
     633printk("\n[%s] thread[%x,%x] set COW for STACK vseg in parent GPT\n",
    639634__FUNCTION__, this->process->pid, this->trdid );
    640635#endif
     
    906901    thread_assert_can_yield( thread , __FUNCTION__ );
    907902
    908     // update target process instrumentation counter
    909         // process->vmm.pgfault_nr += thread->info.pgfault_nr;
     903#if CONFIG_INSTRUMENTATION_PGFAULTS
     904        process->vmm.false_pgfault_nr    += thread->info.false_pgfault_nr;
     905        process->vmm.local_pgfault_nr    += thread->info.local_pgfault_nr;
     906        process->vmm.global_pgfault_nr   += thread->info.global_pgfault_nr;
     907        process->vmm.false_pgfault_cost  += thread->info.false_pgfault_cost;
     908        process->vmm.local_pgfault_cost  += thread->info.local_pgfault_cost;
     909        process->vmm.global_pgfault_cost += thread->info.global_pgfault_cost;
     910#endif
    910911
    911912    // remove thread from process th_tbl[]
    912913    count = process_remove_thread( thread );
    913914
    914     // release memory allocated for CPU context and FPU context if required
     915    // release memory allocated for CPU context and FPU context
    915916        hal_cpu_context_destroy( thread );
    916917        hal_fpu_context_destroy( thread );
     
    933934    // release memory for thread descriptor (including kernel stack)
    934935    kmem_req_t   req;
    935     xptr_t       base_xp = ppm_base2page( XPTR(local_cxy , thread ) );
    936 
    937     req.type  = KMEM_PAGE;
    938     req.ptr   = GET_PTR( base_xp );
     936    req.type  = KMEM_PPM;
     937    req.ptr   = thread;
    939938    kmem_free( &req );
    940939
Note: See TracChangeset for help on using the changeset viewer.