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


Ignore:
Timestamp:
May 29, 2019, 3:26:44 PM (5 years ago)
Author:
alain
Message:

Fix a bug in hal_irqmask.c

File:
1 edited

Legend:

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

    r632 r634  
    4242
    4343////////////////////////////////////////////////////////////////////////////////////////
     44//         global variables
     45////////////////////////////////////////////////////////////////////////////////////////
     46
     47extern chdev_directory_t    chdev_dir;          // allocated in kernel_init.c
     48
     49////////////////////////////////////////////////////////////////////////////////////////
    4450//     functions to  translate [ page <-> base <-> ppn ]
    4551////////////////////////////////////////////////////////////////////////////////////////
    46 
    4752
    4853/////////////////////////////////////////////
     
    212217if( DEBUG_PPM_ALLOC_PAGES < cycle )
    213218printk("\n[%s] thread[%x,%x] enter for %d page(s) in cluster %x / cycle %d\n",
    214 __FUNCTION__, this->process->pid, this->trdid, 1<<order, cxy, cycle );
     219__FUNCTION__, this->process->pid, this->trdid, 1<<order, local_cxy, cycle );
    215220#endif
    216221
     
    266271if( DEBUG_PPM_ALLOC_PAGES < cycle )
    267272printk("\n[%s] thread[%x,%x] cannot allocate %d page(s) in cluster %x / cycle %d\n",
    268 __FUNCTION__, this->process->pid, this->trdid, 1<<order, cxy, cycle );
     273__FUNCTION__, this->process->pid, this->trdid, 1<<order, local_cxy, cycle );
    269274#endif
    270275
     
    307312printk("\n[%s] thread[%x,%x] exit for %d page(s) in cluster %x / ppn = %x / cycle %d\n",
    308313__FUNCTION__, this->process->pid, this->trdid,
    309 1<<order, ppm_page2ppn(XPTR( local_cxy , found_block )), cxy, cycle );
     3141<<order, ppm_page2ppn(XPTR( local_cxy , found_block )), local_cxy, cycle );
    310315#endif
    311316
     
    377382    page_t   * found_block;
    378383
    379 #if DEBUG_PPM_ALLOC_PAGES
     384#if DEBUG_PPM_REMOTE_ALLOC_PAGES
    380385thread_t * this  = CURRENT_THREAD;
    381386uint32_t   cycle = (uint32_t)hal_get_cycles();
    382 if( DEBUG_PPM_ALLOC_PAGES < cycle )
     387if( DEBUG_PPM_REMOTE_ALLOC_PAGES < cycle )
    383388printk("\n[%s] thread[%x,%x] enter for %d small page(s) in cluster %x / cycle %d\n",
    384389__FUNCTION__, this->process->pid, this->trdid, 1<<order, cxy, cycle );
    385390#endif
    386391
    387 #if(DEBUG_PPM_ALLOC_PAGES & 0x1)
    388 if( DEBUG_PPM_ALLOC_PAGES < cycle )
     392#if(DEBUG_PPM_REMOTE_ALLOC_PAGES & 0x1)
     393if( DEBUG_PPM_REMOTE_ALLOC_PAGES < cycle )
    389394ppm_remote_display( cxy );
    390395#endif
     
    436441                remote_busylock_release( lock_xp );
    437442
    438 #if DEBUG_PPM_ALLOC_PAGES
     443#if DEBUG_REMOTE_PPM_ALLOC_PAGES
    439444cycle = (uint32_t)hal_get_cycles();
    440 if( DEBUG_PPM_ALLOC_PAGES < cycle )
     445if( DEBUG_PPM_REMOTE_ALLOC_PAGES < cycle )
    441446printk("\n[%s] thread[%x,%x] cannot allocate %d page(s) in cluster %x / cycle %d\n",
    442447__FUNCTION__, this->process->pid, this->trdid, 1<<order, cxy, cycle );
     
    468473        }
    469474
    470         // update refcount, flags and order fields in found block remote page descriptor
     475        // update refcount, flags and order fields in found block
    471476        page_remote_clear_flag( XPTR( cxy , found_block ), PG_FREE );
    472477        page_remote_refcount_up( XPTR( cxy , found_block ) );
     
    479484    dqdt_increment_pages( cxy , order );
    480485
    481 #if DEBUG_PPM_ALLOC_PAGES
     486#if DEBUG_PPM_REMOTE_ALLOC_PAGES
    482487cycle = (uint32_t)hal_get_cycles();
    483 if( DEBUG_PPM_ALLOC_PAGES < cycle )
     488if( DEBUG_PPM_REMOTE_ALLOC_PAGES < cycle )
    484489printk("\n[%s] thread[%x,%x] exit for %d page(s) / ppn = %x in cluster %x / cycle %d\n",
    485490__FUNCTION__, this->process->pid, this->trdid,
     
    487492#endif
    488493
    489 #if(DEBUG_PPM_ALLOC_PAGES & 0x1)
    490 if( DEBUG_PPM_ALLOC_PAGES < cycle )
     494#if(DEBUG_PPM_REMOTE_ALLOC_PAGES & 0x1)
     495if( DEBUG_PPM_REMOTE_ALLOC_PAGES < cycle )
    491496ppm_remote_display( cxy );
    492497#endif
     
    509514        uint32_t   current_order;    // current (merged) block order
    510515
    511 #if DEBUG_PPM_FREE_PAGES
     516#if DEBUG_PPM_REMOTE_FREE_PAGES
    512517thread_t * this  = CURRENT_THREAD;
    513518uint32_t   cycle = (uint32_t)hal_get_cycles();
    514 if( DEBUG_PPM_FREE_PAGES < cycle )
    515 printk("\n[%s] thread[%x,%x] enter for %d page(s) in cluster %x / ppn %x / cycle %d\n",
     519if( DEBUG_PPM_REMOTE_FREE_PAGES < cycle )
     520printk("\n[%s] thread[%x,%x] enter for %d page(s) / cxy %x / ppn %x / cycle %d\n",
    516521__FUNCTION__, this->process->pid, this->trdid,
    5175221<<page->order, cxy, ppm_page2ppn(XPTR(cxy , page)), cycle );
    518523#endif
    519524
    520 #if(DEBUG_PPM_FREE_PAGES & 0x1)
    521 if( DEBUG_PPM_FREE_PAGES < cycle )
     525#if(DEBUG_PPM_REMOTE_FREE_PAGES & 0x1)
     526if( DEBUG_PPM_REMOTE_FREE_PAGES < cycle )
    522527ppm_remote_display( cxy );
    523528#endif
     
    594599    dqdt_decrement_pages( cxy , page->order );
    595600
    596 #if DEBUG_PPM_FREE_PAGES
     601#if DEBUG_PPM_REMOTE_FREE_PAGES
    597602cycle = (uint32_t)hal_get_cycles();
    598 if( DEBUG_PPM_FREE_PAGES < cycle )
     603if( DEBUG_PPM_REMOTE_FREE_PAGES < cycle )
    599604printk("\n[%s] thread[%x,%x] exit for %d page(s) in cluster %x / ppn %x / cycle %d\n",
    600605__FUNCTION__, this->process->pid, this->trdid,
     
    602607#endif
    603608
    604 #if(DEBUG_PPM_FREE_PAGES & 0x1)
    605 if( DEBUG_PPM_FREE_PAGES < cycle )
     609#if(DEBUG_PPM_REMOTE_FREE_PAGES & 0x1)
     610if( DEBUG_PPM_REMOTE_FREE_PAGES < cycle )
    606611ppm_remote_display( cxy );
    607612#endif
     
    614619        uint32_t       order;
    615620        list_entry_t * iter;
    616         page_t       * page;
     621    xptr_t         page_xp;
    617622
    618623    ppm_t * ppm = &LOCAL_CLUSTER->ppm;
    619624
    620625    // build extended pointer on lock protecting remote PPM
    621     xptr_t lock_xp = XPTR( cxy , &ppm->free_lock );
    622 
    623         // get lock protecting free lists in remote cluster
    624         remote_busylock_acquire( lock_xp );
    625 
    626         printk("\n***** PPM in cluster %x / %d pages\n", local_cxy , ppm->pages_nr );
     626    xptr_t ppm_lock_xp = XPTR( cxy , &ppm->free_lock );
     627
     628    // get pointers on TXT0 chdev
     629    xptr_t    txt0_xp  = chdev_dir.txt_tx[0];
     630    cxy_t     txt0_cxy = GET_CXY( txt0_xp );
     631    chdev_t * txt0_ptr = GET_PTR( txt0_xp );
     632
     633    // build extended pointer on remote TXT0 lock
     634    xptr_t  txt_lock_xp = XPTR( txt0_cxy , &txt0_ptr->wait_lock );
     635
     636        // get PPM lock
     637        remote_busylock_acquire( ppm_lock_xp );
     638
     639    // get TXT0 lock
     640    remote_busylock_acquire( txt_lock_xp );
     641
     642        nolock_printk("\n***** PPM in cluster %x / %d pages\n", local_cxy , ppm->pages_nr );
    627643
    628644        for( order = 0 ; order < CONFIG_PPM_MAX_ORDER ; order++ )
     
    630646        // get number of free pages for free_list[order] in remote cluster
    631647        uint32_t n = hal_remote_l32( XPTR( cxy , &ppm->free_pages_nr[order] ) );
    632                 printk("- order = %d / free_pages = %d\t: ", order , n );
     648
     649                nolock_printk("- order = %d / n = %d\t: ", order , n );
    633650
    634651                LIST_REMOTE_FOREACH( cxy , &ppm->free_pages_root[order] , iter )
    635652                {
    636                         page = LIST_ELEMENT( iter , page_t , list );
    637                         printk("%x," , page - ppm->pages_tbl );
     653            // build extended pointer on page descriptor
     654            page_xp = XPTR( cxy , LIST_ELEMENT( iter , page_t , list ) );
     655
     656            // display PPN
     657                        nolock_printk("%x," , ppm_page2ppn( page_xp ) );
    638658                }
    639659
    640                 printk("\n");
    641         }
    642 
    643         // release lock protecting free lists in remote cluster
    644         remote_busylock_release( lock_xp );
     660                nolock_printk("\n");
     661        }
     662
     663        // release TXT0 lock
     664        remote_busylock_release( txt_lock_xp );
     665
     666        // release PPM lock
     667        remote_busylock_release( ppm_lock_xp );
    645668}
    646669
Note: See TracChangeset for help on using the changeset viewer.