Changeset 626 for trunk/kernel/mm


Ignore:
Timestamp:
Apr 29, 2019, 7:25:09 PM (6 years ago)
Author:
alain
Message:

This version has been tested on the sort multithreaded application
for TSAR_IOB architectures ranging from 1 to 8 clusters.
It fixes three bigs bugs:
1) the dev_ioc device API has been modified: the dev_ioc_sync_read()
and dev_ioc_sync_write() function use now extended pointers on the
kernel buffer to access a mapper stored in any cluster.
2) the hal_uspace API has been modified: the hal_copy_to_uspace()
and hal_copy_from_uspace() functions use now a (cxy,ptr) couple
to identify the target buffer (equivalent to an extended pointer.
3) an implementation bug has been fixed in the assembly code contained
in the hal_copy_to_uspace() and hal_copy_from_uspace() functions.

Location:
trunk/kernel/mm
Files:
2 edited

Legend:

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

    r625 r626  
    280280    printk("\n[%s] thread[%x,%x] enter for page %d in <%s> / cycle %d",
    281281    __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 );
     282    if( DEBUG_MAPPER_HANDLE_MISS & 1 ) grdxt_display( XPTR(local_cxy,&mapper->rt), name );
    283283}
    284284if( (DEBUG_MAPPER_HANDLE_MISS < cycle) && (inode == NULL) )
     
    286286    printk("\n[%s] thread[%x,%x] enter for page %d in FAT / cycle %d",
    287287    __FUNCTION__, this->process->pid, this->trdid, page_id, cycle );
    288    if( DEBUG_MAPPER_HANDLE_MISS & 1 ) grdxt_display( XPTR(local_cxy,&mapper->rt), "FAT" );
     288    if( DEBUG_MAPPER_HANDLE_MISS & 1 ) grdxt_display( XPTR(local_cxy,&mapper->rt), "FAT" );
    289289}
    290290#endif
     
    324324    }
    325325
    326     // launch I/O operation to load page from device to mapper
     326    // launch I/O operation to load page from IOC device to mapper
    327327    error = vfs_fs_move_page( XPTR( local_cxy , page ) , IOC_SYNC_READ );
    328328
     
    401401
    402402#if DEBUG_MAPPER_MOVE_USER
    403 uint32_t   cycle = (uint32_t)hal_get_cycles();
    404 thread_t * this  = CURRENT_THREAD;
     403uint32_t      cycle      = (uint32_t)hal_get_cycles();
     404thread_t    * this       = CURRENT_THREAD;
     405cxy_t         mapper_cxy = GET_CXY( mapper_xp );
     406mapper_t    * mapper_ptr = GET_PTR( mapper_xp );
     407vfs_inode_t * inode_ptr  = hal_remote_lpt( XPTR( mapper_cxy , &mapper_ptr->inode ) );
     408xptr_t        inode_xp   = XPTR( mapper_cxy , inode_ptr );
     409char          name[CONFIG_VFS_MAX_NAME_LENGTH];
     410vfs_inode_get_name( inode_xp , name );
    405411if( DEBUG_MAPPER_MOVE_USER < cycle )
    406 printk("\n[%s] thread[%x,%x] : to_buf %d / buffer %x / size %d / offset %d / cycle %d\n",
    407 __FUNCTION__, this->process->pid, this->trdid,
    408 to_buffer, buffer, size, file_offset, cycle );
     412{
     413    if( to_buffer )
     414    printk("\n[%s] thread[%x,%x] : mapper(%s) -> buffer(%x) / bytes %d / cycle %d\n",
     415    __FUNCTION__, this->process->pid, this->trdid, name, buffer, size, cycle );
     416    else
     417    printk("\n[%s] thread[%x,%x] : buffer(%x) -> mapper(%s) / bytes %d / cycle %d\n",
     418    __FUNCTION__, this->process->pid, this->trdid, buffer, name, size, cycle );
     419}
    409420#endif
    410421
     
    419430#if (DEBUG_MAPPER_MOVE_USER & 1)
    420431if( DEBUG_MAPPER_MOVE_USER < cycle )
    421 printk("\n[%s] thread[%x,%x] : first_page %d / last_page %d\n",
    422 __FUNCTION__, this->process->pid, this->trdid, first, last );
     432printk("\n[%s] thread[%x,%x] : mapper(%x,%x) / first_page %d / last_page %d\n",
     433__FUNCTION__, this->process->pid, this->trdid, mapper_cxy, mapper_ptr, first, last );
    423434#endif
    424435
     
    440451#if (DEBUG_MAPPER_MOVE_USER & 1)
    441452if( DEBUG_MAPPER_MOVE_USER < cycle )
    442 printk("\n[%s] thread[%x,%x] : page_id = %d / page_offset = %d / page_count = %d\n",
     453printk("\n[%s] thread[%x,%x] : page_id %d / page_offset %d / bytes %d\n",
    443454__FUNCTION__, this->process->pid, this->trdid, page_id , page_offset , page_count );
    444455#endif
     
    449460        if ( page_xp == XPTR_NULL ) return -1;
    450461
     462        // compute cluster and pointers on page in mapper
     463        xptr_t     map_xp  = ppm_page2base( page_xp );
     464        uint8_t  * map_ptr = GET_PTR( map_xp );
     465        cxy_t      map_cxy = GET_CXY( map_xp );
     466
    451467#if (DEBUG_MAPPER_MOVE_USER & 1)
    452468if( DEBUG_MAPPER_MOVE_USER < cycle )
    453 printk("\n[%s] thread[%x,%x] : get page (%x,%x) from mapper\n",
    454 __FUNCTION__, this->process->pid, this->trdid, GET_CXY(page_xp), GET_PTR(page_xp) );
    455 #endif
    456 
    457         // compute pointer in mapper
    458         xptr_t    base_xp = ppm_page2base( page_xp );
    459         uint8_t * map_ptr = (uint8_t *)GET_PTR( base_xp ) + page_offset;
    460 
    461         // compute pointer in buffer
     469printk("\n[%s] thread[%x,%x] : get buffer(%x,%x) in mapper\n",
     470__FUNCTION__, this->process->pid, this->trdid, map_cxy, map_ptr );
     471#endif
     472        // compute pointer in user buffer
    462473        uint8_t * buf_ptr = (uint8_t *)buffer + done;
    463474
     
    465476        if( to_buffer )
    466477        {
    467             hal_copy_to_uspace( buf_ptr , map_ptr , page_count );
     478            hal_copy_to_uspace( map_cxy , map_ptr , buf_ptr , page_count );
     479
     480#if DEBUG_MAPPER_MOVE_USER & 1
     481if( DEBUG_MAPPER_MOVE_USER < cycle )
     482printk("\n[%s] thread[%x,%x] moved %d bytes / mapper %s (%x,%x) -> user buffer(%x,%x)\n",
     483__FUNCTION__, this->process->pid, this->trdid, page_count,
     484name, map_cxy, map_ptr, local_cxy, buf_ptr );
     485#endif
     486
    468487        }
    469488        else
    470489        {
    471490            ppm_page_do_dirty( page_xp );
    472             hal_copy_from_uspace( map_ptr , buf_ptr , page_count );
     491            hal_copy_from_uspace( map_cxy , map_ptr , buf_ptr , page_count );
     492
     493#if DEBUG_MAPPER_MOVE_USER & 1
     494if( DEBUG_MAPPER_MOVE_USER < cycle )
     495printk("\n[%s] thread[%x,%x] moved %d bytes / user buffer(%x,%x) -> mapper %s (%x,%x)\n",
     496__FUNCTION__, this->process->pid, this->trdid, page_count,
     497local_cxy, buf_ptr, name, map_cxy, map_ptr );
     498mapper_display_page(  mapper_xp , page_id, 128 );
     499#endif
     500
    473501        }
    474502
     
    477505
    478506#if DEBUG_MAPPER_MOVE_USER
    479 cycle = (uint32_t)hal_get_cycles();
     507cycle      = (uint32_t)hal_get_cycles();
    480508if( DEBUG_MAPPER_MOVE_USER < cycle )
    481 printk("\n[%s] thread[%x,%x] exit / cycle %d\n",
    482 __FUNCTION__, this->process->pid, this->trdid, cycle );
     509{
     510    if( to_buffer )
     511    printk("\n[%s] thread[%x,%x] completed mapper(%s) -> buffer(%x) / cycle %d\n",
     512    __FUNCTION__, this->process->pid, this->trdid, name, buffer, cycle );
     513    else
     514    printk("\n[%s] thread[%x,%x] completed buffer(%x) -> mapper(%s) / cycle %d\n",
     515    __FUNCTION__, this->process->pid, this->trdid, buffer, name, cycle );
     516}
    483517#endif
    484518
     
    717751#if DEBUG_MAPPER_SYNC
    718752if( cycle > DEBUG_MAPPER_SYNC )
    719 printk("\n[%s] thread[%x,%x] synchonise page %d of <%s> to device\n",
     753printk("\n[%s] thread[%x,%x] synchonise page %d of <%s> to IOC device\n",
    720754__FUNCTION__, this->process->pid, this->trdid, page->index, name );
    721755#endif
     
    804838    // display 8 words per line
    805839    tabi = (uint32_t *)buffer;
    806     printk("\n***** <%s> first %d bytes of page %d *****\n", name, nbytes, page_id );
     840    printk("\n***** mapper <%s> / %d bytes in page %d (%x,%x)\n",
     841    name, nbytes, page_id, GET_CXY(base_xp), GET_PTR(base_xp) );
    807842    for( line = 0 ; line < (nbytes >> 5) ; line++ )
    808843    {
  • trunk/kernel/mm/mapper.h

    r625 r626  
    6262 *   and the  allocated memory is only released when the mapper/inode is destroyed.
    6363 *
    64  * TODO : the mapper being only used to implement the VFS cache(s), the mapper.c
    65  *        and mapper.h file should be trandfered to the fs directory.
     64 * TODO (1) the mapper being only used to implement the VFS cache(s), the mapper.c
     65 *          and mapper.h file should be trandfered to the fs directory.
     66 * TODO (2) the "type" field is probably unused...
    6667 ******************************************************************************************/
    6768
     
    230231
    231232/*******************************************************************************************
    232  * This scans all pages present in the mapper identified by the <mapper> argument,
     233 * This function scan all pages present in the mapper identified by the <mapper> argument,
    233234 * and synchronize all pages maked as dirty" on disk.
    234235 * These pages are unmarked and removed from the local PPM dirty_list.
Note: See TracChangeset for help on using the changeset viewer.