Changeset 635 for trunk/kernel/kern


Ignore:
Timestamp:
Jun 26, 2019, 11:42:37 AM (5 years ago)
Author:
alain
Message:

This version is a major evolution: The physical memory allocators,
defined in the kmem.c, ppm.c, and kcm.c files have been modified
to support remote accesses. The RPCs that were previously user
to allocate physical memory in a remote cluster have been removed.
This has been done to cure a dead-lock in case of concurrent page-faults.

This version 2.2 has been tested on a (4 clusters / 2 cores per cluster)
TSAR architecture, for both the "sort" and the "fft" applications.

Location:
trunk/kernel/kern
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/kern/chdev.c

    r625 r635  
    9090
    9191    // allocate memory for chdev
    92     req.type   = KMEM_DEVICE;
    93     req.flags  = AF_ZERO;
    94     chdev      = (chdev_t *)kmem_alloc( &req );
     92    req.type   = KMEM_KCM;
     93    req.order  = bits_log2( sizeof(chdev_t) );
     94    req.flags  = AF_ZERO | AF_KERNEL;
     95    chdev      = kmem_alloc( &req );
    9596
    9697    if( chdev == NULL ) return NULL;
  • trunk/kernel/kern/cluster.c

    r627 r635  
    44 * Author  Ghassan Almaless (2008,2009,2010,2011,2012)
    55 *         Mohamed Lamine Karaoui (2015)
    6  *         Alain Greiner (2016,2017,2018)
     6 *         Alain Greiner (2016,2017,2018,2019)
    77 *
    88 * Copyright (c) UPMC Sorbonne Universites
     
    109109        cluster_t * cluster = LOCAL_CLUSTER;
    110110
    111     // initialize the lock protecting the embedded kcm allocator
    112         busylock_init( &cluster->kcm_lock , LOCK_CLUSTER_KCM );
    113 
    114111#if DEBUG_CLUSTER_INIT
    115112uint32_t   cycle = (uint32_t)hal_get_cycles();
     
    148145
    149146    // initialises embedded KCM
    150         kcm_init( &cluster->kcm , KMEM_KCM );
     147    uint32_t  i;
     148    for( i = 0 ; i < 6 ; i++ ) kcm_init( &cluster->kcm[i] , i+6 );
    151149
    152150#if( DEBUG_CLUSTER_INIT & 1 )
    153151cycle = (uint32_t)hal_get_cycles();
    154152if( DEBUG_CLUSTER_INIT < cycle )
    155 printk("\n[%s] KCM initialized in cluster %x at cycle %d\n",
     153printk("\n[%s] KCM[6:11] initialized in cluster %x at cycle %d\n",
    156154__FUNCTION__ , local_cxy , hal_get_cycles() );
    157155#endif
  • trunk/kernel/kern/cluster.h

    r611 r635  
    126126    ppm_t           ppm;               /*! embedded kernel page manager                   */
    127127    khm_t           khm;               /*! embedded kernel heap manager                   */
    128     kcm_t           kcm;               /*! embedded kernel KCMs manager                   */
    129 
    130     kcm_t         * kcm_tbl[KMEM_TYPES_NR];              /*! pointers on allocated KCMs   */
    131     busylock_t      kcm_lock;                            /*! protect kcm_tbl[] updates    */
     128    kcm_t           kcm[6];            /*! embedded kernel cache managers [6:11]          */
    132129
    133130    // RPC
  • trunk/kernel/kern/kernel_init.c

    r633 r635  
    251251           "\n\n\t\t Advanced Locality Management Operating System / Multi Kernel Hybrid\n"
    252252           "\n\n\t\t %s / %d cluster(s) / %d core(s) per cluster\n\n",
    253            CONFIG_ALMOS_VERSION , nclusters , ncores );
     253           CONFIG_VERSION , nclusters , ncores );
    254254}
    255255
     
    14281428    }
    14291429
    1430 #if( DEBUG_KERNEL_INIT & 1 )
     1430#if CONFIG_INSTRUMENTATION_FOOTPRINT
    14311431if( (core_lid ==  0) & (local_cxy == 0) )
    14321432printk("\n\n***** memory fooprint for main kernel objects\n\n"
     
    14391439                   " - rpc fifo           : %d bytes\n"
    14401440                   " - page descriptor    : %d bytes\n"
    1441                    " - mapper root        : %d bytes\n"
     1441                   " - mapper descriptor  : %d bytes\n"
     1442                   " - vseg descriptor    : %d bytes\n"
    14421443                   " - ppm manager        : %d bytes\n"
    14431444                   " - kcm manager        : %d bytes\n"
     
    14451446                   " - vmm manager        : %d bytes\n"
    14461447                   " - gpt root           : %d bytes\n"
     1448                   " - vfs inode          : %d bytes\n"
     1449                   " - vfs dentry         : %d bytes\n"
     1450                   " - vfs file           : %d bytes\n"
     1451                   " - vfs context        : %d bytes\n"
     1452                   " - xhtab root         : %d bytes\n"
    14471453                   " - list item          : %d bytes\n"
    14481454                   " - xlist item         : %d bytes\n"
     
    14621468                   sizeof( page_t             ),
    14631469                   sizeof( mapper_t           ),
     1470                   sizeof( vseg_t             ),
    14641471                   sizeof( ppm_t              ),
    14651472                   sizeof( kcm_t              ),
     
    14671474                   sizeof( vmm_t              ),
    14681475                   sizeof( gpt_t              ),
     1476                   sizeof( vfs_inode_t        ),
     1477                   sizeof( vfs_dentry_t       ),
     1478                   sizeof( vfs_file_t         ),
     1479                   sizeof( vfs_ctx_t          ),
     1480                   sizeof( xhtab_t            ),
    14691481                   sizeof( list_entry_t       ),
    14701482                   sizeof( xlist_entry_t      ),
     
    14861498    /////////////////////////////////////////////////////////////////////////////////
    14871499
    1488 #if( DEBUG_KERNEL_INIT & 1 )
     1500#if DEBUG_KERNEL_INIT
    14891501thread_t * this = CURRENT_THREAD;
    14901502printk("\n[%s] : thread[%x,%x] on core[%x,%d] jumps to thread_idle_func() / cycle %d\n",
  • trunk/kernel/kern/process.c

    r633 r635  
    7272process_t * process_alloc( void )
    7373{
    74         kmem_req_t   req;
    75 
    76     req.type  = KMEM_PROCESS;
    77         req.size  = sizeof(process_t);
     74        kmem_req_t req;
     75
     76    req.type  = KMEM_KCM;
     77        req.order = bits_log2( sizeof(process_t) );
    7878        req.flags = AF_KERNEL;
    7979
    80     return (process_t *)kmem_alloc( &req );
     80    return kmem_alloc( &req );
    8181}
    8282
     
    8686    kmem_req_t  req;
    8787
    88         req.type = KMEM_PROCESS;
     88        req.type = KMEM_KCM;
    8989        req.ptr  = process;
    9090        kmem_free( &req );
     
    166166#endif
    167167
    168     // initialize VSL locks
     168    // initialize VSL lock
    169169        remote_rwlock_init( XPTR( local_cxy , &vmm->vsl_lock ) , LOCK_VMM_VSL );
    170170
    171     // register kernel vsegs in VMM as required by the architecture
     171    // register kernel vsegs in user process VMM as required by the architecture
    172172    error = hal_vmm_kernel_update( process );
    173173    if( error )
     
    179179#if (DEBUG_PROCESS_REFERENCE_INIT & 1)
    180180if( DEBUG_PROCESS_REFERENCE_INIT < cycle )
    181 printk("\n[%s] thread[%x,%x] registered kernel vsegs for process %x\n",
     181printk("\n[%s] thread[%x,%x] registered kernel vsegs in VSL for process %x\n",
    182182__FUNCTION__, parent_pid, this->trdid, pid );
    183183#endif
     
    374374printk("\n[%s] thread[%x,%x] exit for process %x / cycle %d\n",
    375375__FUNCTION__, parent_pid, this->trdid, pid, cycle );
     376#endif
     377
     378#if (DEBUG_PROCESS_REFERENCE_INIT & 1)
     379hal_vmm_display( parent_xp , false );
     380hal_vmm_display( XPTR( local_cxy , process ) , false );
    376381#endif
    377382
     
    10881093    }
    10891094}
     1095
    10901096////////////////////////////////////////////////////
    10911097error_t process_fd_register( xptr_t      process_xp,
     
    13561362
    13571363#if DEBUG_PROCESS_MAKE_FORK
    1358 uint32_t cycle   = (uint32_t)hal_get_cycles();
     1364uint32_t   cycle;
    13591365thread_t * this  = CURRENT_THREAD;
    13601366trdid_t    trdid = this->trdid;
    13611367pid_t      pid   = this->process->pid;
     1368#endif
     1369
     1370#if( DEBUG_PROCESS_MAKE_FORK & 1 )
     1371cycle   = (uint32_t)hal_get_cycles();
    13621372if( DEBUG_PROCESS_MAKE_FORK < cycle )
    13631373printk("\n[%s] thread[%x,%x] enter / cluster %x / cycle %d\n",
     
    13671377    // allocate a process descriptor
    13681378    process = process_alloc();
     1379
    13691380    if( process == NULL )
    13701381    {
     
    14271438printk("\n[%s] thread[%x,%x] copied VMM from parent to child / cycle %d\n",
    14281439__FUNCTION__, pid, trdid, cycle );
     1440hal_vmm_display( XPTR( local_cxy , process ) , true );
    14291441#endif
    14301442
     
    14381450cycle = (uint32_t)hal_get_cycles();
    14391451if( DEBUG_PROCESS_MAKE_FORK < cycle )
    1440 printk("\n[%s] thread[%x,%x] / child takes TXT ownership / cycle %d\n",
    1441 __FUNCTION__ , pid, trdid, cycle );
     1452printk("\n[%s] thread[%x,%x] / child_process %x takes TXT ownership / cycle %d\n",
     1453__FUNCTION__ , pid, trdid, new_pid, cycle );
    14421454#endif
    14431455
     
    14711483#endif
    14721484
    1473     // set COW flag in DATA, ANON, REMOTE vsegs for parent process VMM
     1485    // set COW flag in DATA, ANON, REMOTE vsegs in parent process VMM
    14741486    // this includes all parent process copies in all clusters
    14751487    if( parent_process_cxy == local_cxy )   // reference is local
     
    14891501cycle = (uint32_t)hal_get_cycles();
    14901502if( DEBUG_PROCESS_MAKE_FORK < cycle )
    1491 printk("\n[%s] thread[%x,%x] set COW in parent and child / cycle %d\n",
     1503printk("\n[%s] thread[%x,%x] set COW in DATA / ANON / REMOTE for parent and child / cycle %d\n",
    14921504__FUNCTION__, pid, trdid, cycle );
    14931505#endif
     
    15461558#if DEBUG_PROCESS_MAKE_EXEC
    15471559uint32_t cycle = (uint32_t)hal_get_cycles();
    1548 if( local_cxy == 0x11 )
     1560if( DEBUG_PROCESS_MAKE_EXEC < cycle )
    15491561printk("\n[%s] thread[%x,%x] enters for %s / cycle %d\n",
    15501562__FUNCTION__, pid, thread->trdid, path, cycle );
     
    15691581#if (DEBUG_PROCESS_MAKE_EXEC & 1)
    15701582cycle = (uint32_t)hal_get_cycles();
    1571 if( local_cxy == 0x11 )
     1583if( DEBUG_PROCESS_MAKE_EXEC < cycle )
    15721584printk("\n[%s] thread[%x,%x] opened file <%s> / cycle %d\n",
    15731585__FUNCTION__, pid, thread->trdid, path, cycle );
     
    15791591#if (DEBUG_PROCESS_MAKE_EXEC & 1)
    15801592cycle = (uint32_t)hal_get_cycles();
    1581 if( local_cxy == 0x11 )
     1593if( DEBUG_PROCESS_MAKE_EXEC < cycle )
    15821594printk("\n[%s] thread[%x,%x] deleted existing threads / cycle %d\n",
    15831595__FUNCTION__, pid, thread->trdid, cycle );
     
    15891601#if( DEBUG_PROCESS_MAKE_EXEC & 1 )
    15901602cycle = (uint32_t)hal_get_cycles();
    1591 if( local_cxy == 0x11 )
     1603if( DEBUG_PROCESS_MAKE_EXEC < cycle )
    15921604printk("\n[%s] thread[%x,%x] completed VMM reset / cycle %d\n",
    15931605__FUNCTION__, pid, thread->trdid, cycle );
     
    16061618#if( DEBUG_PROCESS_MAKE_EXEC & 1 )
    16071619cycle = (uint32_t)hal_get_cycles();
    1608 if( local_cxy == 0x11 )
     1620if( DEBUG_PROCESS_MAKE_EXEC < cycle )
    16091621printk("\n[%s] thread[%x,%x] registered args/envs vsegs / cycle %d\n",
    16101622__FUNCTION__, pid, thread->trdid, cycle );
     
    16241636#if( DEBUG_PROCESS_MAKE_EXEC & 1 )
    16251637cycle = (uint32_t)hal_get_cycles();
    1626 if( local_cxy == 0x11 )
     1638if( DEBUG_PROCESS_MAKE_EXEC < cycle )
    16271639printk("\n[%s] thread[%x,%x] registered code/data vsegs / cycle %d\n",
    16281640__FUNCTION__, pid, thread->trdid, cycle );
     
    16741686        hal_core_sleep();
    16751687    }
     1688
     1689#if (DEBUG_PROCESS_ZERO_CREATE & 1)
     1690if( DEBUG_PROCESS_ZERO_CREATE < cycle )
     1691printk("\n[%s] allocated pid %x in cluster %x\n", __FUNCTION__, pid, local_cxy );
     1692#endif
    16761693
    16771694    // initialize PID, REF_XP, PARENT_XP, and STATE
     
    16841701    process->term_state = 0;
    16851702
    1686     // initilise VSL as empty
     1703    // initialize VSL as empty
    16871704    vmm->vsegs_nr = 0;
    16881705        xlist_root_init( XPTR( local_cxy , &vmm->vsegs_root ) );
    16891706
    1690     // initialise GPT as empty
     1707#if (DEBUG_PROCESS_ZERO_CREATE & 1)
     1708if( DEBUG_PROCESS_ZERO_CREATE < cycle )
     1709printk("\n[%s] initialized VSL empty in cluster %x\n", __FUNCTION__, local_cxy );
     1710#endif
     1711
     1712    // initialize GPT as empty
    16911713    error = hal_gpt_create( &vmm->gpt );
     1714
    16921715    if( error )
    16931716    {
     
    16951718        hal_core_sleep();
    16961719    }
     1720
     1721#if (DEBUG_PROCESS_ZERO_CREATE & 1)
     1722if( DEBUG_PROCESS_ZERO_CREATE < cycle )
     1723printk("\n[%s] initialized GPT empty in cluster %x\n", __FUNCTION__, local_cxy );
     1724#endif
    16971725
    16981726    // initialize VSL and GPT locks
     
    17011729    // create kernel vsegs in GPT and VSL, as required by the hardware architecture
    17021730    error = hal_vmm_kernel_init( info );
     1731
    17031732    if( error )
    17041733    {
     
    17061735        hal_core_sleep();
    17071736    }
     1737
     1738#if (DEBUG_PROCESS_ZERO_CREATE & 1)
     1739if( DEBUG_PROCESS_ZERO_CREATE < cycle )
     1740printk("\n[%s] initialized hal specific VMM in cluster%x\n", __FUNCTION__, local_cxy );
     1741#endif
    17081742
    17091743    // reset th_tbl[] array and associated fields
     
    17161750    rwlock_init( &process->th_lock , LOCK_PROCESS_THTBL );
    17171751
     1752#if (DEBUG_PROCESS_ZERO_CREATE & 1)
     1753if( DEBUG_PROCESS_ZERO_CREATE < cycle )
     1754printk("\n[%s] initialized th_tbl[] in cluster%x\n", __FUNCTION__, local_cxy );
     1755#endif
    17181756
    17191757    // reset children list as empty
     
    17221760    remote_queuelock_init( XPTR( local_cxy , &process->children_lock ),
    17231761                           LOCK_PROCESS_CHILDREN );
     1762
     1763#if (DEBUG_PROCESS_ZERO_CREATE & 1)
     1764if( DEBUG_PROCESS_ZERO_CREATE < cycle )
     1765printk("\n[%s] initialized children list in cluster%x\n", __FUNCTION__, local_cxy );
     1766#endif
    17241767
    17251768    // register kernel process in cluster manager local_list
     
    17591802    // allocates memory for process descriptor from local cluster
    17601803        process = process_alloc();
     1804
     1805
    17611806    if( process == NULL )
    17621807    {
     
    18401885
    18411886#if (DEBUG_PROCESS_INIT_CREATE & 1)
    1842 hal_vmm_display( process , true );
     1887hal_vmm_display( XPTR( local_cxy , process ) , true );
    18431888#endif
    18441889
  • trunk/kernel/kern/process.h

    r625 r635  
    44 * Authors  Ghassan Almaless (2008,2009,2010,2011,2012)
    55 *          Mohamed Lamine Karaoui (2015)
    6  *          Alain Greiner (2016,2017,2018)
     6 *          Alain Greiner (2016,2017,2018,2019)
    77 *
    88 * Copyright (c) UPMC Sorbonne Universites
     
    231231 * descriptor, defined by the <parent_xp> argument. The <process> and <pid> arguments
    232232 * are previously allocated by the caller. This function can be called by two functions:
    233  * 1) process_init_create() : process is the INIT process, and parent is process-zero.
    234  * 2) process_make_fork() : the parent process descriptor is generally remote.
     233 * - process_init_create() : process is the INIT process, and parent is process-zero.
     234 * -  process_make_fork()  : the parent process descriptor is generally remote.
    235235 * The following fields are initialised :
    236236 * - It set the pid / ppid / ref_xp / parent_xp / state fields.
  • trunk/kernel/kern/rpc.c

    r632 r635  
    7575    &rpc_vmm_get_vseg_server,              // 20
    7676    &rpc_vmm_global_update_pte_server,     // 21
    77     &rpc_kcm_alloc_server,                 // 22
    78     &rpc_kcm_free_server,                  // 23
     77    &rpc_undefined,                        // 22
     78    &rpc_undefined,                        // 23
    7979    &rpc_mapper_sync_server,               // 24
    80     &rpc_mapper_handle_miss_server,        // 25
     80    &rpc_undefined,                        // 25
    8181    &rpc_vmm_delete_vseg_server,           // 26
    8282    &rpc_vmm_create_vseg_server,           // 27
    8383    &rpc_vmm_set_cow_server,               // 28
    84     &rpc_hal_vmm_display_server,           // 29
     84    &rpc_undefined,                        // 29
    8585};
    8686
     
    111111    "GET_VSEG",                  // 20
    112112    "GLOBAL_UPDATE_PTE",         // 21
    113     "KCM_ALLOC",                 // 22
    114     "KCM_FREE",                  // 23
     113    "undefined_22",              // 22
     114    "undefined_23",              // 23
    115115    "MAPPER_SYNC",               // 24
    116     "MAPPER_HANDLE_MISS",        // 25
     116    "undefined_25",              // 25
    117117    "VMM_DELETE_VSEG",           // 26
    118118    "VMM_CREATE_VSEG",           // 27
    119119    "VMM_SET_COW",               // 28
    120     "VMM_DISPLAY",               // 29
     120    "undefined_29",              // 29
    121121};
    122122
     
    557557    // release memory to local pmem
    558558    kmem_req_t req;
    559     req.type = KMEM_PAGE;
     559    req.type = KMEM_PPM;
    560560    req.ptr  = page;
    561561    kmem_free( &req );
     
    22312231/////////////////////////////////////////////////////////////////////////////////////////
    22322232
     2233/*
    22332234//////////////////////////////////////////
    22342235void rpc_kcm_alloc_client( cxy_t      cxy,
     
    23042305#endif
    23052306}   
     2307*/
    23062308
    23072309/////////////////////////////////////////////////////////////////////////////////////////
     
    23092311/////////////////////////////////////////////////////////////////////////////////////////
    23102312
     2313/*
    23112314/////////////////////////////////////////
    23122315void rpc_kcm_free_client( cxy_t      cxy,
     
    23772380#endif
    23782381}   
    2379 
    2380 /////////////////////////////////////////////////////////////////////////////////////////
    2381 // [25]          Marshaling functions attached to RPC_MAPPER_SYNC
     2382*/
     2383
     2384/////////////////////////////////////////////////////////////////////////////////////////
     2385// [24]          Marshaling functions attached to RPC_MAPPER_SYNC
    23822386/////////////////////////////////////////////////////////////////////////////////////////
    23832387
     
    24592463/////////////////////////////////////////////////////////////////////////////////////////
    24602464
     2465/*
    24612466//////////////////////////////////////////////////////////
    24622467void rpc_mapper_handle_miss_client( cxy_t             cxy,
     
    25412546#endif
    25422547}
     2548*/
    25432549
    25442550/////////////////////////////////////////////////////////////////////////////////////////
     
    27842790
    27852791/////////////////////////////////////////////////////////////////////////////////////////
    2786 // [29]          Marshaling functions attached to RPC_VMM_DISPLAY
    2787 /////////////////////////////////////////////////////////////////////////////////////////
    2788 
     2792// [29]      RPC_VMM_DISPLAY deprecated [AG] June 2019
     2793/////////////////////////////////////////////////////////////////////////////////////////
     2794
     2795/*
    27892796/////////////////////////////////////////////
    27902797void rpc_hal_vmm_display_client( cxy_t       cxy,
     
    28562863}
    28572864
    2858 
     2865*/
  • trunk/kernel/kern/rpc.h

    r632 r635  
    6060typedef enum
    6161{
    62     RPC_UNDEFINED_0               = 0,   // RPC_PMEM_GET_PAGES     deprecated [AG]
    63     RPC_UNDEFINED_1               = 1,   // RPC_PMEM_RELEASE_PAGES deprecated [AG]
    64     RPC_UNDEFINED_2               = 2,   // RPC_PMEM_DISPLAY       deprecated [AG]     
     62    RPC_UNDEFINED_0               = 0,   // RPC_PMEM_GET_PAGES       deprecated [AG]
     63    RPC_UNDEFINED_1               = 1,   // RPC_PMEM_RELEASE_PAGES   deprecated [AG]
     64    RPC_UNDEFINED_2               = 2,   // RPC_PMEM_DISPLAY         deprecated [AG]     
    6565    RPC_PROCESS_MAKE_FORK         = 3,
    6666    RPC_USER_DIR_CREATE           = 4,
     
    8484    RPC_VMM_GET_VSEG              = 20,
    8585    RPC_VMM_GLOBAL_UPDATE_PTE     = 21,
    86     RPC_KCM_ALLOC                 = 22,
    87     RPC_KCM_FREE                  = 23,
     86    RPC_UNDEFINED_22              = 22,   // RPC_KCM_ALLOC           deprecated [AG]
     87    RPC_UNDEFINED_23              = 23,   // RPC_KCM_FREE            deprecated [AG]
    8888    RPC_MAPPER_SYNC               = 24,
    89     RPC_MAPPER_HANDLE_MISS        = 25,
     89    RPC_UNDEFUNED_25              = 25,   // RPC_MAPPER_HANDLE_MISS  deprecated [AG]
    9090    RPC_VMM_DELETE_VSEG           = 26,
    9191    RPC_VMM_CREATE_VSEG           = 27,
    9292    RPC_VMM_SET_COW               = 28,
    93     RPC_VMM_DISPLAY               = 29,
     93    RPC_UNDEFINED_29              = 29,   // RPC_VMM_DISPLAY         deprecated [AG]
    9494
    9595    RPC_MAX_INDEX                 = 30,
     
    574574 * @ buf_xp    : [out] buffer for extended pointer on allocated buffer.
    575575 **********************************************************************************/
     576
     577/*
    576578void rpc_kcm_alloc_client( cxy_t      cxy,
    577579                           uint32_t   kmem_type,
     
    579581
    580582void rpc_kcm_alloc_server( xptr_t xp );
     583*/
    581584
    582585/***********************************************************************************
     
    588591 * @ kmem_type : [in]  KCM object type (as defined in kmem.h).
    589592 **********************************************************************************/
     593
     594/*
    590595void rpc_kcm_free_client( cxy_t     cxy,
    591596                          void    * buf,
     
    593598
    594599void rpc_kcm_free_server( xptr_t xp );
     600*/
    595601
    596602/***********************************************************************************
     
    621627 * @ error       : [out] error status (0 if success).
    622628 **********************************************************************************/
     629/*
    623630void rpc_mapper_handle_miss_client( cxy_t             cxy,
    624631                                    struct mapper_s * mapper,
     
    628635 
    629636void rpc_mapper_handle_miss_server( xptr_t xp );
    630 
     637*/
    631638/***********************************************************************************
    632639 * [26] The RPC_VMM_DELETE_VSEG allows any client thread  to request a remote
     
    699706 * @ detailed    : [in]  detailed display if true.
    700707 **********************************************************************************/
     708
     709/*
    701710void rpc_hal_vmm_display_client( cxy_t              cxy,
    702711                             struct process_s * process,
     
    704713
    705714void rpc_hal_vmm_display_server( xptr_t xp );
    706 
     715*/
    707716
    708717#endif
  • trunk/kernel/kern/scheduler.c

    r630 r635  
    180180    sched = &core->scheduler;
    181181
    182     ////////////////// scan user threads to handle both ACK and DELETE requests
     182    ////////////////// scan user threads to handle ACK and DELETE requests
    183183    root = &sched->u_root;
    184184    iter = root->next;
     
    195195        {
    196196
    197 // check thread blocked
     197// check target thread blocked
    198198assert( (thread->blocked & THREAD_BLOCKED_GLOBAL) , "thread not blocked" );
    199199 
     
    206206
    207207        // handle REQ_DELETE only if target thread != calling thread
    208         if( (thread->flags & THREAD_FLAG_REQ_DELETE) && (thread != CURRENT_THREAD) )
    209         {
     208        if( thread->flags & THREAD_FLAG_REQ_DELETE )
     209        {
     210
     211// check calling thread != target thread
     212assert( (thread != CURRENT_THREAD) , "calling thread cannot delete itself" );
     213 
    210214            // get thread process descriptor
    211215            process = thread->process;
     
    497501    remote_fifo_t * fifo    = &LOCAL_CLUSTER->rpc_fifo[lid];
    498502 
     503#if DEBUG_SCHED_YIELD
     504uint32_t cycle = (uint32_t)hal_get_cycles();
     505#endif
     506
    499507#if (DEBUG_SCHED_YIELD & 0x1)
    500 if( sched->trace )
     508if( sched->trace || (cycle > DEBUG_SCHED_YIELD) )
    501509sched_display( lid );
    502510#endif
     
    551559
    552560#if DEBUG_SCHED_YIELD
    553 if( sched->trace )
     561if( sched->trace || (cycle > DEBUG_SCHED_YIELD) )
    554562printk("\n[%s] core[%x,%d] / cause = %s\n"
    555563"      thread %x (%s) (%x,%x) => thread %x (%s) (%x,%x) / cycle %d\n",
    556564__FUNCTION__, local_cxy, lid, cause,
    557565current, thread_type_str(current->type), current->process->pid, current->trdid,next ,
    558 thread_type_str(next->type) , next->process->pid , next->trdid , (uint32_t)hal_get_cycles() );
     566thread_type_str(next->type) , next->process->pid , next->trdid , cycle );
    559567#endif
    560568
     
    567575        busylock_release( &sched->lock );
    568576
    569 #if (DEBUG_SCHED_YIELD & 1)
    570 if( sched->trace )
     577#if DEBUG_SCHED_YIELD
     578if( sched->trace || (cycle > DEBUG_SCHED_YIELD) )
    571579printk("\n[%s] core[%x,%d] / cause = %s\n"
    572580"      thread %x (%s) (%x,%x) continue / cycle %d\n",
  • trunk/kernel/kern/thread.c

    r633 r635  
    7878static thread_t * thread_alloc( void )
    7979{
    80         page_t       * page;   // pointer on page descriptor containing thread descriptor
    8180        kmem_req_t     req;    // kmem request
    8281
    8382        // allocates memory for thread descriptor + kernel stack
    84         req.type  = KMEM_PAGE;
    85         req.size = CONFIG_THREAD_DESC_ORDER;
     83        req.type  = KMEM_PPM;
     84        req.order = CONFIG_THREAD_DESC_ORDER;
    8685        req.flags = AF_KERNEL | AF_ZERO;
    87         page      = kmem_alloc( &req );
    88 
    89         if( page == NULL ) return NULL;
    90 
    91     // return pointer on new thread descriptor
    92     xptr_t base_xp = ppm_page2base( XPTR(local_cxy , page ) );
    93     return GET_PTR( base_xp );
     86
     87    return kmem_alloc( &req );
    9488
    9589}  // end thread_alloc()
     
    125119{
    126120
    127 // check type and trdid fields initialized
     121// check type and trdid fields are initialized
    128122assert( (thread->type == type)   , "bad type argument" );
    129123assert( (thread->trdid == trdid) , "bad trdid argument" );
     
    133127thread_t * this  = CURRENT_THREAD;
    134128if( DEBUG_THREAD_INIT < cycle )
    135 printk("\n[%s] thread[%x,%x] enter for thread %x in process %x / cycle %d\n",
    136 __FUNCTION__, this->process->pid, this->trdid, thread->trdid, process->pid , cycle );
     129printk("\n[%s] thread[%x,%x] enter for thread[%x,%x] / cycle %d\n",
     130__FUNCTION__, this->process->pid, this->trdid, process->pid, thread->trdid, cycle );
    137131#endif
    138132
     
    192186cycle = (uint32_t)hal_get_cycles();
    193187if( DEBUG_THREAD_INIT < cycle )
    194 printk("\n[%s] thread[%x,%x] exit for thread %x in process %x / cycle %d\n",
    195 __FUNCTION__, this->process->pid, this->trdid, thread, process->pid, cycle );
     188printk("\n[%s] thread[%x,%x] exit for thread[%x,%x] / cycle %d\n",
     189__FUNCTION__, this->process->pid, this->trdid, process->pid, thread->trdid, cycle );
    196190#endif
    197191
     
    580574    vpn_t  parent_vpn_size = hal_remote_l32( XPTR( parent_cxy, &parent_us_vseg->vpn_size ) );
    581575    vpn_t  child_vpn_base  = child_us_vseg->vpn_base;
     576
    582577    for( parent_vpn = parent_vpn_base , child_vpn = child_vpn_base ;
    583578         parent_vpn < (parent_vpn_base + parent_vpn_size) ;
     
    625620#if (DEBUG_THREAD_USER_FORK & 1)
    626621if( DEBUG_THREAD_USER_FORK < cycle )
    627 printk("\n[%s] thread[%x,%x] copied all stack vseg PTEs to child GPT\n",
     622printk("\n[%s] thread[%x,%x] copied STACK vseg PTEs & set COW in child GPT\n",
    628623__FUNCTION__, this->process->pid, this->trdid );
    629624#endif
     
    636631#if (DEBUG_THREAD_USER_FORK & 1)
    637632if( DEBUG_THREAD_USER_FORK < cycle )
    638 printk("\n[%s] thread[%x,%x] set the COW flag for stack vseg in parent GPT\n",
     633printk("\n[%s] thread[%x,%x] set COW for STACK vseg in parent GPT\n",
    639634__FUNCTION__, this->process->pid, this->trdid );
    640635#endif
     
    906901    thread_assert_can_yield( thread , __FUNCTION__ );
    907902
    908     // update target process instrumentation counter
    909         // process->vmm.pgfault_nr += thread->info.pgfault_nr;
     903#if CONFIG_INSTRUMENTATION_PGFAULTS
     904        process->vmm.false_pgfault_nr    += thread->info.false_pgfault_nr;
     905        process->vmm.local_pgfault_nr    += thread->info.local_pgfault_nr;
     906        process->vmm.global_pgfault_nr   += thread->info.global_pgfault_nr;
     907        process->vmm.false_pgfault_cost  += thread->info.false_pgfault_cost;
     908        process->vmm.local_pgfault_cost  += thread->info.local_pgfault_cost;
     909        process->vmm.global_pgfault_cost += thread->info.global_pgfault_cost;
     910#endif
    910911
    911912    // remove thread from process th_tbl[]
    912913    count = process_remove_thread( thread );
    913914
    914     // release memory allocated for CPU context and FPU context if required
     915    // release memory allocated for CPU context and FPU context
    915916        hal_cpu_context_destroy( thread );
    916917        hal_fpu_context_destroy( thread );
     
    933934    // release memory for thread descriptor (including kernel stack)
    934935    kmem_req_t   req;
    935     xptr_t       base_xp = ppm_base2page( XPTR(local_cxy , thread ) );
    936 
    937     req.type  = KMEM_PAGE;
    938     req.ptr   = GET_PTR( base_xp );
     936    req.type  = KMEM_PPM;
     937    req.ptr   = thread;
    939938    kmem_free( &req );
    940939
  • trunk/kernel/kern/thread.h

    r629 r635  
    101101{
    102102        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              */
    103105    uint32_t     false_pgfault_cost;     /*! cumulated cost                           */
    104         uint32_t     local_pgfault_nr;       /*! number of local page fault               */
    105106    uint32_t     local_pgfault_cost;     /*! cumulated cost                           */
    106         uint32_t     global_pgfault_nr;      /*! number of global page fault              */
    107107    uint32_t     global_pgfault_cost;    /*! cumulated cost                           */
    108108
     
    339339 * this. This includes the thread descriptor itself, the associated CPU and FPU context,
    340340 * and the physical memory allocated for an user thread stack.
     341 * This function does not remove the thread from the scheduler, as this is done by
     342 * the scheduler itself.
    341343 ***************************************************************************************
    342344 * @ thread  : pointer on the thread descriptor to release.
     
    394396 * The calling thread can run in any cluster, as it uses remote accesses.
    395397 * This function makes a kernel panic if the target thread is the main thread,
    396  * because * the main thread deletion will cause the process deletion, and a process
     398 * because the main thread deletion will cause the process deletion, and a process
    397399 * must be deleted by the parent process, running the wait function.
    398400 * If the target thread is running in "attached" mode, and the <is_forced> argument
Note: See TracChangeset for help on using the changeset viewer.