Changeset 635 for trunk/kernel/fs


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.

Location:
trunk/kernel/fs
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/fs/devfs.c

    r624 r635  
    5858    kmem_req_t    req;
    5959
    60         req.type    = KMEM_DEVFS_CTX;
    61         req.size    = sizeof(devfs_ctx_t);
     60        req.type    = KMEM_KCM;
     61        req.order   = bits_log2( sizeof(devfs_ctx_t) );
    6262    req.flags   = AF_KERNEL | AF_ZERO;
    6363
    64         return (devfs_ctx_t *)kmem_alloc( &req );
     64        return kmem_alloc( &req );
    6565}
    6666
     
    8181    kmem_req_t    req;
    8282
    83     req.type = KMEM_DEVFS_CTX;
     83    req.type = KMEM_KCM;
    8484    req.ptr  = devfs_ctx;
    8585    kmem_free( &req );
  • trunk/kernel/fs/fatfs.c

    r633 r635  
    10691069{
    10701070    kmem_req_t    req;
    1071         req.type    = KMEM_FATFS_CTX;
    1072         req.size    = sizeof(fatfs_ctx_t);
     1071        req.type    = KMEM_KCM;
     1072        req.order   = bits_log2( sizeof(fatfs_ctx_t) );
    10731073    req.flags   = AF_KERNEL | AF_ZERO;
    10741074
    1075         return (fatfs_ctx_t *)kmem_alloc( &req );
     1075        return kmem_alloc( &req );
    10761076}
    10771077
     
    11011101    // - temporarily the BOOT sector
    11021102    // - permanently the FS_INFO sector
    1103         req.type    = KMEM_512_BYTES;
     1103        req.type    = KMEM_KCM;
     1104    req.order   = 9;                    // 512 bytes
    11041105    req.flags   = AF_KERNEL | AF_ZERO;
    1105         buffer      = (uint8_t *)kmem_alloc( &req );
    1106     buffer_xp   = XPTR( local_cxy , buffer );
     1106        buffer      = kmem_alloc( &req );
    11071107
    11081108    if( buffer == NULL )
     
    11121112    }
    11131113     
     1114    buffer_xp   = XPTR( local_cxy , buffer );
     1115
    11141116    // load the BOOT record from device
    11151117    error = dev_ioc_sync_read( buffer_xp , 0 , 1 );
     
    12421244{
    12431245    kmem_req_t    req;
    1244     req.type = KMEM_FATFS_CTX;
     1246    req.type = KMEM_KCM;
    12451247    req.ptr  = fatfs_ctx;
    12461248    kmem_free( &req );
  • trunk/kernel/fs/vfs.c

    r634 r635  
    150150    mapper_t         * mapper;     // associated mapper( to be allocated)
    151151    vfs_inode_t      * inode;      // inode descriptor (to be allocated)
     152   
    152153    uint32_t           inum;       // inode identifier (to be allocated)
    153154    vfs_ctx_t        * ctx;        // file system context
     
    155156    error_t            error;
    156157
    157 #if DEBUG_VFS_INODE_CREATE
    158 char           name[CONFIG_VFS_MAX_NAME_LENGTH];
    159 uint32_t       cycle      = (uint32_t)hal_get_cycles();
    160 cxy_t          dentry_cxy = GET_CXY( dentry_xp );
    161 vfs_dentry_t * dentry_ptr = GET_PTR( dentry_xp );
    162 thread_t *     this       = CURRENT_THREAD;
    163 if( dentry_xp != XPTR_NULL ) hal_remote_strcpy( XPTR( local_cxy  , name ),
    164                                                 XPTR( dentry_cxy , dentry_ptr->name ) );
    165 else                         strcpy( name , "/" );
    166 if( DEBUG_VFS_INODE_CREATE < cycle )
    167 printk("\n[%s] thread[%x,%x] enter for <%s> / cycle %d\n",
    168 __FUNCTION__, this->process->pid, this->trdid, name, cycle );
    169 #endif
    170  
    171158    // check fs type and get pointer on context
    172159    if     ( fs_type == FS_TYPE_FATFS ) ctx = &fs_context[FS_TYPE_FATFS];
     
    198185    }
    199186
    200     // allocate memory for VFS inode descriptor
    201         req.type  = KMEM_VFS_INODE;
    202         req.size  = sizeof(vfs_inode_t);
     187// check inode descriptor contained in one page
     188assert( (sizeof(vfs_inode_t) <= CONFIG_PPM_PAGE_SIZE),
     189"inode descriptor must fit in one page" );
     190
     191    // allocate one page for VFS inode descriptor
     192    // because the embedded "children xhtab footprint
     193        req.type  = KMEM_PPM;
     194        req.order = 0;
    203195    req.flags = AF_KERNEL | AF_ZERO;
    204         inode     = (vfs_inode_t *)kmem_alloc( &req );
     196        inode     = kmem_alloc( &req );
    205197
    206198    if( inode == NULL )
     
    243235
    244236#if DEBUG_VFS_INODE_CREATE
    245 cycle      = (uint32_t)hal_get_cycles();
     237char           name[CONFIG_VFS_MAX_NAME_LENGTH];
     238uint32_t       cycle      = (uint32_t)hal_get_cycles();
     239thread_t *     this       = CURRENT_THREAD;
     240vfs_inode_get_name( *inode_xp , name );
    246241if( DEBUG_VFS_INODE_CREATE < cycle )
    247 printk("\n[%s] thread[%x,%x] exit for <%s> / inode [%x,%x] / cycle %d\n",
     242printk("\n[%s] thread[%x,%x] created <%s> / inode [%x,%x] / cycle %d\n",
    248243__FUNCTION__, this->process->pid, this->trdid, name, local_cxy, inode, cycle );
    249244#endif
     
    261256    // release memory allocate for inode descriptor
    262257        kmem_req_t req;
     258        req.type  = KMEM_PPM;
    263259        req.ptr   = inode;
    264         req.type  = KMEM_VFS_INODE;
    265260        kmem_free( &req );
    266261
     
    477472        kmem_req_t       req;        // request to kernel memory allocator
    478473
    479 #if DEBUG_VFS_DENTRY_CREATE
    480 thread_t * this = CURRENT_THREAD;
    481 uint32_t cycle = (uint32_t)hal_get_cycles();
    482 if( DEBUG_VFS_DENTRY_CREATE < cycle )
    483 printk("\n[%s] thread[%x,%x] enter for <%s> / cycle %d\n",
    484 __FUNCTION__, this->process->pid, this->trdid, name, cycle );
    485 #endif
    486 
    487474    // get pointer on context
    488475    if     ( fs_type == FS_TYPE_FATFS ) ctx = &fs_context[FS_TYPE_FATFS];
     
    501488
    502489    // allocate memory for dentry descriptor
    503         req.type  = KMEM_VFS_DENTRY;
    504         req.size  = sizeof(vfs_dentry_t);
     490        req.type  = KMEM_KCM;
     491        req.order = bits_log2( sizeof(vfs_dentry_t) );
    505492    req.flags = AF_KERNEL | AF_ZERO;
    506         dentry     = (vfs_dentry_t *)kmem_alloc( &req );
     493        dentry    = kmem_alloc( &req );
    507494
    508495    if( dentry == NULL )
     
    523510
    524511#if DEBUG_VFS_DENTRY_CREATE
    525 cycle = (uint32_t)hal_get_cycles();
     512thread_t * this  = CURRENT_THREAD;
     513uint32_t   cycle = (uint32_t)hal_get_cycles();
    526514if( DEBUG_VFS_DENTRY_CREATE < cycle )
    527 printk("\n[%s] thread[%x,%x] exit for <%s> / dentry [%x,%x] / cycle %d\n",
     515printk("\n[%s] thread[%x,%x] created <%s> / dentry [%x,%x] / cycle %d\n",
    528516__FUNCTION__, this->process->pid, this->trdid, name, local_cxy, dentry, cycle );
    529517#endif
     
    538526    // release memory allocated to dentry
    539527        kmem_req_t req;
     528        req.type  = KMEM_KCM;
    540529        req.ptr   = dentry;
    541         req.type  = KMEM_VFS_DENTRY;
    542530        kmem_free( &req );
    543531
     
    566554
    567555    // allocate memory for new file descriptor
    568         req.type  = KMEM_VFS_FILE;
    569         req.size  = sizeof(vfs_file_t);
     556        req.type  = KMEM_KCM;
     557        req.order = bits_log2( sizeof(vfs_file_t) );
    570558    req.flags = AF_KERNEL | AF_ZERO;
    571         file      = (vfs_file_t *)kmem_alloc( &req );
     559        file      = kmem_alloc( &req );
    572560
    573561    if( file == NULL ) return ENOMEM;
     
    602590{
    603591        kmem_req_t req;
     592        req.type  = KMEM_KCM;
    604593        req.ptr   = file;
    605         req.type  = KMEM_VFS_FILE;
    606594        kmem_free( &req );
    607595
     
    33473335#endif
    33483336
     3337
    33493338    // 3. register new_dentry in new_inode xlist of parents
    33503339    parents_root_xp  = XPTR( child_cxy , &new_inode_ptr->parents );
  • trunk/kernel/fs/vfs.h

    r633 r635  
    306306/******************************************************************************************
    307307 * This function allocates memory from local cluster for an inode descriptor and the
    308  * associated mapper. It initialise these descriptors from arguments values.
     308 * associated mapper, and partially initialise this inode from arguments values.
     309 * It does NOT link it to the Inode Tree, as this is done by add_child_in_parent().
    309310 * It must called by a local thread. Use the RPC_INODE_CREATE if client thread is remote.
    310311 ******************************************************************************************
Note: See TracChangeset for help on using the changeset viewer.