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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/libk/xhtab.c

    r614 r635  
    22 * xhtab.c - Remote access embedded hash table implementation.
    33 *
    4  * Author     Alain Greiner          (2016,2017)
     4 * Author     Alain Greiner   (2016,2017,2018,2019)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    134134        uint32_t i;
    135135
    136     // initialize readlock
     136    // initialize lock
    137137    remote_busylock_init( XPTR( local_cxy , &xhtab->lock), LOCK_XHTAB_STATE );
    138138
     
    153153    }
    154154
    155         for( i=0 ; i < XHASHTAB_SIZE ; i++ )
    156     {
    157                 xlist_root_init( XPTR( local_cxy , &xhtab->roots[i] ) );
    158     } 
    159 
    160 #if DEBUG_XHTAB
    161 printk("\n@@@ %s for xhtab (%x,%x)\n"
     155#if DEBUG_XHTAB
     156printk("\n[%s] for xhtab (%x,%x)\n"
    162157" - index_from_key  = %x (@ %x)\n"
    163158" - item_match_key  = %x (@ %x)\n"
     
    169164#endif
    170165
     166        for( i=0 ; i < XHASHTAB_SIZE ; i++ )
     167    {
     168                xlist_root_init( XPTR( local_cxy , &xhtab->roots[i] ) );
     169
     170#if (DEBUG_XHTAB & 1)
     171printk("\n - initialize root[%d] / %x\n", i , &xhtab->roots[i] );
     172#endif
     173
     174    } 
     175
    171176}  // end xhtab_init()
    172177
    173 //////////////////////////////////////
    174 xptr_t xhtab_scan( xptr_t    xhtab_xp,
    175                    uint32_t  index,
    176                    void    * key )
     178/////////////////////////////////////////////////////////////////////////////////////////////
     179// This static function traverse the subset identified by the <index> argument
     180// to find an item identified by the <key> argument.
     181/////////////////////////////////////////////////////////////////////////////////////////////
     182// @ xhtab_xp  : extended pointer on the xhtab descriptor.
     183// @ index     : subset index.
     184// @ key       : searched key value.
     185// @ return  extended pointer on the found item if success / return XPTR_NULL if not found.
     186/////////////////////////////////////////////////////////////////////////////////////////////
     187static xptr_t xhtab_scan( xptr_t    xhtab_xp,
     188                          uint32_t  index,
     189                          void    * key )
    177190{
    178191    xptr_t              xlist_xp;           // xlist_entry_t (iterator)
     
    220233    index_from_key_t * index_from_key;     // function pointer
    221234   
    222 #if DEBUG_XHTAB
    223 printk("\n[%s] enter / key %s\n", __FUNCTION__, key );
    224 #endif
    225 
    226     // get xhtab cluster and local pointer
    227     xhtab_cxy = GET_CXY( xhtab_xp );
    228     xhtab_ptr = GET_PTR( xhtab_xp );
     235    // get xhtab cluster and local pointer
     236    xhtab_cxy = GET_CXY( xhtab_xp );
     237    xhtab_ptr = GET_PTR( xhtab_xp );
     238
     239#if DEBUG_XHTAB
     240printk("\n[%s] enter / xhtab (%x,%x) / key = <%s> / cycle %d\n",
     241__FUNCTION__, xhtab_cxy, xhtab_ptr, key, (uint32_t)hal_get_cycles() );
     242#endif
     243
     244    // build extended pointer on xhtab lock
     245    xptr_t lock_xp = XPTR( xhtab_cxy , &xhtab_ptr->lock );
    229246
    230247    // get pointer on "index_from_key" function
    231248    index_from_key = (index_from_key_t *)hal_remote_lpt( XPTR( xhtab_cxy ,
    232249                                                         &xhtab_ptr->index_from_key ) );
     250#if DEBUG_XHTAB
     251printk("\n[%s] remote = %x / direct = %x / @ = %x\n",
     252__FUNCTION__, index_from_key, xhtab_ptr->index_from_key, &xhtab_ptr->index_from_key );
     253#endif
     254
    233255    // compute index from key
    234256        index = index_from_key( key );
    235257
     258#if DEBUG_XHTAB
     259printk("\n[%s] index = %x\n", __FUNCTION__, index );
     260#endif
     261
    236262    // take the lock protecting hash table
    237     remote_busylock_acquire( XPTR( xhtab_cxy , &xhtab_ptr->lock ) );
    238 
    239     // search a matching item
     263    remote_busylock_acquire( lock_xp );
     264
     265    // search a matching item in subset
    240266    item_xp = xhtab_scan( xhtab_xp , index , key );
    241267
    242     if( item_xp != XPTR_NULL )    // error if found
     268    if( item_xp != XPTR_NULL )    // error if item already registered
    243269    {
    244270        // release the lock protecting hash table
    245         remote_busylock_release( XPTR( xhtab_cxy , &xhtab_ptr->lock ) );
     271        remote_busylock_release( lock_xp );
    246272
    247273        return -1;
     
    256282
    257283        // release the lock protecting hash table
    258         remote_busylock_release( XPTR( xhtab_cxy , &xhtab_ptr->lock ) );
     284        remote_busylock_release( lock_xp );
    259285   
    260286#if DEBUG_XHTAB
    261 printk("\n[%s] success / %s\n", __FUNCTION__, key );
     287printk("\n[%s] success / <%s>\n", __FUNCTION__, key );
    262288#endif
    263289
Note: See TracChangeset for help on using the changeset viewer.