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.

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.