Changeset 641


Ignore:
Timestamp:
Oct 10, 2019, 1:42:04 PM (4 years ago)
Author:
alain
Message:
  • Fix several bugs.
  • Introduce the "stat" command in KSH.

This almos-mkh version sucessfully executed the FFT application
(65536 complex points) on the TSAR architecture from 1 to 64 cores.

Location:
trunk
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/Makefile

    r637 r641  
    189189              build/syscalls/sys_fsync.o           \
    190190              build/syscalls/sys_get_best_core.o   \
    191               build/syscalls/sys_get_nb_cores.o
     191              build/syscalls/sys_get_nb_cores.o    \
     192              build/syscalls/sys_get_thread_info.o
    192193
    193194VFS_OBJS    = build/fs/vfs.o              \
  • trunk/kernel/kern/do_syscall.c

    r637 r641  
    110110    sys_get_best_core,      // 53
    111111    sys_get_nb_cores,       // 54
     112    sys_get_thread_info,    // 55
    112113};
    113114
     
    177178    case SYS_GET_BEST_CORE:                return "GET_BEST_CORE";    // 53
    178179    case SYS_GET_NB_CORES:                 return "GET_NB_CORES";     // 54
     180    case SYS_GET_THREAD_INFO:              return "GET_THREAD_INFO";  // 55
    179181
    180182    default:                               return "undefined";
  • trunk/kernel/kern/rpc.c

    r640 r641  
    349349                rpc_server[index]( desc_xp );
    350350
     351                // update responses counter
     352                responses = hal_remote_atomic_add( rsp_xp , -1 );
     353
    351354#if DEBUG_RPC_SERVER_GENERIC
    352355cycle = (uint32_t)hal_get_cycles();
    353356if( DEBUG_RPC_SERVER_GENERIC < cycle )
    354 printk("\n[%s] RPC thread[%x,%x] completes rpc %s / client_cxy %x / cycle %d\n",
    355 __FUNCTION__, server_ptr->process->pid, server_ptr->trdid, rpc_str[index], desc_cxy, cycle );
     357printk("\n[%s] RPC thread[%x,%x] completes rpc %s / responses %d / cycle %d\n",
     358__FUNCTION__, server_ptr->process->pid, server_ptr->trdid, rpc_str[index], responses, cycle );
    356359#endif
    357360                // decrement expected responses counter
    358                 responses = hal_remote_atomic_add( rsp_xp , -1 );
    359 
    360361                // unblock client thread if last response
    361362                if( responses == 1 )
     
    23882389
    23892390//////////////////////////////////////////////////////////
    2390 void rpc_vmm_resize_vseg_client( cxy_t             cxy,
    2391                                  struct process_s * process,
    2392                                  struct vseg_s    * vseg,
    2393                                  intptr_t           new_base,
    2394                                  intptr_t           new_size )
     2391void rpc_vmm_resize_vseg_client( cxy_t          cxy,
     2392                                 pid_t          pid,
     2393                                 intptr_t       base,
     2394                                 intptr_t       new_base,
     2395                                 intptr_t       new_size )
    23952396{
    23962397#if DEBUG_RPC_VMM_RESIZE_VSEG
     
    24112412
    24122413    // set input arguments in RPC descriptor
    2413     rpc.args[0] = (uint64_t)(intptr_t)process;
    2414     rpc.args[1] = (uint64_t)(intptr_t)vseg;
     2414    rpc.args[0] = (uint64_t)pid;
     2415    rpc.args[1] = (uint64_t)base;
    24152416    rpc.args[2] = (uint64_t)new_base;
    24162417    rpc.args[3] = (uint64_t)new_size;
     
    24382439#endif
    24392440
     2441    pid_t       pid;
    24402442    process_t * process;
     2443    intptr_t    base;
    24412444    vseg_t    * vseg;
    24422445    intptr_t    new_base;
     
    24482451
    24492452    // get arguments from client RPC descriptor
    2450     process  = (process_t *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
    2451     vseg     = (vseg_t    *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) );
    2452     new_base =              (intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[2] ) );
    2453     new_size =              (intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[3] ) );
     2453    pid      = (pid_t)   hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
     2454    base     = (intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) );
     2455    new_base = (intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[2] ) );
     2456    new_size = (intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[3] ) );
     2457
     2458    // get local pointer on target process
     2459    process = cluster_get_local_process_from_pid( pid );
     2460
     2461    // get target vseg from vaddr
     2462    vmm_get_vseg( process , base , &vseg );
    24542463
    24552464    // call relevant kernel function
     
    24742483/////////////////////////////////////////////////
    24752484void rpc_vmm_remove_vseg_client( cxy_t       cxy,
    2476                                  process_t * process,
    2477                                  vseg_t    * vseg )
     2485                                 pid_t       pid,
     2486                                 intptr_t    base )
    24782487{
    24792488#if DEBUG_RPC_VMM_REMOVE_VSEG
     
    24942503
    24952504    // set input arguments in RPC descriptor
    2496     rpc.args[0] = (uint64_t)(intptr_t)process;
    2497     rpc.args[1] = (uint64_t)(intptr_t)vseg;
     2505    rpc.args[0] = (uint64_t)pid;
     2506    rpc.args[1] = (uint64_t)base;
    24982507
    24992508    // register RPC request in remote RPC fifo
     
    25192528#endif
    25202529
     2530    pid_t       pid;
     2531    intptr_t    vaddr;
    25212532    process_t * process;
    25222533    vseg_t    * vseg;
     
    25272538
    25282539    // get arguments from RPC descriptor
    2529     process  = (process_t *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
    2530     vseg     = (vseg_t    *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) );
     2540    pid   = (pid_t)   hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
     2541    vaddr = (intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) );
     2542
     2543    // get local pointer on target process
     2544    process = cluster_get_local_process_from_pid( pid );
     2545
     2546    // get target vseg from vaddr
     2547    vmm_get_vseg( process , vaddr , &vseg );
    25312548
    25322549    // call relevant kernel function
  • trunk/kernel/kern/rpc.h

    r640 r641  
    130130 * the caller. It exit with a Panic message if remote fifo is still full after
    131131 * (CONFIG_RPC_PUT_MAX_ITERATIONS) retries.
    132  * - When the RPC <blocking> field is true, this function blocks and deschedule.
    133  *   It returns only when the server acknowledges the RPC by writing in the RPC
    134  *   "response" field, and unblocks the client.
     132 * - When the RPC <blocking> field is true, this function blocks and deschedule
     133 *   the client thread. It returns only when the server completes the RPC and
     134 *   unblocks the client thread.
    135135 * - When the <blocking> field is false, this function returns as soon as the RPC
    136  *   has been registered in the FIFO, and the server thread must directly signal
    137  *   completion to the client thread.
     136 *   has been registered in the FIFO, and the client thread must block itself when
     137 *   all RPCS have been registered in all target clusters.
    138138 ***********************************************************************************
    139139 * @ cxy   : server cluster identifier
     
    520520
    521521/***********************************************************************************
    522  * [25] The RPC_VMM_RESIZE_VSEG allows a client thread to request a remote vseg
    523  * resize. Both the VSL and the GPT are updated in the remote cluster.
     522 * [25] The RPC_VMM_RESIZE_VSEG allows a client thread to request a remote cluster
     523 * to resize a vseg identified by the <base> argument in a process descriptor
     524 * identified by the <pid> argument, as defined by the <new_base> and <new_size>
     525 * arguments. Both the VSL and the GPT are updated in the remote cluster.
    524526 ***********************************************************************************
    525527 * @ cxy         : server cluster identifier.
    526  * @ process     : [in] local pointer on remote process.
    527  * @ vseg        : [in] local pointer on remote vseg.
    528  * @ new_base    : [in] new vseg base address.
     528 * @ pid         : [in] process identifier.
     529 * @ base        : [in] vseg base.
     530 * @ new_base    : [in] new vseg base.
    529531 * @ new_size    : [in] new vseg size.
    530532 **********************************************************************************/
    531533void rpc_vmm_resize_vseg_client( cxy_t              cxy,
    532                                  struct process_s * process,
    533                                  struct vseg_s    * vseg,
     534                                 pid_t              pid,
     535                                 intptr_t           base,
    534536                                 intptr_t           new_base,
    535537                                 intptr_t           new_size );
     
    538540
    539541/***********************************************************************************
    540  * [26] The RPC_VMM_REMOVE_VSEG allows a client thread  to request a remote vseg
    541  * delete. Bothe the VSL and the GPT are updated in the remote cluster.
    542  ***********************************************************************************
    543  * @ cxy         : server cluster identifier.
    544  * @ process     : [in] local pointer on remote process.
    545  * @ vseg        : [in] local pointer on remote vseg.
    546  **********************************************************************************/
    547 void rpc_vmm_remove_vseg_client( cxy_t              cxy,
    548                                  struct process_s * process,
    549                                  struct vseg_s    * vseg );
     542 * [26] The RPC_VMM_REMOVE_VSEG allows a client thread  to request a remote cluster
     543 * to delete a vseg identified by the <vaddr> argument in a process descriptor
     544 * identified by the <pid> argument.
     545 * Both the VSL and the GPT are updated in the remote cluster.
     546 ***********************************************************************************
     547 * @ cxy       : server cluster identifier.
     548 * @ pid       : [in] process identifier.
     549 * @ base      : [in] vseg base.
     550 **********************************************************************************/
     551void rpc_vmm_remove_vseg_client( cxy_t      cxy,
     552                                 pid_t      pid,
     553                                 intptr_t   base );
    550554 
    551555void rpc_vmm_remove_vseg_server( xptr_t xp );
  • trunk/kernel/kern/scheduler.c

    r640 r641  
    255255__FUNCTION__, process->pid, thread->trdid, local_cxy, thread->core->lid, cycle );
    256256#endif
    257 
    258 #if CONFIG_INSTRUMENTATION_PGFAULTS
    259 uint32_t local_nr    = thread->info.local_pgfault_nr;
    260 uint32_t local_cost  = (local_nr == 0)  ? 0 : (thread->info.local_pgfault_cost / local_nr);
    261 uint32_t global_nr   = thread->info.global_pgfault_nr;
    262 uint32_t global_cost = (global_nr == 0) ? 0 : (thread->info.global_pgfault_cost / global_nr);
    263 uint32_t false_nr    = thread->info.false_pgfault_nr;
    264 uint32_t false_cost  = (false_nr == 0)  ? 0 : (thread->info.false_pgfault_cost / false_nr);
    265 printk("\n***** page faults for thread[%x,%x]\n"
    266        "  - %d local  : %d cycles\n"
    267        "  - %d global : %d cycles\n"
    268        "  - %d false  : %d cycles\n",
    269        process->pid, thread->trdid,
    270        local_nr,  local_cost,
    271        global_nr, global_cost,
    272        false_nr,  false_cost );
    273 #endif
    274257            // destroy process descriptor if last thread
    275258            if( count == 1 )
  • trunk/kernel/kern/thread.c

    r640 r641  
    183183    dqdt_increment_threads();
    184184
     185#if CONFIG_INSTRUMENTATION_PGFAULTS
     186    thread->info.false_pgfault_nr    = 0;
     187    thread->info.false_pgfault_cost  = 0;
     188    thread->info.false_pgfault_max   = 0;
     189    thread->info.local_pgfault_nr    = 0;
     190    thread->info.local_pgfault_cost  = 0;
     191    thread->info.local_pgfault_max   = 0;
     192    thread->info.global_pgfault_nr   = 0;
     193    thread->info.global_pgfault_cost = 0;
     194    thread->info.global_pgfault_max  = 0;
     195#endif
     196
    185197#if DEBUG_THREAD_INIT
    186198cycle = (uint32_t)hal_get_cycles();
     
    890902    core_t        * core    = thread->core;
    891903
    892 
    893 #if DEBUG_THREAD_DESTROY || CONFIG_INSTRUMENTATION_PGFAULTS
     904#if DEBUG_THREAD_DESTROY
    894905uint32_t   cycle;
    895906thread_t * this  = CURRENT_THREAD;
     
    908919#if CONFIG_INSTRUMENTATION_PGFAULTS
    909920process->vmm.false_pgfault_nr    += thread->info.false_pgfault_nr;
     921process->vmm.false_pgfault_cost  += thread->info.false_pgfault_cost;
    910922process->vmm.local_pgfault_nr    += thread->info.local_pgfault_nr;
     923process->vmm.local_pgfault_cost  += thread->info.local_pgfault_cost;
    911924process->vmm.global_pgfault_nr   += thread->info.global_pgfault_nr;
    912 process->vmm.false_pgfault_cost  += thread->info.false_pgfault_cost;
    913 process->vmm.local_pgfault_cost  += thread->info.local_pgfault_cost;
    914925process->vmm.global_pgfault_cost += thread->info.global_pgfault_cost;
    915926#endif
     
    917928#if (CONFIG_INSTRUMENTATION_PGFAULTS & 1)
    918929uint32_t false_nr    = thread->info.false_pgfault_nr;
     930uint32_t false_cost  = thread->info.false_pgfault_cost;
     931uint32_t false_max   = thread->info.false_pgfault_max;
     932uint32_t false_one   = false_nr  ? (false_cost  / false_nr ) : 0;
     933
    919934uint32_t local_nr    = thread->info.local_pgfault_nr;
     935uint32_t local_cost  = thread->info.local_pgfault_cost;
     936uint32_t local_max   = thread->info.local_pgfault_max;
     937uint32_t local_one   = local_nr  ? (local_cost  / local_nr ) : 0;
     938
    920939uint32_t global_nr   = thread->info.global_pgfault_nr;
    921 uint32_t false_cost  = thread->info.false_pgfault_cost;
    922 uint32_t local_cost  = thread->info.local_pgfault_cost;
    923940uint32_t global_cost = thread->info.global_pgfault_cost;
    924 printk("***** thread[%x,%x] page-faults\n"
    925        " - false    %d ( %d cycles )\n"
    926        " - local    %d ( %d cycles )\n"
    927        " - global   %d ( %d cycles )\n",
    928        this->process->pid, this->trdid,
    929        false_nr , false_cost / false_nr,
    930        local_nr , local_cost / local_nr,
    931        global_nr, global_cost / global_nr );
     941uint32_t global_max  = thread->info.global_pgfault_max;
     942uint32_t global_one  = global_nr ? (global_cost / global_nr) : 0;
     943
     944printk("\n***** thread[%x,%x] page-faults\n"
     945       " - false  : %d events / cost %d cycles / max %d cycles\n"
     946       " - local  : %d events / cost %d cycles / max %d cycles\n"
     947       " - global : %d events / cost %d cycles / max %d cycles\n",
     948       thread->process->pid, thread->trdid,
     949       false_nr , false_one , false_max,
     950       local_nr , local_one , local_max,
     951       global_nr, global_one, global_max );
    932952#endif
    933953
  • trunk/kernel/kern/thread.h

    r635 r641  
    2828#include <hal_kernel_types.h>
    2929#include <shared_syscalls.h>
     30#include <shared_almos.h>
    3031#include <hal_special.h>
    3132#include <hal_kentry.h>
     
    9596
    9697/***************************************************************************************
    97  * This structure defines thread instrumentation informations.
    98  **************************************************************************************/
    99 
    100 typedef struct thread_info_s
    101 {
    102         uint32_t     false_pgfault_nr;       /*! number of local page fault               */
    103         uint32_t     local_pgfault_nr;       /*! number of local page fault               */
    104         uint32_t     global_pgfault_nr;      /*! number of global page fault              */
    105     uint32_t     false_pgfault_cost;     /*! cumulated cost                           */
    106     uint32_t     local_pgfault_cost;     /*! cumulated cost                           */
    107     uint32_t     global_pgfault_cost;    /*! cumulated cost                           */
    108 
    109         cycle_t      last_cycle;             /*! last cycle counter value (date)          */
    110         cycle_t      usr_cycles;             /*! user execution duration (cycles)         */
    111         cycle_t      sys_cycles;             /*! system execution duration (cycles)       */
    112 }
    113 thread_info_t;
    114 
    115 /***************************************************************************************
    11698 * This structure defines a thread descriptor.
    11799 * It is used for both the user threads and the kernel threads.
     
    119101 * - The TRDID 16 LSB bits contain the LTID (Local Thread Index).
    120102 * - The TRDID 16 MSB bits contain the CXY of cluster containing the thread.
    121  * The main thread LTID value is always 0.
     103 * For the main thread the LTID value is always 0, in the owner cluster.
    122104 * The LTID is used to index the th_tbl[] array in the local process descriptor.
    123105 * This TRDID is computed by the process_register_thread() function, when the user
    124106 * thread is registered in the local copy of the process descriptor.
    125107 *
    126  * WARNING (1) Don't modify the first 4 fields order, as this order is used by the
    127  *             hal_kentry assembly code for the TSAR architectures.
    128  *
    129  * WARNING (2) Most of the thread state is private and accessed only by this thread,
    130  *             but some fields are shared, and can be modified by other threads.
    131  *             - the "blocked" bit_vector can be modified by another thread
    132  *               running in another cluster (using atomic instructions),
    133  *               to change this thread scheduling status.
    134  *             - the "flags" bit_vector can be modified by another thread
    135  *               running in another cluster (using atomic instructions),
    136  *               to register requests such as ACK or DELETE.
    137  *             - the "join_xp" field can be modified by the joining thread,
    138  *               and this rendez-vous is protected by the dedicated "join_lock".
    139  *
    140  * WARNING (3) When this thread is blocked on a shared resource (queuelock, condvar,
    141  *             or chdev), it registers in the associated waiting queue, using the
    142  *             "wait_list" (local list) or "wait_xlist" (trans-cluster list) fields.
     108 * Implementation notes:
     109 *
     110 * (1) Don't modify the first 4 fields order, as this order is used by the
     111 *     hal_kentry assembly code for the TSAR architectures.
     112 *
     113 * (2) Most of the thread state is private and accessed only by this thread,
     114 *     but some fields are shared, and can be modified by other threads.
     115 *     - the "blocked" bit_vector can be modified by another thread
     116 *       running in another cluster (using atomic instructions),
     117 *       to change this thread scheduling status.
     118 *     - the "flags" bit_vector can be modified by another thread
     119 *       running in another cluster (using atomic instructions),
     120 *       to register requests such as ACK or DELETE.
     121 *     - the "join_xp" field can be modified by the joining thread,
     122 *       and this rendez-vous is protected by the dedicated "join_lock".
     123 *
     124 * (3) When this thread is blocked on a shared resource (queuelock, condvar,
     125 *     or chdev), it registers in the associated waiting queue, using the
     126 *     "wait_list" (local list) or "wait_xlist" (trans-cluster list) fields.
     127 *
     128 * (4) The thread_info_t structure is defined in the shared_almos.h file in the
     129 *     /kernel/syscall/shared_include directory.
    143130 **************************************************************************************/
    144131
  • trunk/kernel/kernel_config.h

    r640 r641  
    9696#define DEBUG_HAL_GPT_CREATE              0
    9797#define DEBUG_HAL_GPT_DESTROY             0
    98 #define DEBUG_HAL_GPT_LOCK_PTE               2
     98#define DEBUG_HAL_GPT_LOCK_PTE            0
    9999#define DEBUG_HAL_GPT_SET_COW             0
    100100#define DEBUG_HAL_GPT_SET_PTE             0
     
    194194#define DEBUG_SYS_GET_CORE_ID             0
    195195#define DEBUG_SYS_GET_NB_CORES            0
     196#define DEBUG_SYS_GET_THREAD_INFO         0
    196197#define DEBUG_SYS_ISATTY                  0
    197198#define DEBUG_SYS_IS_FG                   0
     
    254255
    255256#define DEBUG_VMM_CREATE_VSEG             0
    256 #define DEBUG_VMM_DELETE_VSEG             0
    257257#define DEBUG_VMM_DESTROY                 0
    258258#define DEBUG_VMM_FORK_COPY               0
     
    462462
    463463#define CONFIG_INSTRUMENTATION_SYSCALLS    0
    464 #define CONFIG_INSTRUMENTATION_PGFAULTS    0
     464#define CONFIG_INSTRUMENTATION_PGFAULTS    1
    465465#define CONFIG_INSTRUMENTATION_FOOTPRINT   0
    466466#define CONFIG_INSTRUMENTATION_GPT         1
  • trunk/kernel/libk/user_dir.c

    r640 r641  
    145145    }
    146146
    147     // Build an initialize the dirent array as a list of pages.
     147    // Build and initialize the dirent array as a list of pages.
    148148    // For each iteration in this while loop:
    149149    // - allocate one physical 4 Kbytes (64 dirent slots)
     
    174174        }
    175175
    176         // call the relevant FS specific function to copy up to 64 dirents in page
     176        // call the relevant FS specific function to copy dirents in page
    177177        error = vfs_fs_get_user_dir( inode,
    178178                                     base,
     
    210210#endif
    211211
    212     // compute required vseg size for a 64 bytes dirent
     212    // compute required vseg size
    213213    vseg_size = total_dirents << 6;
    214214
     
    254254// check vseg size
    255255assert( (total_pages == hal_remote_l32( XPTR( ref_cxy , &vseg->vpn_size ) ) ),
    256 "unconsistent vseg size for dirent array" );
     256"unconsistent vseg size for dirent array " );
    257257
    258258    // build extended pointer on reference process GPT
     
    294294
    295295            // delete the vseg
    296             if( ref_cxy == local_cxy)  vmm_remove_vseg( ref_ptr, vseg );
    297             else                       rpc_vmm_remove_vseg_client( ref_cxy, ref_ptr, vseg );
     296            intptr_t base = (intptr_t)hal_remote_lpt( XPTR( ref_cxy , &vseg->min ) );
     297            rpc_vmm_remove_vseg_client( ref_cxy, ref_pid, base );
    298298         
    299299            // release the user_dir descriptor
     
    434434    // to wait all RPC responses, and will be unblocked by the last RPC server thread.
    435435    // It allocates a - shared - RPC descriptor in the stack,  because all parallel
    436     // server threads use the same input arguments, and the same response field.
     436    // server threads use the same input arguments, and there is no out argument.
    437437
    438438    // get owner cluster identifier and process lpid
     
    454454
    455455    // initialize a shared RPC descriptor
    456     // can be shared, because no out arguments
    457456    rpc.rsp       = &responses;
    458     rpc.blocking  = false;
     457    rpc.blocking  = false;                  // non blocking behaviour for rpc_send()
    459458    rpc.index     = RPC_VMM_REMOVE_VSEG;
    460459    rpc.thread    = this;
     
    476475        hal_atomic_add( &responses , 1 );
    477476
     477#if (DEBUG_USER_DIR & 1)
     478uint32_t cycle = (uint32_t)hal_get_cycles();
     479if( cycle > DEBUG_USER_DIR )
     480printk("\n[%s] thread[%x,%x] register RPC request in cluster %x\n",
     481__FUNCTION__, this->process->pid, this->trdid, process_cxy );
     482#endif
     483
    478484        // send RPC to target cluster 
    479485        rpc_send( process_cxy , &rpc );
  • trunk/kernel/mm/vmm.c

    r640 r641  
    33 *
    44 * Authors   Ghassan Almaless (2008,2009,2010,2011, 2012)
    5  *           Mohamed Lamine Karaoui (2015)
    65 *           Alain Greiner (2016,2017,2018,2019)
    76 *
     
    2928#include <hal_gpt.h>
    3029#include <hal_vmm.h>
     30#include <hal_irqmask.h>
    3131#include <hal_macros.h>
    3232#include <printk.h>
     
    217217
    218218////////////////////////////////////////////////////////////////////////////////////////////
    219 // This static function is called by the vmm_remove_vseg() function, and implements
    220 // the VMM MMAP specific desallocator.
     219// This static function implements the VMM MMAP specific desallocator.
     220// It is called by the vmm_remove_vseg() function.
    221221////////////////////////////////////////////////////////////////////////////////////////////
    222222// @ vmm      : [in] pointer on VMM.
     
    495495                             intptr_t    base )
    496496{
    497     pid_t           pid;
    498497    cxy_t           owner_cxy;
    499498    lpid_t          owner_lpid;
    500 
    501     xlist_entry_t * process_root_ptr;
     499    reg_t           save_sr;
     500
     501    xptr_t          process_lock_xp;
    502502    xptr_t          process_root_xp;
    503503    xptr_t          process_iter_xp;
     
    511511    xptr_t          vsl_iter_xp;
    512512
     513    rpc_desc_t      rpc;                  // shared rpc descriptor for parallel RPCs
     514    uint32_t        responses;            // RPC responses counter
     515
     516    thread_t      * this    = CURRENT_THREAD;
     517    pid_t           pid     = process->pid;
     518    cluster_t     * cluster = LOCAL_CLUSTER;
     519
    513520#if DEBUG_VMM_GLOBAL_DELETE_VSEG
    514521uint32_t cycle = (uint32_t)hal_get_cycles();
    515 thread_t * this = CURRENT_THREAD;
    516522#endif
    517523
    518524#if (DEBUG_VMM_GLOBAL_DELETE_VSEG & 1)
    519525if( DEBUG_VMM_GLOBAL_DELETE_VSEG < cycle )
    520 printk("\n[%s] thread[%x,%x] : process %x / base %x / cycle %d\n",
     526printk("\n[%s] thread[%x,%x] enters / process %x / base %x / cycle %d\n",
    521527__FUNCTION__, this->process->pid, this->trdid, process->pid, base, cycle );
    522528#endif
    523529
     530    // initialize a shared RPC descriptor
     531    rpc.rsp       = &responses;
     532    rpc.blocking  = false;                  // non blocking behaviour for rpc_send()
     533    rpc.index     = RPC_VMM_REMOVE_VSEG;
     534    rpc.thread    = this;
     535    rpc.lid       = this->core->lid;
     536    rpc.args[0]   = this->process->pid;
     537    rpc.args[1]   = base;
     538
    524539    // get owner process cluster and local index
    525     pid              = process->pid;
    526540    owner_cxy        = CXY_FROM_PID( pid );
    527541    owner_lpid       = LPID_FROM_PID( pid );
    528542
    529     // get extended pointer on root of process copies xlist in owner cluster
    530     process_root_ptr = &LOCAL_CLUSTER->pmgr.copies_root[owner_lpid];
    531     process_root_xp  = XPTR( owner_cxy , process_root_ptr );
     543    // get extended pointer on root and lock of process copies xlist in owner cluster
     544    process_root_xp  = XPTR( owner_cxy , &cluster->pmgr.copies_root[owner_lpid] );
     545    process_lock_xp  = XPTR( owner_cxy , &cluster->pmgr.copies_lock[owner_lpid] );
     546
     547    // mask IRQs
     548    hal_disable_irq( &save_sr );
     549
     550    // client thread blocks itself
     551    thread_block( XPTR( local_cxy , this ) , THREAD_BLOCKED_RPC );
     552
     553    // take the lock protecting process copies
     554    remote_queuelock_acquire( process_lock_xp );
     555
     556    // initialize responses counter
     557    responses = 0;
    532558
    533559    // loop on process copies
     
    559585            if( vseg_base == base )   // found searched vseg
    560586            {
    561                 if( remote_process_cxy == local_cxy )
    562                 {
    563                     vmm_remove_vseg( process,
    564                                      vseg_ptr );
    565                 }
    566                 else
    567                 {
    568                     rpc_vmm_remove_vseg_client( remote_process_cxy,
    569                                                 remote_process_ptr,
    570                                                 vseg_ptr );
    571                 }
     587                // atomically increment responses counter
     588                hal_atomic_add( &responses , 1 );
    572589
    573590#if (DEBUG_VMM_GLOBAL_DELETE_VSEG & 1)
    574591if( DEBUG_VMM_GLOBAL_DELETE_VSEG < cycle )
    575 printk("\n[%s] thread[%x,%x] deleted vseg %x for process %x in cluster %x\n",
    576 __FUNCTION__, this->process->pid, this->trdid, base, process->pid, remote_process_cxy );
    577 #endif
    578 
     592printk("\n[%s] thread[%x,%x] register RPC request in cluster %x\n",
     593__FUNCTION__, this->process->pid, this->trdid, remote_process_cxy );
     594#endif
     595                // send RPC to remote cluster
     596                rpc_send( remote_process_cxy , &rpc );
     597
     598                // exit loop on vsegs
     599                break;
    579600            }
    580601        }  // end of loop on vsegs
    581602
     603        // release lock on remote VSL
     604        remote_queuelock_release( vsl_lock_xp );
     605
     606    }  // end of loop on process copies
     607
     608    // release the lock protecting process copies
     609    remote_queuelock_release( process_lock_xp );
     610
    582611#if (DEBUG_VMM_GLOBAL_DELETE_VSEG & 1)
    583612if( DEBUG_VMM_GLOBAL_DELETE_VSEG < cycle )
    584 hal_vmm_display( remote_process_xp , false );
    585 #endif
    586 
    587         // release lock on remote VSL
    588         remote_queuelock_release( vsl_lock_xp );
    589 
    590     }  // end of loop on process copies
     613printk("\n[%s] thread[%x,%x] deschedule / process %x / base %x\n",
     614__FUNCTION__, this->process->pid, this->trdid, process->pid, base );
     615#endif
     616
     617    // client thread deschedule
     618    sched_yield("blocked on rpc_vmm_delete_vseg");
     619 
     620    // restore IRQs
     621    hal_restore_irq( save_sr );
    591622
    592623#if DEBUG_VMM_GLOBAL_DELETE_VSEG
    593624cycle = (uint32_t)hal_get_cycles();
    594625if( DEBUG_VMM_GLOBAL_DELETE_VSEG < cycle )
    595 printk("\n[%s] thread[%x,%x] exit for process %x / base %x / cycle %d\n",
    596 __FUNCTION__, this->process->pid, this->trdid, process->pid , base, cycle );
     626printk("\n[%s] thread[%x,%x] exit / process %x / base %x / cycle %d\n",
     627__FUNCTION__, this->process->pid, this->trdid, process->pid, base, cycle );
    597628#endif
    598629
     
    605636                             intptr_t    new_size )
    606637{
    607     pid_t           pid;
    608638    cxy_t           owner_cxy;
    609639    lpid_t          owner_lpid;
    610 
    611     xlist_entry_t * process_root_ptr;
     640    reg_t           save_sr;
     641
     642    xptr_t          process_lock_xp;
    612643    xptr_t          process_root_xp;
    613644    xptr_t          process_iter_xp;
     
    621652    xptr_t          vsl_iter_xp;
    622653
     654    rpc_desc_t      rpc;                  // shared rpc descriptor for parallel RPCs
     655    uint32_t        responses;            // RPC responses counter
     656
     657    thread_t      * this    = CURRENT_THREAD;
     658    pid_t           pid     = process->pid;
     659    cluster_t     * cluster = LOCAL_CLUSTER;
     660
    623661#if DEBUG_VMM_GLOBAL_RESIZE_VSEG
    624662uint32_t cycle = (uint32_t)hal_get_cycles();
    625 thread_t * this = CURRENT_THREAD;
    626663#endif
    627664
     
    632669#endif
    633670
    634     // get owner process cluster and local index
    635     pid              = process->pid;
     671    // initialize a shared RPC descriptor
     672    rpc.rsp       = &responses;
     673    rpc.blocking  = false;                  // non blocking behaviour for rpc_send()
     674    rpc.index     = RPC_VMM_REMOVE_VSEG;
     675    rpc.thread    = this;
     676    rpc.lid       = this->core->lid;
     677    rpc.args[0]   = this->process->pid;
     678    rpc.args[1]   = base;
     679    rpc.args[2]   = new_base;
     680    rpc.args[3]   = new_size;
     681
     682    // get owner process cluster and local index
    636683    owner_cxy        = CXY_FROM_PID( pid );
    637684    owner_lpid       = LPID_FROM_PID( pid );
    638685
    639     // get extended pointer on root of process copies xlist in owner cluster
    640     process_root_ptr = &LOCAL_CLUSTER->pmgr.copies_root[owner_lpid];
    641     process_root_xp  = XPTR( owner_cxy , process_root_ptr );
     686    // get extended pointer on root and lock of process copies xlist in owner cluster
     687    process_root_xp  = XPTR( owner_cxy , &cluster->pmgr.copies_root[owner_lpid] );
     688    process_lock_xp  = XPTR( owner_cxy , &cluster->pmgr.copies_lock[owner_lpid] );
     689
     690    // mask IRQs
     691    hal_disable_irq( &save_sr );
     692
     693    // client thread blocks itself
     694    thread_block( XPTR( local_cxy , this ) , THREAD_BLOCKED_RPC );
     695
     696    // take the lock protecting process copies
     697    remote_queuelock_acquire( process_lock_xp );
     698
     699    // initialize responses counter
     700    responses = 0;
    642701
    643702    // loop on process copies
     
    669728            if( vseg_base == base )   // found searched vseg
    670729            {
    671                 if( remote_process_cxy == local_cxy )
    672                 {
    673                     vmm_resize_vseg( remote_process_ptr,
    674                                      vseg_ptr,
    675                                      new_base,
    676                                      new_size );
    677                 }
    678                 else
    679                 {
    680                     rpc_vmm_resize_vseg_client( remote_process_cxy,
    681                                                 remote_process_ptr,
    682                                                 vseg_ptr,
    683                                                 new_base,
    684                                                 new_size );
    685                 }
    686  
     730                // atomically increment responses counter
     731                hal_atomic_add( &responses , 1 );
     732
    687733#if (DEBUG_VMM_GLOBAL_RESIZE_VSEG & 1)
    688734if( DEBUG_VMM_GLOBAL_RESIZE_VSEG < cycle )
    689 printk("\n[%s] thread[%x,%x] resized vseg %x for process %x in cluster %x\n",
    690 __FUNCTION__, this->process->pid, this->trdid, base, process->pid, remote_process_cxy );
    691 #endif
    692 
     735printk("\n[%s] thread[%x,%x] register RPC request in cluster %x\n",
     736__FUNCTION__, this->process->pid, this->trdid, remote_process_cxy );
     737#endif
     738                // send RPC to remote cluster
     739                rpc_send( remote_process_cxy , & rpc );
     740
     741                // exit loop on vsegs
     742                break;
    693743            }
     744
    694745        }  // end of loop on vsegs
    695746
     
    701752        // release lock on remote VSL
    702753        remote_queuelock_release( vsl_lock_xp );
     754
    703755    }  // end of loop on process copies
     756
     757    // release the lock protecting process copies
     758    remote_queuelock_release( process_lock_xp );
     759
     760#if (DEBUG_VMM_GLOBAL_RESIZE_VSEG & 1)
     761if( DEBUG_VMM_GLOBAL_RESIZE_VSEG < cycle )
     762printk("\n[%s] thread[%x,%x] deschedule / process %x / base %x\n",
     763__FUNCTION__, this->process->pid, this->trdid, process->pid, base );
     764#endif
     765
     766    // client thread deschedule
     767    sched_yield("blocked on rpc_vmm_delete_vseg");
     768
     769    // restore IRQs
     770    hal_restore_irq( save_sr );
    704771
    705772#if DEBUG_VMM_GLOBAL_RESIZE_VSEG
     
    15521619#if (DEBUG_VMM_REMOVE_VSEG & 1 )
    15531620if( DEBUG_VMM_REMOVE_VSEG < cycle )
    1554 printk("\n[%s] thread[%x,%x] enter / process %x / %s / base %x / cycle %d\n",
     1621printk("\n[%s] thread[%x,%x] enters / process %x / type %s / base %x / cycle %d\n",
    15551622__FUNCTION__, this->process->pid, this->trdid,
    15561623process->pid, vseg_type_str(vseg->type), vseg->min, cycle );
     
    15681635#if( DEBUG_VMM_REMOVE_VSEG & 1 )
    15691636if( DEBUG_VMM_REMOVE_VSEG < cycle )
    1570 printk("\n[%s] thread[%x,%x] unmap vpn %x / ppn %x / %s",
     1637printk("\n[%s] thread[%x,%x] unmap vpn %x / ppn %x / type %s\n",
    15711638__FUNCTION__, this->process->pid, this->trdid, vpn , ppn, vseg_type_str(vseg_type) );
    15721639#endif
     
    16071674cycle = (uint32_t)hal_get_cycles();
    16081675if( DEBUG_VMM_REMOVE_VSEG < cycle )
    1609 printk("[%s] thread[%x,%x] exit / process %x / %s / base %x / cycle %d\n",
     1676printk("\n[%s] thread[%x,%x] exit / process %x / type %s / base %x / cycle %d\n",
    16101677__FUNCTION__, this->process->pid, this->trdid,
    16111678process->pid, vseg_type_str(vseg->type), vseg->min, cycle );
     
    16841751        {
    16851752
    1686 #if( DEBUG_VMM_REMOVE_VSEG & 1 )
     1753#if( DEBUG_VMM_RESIZE_VSEG & 1 )
    16871754if( DEBUG_VMM_RESIZE_VSEG < cycle )
    16881755printk("\n[%s] thread[%x,%x] unmap vpn %x / ppn %x / %s",
     
    21892256#if (CONFIG_INSTRUMENTATION_PGFAULTS || DEBUG_VMM_HANDLE_PAGE_FAULT)
    21902257uint32_t end_cycle = (uint32_t)hal_get_cycles();
     2258uint32_t cost      = end_cycle - start_cycle;
    21912259#endif
    21922260
     
    21992267#if CONFIG_INSTRUMENTATION_PGFAULTS
    22002268this->info.local_pgfault_nr++;
    2201 this->info.local_pgfault_cost += (end_cycle - start_cycle);
     2269this->info.local_pgfault_cost += cost;
     2270if( cost > this->info.local_pgfault_max ) this->info.local_pgfault_max = cost;
    22022271#endif
    22032272            return EXCP_NON_FATAL;
     
    22672336#if (CONFIG_INSTRUMENTATION_PGFAULTS || DEBUG_VMM_HANDLE_PAGE_FAULT)
    22682337uint32_t end_cycle = (uint32_t)hal_get_cycles();
     2338uint32_t cost      = end_cycle - start_cycle;
    22692339#endif
    22702340
     
    22772347#if CONFIG_INSTRUMENTATION_PGFAULTS
    22782348this->info.false_pgfault_nr++;
    2279 this->info.false_pgfault_cost += (end_cycle - start_cycle);
     2349this->info.false_pgfault_cost += cost;
     2350if( cost > this->info.false_pgfault_max ) this->info.false_pgfault_max = cost;
    22802351#endif
    22812352                return EXCP_NON_FATAL;
     
    23322403#if (CONFIG_INSTRUMENTATION_PGFAULTS || DEBUG_VMM_HANDLE_PAGE_FAULT)
    23332404uint32_t end_cycle = (uint32_t)hal_get_cycles();
     2405uint32_t cost      = end_cycle - start_cycle;
    23342406#endif
    23352407
     
    23422414#if CONFIG_INSTRUMENTATION_PGFAULTS
    23432415this->info.global_pgfault_nr++;
    2344 this->info.global_pgfault_cost += (end_cycle - start_cycle);
     2416this->info.global_pgfault_cost += cost;
     2417if( cost > this->info.global_pgfault_max ) this->info.global_pgfault_max = cost;
    23452418#endif
    23462419                return EXCP_NON_FATAL;
     
    23552428#if (CONFIG_INSTRUMENTATION_PGFAULTS || DEBUG_VMM_HANDLE_PAGE_FAULT)
    23562429uint32_t end_cycle = (uint32_t)hal_get_cycles();
     2430uint32_t cost      = end_cycle - start_cycle;
    23572431#endif
    23582432
     
    23652439#if CONFIG_INSTRUMENTATION_PGFAULTS
    23662440this->info.false_pgfault_nr++;
    2367 this->info.false_pgfault_cost += (end_cycle - start_cycle);
     2441this->info.false_pgfault_cost += cost;
     2442if( cost > this->info.false_pgfault_max ) this->info.false_pgfault_max = cost;
    23682443#endif
    23692444        return EXCP_NON_FATAL;
  • trunk/kernel/syscalls/shared_include/shared_almos.h

    r626 r641  
    5858display_type_t;
    5959
     60/*******************************************************************************************
     61 * This structure defines the - user accessible - information stored in a thread.
     62 ******************************************************************************************/
     63
     64typedef struct thread_info_s
     65{
     66        unsigned long      false_pgfault_nr;     /*! number of local page fault               */
     67    unsigned long      false_pgfault_cost;   /*! cumulated cost                           */
     68    unsigned long      false_pgfault_max;    /*! max cost of a local page fault           */
     69
     70        unsigned long      local_pgfault_nr;     /*! number of local page fault               */
     71    unsigned long      local_pgfault_cost;   /*! cumulated cost                           */
     72    unsigned long      local_pgfault_max;    /*! max cost of a false page fault           */
     73
     74        unsigned long      global_pgfault_nr;    /*! number of global page fault              */
     75    unsigned long      global_pgfault_cost;  /*! cumulated cost                           */
     76    unsigned long      global_pgfault_max;   /*! max cost of a global page fault          */
     77
     78        unsigned long long last_cycle;           /*! last cycle counter value (date)          */
     79        unsigned long long usr_cycles;           /*! user execution duration (cycles)         */
     80        unsigned long long sys_cycles;           /*! system execution duration (cycles)       */
     81}
     82thread_info_t;
    6083
    6184#endif /* _SHARED_ALMOS_H_ */
  • trunk/kernel/syscalls/shared_include/syscalls_numbers.h

    r637 r641  
    3131typedef enum
    3232{
    33     SYS_THREAD_EXIT    = 0,
    34     SYS_THREAD_YIELD   = 1,
    35     SYS_THREAD_CREATE  = 2,
    36     SYS_THREAD_JOIN    = 3,
    37     SYS_THREAD_DETACH  = 4,
    38     SYS_THREAD_CANCEL  = 5,
    39     SYS_SEM            = 6,
    40     SYS_CONDVAR        = 7,
    41     SYS_BARRIER        = 8,
    42     SYS_MUTEX          = 9,
     33    SYS_THREAD_EXIT     = 0,
     34    SYS_THREAD_YIELD    = 1,
     35    SYS_THREAD_CREATE   = 2,
     36    SYS_THREAD_JOIN     = 3,
     37    SYS_THREAD_DETACH   = 4,
     38    SYS_THREAD_CANCEL   = 5,
     39    SYS_SEM             = 6,
     40    SYS_CONDVAR         = 7,
     41    SYS_BARRIER         = 8,
     42    SYS_MUTEX           = 9,
    4343
    44     SYS_RENAME         = 10,
    45     SYS_MUNMAP         = 11,
    46     SYS_OPEN           = 12,
    47     SYS_MMAP           = 13,
    48     SYS_READ           = 14,
    49     SYS_WRITE          = 15,
    50     SYS_LSEEK          = 16,
    51     SYS_CLOSE          = 17,
    52     SYS_UNLINK         = 18,
    53     SYS_PIPE           = 19,
     44    SYS_RENAME          = 10,
     45    SYS_MUNMAP          = 11,
     46    SYS_OPEN            = 12,
     47    SYS_MMAP            = 13,
     48    SYS_READ            = 14,
     49    SYS_WRITE           = 15,
     50    SYS_LSEEK           = 16,
     51    SYS_CLOSE           = 17,
     52    SYS_UNLINK          = 18,
     53    SYS_PIPE            = 19,
    5454
    55     SYS_CHDIR          = 20,
    56     SYS_MKDIR          = 21,
    57     SYS_MKFIFO         = 22,
    58     SYS_OPENDIR        = 23,
    59     SYS_READDIR        = 24,
    60     SYS_CLOSEDIR       = 25,
    61     SYS_GETCWD         = 26,
    62     SYS_ISATTY         = 27,
    63     SYS_ALARM          = 28,
    64     SYS_RMDIR          = 29,
     55    SYS_CHDIR           = 20,
     56    SYS_MKDIR           = 21,
     57    SYS_MKFIFO          = 22,
     58    SYS_OPENDIR         = 23,
     59    SYS_READDIR         = 24,
     60    SYS_CLOSEDIR        = 25,
     61    SYS_GETCWD          = 26,
     62    SYS_ISATTY          = 27,
     63    SYS_ALARM           = 28,
     64    SYS_RMDIR           = 29,
    6565
    66     SYS_UTLS           = 30,
    67     SYS_CHMOD          = 31,
    68     SYS_SIGNAL         = 32,
    69     SYS_TIMEOFDAY      = 33,
    70     SYS_KILL           = 34,
    71     SYS_GETPID         = 35,
    72     SYS_FORK           = 36,
    73     SYS_EXEC           = 37,
    74     SYS_STAT           = 38,
    75     SYS_WAIT           = 39,
     66    SYS_UTLS            = 30,
     67    SYS_CHMOD           = 31,
     68    SYS_SIGNAL          = 32,
     69    SYS_TIMEOFDAY       = 33,
     70    SYS_KILL            = 34,
     71    SYS_GETPID          = 35,
     72    SYS_FORK            = 36,
     73    SYS_EXEC            = 37,
     74    SYS_STAT            = 38,
     75    SYS_WAIT            = 39,
    7676
    77     SYS_GET_CONFIG     = 40,
    78     SYS_GET_CORE_ID    = 41,
    79     SYS_GET_CYCLE      = 42,
    80     SYS_DISPLAY        = 43,
    81     SYS_PLACE_FORK     = 44, 
    82     SYS_THREAD_SLEEP   = 45,
    83     SYS_THREAD_WAKEUP  = 46,
    84     SYS_TRACE          = 47,
    85     SYS_FG             = 48,
    86     SYS_IS_FG          = 49,
     77    SYS_GET_CONFIG      = 40,
     78    SYS_GET_CORE_ID     = 41,
     79    SYS_GET_CYCLE       = 42,
     80    SYS_DISPLAY         = 43,
     81    SYS_PLACE_FORK      = 44, 
     82    SYS_THREAD_SLEEP    = 45,
     83    SYS_THREAD_WAKEUP   = 46,
     84    SYS_TRACE           = 47,
     85    SYS_FG              = 48,
     86    SYS_IS_FG           = 49,
    8787
    88     SYS_EXIT           = 50,
    89     SYS_SYNC           = 51,
    90     SYS_FSYNC          = 52,
    91     SYS_GET_BEST_CORE  = 53,
    92     SYS_GET_NB_CORES   = 54,
     88    SYS_EXIT            = 50,
     89    SYS_SYNC            = 51,
     90    SYS_FSYNC           = 52,
     91    SYS_GET_BEST_CORE   = 53,
     92    SYS_GET_NB_CORES    = 54,
     93    SYS_GET_THREAD_INFO = 55,
    9394
    94     SYSCALLS_NR        = 55,
     95    SYSCALLS_NR         = 56,
    9596
    9697} syscalls_t;
  • trunk/kernel/syscalls/sys_munmap.c

    r640 r641  
    5454#if DEBUG_SYS_MUNMAP
    5555if( DEBUG_SYS_MUNMAP < tm_start )
    56 printk("\n[DBG] %s : thread %x enter / process %x / cycle %d\n",
    57 __FUNCTION__ , this, process->pid, (uint32_t)tm_start );
     56printk("\n[%s] thread[%x,%x] enter / cycle %d\n",
     57__FUNCTION__, process->pid, this->trdid, (uint32_t)tm_start );
    5858#endif
    5959
     
    9595                return -1;
    9696    }
    97     else if( (vseg_min == addr_min) && (vseg_min == vseg_max) ) 
     97    else if( (vseg_min == addr_min) && (vseg_max == addr_max) ) 
    9898    {
    9999
    100100#if( DEBUG_SYS_MUNMAP & 1 )
    101 if( DEBUG_SYS_MUNMAP < cycle )
    102 printk("\n[%s] unmapped region[%x->%x[ / vseg[%x->%x[ => vseg deleted\n",
    103 __FUNCTION__, addr_min, addr_max, vseg_min, vseg_max );
     101if( DEBUG_SYS_MUNMAP < tm_start )
     102printk("\n[%s] thread[%x,%x] unmapped region[%x->%x[ / vseg[%x->%x[ => delete vseg\n",
     103__FUNCTION__, process->pid, this->trdid, addr_min, addr_max, vseg_min, vseg_max );
    104104#endif
    105105        // delete existing vseg
     
    107107                                vseg_min );
    108108    }
    109     else if( (vseg_min == addr_min) || (vseg_min == vseg_max) ) 
     109    else if( (vseg_min == addr_min) || (vseg_max == addr_max) ) 
    110110    {
    111111
    112112#if( DEBUG_SYS_MUNMAP & 1 )
    113 if( DEBUG_SYS_MUNMAP < cycle )
    114 printk("\n[%s] unmapped region[%x->%x[ / vseg[%x->%x[ => vseg resized\n",
    115 __FUNCTION__, addr_min, addr_max, vseg_min, vseg_max );
     113if( DEBUG_SYS_MUNMAP < tm_start )
     114printk("\n[%s] thread[%x,%x] unmapped region[%x->%x[ / vseg[%x->%x[ => resize vseg\n",
     115__FUNCTION__, process->pid, this->trdid, addr_min, addr_max, vseg_min, vseg_max );
    116116#endif
    117117        // resize existing vseg
     
    121121                                addr_max - addr_min );
    122122    }
    123     else     //  vseg_min < addr_min) && (addr_max < vseg_max)         
     123    else     //  addr_min > vseg_min) && (addr_max < vseg_max)         
    124124    {
    125125
    126126#if( DEBUG_SYS_MUNMAP & 1 )
    127 if( DEBUG_SYS_MUNMAP < cycle )
    128 printk("\n[%s] unmapped region[%x->%x[ / vseg[%x->%x[ => vseg resized & new vseg created\n",
    129 __FUNCTION__, addr_min, addr_max, vseg_min, vseg_max );
     127if( DEBUG_SYS_MUNMAP < tm_start )
     128printk("\n[%s] thread[%x,%x] unmapped region[%x->%x[ / vseg[%x->%x[ => create new vseg\n",
     129__FUNCTION__, process->pid, this->trdid, addr_min, addr_max, vseg_min, vseg_max );
    130130#endif
    131131        // resize existing vseg
     
    160160#if DEBUG_SYS_MUNMAP
    161161if( DEBUG_SYS_MUNMAP < tm_start )
    162 printk("\n[DBG] %s : thread %x exit / process %x / cycle %d\n",
    163 __FUNCTION__ , this, process->pid, (uint32_t)tm_end );
     162printk("\n[%s] thread [%x,%x] exit / cycle %d\n",
     163__FUNCTION__ , process->pid, this->trdid, (uint32_t)tm_end );
    164164#endif
    165165
  • trunk/kernel/syscalls/syscalls.h

    r640 r641  
    733733                      uint32_t * ncores );
    734734
     735/******************************************************************************************
     736 * [55] This function implements the non-standard "get_thread_info" syscall.
     737 * It copies in the user structure defined by the <info> argument the values registered
     738 * in the calling thread "thread_info_t" kernel structure.
     739 ******************************************************************************************
     740 * @ info      : [out] pointer on thread_info_t structure in user space.
     741 * @ return 0 if success / return -1 if illegal argument.
     742 *****************************************************************************************/
     743int sys_get_thread_info( thread_info_t * info );
     744
    735745#endif  // _SYSCALLS_H_
  • trunk/libs/libalmosmkh/almosmkh.c

    r640 r641  
    279279///////////////    non standard debug functions    ///////////////////////////////////
    280280//////////////////////////////////////////////////////////////////////////////////////
     281
     282///////////////////////////////////////////
     283int get_thread_info( thread_info_t * info )
     284{
     285    return hal_user_syscall( SYS_GET_THREAD_INFO,
     286                             (reg_t)info, 0, 0, 0 );
     287}
    281288
    282289////////////////////////////////////
  • trunk/libs/libalmosmkh/almosmkh.h

    r640 r641  
    148148/***************** Non standard (ALMOS-MKH specific) debug functions ******************/
    149149
     150/***************************************************************************************
     151 * This syscall copies in the user structure defined by the <info> argument the values
     152 * registered in the calling thread "thread_info_t" kernel structure.
     153 ******************************************************************************************
     154 * @ info    : [out] pointer on thread_info_t structure in user space.
     155 * @ return 0 if success / return -1 if illegal argument.
     156 *****************************************************************************************/
     157int get_thread_info( thread_info_t * info );
    150158
    151159/***************************************************************************************
  • trunk/params-hard.mk

    r640 r641  
    22
    33ARCH      = /Users/alain/soc/tsar-trunk-svn-2013/platforms/tsar_generic_iob
    4 X_SIZE    = 1
     4X_SIZE    = 4
    55Y_SIZE    = 2
    6 NB_PROCS  = 1
     6NB_PROCS  = 4
    77NB_TTYS   = 2
    88IOC_TYPE  = IOC_BDV
  • trunk/user/fft/fft.c

    r640 r641  
    9292// parameters
    9393
    94 #define DEFAULT_M               14              // 16384 data points
     94#define DEFAULT_M               16              // 16384 data points
    9595#define USE_DQT_BARRIER         1               // use DDT barrier if non zero
    9696#define MODE                    COSIN           // DATA array initialisation mode
     
    135135
    136136// instrumentation counters
     137unsigned int   pgfault_nr[THREADS_MAX];    // total number of page faults (per thread)
     138unsigned int   pgfault_cost[THREADS_MAX];  // total page faults cost (per thread)
     139unsigned int   pgfault_max[THREADS_MAX];   // max page faults cost (per thread)
    137140unsigned int   parallel_time[THREADS_MAX]; // total computation time (per thread)
    138141unsigned int   sync_time[THREADS_MAX];     // cumulated waiting time in barriers (per thread)
     
    458461    }
    459462
    460     // get instrumentation results for each thread
     463    // initializes global (all threads) instrumentation values
     464    unsigned int time_para      = parallel_time[0];
     465    unsigned int time_sync      = sync_time[0];
     466    unsigned int pgfaults_nr    = 0;
     467    unsigned int pgfaults_cost  = 0;
     468    unsigned int pgfaults_max   = pgfault_max[0];
     469
     470    // loop on threads to compute global instrumentation results
    461471    for (tid = 0 ; tid < nthreads ; tid++)
    462472    {
    463         snprintf( string , 256 , "- tid %d : Sequencial %d / Parallel %d / Barrier %d\n",
    464         tid, init_time, parallel_time[tid], sync_time[tid] );
     473        snprintf( string , 256 ,
     474        "- tid %d : Seq %d / Para %d / Sync %d / Pgfaults %d ( cost %d / max %d )\n",
     475        tid, init_time, parallel_time[tid], sync_time[tid],
     476        pgfault_nr[tid], (pgfault_cost[tid] / pgfault_nr[tid]) , pgfault_max[tid] );
    465477
    466478        // save  to instrumentation file
     
    468480        if( ret < 0 )
    469481        {
    470             printf("\n[fft error] cannot write thread %d to file <%s>\n", tid, path );
     482            printf("\n[fft error] cannot save thread %d results to file <%s>\n", tid, path );
    471483            printf("%s", string );
    472484            exit(0);
    473485        }
    474     }
    475 
    476     // compute min/max values
    477     unsigned int min_para = parallel_time[0];
    478     unsigned int max_para = parallel_time[0];
    479     unsigned int min_sync = sync_time[0];
    480     unsigned int max_sync = sync_time[0];
    481 
    482     for (tid = 0 ; tid < nthreads ; tid++)
    483     {
    484         if (parallel_time[tid] > max_para)  max_para = parallel_time[tid];
    485         if (parallel_time[tid] < min_para)  min_para = parallel_time[tid];
    486         if (sync_time[tid]     > max_sync)  max_sync = sync_time[tid];
    487         if (sync_time[tid]     < min_sync)  min_sync = sync_time[tid];
    488     }
    489 
    490     // display MIN/MAX values on terminal and save to file
    491     snprintf( string , 256 , "\n      Sequencial  Parallel       Barrier\n"
    492                              "MIN : %d\t | %d\t | %d\t   (cycles)\n"
    493                              "MAX : %d\t | %d\t | %d\t   (cycles)\n",
    494                              (int)init_time, (int)min_para, (int)min_sync,
    495                              (int)init_time, (int)max_para, (int)max_sync );
     486
     487        // compute global values
     488        if (parallel_time[tid] > time_para)    time_para      = parallel_time[tid];
     489        if (sync_time[tid]     > time_sync)    time_sync      = sync_time[tid];
     490                                               pgfaults_nr   += pgfault_nr[tid];
     491                                               pgfaults_cost += pgfault_cost[tid];
     492        if (pgfault_max[tid]   > pgfaults_max) pgfaults_max   = pgfault_max[tid];
     493    }
     494
     495    // display global values on terminal and save to file
     496    snprintf( string , 256 ,
     497    "\nSeq %d / Para %d / Sync %d / Pgfaults %d ( cost %d / max %d )\n",
     498    init_time, time_para, time_sync, pgfaults_nr, (pgfaults_cost / pgfaults_nr), pgfaults_max );
     499
    496500    printf("%s", string );
     501
     502    // save global values to file
    497503    ret = fprintf( f , "%s", string );
     504
    498505    if( ret < 0 )
    499506    {
    500         printf("\n[fft error] cannot write MIN/MAX to file <%s>\n", path );
     507        printf("\n[fft error] cannot save global results to file <%s>\n", path );
     508        exit(0);
     509    }
     510
     511    // close instrumentation file
     512    ret = fclose( f );
     513
     514    if( ret < 0 )
     515    {
     516        printf("\n[fft error] cannot close file <%s>\n", path );
    501517        exit(0);
    502518    }
     
    504520#if DEBUG_MAIN
    505521get_cycle( &debug_cycle );
    506 printf("\n[fft] main close file <%s> at cycle %d\n",
     522printf("\n[fft] main exit <%s> at cycle %d\n",
    507523path, (unsigned int)debug_cycle );
    508524#endif
     
    645661    get_cycle( &parallel_stop );
    646662
    647     // register parallel time
     663    // register parallel time in instrumentation counters
    648664    parallel_time[tid] = (unsigned int)(parallel_stop - parallel_start);
    649665
     666    // get work thread info for page faults
     667    thread_info_t info;
     668    get_thread_info( &info );
     669   
     670    // register page faults in instrumentation counters
     671    pgfault_nr[tid]   = info.false_pgfault_nr +
     672                        info.local_pgfault_nr +
     673                        info.global_pgfault_nr;
     674    pgfault_cost[tid] = info.false_pgfault_cost +
     675                        info.local_pgfault_cost +
     676                        info.global_pgfault_cost;
     677    pgfault_max[tid]  = info.false_pgfault_max +
     678                        info.local_pgfault_max +
     679                        info.global_pgfault_max;
    650680#if DEBUG_WORK
    651681printf("\n[fft] %s : thread %d completes fft / p_start %d / p_stop %d\n",
  • trunk/user/ksh/ksh.c

    r640 r641  
    123123
    124124#if DEBUG_CMD_CAT
    125 snprintf( string , 128 , "[ksh] enter %s" , __FUNCTION__);
     125snprintf( string , 128 , "[ksh] %s enters" , __FUNCTION__);
    126126display_string( string );
    127127#endif
     
    138138
    139139#if DEBUG_CMD_CAT
    140 snprintf( string , 128 , "[ksh] in %s : after strcpy" , __FUNCTION__ );
     140snprintf( string , 128 , "[ksh] %s : after strcpy" , __FUNCTION__ );
    141141display_string( string );
    142142#endif
     
    180180
    181181#if DEBUG_CMD_CAT
    182 snprintf( string , 128 , "[ksh] %s : size = %d", __FUNCTION__, size );
     182snprintf( string , 128 , "[ksh] %s : size = %d",
     183__FUNCTION__, size );
    183184display_string( string );
    184185#endif
     
    206207
    207208#if DEBUG_CMD_CAT
    208 snprintf( string , 128 , "[ksh] %s : maped file %d to buffer %x", __FUNCTION__, fd , buf );
     209snprintf( string , 128 , "[ksh] %s : mapped file %d to buffer %x",
     210__FUNCTION__, fd , buf );
    209211display_string( string );
    210212#endif
     
    213215    write( 1 , buf , size );
    214216
    215     // unmap te file
     217    // unmap the file
    216218    if( munmap( buf , size ) )
    217219    {
     
    220222
    221223#if DEBUG_CMD_CAT
    222 snprintf( string , 128 , "[ksh] %s : unmaped file %d from buffer %x", __FUNCTION__, fd , buf );
     224snprintf( string , 128 , "[ksh] %s : unmapped file %d from buffer %x",
     225__FUNCTION__, fd , buf );
    223226display_string( string );
    224227#endif
     
    852855
    853856#if DEBUG_CMD_LS
    854 snprintf( string , 128 , "[ksh] %s : directory <%s> open / DIR %x\n",
     857snprintf( string , 128 , "[ksh] %s : directory <%s> open / DIR %x",
    855858__FUNCTION__, pathname , dir );
    856859display_string( string );
     
    875878
    876879#if DEBUG_CMD_LS
    877 snprintf( string , 128 , "[ksh] %s : directory <%s> closed\n",
     880snprintf( string , 128 , "[ksh] %s : directory <%s> closed",
    878881__FUNCTION__, pathname );
    879882display_string( string );
     
    10201023    sem_post( &semaphore );
    10211024
    1022 }  // end_cmd_rm()
     1025}  // end cmd_rm()
     1026
     1027///////////////////////////////////////////////
     1028static void cmd_stat( int argc , char **argv )
     1029{
     1030    struct stat    st;
     1031    unsigned int   size;
     1032
     1033        if (argc != 2)
     1034    {
     1035                printf("  usage: %s pathname\n", argv[0]);
     1036        }
     1037    else
     1038    {
     1039            strcpy( pathname , argv[1] );
     1040
     1041        if ( stat( pathname , &st ) )
     1042        {
     1043                    printf("  error: cannot stat <%s>\n", argv[2] );
     1044                }
     1045        else
     1046        {
     1047            // get file size
     1048            size = st.st_size;
     1049
     1050            // print file stat info
     1051            printf("   <%s> : %d bytes\n", pathname, size );
     1052        }
     1053        }
     1054
     1055    // release semaphore to get next command
     1056    sem_post( &semaphore );
     1057
     1058}  // end cmd_stat()
    10231059
    10241060///////////////////////////////////////////////
     
    11031139        { "rm",      "remove a file from file system",                  cmd_rm      },
    11041140        { "rmdir",   "remove a directory from file system",             cmd_rmdir   },
     1141        { "stat",    "print infos on a given file",                     cmd_stat    },
    11051142        { "trace",   "activate trace for a given core",                 cmd_trace   },
    11061143        { "untrace", "desactivate trace for a given core",              cmd_untrace },
     
    11491186
    11501187#if DEBUG_EXECUTE
    1151 snprintf( string , 128 , "\n[ksh] in %s : argc = %d / arg0 = %s / arg1 = %s\n",
     1188snprintf( string , 128 , "\n[ksh] in %s : argc = %d / arg0 = %s / arg1 = %s",
    11521189__FUNCTION__ , argc , argv[0], argv[1] );
    11531190#endif
     
    11871224        char           cmd[CMD_MAX_SIZE];               // buffer for one command
    11881225
    1189 /* 1. first direct command
     1226
     1227
     1228// 1. first direct command
    11901229if( sem_wait( &semaphore ) )
    11911230{
     
    11951234else
    11961235{
    1197     printf("\n[ksh] load bin/user/sort.elf\n");
     1236    strcpy( cmd , "load bin/user/fft.elf" );
     1237    printf("[ksh] %s\n", cmd );
     1238    execute( cmd );
    11981239}
    1199 
    1200 strcpy( cmd , "load bin/user/sort.elf" );
    1201 execute( cmd );
    1202 */
    1203 
    1204 
    1205 
    1206 // 2. second direct command
     1240//
     1241
     1242
     1243
     1244/* 2. second direct command
    12071245if( sem_wait( &semaphore ) )
    12081246{
     
    12121250else
    12131251{
    1214     printf("\n[ksh] load bin/user/fft.elf\n");
     1252    strcpy( cmd , "cat home/p_fft_dqt_16384_1_2" );
     1253    printf("[ksh] %s\n", cmd );
     1254    execute( cmd );
    12151255}
    1216 
    1217 strcpy( cmd , "load bin/user/fft.elf" );
    1218 execute( cmd );
    1219 //
    1220 
     1256*/
    12211257
    12221258
     
    12531289        {
    12541290            // initialize command buffer
    1255             // memset( cmd , 0x20 , sizeof(cmd) );   // TODO useful ?
    12561291            count       = 0;
    12571292            state       = NORMAL;
     
    14591494
    14601495#if DEBUG_MAIN
    1461 snprintf( string , 128 , "\n[ksh] main thread started on core[%x,%d]\n", cxy , lid );
     1496snprintf( string , 128 , "\n[ksh] main thread started on core[%x,%d]", cxy , lid );
    14621497display_string( string );
    14631498#endif
     
    14711506
    14721507#if DEBUG_MAIN
    1473 snprintf( string , 128 , "\n[ksh] main initialized semaphore\n" );
     1508snprintf( string , 128 , "\n[ksh] main initialized semaphore" );
    14741509display_string( string );
    14751510#endif
     
    14851520                    NULL );
    14861521#if DEBUG_MAIN
    1487 snprintf( string , 128 , "\n[ksh] main thread launched interactive thread %x\n", trdid );
     1522snprintf( string , 128 , "\n[ksh] main thread launched interactive thread %x", trdid );
    14881523display_string( string );
    14891524#endif
Note: See TracChangeset for help on using the changeset viewer.