Ignore:
Timestamp:
Apr 10, 2019, 10:09:39 AM (5 years ago)
Author:
alain
Message:

Fix a bug in the vmm_remove_vseg() function: the physical pages
associated to an user DATA vseg were released to the kernel when
the target process descriptor was in the reference cluster.
This physical pages release should be done only when the page
forks counter value is zero.
All other modifications are cosmetic.

File:
1 edited

Legend:

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

    r624 r625  
    153153
    154154#if DEBUG_MAPPER_GET_PAGE
    155 uint32_t cycle = (uint32_t)hal_get_cycles();
     155vfs_inode_t * inode = hal_remote_lpt( XPTR( mapper_cxy , &mapper_ptr->inode ) );
     156uint32_t      cycle = (uint32_t)hal_get_cycles();
    156157char          name[CONFIG_VFS_MAX_NAME_LENGTH];
    157 vfs_inode_t * inode = hal_remote_lpt( XPTR( mapper_cxy , &mapper_ptr->inode ) );
    158 vfs_inode_get_name( XPTR( mapper_cxy , inode ) , name );
    159 if( DEBUG_MAPPER_GET_PAGE < cycle )
    160 printk("\n[%s] thread [%x,%x] enter for page %d of <%s> / cycle %d\n",
    161 __FUNCTION__, this->process->pid, this->trdid, page_id, name, cycle );
     158if( (DEBUG_MAPPER_GET_PAGE < cycle) && (inode == NULL) )  // FAT mapper
     159{
     160    printk("\n[%s] thread[%x,%x] enter for page %d of FAT mapper / cycle %d\n",
     161    __FUNCTION__, this->process->pid, this->trdid, page_id, cycle );
     162}
     163if( (DEBUG_MAPPER_GET_PAGE < cycle) && (inode != NULL) )  // file mapper
     164{
     165    vfs_inode_get_name( XPTR( mapper_cxy , inode ) , name );
     166    printk("\n[%s] thread[%x,%x] enter for page %d of <%s> mapper / cycle %d\n",
     167    __FUNCTION__, this->process->pid, this->trdid, page_id, name, cycle );
     168}
    162169#endif
    163170
     
    235242#if DEBUG_MAPPER_GET_PAGE
    236243cycle = (uint32_t)hal_get_cycles();
    237 if( DEBUG_MAPPER_GET_PAGE < cycle )
    238 printk("\n[%s] thread[%x,%x] exit for page %d of <%s> / ppn %x / cycle %d\n",
    239 __FUNCTION__, this->process->pid, this->trdid,
    240 page_id, name, ppm_page2ppn( page_xp ), cycle );
     244if( (DEBUG_MAPPER_GET_PAGE < cycle) && (inode != NULL) )
     245{
     246    printk("\n[%s] thread[%x,%x] exit for page %d of <%s> mapper / ppn %x / cycle %d\n",
     247    __FUNCTION__, this->process->pid, this->trdid, page_id,
     248    name, ppm_page2ppn(page_xp), cycle );
     249}
     250if( (DEBUG_MAPPER_GET_PAGE < cycle) && (inode == NULL) )
     251{
     252    printk("\n[%s] thread[%x,%x] exit for page %d of FAT mapper  / ppn %x / cycle %d\n",
     253    __FUNCTION__, this->process->pid, this->trdid, page_id,
     254    ppm_page2ppn(page_xp), cycle );
     255}
    241256#endif
    242257
     
    257272
    258273#if DEBUG_MAPPER_HANDLE_MISS
    259 uint32_t cycle = (uint32_t)hal_get_cycles();
     274uint32_t      cycle = (uint32_t)hal_get_cycles();
    260275char          name[CONFIG_VFS_MAX_NAME_LENGTH];
    261276vfs_inode_t * inode = mapper->inode;
    262 vfs_inode_get_name( XPTR( local_cxy , inode ) , name );
    263 if( DEBUG_MAPPER_HANDLE_MISS < cycle )
    264 printk("\n[%s] enter for page %d in <%s> / cycle %d",
    265 __FUNCTION__, page_id, name, cycle );
    266 if( DEBUG_MAPPER_HANDLE_MISS & 1 )
    267 grdxt_display( XPTR( local_cxy , &mapper->rt ) , name );
     277if( (DEBUG_MAPPER_HANDLE_MISS < cycle) && (inode != NULL) )
     278{
     279    vfs_inode_get_name( XPTR( local_cxy , inode ) , name );
     280    printk("\n[%s] thread[%x,%x] enter for page %d in <%s> / cycle %d",
     281    __FUNCTION__, this->process->pid, this->trdid, page_id, name, cycle );
     282   if( DEBUG_MAPPER_HANDLE_MISS & 1 ) grdxt_display( XPTR(local_cxy,&mapper->rt), name );
     283}
     284if( (DEBUG_MAPPER_HANDLE_MISS < cycle) && (inode == NULL) )
     285{
     286    printk("\n[%s] thread[%x,%x] enter for page %d in FAT / cycle %d",
     287    __FUNCTION__, this->process->pid, this->trdid, page_id, cycle );
     288   if( DEBUG_MAPPER_HANDLE_MISS & 1 ) grdxt_display( XPTR(local_cxy,&mapper->rt), "FAT" );
     289}
    268290#endif
    269291
     
    321343#if DEBUG_MAPPER_HANDLE_MISS
    322344cycle = (uint32_t)hal_get_cycles();
    323 if( DEBUG_MAPPER_HANDLE_MISS < cycle )
    324 printk("\n[%s] exit for page %d in <%s> / ppn %x / cycle %d",
    325 __FUNCTION__, page_id, name, ppm_page2ppn( *page_xp ), cycle );
    326 if( DEBUG_MAPPER_HANDLE_MISS & 1 )
    327 grdxt_display( XPTR( local_cxy , &mapper->rt ) , name );
     345if( (DEBUG_MAPPER_HANDLE_MISS < cycle) && (inode != NULL) )
     346{
     347    printk("\n[%s] thread[%x,%x] exit for page %d in <%s> / ppn %x / cycle %d",
     348    __FUNCTION__, this->process->pid, this->trdid,
     349    page_id, name, ppm_page2ppn( *page_xp ), cycle );
     350    if( DEBUG_MAPPER_HANDLE_MISS & 1 ) grdxt_display( XPTR(local_cxy,&mapper->rt) , name );
     351}
     352if( (DEBUG_MAPPER_HANDLE_MISS < cycle) && (inode == NULL) )
     353{
     354    printk("\n[%s] thread[%x,%x] exit for page %d in FAT / ppn %x / cycle %d",
     355    __FUNCTION__, this->process->pid, this->trdid,
     356    page_id, ppm_page2ppn( *page_xp ), cycle );
     357    if( DEBUG_MAPPER_HANDLE_MISS & 1 ) grdxt_display( XPTR(local_cxy,&mapper->rt ), "FAT" );
     358}
    328359#endif
    329360
     
    482513
    483514#if DEBUG_MAPPER_MOVE_KERNEL
    484 uint32_t   cycle = (uint32_t)hal_get_cycles();
    485 thread_t * this  = CURRENT_THREAD;
     515char          name[CONFIG_VFS_MAX_NAME_LENGTH];
     516uint32_t      cycle  = (uint32_t)hal_get_cycles();
     517thread_t    * this   = CURRENT_THREAD;
     518mapper_t    * mapper = GET_PTR( mapper_xp );
     519vfs_inode_t * inode  = hal_remote_lpt( XPTR( mapper_cxy , &mapper->inode ) );
     520vfs_inode_get_name( XPTR( mapper_cxy , inode ) , name );
    486521if( DEBUG_MAPPER_MOVE_KERNEL < cycle )
    487 printk("\n[%s] thread[%x,%x] enter / to_buf %d / buf_cxy %x / buf_ptr %x / cycle %d\n",
    488 __FUNCTION__, this->process->pid, this->trdid, to_buffer, buffer_cxy, buffer_ptr, cycle );
     522printk("\n[%s] thread[%x,%x] enter / %d bytes / offset %d / mapper <%s> / cycle %d\n",
     523__FUNCTION__, this->process->pid, this->trdid, size, file_offset, name, cycle );
    489524#endif
    490525
     
    496531    uint32_t first = min_byte >> CONFIG_PPM_PAGE_SHIFT;
    497532    uint32_t last  = max_byte >> CONFIG_PPM_PAGE_SHIFT;
    498 
    499 #if (DEBUG_MAPPER_MOVE_KERNEL & 1)
    500 if( DEBUG_MAPPER_MOVE_KERNEL < cycle )
    501 printk("\n[%s] first_page %d / last_page %d\n", __FUNCTION__, first, last );
    502 #endif
    503533
    504534    // compute source and destination clusters
     
    528558        else if ( page_id == last  ) page_count = (max_byte & CONFIG_PPM_PAGE_MASK) + 1;
    529559        else                         page_count = CONFIG_PPM_PAGE_SIZE;
    530 
    531 #if (DEBUG_MAPPER_MOVE_KERNEL & 1)
    532 if( DEBUG_MAPPER_MOVE_KERNEL < cycle )
    533 printk("\n[%s] page_id = %d / offset = %d / bytes = %d\n",
    534 __FUNCTION__ , page_id , page_offset , page_count );
    535 #endif
    536560
    537561        // get extended pointer on page descriptor
     
    560584#if (DEBUG_MAPPER_MOVE_KERNEL & 1)
    561585if( DEBUG_MAPPER_MOVE_KERNEL < cycle )
    562 printk("\n[%s] src_cxy %x / src_ptr %x / dst_cxy %x / dst_ptr %x\n",
    563 __FUNCTION__, src_cxy, src_ptr, dst_cxy, dst_ptr );
     586{
     587    if( to_buffer )
     588    printk("\n[%s] mapper <%s> page %d => buffer(%x,%x) / %d bytes\n",
     589    __FUNCTION__, name, page_id, dst_cxy, dst_ptr, page_count );
     590    else
     591    printk("\n[%s] buffer(%x,%x) => mapper <%s> page %d / %d bytes\n",
     592    __FUNCTION__, src_cxy, src_ptr, name, page_id, page_count );
     593}
    564594#endif
    565595
     
    571601
    572602#if DEBUG_MAPPER_MOVE_KERNEL
    573 cycle = (uint32_t)hal_get_cycles();
     603cycle  = (uint32_t)hal_get_cycles();
    574604if( DEBUG_MAPPER_MOVE_KERNEL < cycle )
    575 printk("\n[%s] thread[%x,%x] exit / to_buf %d / buf_cxy %x / buf_ptr %x / cycle %d\n",
    576 __FUNCTION__, this->process->pid, this->trdid, to_buffer, buffer_cxy, buffer_ptr, cycle );
     605printk("\n[%s] thread[%x,%x] exit / cycle %d\n",
     606__FUNCTION__, this->process->pid, this->trdid, cycle );
    577607#endif
    578608
     
    662692
    663693    // get pointer on radix tree
    664     rt        = &mapper->rt;
     694    rt = &mapper->rt;
    665695
    666696    // initialise loop variable
     
    675705        if( page == NULL ) break;
    676706
    677 assert( (page->index == found_key ), __FUNCTION__, "wrong page descriptor index" );
    678 assert( (page->order == 0),          __FUNCTION__, "mapper page order must be 0" );
     707assert( (page->index == found_key ), "wrong page descriptor index" );
     708assert( (page->order == 0),          "mapper page order must be 0" );
    679709
    680710        // build extended pointer on page descriptor
     
    730760    char          buffer[4096];   // local buffer
    731761    uint32_t    * tabi;           // pointer on uint32_t to scan buffer
    732     char        * tabc;           // pointer on char to scan buffer
    733762    uint32_t      line;           // line index
    734763    uint32_t      word;           // word index
    735     uint32_t      n;              // char index
    736764    cxy_t         mapper_cxy;     // mapper cluster identifier
    737765    mapper_t    * mapper_ptr;     // mapper local pointer
     
    776804    // display 8 words per line
    777805    tabi = (uint32_t *)buffer;
    778     tabc = (char *)buffer;
    779806    printk("\n***** <%s> first %d bytes of page %d *****\n", name, nbytes, page_id );
    780807    for( line = 0 ; line < (nbytes >> 5) ; line++ )
    781808    {
    782         printk("%X : ", line );
     809        printk("%X : ", line << 5 );
    783810        for( word = 0 ; word < 8 ; word++ ) printk("%X ", tabi[(line<<3) + word] );
    784         printk(" | ");
    785         for( n = 0 ; n < 32 ; n++ ) printk("%c", tabc[(line<<5) + n] );
    786811        printk("\n");
    787812    }
Note: See TracChangeset for help on using the changeset viewer.