Changeset 672 for trunk/kernel/mm/kcm.c


Ignore:
Timestamp:
Nov 19, 2020, 11:49:01 PM (4 years ago)
Author:
alain
Message:

1) Introduce up to 4 command lines arguments in the KSH "load" command.
These arguments are transfered to the user process through the
argc/argv mechanism, using the user space "args" vseg.

2) Introduce the named and anonymous "pipes", for inter-process communication
through the pipe() and mkfifo() syscalls.

3) Introduce the "chat" application to validate the two above mechanisms.

4) Improve printk() and assert() fonctions in printk.c.

File:
1 edited

Legend:

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

    r657 r672  
    22 * kcm.c -  Kernel Cache Manager implementation.
    33 *
    4  * Author  Alain Greiner    (2016,2017,2018,2019)
     4 * Author  Alain Greiner    (2016,2017,2018,2019,2020)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    6060    uint64_t status = kcm_page->status;
    6161
    62 assert( (count < max) , "kcm_page should not be full" );
     62assert( __FUNCTION__, (count < max) , "kcm_page should not be full" );
    6363
    6464    uint32_t index  = 1;
     
    9494        void * ptr = (void *)((intptr_t)kcm_page + (index * size) );
    9595
    96 #if (DEBUG_KCM & 1)
     96#if DEBUG_KCM
    9797thread_t * this  = CURRENT_THREAD;
    9898uint32_t   cycle = (uint32_t)hal_get_cycles();
     
    132132    uint64_t mask = ((uint64_t)0x1) << index;
    133133
    134 assert( (status & mask) , "released block not allocated : status (%x,%x) / mask(%x,%x)",
    135 GET_CXY(status), GET_PTR(status), GET_CXY(mask  ), GET_PTR(mask  ) );
     134    if( (status & mask) == 0 )
     135    {
     136        printk("\n[WARNING] in %s : block[%x,%x] not allocated / kcm %x / kcm_page %x\n",
     137        __FUNCTION__, local_cxy, block_ptr, kcm, kcm_page );
     138        printk("   status %L / mask %L / sts & msk %L\n", status, mask, (status & mask) );
     139        kcm_remote_display( local_cxy , kcm );
     140        return;
     141    }
    136142
    137143    // update status & count in kcm_page
     
    149155        }
    150156
    151 #if (DEBUG_KCM & 1)
     157#if DEBUG_KCM
    152158thread_t * this  = CURRENT_THREAD;
    153159uint32_t   cycle = (uint32_t)hal_get_cycles();
    154160if( DEBUG_KCM < cycle )
    155 printk("\n[%s] thread[%x,%x] released block %x in page %x / size %d / count %d / cycle %d\n",
     161printk("\n[%s] thread[%x,%x] block %x / page %x / size %d / count %d / cycle %d\n",
    156162__FUNCTION__, this->process->pid, this->trdid, block_ptr, kcm_page, size, count - 1, cycle );
    157163#endif
     
    219225{
    220226
    221 assert( ((order > 5) && (order < 12)) , "order must be in [6,11]" );
     227assert( __FUNCTION__, ((order > 5) && (order < 12)) , "order must be in [6,11]" );
     228
     229assert( __FUNCTION__, (CONFIG_PPM_PAGE_SHIFT == 12) , "check status bit_vector width" );
    222230
    223231        // initialize lock
     
    286294    if( order < 6 ) order = 6;
    287295
    288 assert( (order < 12) , "order = %d / must be less than 12" , order );
     296assert( __FUNCTION__, (order < 12) , "order = %d / must be less than 12" , order );
    289297
    290298    // get local pointer on relevant KCM allocator
     
    303311thread_t * this  = CURRENT_THREAD;
    304312uint32_t   cycle = (uint32_t)hal_get_cycles();
    305 if( (DEBUG_KCM < cycle) && (local_cxy == 1) )
     313if( DEBUG_KCM < cycle )
    306314{
    307315printk("\n[%s] thread[%x,%x] enters / order %d / page %x / kcm %x / page_status (%x|%x)\n",
     
    325333
    326334#if DEBUG_KCM
    327 if( (DEBUG_KCM < cycle) && (local_cxy == 1) )
    328 {
     335if( DEBUG_KCM < cycle )
    329336printk("\n[%s] thread[%x,%x] exit / order %d / block %x / kcm %x / page_status (%x|%x)\n",
    330337__FUNCTION__, this->process->pid, this->trdid, order, block_ptr, kcm_ptr,
    331338GET_CXY( kcm_page->status ), GET_PTR( kcm_page->status ) );
    332 kcm_remote_display( local_cxy , kcm_ptr );
    333 }
    334339#endif
    335340
     
    345350
    346351// check argument
    347 assert( (block_ptr != NULL) , "block pointer cannot be NULL" );
     352assert( __FUNCTION__, (block_ptr != NULL) , "block pointer cannot be NULL" );
    348353
    349354    // get local pointer on KCM page
     
    389394}  // end kcm_free()
    390395
     396
    391397/////////////////////////////////////////////////////////////////////////////////////
    392398//        Remote access functions
     
    414420    uint32_t size   = 1 << order;
    415421
    416 assert( (count < max) , "kcm_page should not be full" );
     422assert( __FUNCTION__, (count < max) , "kcm_page should not be full" );
    417423
    418424    uint32_t index  = 1;
     
    485491
    486492    // compute mask in bit vector
    487     uint64_t mask = 1 << index;
    488 
    489 assert( (status & mask) , "released page not allocated" );
     493    uint64_t mask = ((uint64_t)0x1) << index;
     494
     495    if( (status & mask) == 0 )
     496    {
     497        printk("\n[WARNING] in %s : block[%x,%x] not allocated / kcm %x / kcm_page %x\n",
     498        __FUNCTION__, kcm_cxy, block_ptr, kcm_ptr, kcm_page );
     499        printk("   status %L / mask %L / sts & msk %L\n", status, mask, (status & mask) );
     500        kcm_remote_display( kcm_cxy , kcm_ptr );
     501        return;
     502    }
    490503
    491504    // update status & count in kcm_page
     
    507520uint32_t   cycle = (uint32_t)hal_get_cycles();
    508521if( DEBUG_KCM_REMOTE < cycle )
    509 printk("\n[%s] thread[%x,%x] released block %x in page %x / cluster %x / size %x / count %d\n",
     522printk("\n[%s] thread[%x,%x] block %x / page %x / cluster %x / size %x / count %d\n",
    510523__FUNCTION__, this->process->pid, this->trdid, block_ptr, kcm_page, size, count - 1 )
    511524#endif
     
    564577}  // end kcm_remote_get_page()
    565578
    566 /////////////////////////////////////////
     579//////////////////////////////////////////
    567580void * kcm_remote_alloc( cxy_t    kcm_cxy,
    568581                         uint32_t order )
     
    574587    if( order < 6 ) order = 6;
    575588
    576 assert( (order < 12) , "order = %d / must be less than 12" , order );
     589assert( __FUNCTION__, (order < 12) , "order = %d / must be less than 12" , order );
    577590
    578591    // get local pointer on relevant KCM allocator
     
    620633
    621634// check argument
    622 assert( (block_ptr != NULL) , "block pointer cannot be NULL" );
     635assert( __FUNCTION__, (block_ptr != NULL) , "block pointer cannot be NULL" );
    623636
    624637    // get local pointer on remote KCM page
Note: See TracChangeset for help on using the changeset viewer.