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/hal/tsar_mips32/core/hal_vmm.c

    r633 r635  
    4444extern process_t            process_zero;
    4545extern chdev_directory_t    chdev_dir;
     46extern char               * lock_type_str[];
    4647
    4748//////////////////////////////////////////////////////////////////////////////////////////
    4849// This function is called by the process_zero_init() function during kernel_init.
    4950// It initializes the VMM of the kernel proces_zero (containing all kernel threads)
    50 // in the local cluster: For TSAR, it registers one "kcode" vseg in kernel VSL,
    51 // and registers one big page in slot[0] of kernel GPT.
     51// in the local cluster.
     52// For TSAR, it registers one "kcode" vseg in kernel VSL, and registers one big page
     53// in slot[0] of kernel GPT.
    5254//////////////////////////////////////////////////////////////////////////////////////////
    5355error_t  hal_vmm_kernel_init( boot_info_t * info )
     
    5860    gpt_t * gpt = &process_zero.vmm.gpt;
    5961
    60     // get cluster identifier
    61     cxy_t cxy = local_cxy;
     62#if DEBUG_HAL_VMM
     63thread_t * this = CURRENT_THREAD;
     64printk("\n[%s] thread[%x,%x] enter in cluster %x\n",
     65__FUNCTION__, this->process->pid, this->trdid, local_cxy );
     66#endif
    6267
    6368    // allocate memory for kernel GPT
     
    6772    {
    6873        printk("\n[PANIC] in %s : cannot allocate kernel GPT in cluster %x\n",
    69         __FUNCTION__ , cxy );
     74        __FUNCTION__ , local_cxy );
    7075        hal_core_sleep();
    7176    }
    7277
    7378#if DEBUG_HAL_VMM
    74 thread_t * this = CURRENT_THREAD;
    75 printk("\n[%s] thread[%x,%x] enter in cluster %x / gpt %x\n",
     79printk("\n[%s] thread[%x,%x] created GPT PT1 in cluster %x / gpt %x\n",
    7680__FUNCTION__, this->process->pid, this->trdid, local_cxy, gpt );
    7781#endif
     
    7983    // compute attr and ppn for one PTE1
    8084    uint32_t attr = GPT_MAPPED | GPT_READABLE | GPT_CACHABLE | GPT_EXECUTABLE | GPT_GLOBAL;
    81     uint32_t ppn  = cxy << 20;   
     85    uint32_t ppn  = local_cxy << 20;   
    8286
    8387    // set PT1[0]
    84     hal_gpt_set_pte( XPTR( cxy , gpt ) , 0 , attr , ppn );
    85 
    86 #if DEBUG_HAL_VMM
    87 printk("\n[%s] thread[%x,%x] created PT1[0] : ppn %x / attr %x\n",
    88 __FUNCTION__, this->process->pid, this->trdid, ppn, attr );
     88    hal_gpt_set_pte( XPTR( local_cxy , gpt ) , 0 , attr , ppn );
     89
     90#if DEBUG_HAL_VMM
     91printk("\n[%s] thread[%x,%x] mapped PT1[0] in cluster %d : ppn %x / attr %x\n",
     92__FUNCTION__, this->process->pid, this->trdid, local_cxy, ppn, attr );
    8993#endif
    9094
     
    9498                                     info->kcode_base,
    9599                                     info->kcode_size,
    96                                      0, 0,                  // file ofset and file size (unused)
    97                                      XPTR_NULL,             // no mapper
     100                                     0, 0,               // file ofset and file size (unused)
     101                                     XPTR_NULL,          // no mapper
    98102                                     local_cxy );
    99103    if( vseg == NULL )
    100104    {
    101105        printk("\n[PANIC] in %s : cannot register vseg to VSL in cluster %x\n",
    102         __FUNCTION__ , cxy );
     106        __FUNCTION__ , local_cxy );
    103107        hal_core_sleep();
    104108    }
    105109
    106110#if DEBUG_HAL_VMM
    107 printk("\n[%s] thread[%x,%x] registered kcode vseg[%x,%x]\n",
    108 __FUNCTION__, this->process->pid, this->trdid, info->kcode_base, info->kcode_size );
     111printk("\n[%s] thread[%x,%x] registered kcode vseg[%x,%x] in cluster %x\n",
     112__FUNCTION__, this->process->pid, this->trdid, info->kcode_base, info->kcode_size, local_cxy );
    109113hal_vmm_display( &process_zero , true );
    110114#endif
     
    194198
    195199//////////////////////////////////////////
    196 void hal_vmm_display( process_t * process,
    197                       bool_t      mapping )
     200void hal_vmm_display( xptr_t   process_xp,
     201                      bool_t   mapping )
    198202{
    199     // get pointer on process VMM
    200     vmm_t * vmm = &process->vmm;
     203    // get target process cluster and local pointer
     204    process_t * process_ptr = GET_PTR( process_xp );
     205    cxy_t       process_cxy = GET_CXY( process_xp );
     206
     207    // get local pointer on target process VMM
     208    vmm_t * vmm = &process_ptr->vmm;
    201209
    202210    // get pointers on TXT0 chdev
     
    205213    chdev_t * txt0_ptr = GET_PTR( txt0_xp );
    206214
    207     // build extended pointer on TXT0 lock and VSL lock
     215    // build extended pointer on TXT0 lock
    208216    xptr_t  txt_lock_xp = XPTR( txt0_cxy  , &txt0_ptr->wait_lock );
    209     xptr_t  vsl_lock_xp = XPTR( local_cxy , &vmm->vsl_lock );
    210 
    211     // get root of vsegs list
    212     xptr_t root_xp = XPTR( local_cxy , &vmm->vsegs_root );
    213 
    214     // get the locks protecting TXT0, VSL, and GPT
     217
     218    // build extended pointers on VSL lock and VSL root
     219    xptr_t vsl_root_xp = XPTR( process_cxy , &vmm->vsegs_root );
     220    xptr_t vsl_lock_xp = XPTR( process_cxy , &vmm->vsl_lock );
     221
     222    // get the locks protecting TXT0 and VSL
    215223    remote_rwlock_rd_acquire( vsl_lock_xp );
    216224    remote_busylock_acquire( txt_lock_xp );
    217225
    218     nolock_printk("\n***** VSL and GPT for process %x in cluster %x / PT1 = %x\n",
    219     process->pid , local_cxy , vmm->gpt.ptr );
    220 
    221     if( xlist_is_empty( root_xp ) )
     226    // get PID and PT1 values
     227    pid_t      pid = hal_remote_l32( XPTR( process_cxy , &process_ptr->pid ) );
     228    uint32_t * pt1 = hal_remote_lpt( XPTR( process_cxy , &vmm->gpt.ptr ) );
     229
     230    nolock_printk("\n***** VSL and GPT / process %x / cluster %x / PT1 %x / cycle %d\n",
     231    pid , process_cxy , pt1 , (uint32_t)hal_get_cycles() );
     232
     233    if( xlist_is_empty( vsl_root_xp ) )
    222234    {
    223235        nolock_printk("   ... no vsegs registered\n");
     
    227239        xptr_t         iter_xp;
    228240        xptr_t         vseg_xp;
    229         vseg_t       * vseg;
    230 
    231         XLIST_FOREACH( root_xp , iter_xp )
     241        vseg_t       * vseg_ptr;
     242        cxy_t          vseg_cxy;
     243        intptr_t       min;
     244        intptr_t       max;
     245        uint32_t       type;
     246        intptr_t       vpn_base;
     247        intptr_t       vpn_size;
     248
     249        XLIST_FOREACH( vsl_root_xp , iter_xp )
    232250        {
    233             vseg_xp = XLIST_ELEMENT( iter_xp , vseg_t , xlist );
    234             vseg    = GET_PTR( vseg_xp );
     251            vseg_xp  = XLIST_ELEMENT( iter_xp , vseg_t , xlist );
     252            vseg_ptr = GET_PTR( vseg_xp );
     253            vseg_cxy = GET_CXY( vseg_xp );
     254
     255            type     =           hal_remote_l32( XPTR( vseg_cxy , &vseg_ptr->type ) );
     256            min      = (intptr_t)hal_remote_lpt( XPTR( vseg_cxy , &vseg_ptr->min ) );
     257            max      = (intptr_t)hal_remote_lpt( XPTR( vseg_cxy , &vseg_ptr->max ) );
     258            vpn_size = (intptr_t)hal_remote_lpt( XPTR( vseg_cxy , &vseg_ptr->vpn_size ) );
     259            vpn_base = (intptr_t)hal_remote_lpt( XPTR( vseg_cxy , &vseg_ptr->vpn_base ) );
    235260
    236261            nolock_printk(" - %s : base = %X / size = %X / npages = %d\n",
    237             vseg_type_str(vseg->type), vseg->min, vseg->max - vseg->min, vseg->vpn_size );
     262            vseg_type_str(type), min, max - min, vpn_size );
    238263
    239264            if( mapping ) 
    240265            {
    241                 vpn_t    vpn     = vseg->vpn_base;
    242                 vpn_t    vpn_max = vpn + vseg->vpn_size;
     266                vpn_t    vpn     = vpn_base;
     267                vpn_t    vpn_max = vpn_base + vpn_size;
    243268                ppn_t    ppn;
    244269                uint32_t attr;
     
    246271                while( vpn < vpn_max )   // scan the PTEs
    247272                {
    248                     hal_gpt_get_pte( XPTR( local_cxy , &vmm->gpt ) , vpn , &attr , &ppn );
     273                    hal_gpt_get_pte( XPTR( process_cxy , &vmm->gpt ) , vpn , &attr , &ppn );
    249274
    250275                    if( attr & GPT_MAPPED )
Note: See TracChangeset for help on using the changeset viewer.