Changeset 632 for trunk/kernel/kern


Ignore:
Timestamp:
May 28, 2019, 2:56:04 PM (5 years ago)
Author:
alain
Message:

This version replace the RPC by direct remote memory access
for physical pages allacation/release.
It is commited before being tested.

Location:
trunk/kernel/kern
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/kern/dqdt.c

    r583 r632  
    373373// It traverses the quad tree from clusters to root.
    374374///////////////////////////////////////////////////////////////////////////
    375 // @ node       : extended pointer on current node
     375// @ node_xp    : extended pointer on current node
    376376// @ increment  : number of pages variation
    377377///////////////////////////////////////////////////////////////////////////
    378 static void dqdt_propagate_pages( xptr_t  node,
     378static void dqdt_propagate_pages( xptr_t  node_xp,
    379379                                  int32_t increment )
    380380{
    381381    // get current node cluster identifier and local pointer
    382     cxy_t         cxy = GET_CXY( node );
    383     dqdt_node_t * ptr = GET_PTR( node );
     382    cxy_t         node_cxy = GET_CXY( node_xp );
     383    dqdt_node_t * node_ptr = GET_PTR( node_xp );
    384384
    385385    // update current node pages number
    386     hal_remote_atomic_add( XPTR( cxy , &ptr->pages ) , increment );
     386    hal_remote_atomic_add( XPTR( node_cxy , &node_ptr->pages ) , increment );
    387387
    388388    // get extended pointer on parent node
    389     xptr_t parent = (xptr_t)hal_remote_l64( XPTR( cxy , &ptr->parent ) );
     389    xptr_t parent_xp = (xptr_t)hal_remote_l64( XPTR( node_cxy , &node_ptr->parent ) );
    390390
    391391    // propagate if required
    392     if ( parent != XPTR_NULL ) dqdt_propagate_pages( parent, increment );
    393 }
    394 
    395 ///////////////////////////////////////////
    396 void dqdt_increment_pages( uint32_t order )
    397 {
    398         cluster_t   * cluster = LOCAL_CLUSTER;
    399     dqdt_node_t * node    = &cluster->dqdt_tbl[0];
    400 
    401     // update DQDT node level 0
    402     hal_atomic_add( &node->pages , (1 << order) );
    403 
    404     // propagate to DQDT upper levels
    405     if( node->parent != XPTR_NULL ) dqdt_propagate_pages( node->parent , (1 << order) );
     392    if ( parent_xp != XPTR_NULL ) dqdt_propagate_pages( parent_xp, increment );
     393}
     394
     395////////////////////////////////////////
     396void dqdt_increment_pages( cxy_t    cxy,
     397                           uint32_t order )
     398{
     399    // get local pointer on node[0] (same in all clusters)
     400    dqdt_node_t * node_ptr = &LOCAL_CLUSTER->dqdt_tbl[0];
     401
     402    // update DQDT node[0] in remote cluster cxy
     403    hal_remote_atomic_add( XPTR( cxy , &node_ptr->pages ) , (1 << order) );
     404
     405    // get extended pointer on parent node in remote cluster cxy
     406    xptr_t parent_xp = hal_remote_l64( XPTR( cxy , &node_ptr->parent ) );
     407
     408     // propagate to DQDT upper levels
     409    if( parent_xp != XPTR_NULL ) dqdt_propagate_pages( parent_xp , (1 << order) );
    406410
    407411#if DEBUG_DQDT_UPDATE_PAGES
     
    409413if( cycle > DEBUG_DQDT_UPDATE_PAGES )
    410414printk("\n[DBG] %s : thread %x in process %x / %x pages in cluster %x / cycle %d\n",
    411 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, node->pages, local_cxy, cycle );
    412 #endif
    413 
    414 }
    415 
    416 ///////////////////////////////////////////
    417 void dqdt_decrement_pages( uint32_t order )
    418 {
    419         cluster_t   * cluster = LOCAL_CLUSTER;
    420     dqdt_node_t * node    = &cluster->dqdt_tbl[0];
    421 
    422     // update DQDT node level 0
    423     hal_atomic_add( &node->pages , -(1 << order) );
    424 
    425     // propagate to DQDT upper levels
    426     if( node->parent != XPTR_NULL ) dqdt_propagate_pages( node->parent , -(1 << order) );
     415__FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid,
     416hal_remote_l32( XPTR( cxy , &node_ptr->pages ), cxy, cycle );
     417#endif
     418
     419}
     420
     421////////////////////////////////////////
     422void dqdt_decrement_pages( cxy_t    cxy,
     423                           uint32_t order )
     424{
     425    // get local pointer on node[0] (same in all clusters)
     426    dqdt_node_t * node_ptr = &LOCAL_CLUSTER->dqdt_tbl[0];
     427
     428    // update DQDT node[0] in remote cluster cxy
     429    hal_remote_atomic_add( XPTR( cxy , &node_ptr->pages ) , -(1 << order) );
     430
     431    // get extended pointer on parent node in remote cluster cxy
     432    xptr_t parent_xp = hal_remote_l64( XPTR( cxy , &node_ptr->parent ) );
     433
     434     // propagate to DQDT upper levels
     435    if( parent_xp != XPTR_NULL ) dqdt_propagate_pages( parent_xp , -(1 << order) );
    427436
    428437#if DEBUG_DQDT_UPDATE_PAGES
     
    430439if( cycle > DEBUG_DQDT_UPDATE_PAGES )
    431440printk("\n[DBG] %s : thread %x in process %x / %x pages in cluster %x / cycle %d\n",
    432 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, node->pages, local_cxy, cycle );
     441__FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid,
     442hal_remote_l32( XPTR( cxy , &node_ptr->pages ), cxy, cycle );
    433443#endif
    434444
     
    478488if( cycle > DEBUG_DQDT_UPDATE_THREADS )
    479489printk("\n[DBG] %s : thread %x in process %x / %d threads in cluster %x / cycle %d\n",
    480 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, node->threads, local_cxy, cycle );
     490__FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid,
     491node->threads, local_cxy, cycle );
    481492#endif
    482493
     
    499510if( cycle > DEBUG_DQDT_UPDATE_THREADS )
    500511printk("\n[DBG] %s : thread %x in process %x / %d threads in cluster %x / cycle %d\n",
    501 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, node->threads, local_cxy, cycle );
     512__FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid,
     513node->threads, local_cxy, cycle );
    502514#endif
    503515
  • trunk/kernel/kern/dqdt.h

    r583 r632  
    105105
    106106/****************************************************************************************
    107  * This local function updates the total number of pages in level 0 DQDT node,
    108  * and immediately propagates the variation to the DQDT upper levels.
     107 * These two functions can be called by any thread running in any cluster.
     108 * They increment/decrement the total number of 4 Kbytes pages allocated in a cluster
     109 * identified by the <cxy> argument, as specified by the <order> argument. The level 0
     110 * DQDT node is udated, and this change is immediately propagated to upper levels.
    109111 * They are called by PPM on each physical memory page allocation or release.
    110112 ****************************************************************************************
    111  * @ order   : ln2( number of small pages )
     113 * @ cxy     : target cluster identifier.
     114 * @ order   : ln2( number of 4 Kbytes pages )
    112115 ***************************************************************************************/
    113 void dqdt_increment_pages( uint32_t order );
    114 void dqdt_decrement_pages( uint32_t order );
     116void dqdt_increment_pages( cxy_t    cxy ,
     117                           uint32_t order );
     118
     119void dqdt_decrement_pages( cxy_t    cxy,
     120                           uint32_t order );
    115121
    116122/****************************************************************************************
  • trunk/kernel/kern/kernel_init.c

    r630 r632  
    133133
    134134    "CLUSTER_KCM",           //  1
    135     "PPM_FREE",              //  2
    136     "SCHED_STATE",           //  3
    137     "VMM_STACK",             //  4
    138     "VMM_MMAP",              //  5
    139     "VFS_CTX",               //  6
    140     "KCM_STATE",             //  7
    141     "KHM_STATE",             //  8
    142     "HTAB_STATE",            //  9
    143 
     135    "SCHED_STATE",           //  2
     136    "VMM_STACK",             //  3
     137    "VMM_MMAP",              //  4
     138    "VFS_CTX",               //  5
     139    "KCM_STATE",             //  6
     140    "KHM_STATE",             //  7
     141    "HTAB_STATE",            //  8
     142
     143    "PPM_FREE",              //  9
    144144    "THREAD_JOIN",           // 10
    145145    "XHTAB_STATE",           // 11
  • trunk/kernel/kern/rpc.c

    r629 r632  
    5151rpc_server_t * rpc_server[RPC_MAX_INDEX] =
    5252{
    53     &rpc_pmem_get_pages_server,            // 0
    54     &rpc_pmem_release_pages_server,        // 1
    55     &rpc_ppm_display_server,               // 2
     53    &rpc_undefined,                        // 0
     54    &rpc_undefined,                        // 1
     55    &rpc_undefined,                        // 2
    5656    &rpc_process_make_fork_server,         // 3
    5757    &rpc_user_dir_create_server,           // 4
     
    8787char * rpc_str[RPC_MAX_INDEX] =
    8888{
    89     "PMEM_GET_PAGES",            // 0
    90     "PMEM_RELEASE_PAGES",        // 1
    91     "PPM_DISPLAY",               // 2
     89    "undefined_0",               // 0
     90    "undefined_1",               // 1
     91    "undefined_2",               // 2
    9292    "PROCESS_MAKE_FORK",         // 3
    9393    "USER_DIR_CREATE",           // 4
     
    423423
    424424/////////////////////////////////////////////////////////////////////////////////////////
    425 // [0]           Marshaling functions attached to RPC_PMEM_GET_PAGES (blocking)
    426 /////////////////////////////////////////////////////////////////////////////////////////
    427 
     425// [0]       RPC_PMEM_GET_PAGES deprecated [AG] May 2019
     426/////////////////////////////////////////////////////////////////////////////////////////
     427
     428/*
    428429///////////////////////////////////////////////
    429430void rpc_pmem_get_pages_client( cxy_t      cxy,
     
    495496#endif
    496497}
    497 
    498 /////////////////////////////////////////////////////////////////////////////////////////
    499 // [1]       Marshaling functions attached to RPC_PMEM_RELEASE_PAGES
    500 /////////////////////////////////////////////////////////////////////////////////////////
    501 
     498*/
     499
     500/////////////////////////////////////////////////////////////////////////////////////////
     501// [1]       RPC_PMEM_RELEASE_PAGES deprecated [AG] may 2019
     502/////////////////////////////////////////////////////////////////////////////////////////
     503
     504/*
    502505//////////////////////////////////////////////////
    503506void rpc_pmem_release_pages_client( cxy_t     cxy,
     
    565568#endif
    566569}
    567 
    568 /////////////////////////////////////////////////////////////////////////////////////////
    569 // [2]            Marshaling functions attached to RPC_PPM_DISPLAY   
    570 /////////////////////////////////////////////////////////////////////////////////////////
    571 
     570*/
     571
     572/////////////////////////////////////////////////////////////////////////////////////////
     573// [2]          RPC_PPM_DISPLAY deprecated [AG] May 2019   
     574/////////////////////////////////////////////////////////////////////////////////////////
     575
     576/*
    572577/////////////////////////////////////////
    573578void rpc_ppm_display_client( cxy_t  cxy )
     
    621626#endif
    622627}
     628*/
    623629
    624630/////////////////////////////////////////////////////////////////////////////////////////
  • trunk/kernel/kern/rpc.h

    r628 r632  
    6060typedef enum
    6161{
    62     RPC_PMEM_GET_PAGES            = 0,
    63     RPC_PMEM_RELEASE_PAGES        = 1,
    64     RPC_PPM_DISPLAY               = 2,      
     62    RPC_UNDEFINED_0               = 0,   // RPC_PMEM_GET_PAGES     deprecated [AG]
     63    RPC_UNDEFINED_1               = 1,   // RPC_PMEM_RELEASE_PAGES deprecated [AG]
     64    RPC_UNDEFINED_2               = 2,   // RPC_PMEM_DISPLAY       deprecated [AG]     
    6565    RPC_PROCESS_MAKE_FORK         = 3,
    6666    RPC_USER_DIR_CREATE           = 4,
     
    177177 * [0] The RPC_PMEM_GET_PAGES allocates one or several pages in a remote cluster,
    178178 * and returns the local pointer on the page descriptor.
     179 *         deprecated [AG] may 2019
    179180 ***********************************************************************************
    180181 * @ cxy     : server cluster identifier
     
    182183 * @ page    : [out] local pointer on page descriptor / NULL if failure
    183184 **********************************************************************************/
     185
     186/*
    184187void rpc_pmem_get_pages_client( cxy_t             cxy,
    185188                                uint32_t          order,
     
    187190
    188191void rpc_pmem_get_pages_server( xptr_t xp );
     192*/
    189193
    190194/***********************************************************************************
    191195 * [1] The RPC_PMEM_RELEASE_PAGES release one or several pages to a remote cluster.
     196 *         deprecated [AG] may 2019
    192197 ***********************************************************************************
    193198 * @ cxy     : server cluster identifier
    194199 * @ page    : [in] local pointer on page descriptor to release.
    195200 **********************************************************************************/
     201
     202/*
    196203void rpc_pmem_release_pages_client( cxy_t            cxy,
    197204                                    struct page_s  * page );
    198205
    199206void rpc_pmem_release_pages_server( xptr_t xp );
     207*/
    200208
    201209/***********************************************************************************
    202210 * [2] The RPC_PPM_DISPLAY allows any client thread to require any remote cluster
    203211 * identified by the <cxy> argumentto display the physical memory allocator state.
    204  **********************************************************************************/
     212 *         deprecated [AG] may 2019
     213 **********************************************************************************/
     214
     215/*
    205216void rpc_ppm_display_client( cxy_t  cxy );
    206217
    207218void rpc_ppm_display_server( xptr_t xp );
     219*/
    208220
    209221/***********************************************************************************
Note: See TracChangeset for help on using the changeset viewer.