Changeset 683 for trunk/kernel/mm/ppm.c


Ignore:
Timestamp:
Jan 13, 2021, 12:36:17 AM (3 years ago)
Author:
alain
Message:

All modifications required to support the <tcp_chat> application
including error recovery in case of packet loss.A

File:
1 edited

Legend:

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

    r672 r683  
    6060
    6161   void   * base_ptr = ppm->vaddr_base +
    62                        ((page_ptr - ppm->pages_tbl)<<CONFIG_PPM_PAGE_SHIFT);
     62                       ((page_ptr - ppm->pages_tbl)<<CONFIG_PPM_PAGE_ORDER);
    6363
    6464        return XPTR( page_cxy , base_ptr );
     
    7575
    7676        page_t * page_ptr = ppm->pages_tbl +
    77                         ((base_ptr - ppm->vaddr_base)>>CONFIG_PPM_PAGE_SHIFT);
     77                        ((base_ptr - ppm->vaddr_base)>>CONFIG_PPM_PAGE_ORDER);
    7878
    7979        return XPTR( base_cxy , page_ptr );
     
    9191    page_t * page_ptr = GET_PTR( page_xp );
    9292
    93     paddr_t  paddr    = PADDR( page_cxy , (page_ptr - ppm->pages_tbl)<<CONFIG_PPM_PAGE_SHIFT );
    94 
    95     return (ppn_t)(paddr >> CONFIG_PPM_PAGE_SHIFT);
     93    paddr_t  paddr    = PADDR( page_cxy , (page_ptr - ppm->pages_tbl)<<CONFIG_PPM_PAGE_ORDER );
     94
     95    return (ppn_t)(paddr >> CONFIG_PPM_PAGE_ORDER);
    9696
    9797}  // end hal_page2ppn()
     
    102102        ppm_t   * ppm  = &LOCAL_CLUSTER->ppm;
    103103
    104     paddr_t  paddr = ((paddr_t)ppn) << CONFIG_PPM_PAGE_SHIFT;
     104    paddr_t  paddr = ((paddr_t)ppn) << CONFIG_PPM_PAGE_ORDER;
    105105
    106106    cxy_t    cxy   = CXY_FROM_PADDR( paddr );
    107107    lpa_t    lpa   = LPA_FROM_PADDR( paddr );
    108108
    109     return XPTR( cxy , &ppm->pages_tbl[lpa>>CONFIG_PPM_PAGE_SHIFT] );
     109    return XPTR( cxy , &ppm->pages_tbl[lpa>>CONFIG_PPM_PAGE_ORDER] );
    110110
    111111}  // end hal_ppn2page
     
    118118        ppm_t  * ppm   = &LOCAL_CLUSTER->ppm;
    119119   
    120     paddr_t  paddr = ((paddr_t)ppn) << CONFIG_PPM_PAGE_SHIFT;
     120    paddr_t  paddr = ((paddr_t)ppn) << CONFIG_PPM_PAGE_ORDER;
    121121
    122122    cxy_t    cxy   = CXY_FROM_PADDR( paddr );
     
    137137    paddr_t  paddr    = PADDR( base_cxy , (base_ptr - ppm->vaddr_base) );
    138138
    139     return (ppn_t)(paddr >> CONFIG_PPM_PAGE_SHIFT);
     139    return (ppn_t)(paddr >> CONFIG_PPM_PAGE_ORDER);
    140140
    141141}  // end ppm_base2ppn()
     
    159159
    160160assert( __FUNCTION__, !page_is_flag( page , PG_FREE ) ,
    161 "page already released : ppn = %x\n" , ppm_page2ppn( XPTR( local_cxy , page ) ) );
     161"page already released : ppn = %x" , ppm_page2ppn( XPTR( local_cxy , page ) ) );
    162162
    163163assert( __FUNCTION__, !page_is_flag( page , PG_RESERVED ) ,
    164 "reserved page : ppn = %x\n" , ppm_page2ppn( XPTR( local_cxy , page ) ) );
     164"reserved page : ppn = %x" , ppm_page2ppn( XPTR( local_cxy , page ) ) );
    165165
    166166        // set FREE flag in released page descriptor
     
    214214        page_t   * found_block; 
    215215
    216     thread_t * this = CURRENT_THREAD;
    217 
    218216        ppm_t    * ppm = &LOCAL_CLUSTER->ppm;
    219217
    220 #if DEBUG_PPM_ALLOC_PAGES
    221 uint32_t cycle = (uint32_t)hal_get_cycles();
     218#if DEBUG_PPM_ALLOC_PAGES || DEBUG_PPM_ERROR
     219thread_t * this  = CURRENT_THREAD;
     220uint32_t   cycle = (uint32_t)hal_get_cycles();
    222221#endif
    223222
     
    232231
    233232// check order
    234 assert( __FUNCTION__, (order < CONFIG_PPM_MAX_ORDER) , "illegal order argument = %d\n" , order );
     233assert( __FUNCTION__, (order < CONFIG_PPM_MAX_ORDER) ,
     234"illegal order argument = %d" , order );
    235235
    236236    //build extended pointer on lock protecting remote PPM
     
    273273        if( current_block == NULL ) // return failure if no free block found
    274274        {
    275                 // release lock protecting free lists
     275
     276#if DEBUG_PPM_ERROR
     277printk("\n[ERROR] in %s thread[%x,%x] cannot allocate %d page(s) in cluster %x / cycle %d\n",
     278__FUNCTION__, this->process->pid, this->trdid, 1<<order, local_cxy, cycle );
     279#endif
     280        // release lock protecting free lists
    276281                remote_busylock_release( lock_xp );
    277 
    278         printk("\n[%s] thread[%x,%x] cannot allocate %d page(s) in cluster %x\n",
    279         __FUNCTION__, this->process->pid, this->trdid, 1<<order, local_cxy );
    280 
    281282                return NULL;
    282283        }
     
    385386    page_t   * found_block;
    386387
    387     thread_t * this  = CURRENT_THREAD;
    388 
    389388// check order
    390 assert( __FUNCTION__, (order < CONFIG_PPM_MAX_ORDER) , "illegal order argument = %d\n" , order );
     389assert( __FUNCTION__, (order < CONFIG_PPM_MAX_ORDER) ,
     390"illegal order argument = %d" , order );
    391391
    392392    // get local pointer on PPM (same in all clusters)
    393393        ppm_t * ppm = &LOCAL_CLUSTER->ppm;
    394394
    395 #if DEBUG_PPM_REMOTE_ALLOC_PAGES
     395#if DEBUG_PPM_ALLOC_PAGES || DEBUG_PPM_ERROR
     396thread_t * this  = CURRENT_THREAD;
    396397uint32_t   cycle = (uint32_t)hal_get_cycles();
    397398#endif
    398399
    399 #if DEBUG_PPM_REMOTE_ALLOC_PAGES
    400 if( DEBUG_PPM_REMOTE_ALLOC_PAGES < cycle )
     400#if DEBUG_PPM_ALLOC_PAGES
     401if( DEBUG_PPM_ALLOC_PAGES < cycle )
    401402{
    402403    printk("\n[%s] thread[%x,%x] enter for %d page(s) in cluster %x / cycle %d\n",
    403404    __FUNCTION__, this->process->pid, this->trdid, 1<<order, cxy, cycle );
    404     if( DEBUG_PPM_REMOTE_ALLOC_PAGES & 1 ) ppm_remote_display( cxy );
     405    if( DEBUG_PPM_ALLOC_PAGES & 1 ) ppm_remote_display( cxy );
    405406}
    406407#endif
     
    445446        if( current_block == NULL ) // return failure
    446447        {
     448
     449#if DEBUG_PPM_ERROR
     450 printk("\n[ERROR] in %s : thread[%x,%x] cannot allocate %d page(s) in cluster %x / cycle %d\n",
     451__FUNCTION__, this->process->pid, this->trdid, 1<<order, cxy, cycle );
     452#endif
    447453                // release lock protecting free lists
    448454                remote_busylock_release( lock_xp );
    449 
    450         printk("\n[ERROR] in %s : thread[%x,%x] cannot allocate %d page(s) in cluster %x\n",
    451         __FUNCTION__, this->process->pid, this->trdid, 1<<order, cxy );
    452 
    453455                return XPTR_NULL;
    454456        }
     
    489491    hal_fence();
    490492
    491 #if DEBUG_PPM_REMOTE_ALLOC_PAGES
    492 if( DEBUG_PPM_REMOTE_ALLOC_PAGES < cycle )
     493#if DEBUG_PPM_ALLOC_PAGES
     494if( DEBUG_PPM_ALLOC_PAGES < cycle )
    493495{
    494496    printk("\n[%s] thread[%x,%x] allocated %d page(s) in cluster %x / ppn %x / cycle %d\n",
    495497    __FUNCTION__, this->process->pid, this->trdid,
    496498    1<<order, cxy, ppm_page2ppn(XPTR( cxy , found_block )), cycle );
    497     if( DEBUG_PPM_REMOTE_ALLOC_PAGES & 1 ) ppm_remote_display( cxy );
     499    if( DEBUG_PPM_ALLOC_PAGES & 1 ) ppm_remote_display( cxy );
    498500}
    499501#endif
     
    521523    uint32_t   order = hal_remote_l32( XPTR( page_cxy , &page_ptr->order ) );
    522524
    523 #if DEBUG_PPM_REMOTE_FREE_PAGES
     525#if DEBUG_PPM_FREE_PAGES
    524526thread_t * this  = CURRENT_THREAD;
    525527uint32_t   cycle = (uint32_t)hal_get_cycles();
     
    527529#endif
    528530
    529 #if DEBUG_PPM_REMOTE_FREE_PAGES
    530 if( DEBUG_PPM_REMOTE_FREE_PAGES < cycle )
     531#if DEBUG_PPM_FREE_PAGES
     532if( DEBUG_PPM_FREE_PAGES < cycle )
    531533{
    532534    printk("\n[%s] thread[%x,%x] enter for %d page(s) in cluster %x / ppn %x / cycle %d\n",
    533535    __FUNCTION__, this->process->pid, this->trdid, 1<<order, page_cxy, ppn, cycle );
    534     if( DEBUG_PPM_REMOTE_FREE_PAGES & 1 ) ppm_remote_display( page_cxy );
     536    if( DEBUG_PPM_FREE_PAGES & 1 ) ppm_remote_display( page_cxy );
    535537}
    536538#endif
     
    549551
    550552assert( __FUNCTION__, !page_remote_is_flag( page_xp , PG_FREE ) ,
    551 "page already released : ppn = %x\n" , ppm_page2ppn(XPTR( page_cxy , page_ptr ) ) );
     553"page already released : ppn = %x" , ppm_page2ppn(XPTR( page_cxy , page_ptr ) ) );
    552554
    553555assert( __FUNCTION__, !page_remote_is_flag( page_xp , PG_RESERVED ) ,
    554 "reserved page : ppn = %x\n" , ppm_page2ppn(XPTR( page_cxy , page_ptr ) ) );
     556"reserved page : ppn = %x" , ppm_page2ppn(XPTR( page_cxy , page_ptr ) ) );
    555557
    556558        // set the FREE flag in released page descriptor
     
    607609    hal_fence();
    608610
    609 #if DEBUG_PPM_REMOTE_FREE_PAGES
    610 if( DEBUG_PPM_REMOTE_FREE_PAGES < cycle )
     611#if DEBUG_PPM_FREE_PAGES
     612if( DEBUG_PPM_FREE_PAGES < cycle )
    611613{
    612614    printk("\n[%s] thread[%x,%x] released %d page(s) in cluster %x / ppn %x / cycle %d\n",
    613615    __FUNCTION__, this->process->pid, this->trdid, 1<<order, page_cxy, ppn, cycle );
    614     if( DEBUG_PPM_REMOTE_FREE_PAGES & 1 ) ppm_remote_display( page_cxy );
     616    if( DEBUG_PPM_FREE_PAGES & 1 ) ppm_remote_display( page_cxy );
    615617}
    616618#endif
Note: See TracChangeset for help on using the changeset viewer.