Changeset 641 for trunk/kernel/kern


Ignore:
Timestamp:
Oct 10, 2019, 1:42:04 PM (5 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/kernel/kern
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.