Changeset 640 for trunk/kernel/mm/vmm.h


Ignore:
Timestamp:
Oct 1, 2019, 1:19:00 PM (5 years ago)
Author:
alain
Message:

Remove all RPCs in page-fault handling.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/mm/vmm.h

    r635 r640  
    112112typedef struct vmm_s
    113113{
    114         remote_rwlock_t  vsl_lock;            /*! lock protecting the local VSL                 */
    115         xlist_entry_t    vsegs_root;          /*! Virtual Segment List (complete in reference)  */
    116         uint32_t         vsegs_nr;            /*! total number of local vsegs                   */
    117 
    118     gpt_t            gpt;                 /*! Generic Page Table (complete in reference)    */
    119 
    120     stack_mgr_t      stack_mgr;           /*! embedded STACK vsegs allocator                */
    121     mmap_mgr_t       mmap_mgr;            /*! embedded MMAP vsegs allocator                 */
    122 
    123         uint32_t         false_pgfault_nr;    /*! false page fault counter (for all threads)    */
    124         uint32_t         local_pgfault_nr;    /*! false page fault counter (for all threads)    */
    125         uint32_t         global_pgfault_nr;   /*! false page fault counter (for all threads)    */
    126     uint32_t         false_pgfault_cost;  /*! cumulated cost (for all threads)              */
    127     uint32_t         local_pgfault_cost;  /*! cumulated cost (for all threads)              */
    128     uint32_t         global_pgfault_cost; /*! cumulated cost (for all threads)              */
    129 
    130     vpn_t            args_vpn_base;       /*! args vseg first page                          */
    131     vpn_t            envs_vpn_base;       /*! envs vseg first page                          */
    132         vpn_t            code_vpn_base;       /*! code vseg first page                          */
    133         vpn_t            data_vpn_base;       /*! data vseg first page                          */
    134     vpn_t            heap_vpn_base;       /*! heap zone first page                          */
    135 
    136         intptr_t         entry_point;         /*! main thread entry point                       */
     114        remote_queuelock_t vsl_lock;            /*! lock protecting the local VSL               */
     115        xlist_entry_t      vsegs_root;          /*! Virtual Segment List root                   */
     116        uint32_t           vsegs_nr;            /*! total number of local vsegs                 */
     117
     118    gpt_t              gpt;                 /*! Generic Page Table descriptor               */
     119
     120    stack_mgr_t        stack_mgr;           /*! embedded STACK vsegs allocator              */
     121    mmap_mgr_t         mmap_mgr;            /*! embedded MMAP vsegs allocator               */
     122
     123        uint32_t           false_pgfault_nr;    /*! false page fault counter (for all threads)  */
     124        uint32_t           local_pgfault_nr;    /*! false page fault counter (for all threads)  */
     125        uint32_t           global_pgfault_nr;   /*! false page fault counter (for all threads)  */
     126    uint32_t           false_pgfault_cost;  /*! cumulated cost (for all threads)            */
     127    uint32_t           local_pgfault_cost;  /*! cumulated cost (for all threads)            */
     128    uint32_t           global_pgfault_cost; /*! cumulated cost (for all threads)            */
     129
     130    vpn_t              args_vpn_base;       /*! args vseg first page                        */
     131    vpn_t              envs_vpn_base;       /*! envs vseg first page                        */
     132        vpn_t              code_vpn_base;       /*! code vseg first page                        */
     133        vpn_t              data_vpn_base;       /*! data vseg first page                        */
     134    vpn_t              heap_vpn_base;       /*! heap zone first page                        */
     135
     136        intptr_t           entry_point;         /*! main thread entry point                     */
    137137}
    138138vmm_t;
     
    143143 * - The GPT has been previously created, with the hal_gpt_create() function.
    144144 * - The "kernel" vsegs are previously registered, by the hal_vmm_kernel_update() function.
    145  * - The "code" and "data" vsegs are registered by the elf_load_process() function.
     145 * - The "code" and "data" vsegs arlmmmmmme registered by the elf_load_process() function.
    146146 * - The "stack" vsegs are dynamically registered by the thread_user_create() function.
    147147 * - The "file", "anon", "remote" vsegs are dynamically registered by the mmap() syscall.
     
    206206
    207207/*********************************************************************************************
     208 * This function modifies the size of the vseg identified by <process> and <base> arguments
     209 * in all clusters containing a VSL copy, as defined by <new_base> and <new_size> arguments.
     210 * This function is called by the sys_munmap() function, and can be called by a thread
     211 * running in any cluster, as it uses remote accesses.
     212 * It cannot fail, as only vseg registered  in VSL copies are updated.
     213 *********************************************************************************************
     214 * @ process   : local pointer on process descriptor.
     215 * @ base      : current vseg base address in user space.
     216 * @ new_base  : new vseg base.
     217 * @ new_size  : new vseg size.
     218 ********************************************************************************************/
     219void vmm_global_resize_vseg( struct process_s * process,
     220                             intptr_t           base,
     221                             intptr_t           new_base,
     222                             intptr_t           new_size );
     223
     224/*********************************************************************************************
     225 * This function removes the vseg identified by the <process> and <base> arguments from
     226 * the VSL and remove all associated PTE entries from the GPT.
     227 * This is done in all clusters containing a VMM copy to maintain VMM coherence.
     228 * This function can be called by a thread running in any cluster, as it uses the
     229 * vmm_remove_vseg() in the local cluster, and the RPC_VMM_REMOVE_VSEG for remote clusters.
     230 * It cannot fail, as only vseg registered  in VSL copies are deleted.
     231 *********************************************************************************************
     232 * @ pid      : local pointer on process identifier.
     233 * @ base     : vseg base address in user space.
     234 ********************************************************************************************/
     235void vmm_global_delete_vseg( struct process_s * process,
     236                             intptr_t           base );
     237
     238/*********************************************************************************************
    208239 * This function modifies one GPT entry identified by the <process> and <vpn> arguments
    209  * in all clusters containing a process copy. It is used to maintain coherence in GPT
    210  * copies, using remote_write accesses.
    211  * It must be called by a thread running in the process owner cluster.
    212  * Use the RPC_VMM_GLOBAL_UPDATE_PTE if required.
     240 * in all clusters containing a process copy. It maintains coherence in GPT copies,
     241 * using remote_write accesses.
    213242 * It cannot fail, as only mapped PTE2 in GPT copies are updated.
    214243 *********************************************************************************************
     
    282311/*********************************************************************************************
    283312 * This function removes from the VMM of a process descriptor identified by the <process>
    284  * argument the vseg identified by the <vseg> argument. It can be used for any type of vseg.
    285  * As it uses local pointers, it must be called by a local thread.
    286  * It is called by the vmm_user_reset(), vmm_delete_vseg() and vmm_destroy() functions.
     313 * argument the vseg identified by the <vseg> argument. 
     314 * It is called by the vmm_user_reset(), vmm_global_delete_vseg() and vmm_destroy() functions.
     315 * It must be called by a local thread, running in the cluster containing the modified VMM.
     316 * Use the RPC_VMM_REMOVE_VSEG if required.
    287317 * It makes a kernel panic if the process is not registered in the local cluster,
    288318 * or if the vseg is not registered in the process VSL.
    289319 * For all vseg types, the vseg is detached from local VSL, and all associated PTEs are
    290320 * unmapped from local GPT. Other actions depend on the vseg type:
    291  * - Regarding the vseg descriptor release:
     321 * Regarding the vseg descriptor release:
    292322 *   . for ANON and REMOTE, the vseg is not released, but registered in local zombi_list.
    293323 *   . for STACK the vseg is released to the local stack allocator.
    294324 *   . for all other types, the vseg is released to the local kmem.
    295  * - Regarding the physical pages release:
     325 * Regarding the physical pages release:
    296326 *   . for KERNEL and FILE, the pages are not released to kmem.
    297327 *   . for CODE and STACK, the pages are released to local kmem when they are not COW.
    298328 *   . for DATA, ANON and REMOTE, the pages are released to relevant kmem only when
    299329 *     the local cluster is the reference cluster.
    300  * The lock protecting the VSL must be taken by the caller.
    301  *********************************************************************************************
    302  * @ process  : local pointer on process.
    303  * @ vseg     : local pointer on vseg.
     330 * The VSL lock protecting the VSL must be taken by the caller.
     331 *********************************************************************************************
     332 * @ process  : local pointer on process descriptor.
     333 * @ vseg     : local pointer on target vseg.
    304334 ********************************************************************************************/
    305335void vmm_remove_vseg( struct process_s * process,
     
    307337
    308338/*********************************************************************************************
    309  * This function call the vmm_remove vseg() function to remove from the VMM of a local
    310  * process descriptor, identified by the <pid> argument the vseg identified by the <vaddr>
    311  * virtual address in user space.
    312  * Use the RPC_VMM_DELETE_VSEG to remove a vseg from a remote process descriptor.
    313  *********************************************************************************************
    314  * @ pid      : process identifier.
    315  * @ vaddr    : virtual address in user space.
    316  ********************************************************************************************/
    317 void vmm_delete_vseg( pid_t    pid,
    318                       intptr_t vaddr );
    319 
    320 /*********************************************************************************************
    321  * This function removes a given region (defined by a base address and a size) from
    322  * the VMM of a given process descriptor. This can modify the number of vsegs:
    323  * (a) if the region is not entirely mapped in an existing vseg, it's an error.
    324  * (b) if the region has same base and size as an existing vseg, the vseg is removed.
    325  * (c) if the removed region cut the vseg in two parts, it is modified.
    326  * (d) if the removed region cut the vseg in three parts, it is modified, and a new
    327  *     vseg is created with same type.
    328  * FIXME [AG] this function should be called by a thread running in the reference cluster,
    329  *       and the VMM should be updated in all process descriptors copies.
    330  *********************************************************************************************
    331  * @ process   : pointer on process descriptor
    332  * @ base      : vseg base address
    333  * @ size      : vseg size (bytes)
    334  ********************************************************************************************/
    335 error_t vmm_resize_vseg( struct process_s * process,
    336                          intptr_t           base,
    337                          intptr_t           size );
    338 
    339 /*********************************************************************************************
    340  * This low-level function scan the local VSL in <vmm> to find the unique vseg containing
    341  * a given virtual address <vaddr>.
    342  * It is called by the vmm_get_vseg(), vmm_get_pte(), and vmm_resize_vseg() functions.
    343  *********************************************************************************************
    344  * @ vmm     : pointer on the process VMM.
    345  * @ vaddr   : virtual address.
    346  * @ return vseg pointer if success / return NULL if not found.
    347  ********************************************************************************************/
    348 struct vseg_s * vmm_vseg_from_vaddr( vmm_t    * vmm,
    349                                      intptr_t   vaddr );
    350 
    351 /*********************************************************************************************
    352  * This function checks that a given virtual address is contained in a registered vseg.
    353  * It can be called by any thread running in any cluster:
    354  * - if the vseg is registered in the local process VMM, it returns the local vseg pointer.
    355  * - if the vseg is missing in local VMM, it uses a RPC to get it from the reference cluster,
    356  *   register it in local VMM and returns the local vseg pointer, if success.
    357  * - it returns an user error if the vseg is missing in the reference VMM, or if there is
    358  *   not enough memory for a new vseg descriptor in the calling thread cluster.
    359  *********************************************************************************************
    360  * @ process   : [in] pointer on process descriptor
    361  * @ vaddr     : [in] virtual address
    362  * @ vseg      : [out] local pointer on local vseg
    363  * @ returns 0 if success / returns -1 if user error (out of segment).
     339 * This function resize a local vseg identified by the <process> and <vseg> arguments.
     340 * It is called by the vmm_global_resize() function.
     341 * It must be called by a local thread, running in the cluster containing the modified VMM.
     342 * Use the RPC_VMM_RESIZE_VSEG if required.
     343 * It makes a kernel panic if the process is not registered in the local cluster,
     344 * or if the vseg is not registered in the process VSL.
     345 * The new vseg, defined by the <new_base> and <new_size> arguments must be strictly
     346 * included in the target vseg. The target VSL size and base fields are modified in the VSL.
     347 * If the new vseg contains less pages than the target vseg, the relevant pages are
     348 * removed from the GPT.
     349 * The VSL lock protecting the VSL must be taken by the caller.
     350 *********************************************************************************************
     351 * @ process   : local pointer on process descriptor
     352 * @ vseg      : local pointer on target vseg
     353 * @ new_base  : vseg base address
     354 * @ new_size  : vseg size (bytes)
     355 ********************************************************************************************/
     356void vmm_resize_vseg( struct process_s * process,
     357                      struct vseg_s    * vseg,
     358                      intptr_t           new_base,
     359                      intptr_t           new_size );
     360
     361/*********************************************************************************************
     362 * This function checks that a given virtual address <vaddr> in a given <process> is
     363 * contained in a registered vseg. It can be called by any thread running in any cluster.
     364 * - if the vseg is registered in the local process VSL, it returns the local vseg pointer.
     365 * - if the vseg is missing in local VSL, it access directly the reference VSL.
     366 * - if the vseg is found in reference VSL, it updates the local VSL and returns this pointer.
     367 * It returns an error when the vseg is missing in the reference VMM, or when there is
     368 * not enough memory for a new vseg descriptor in the calling thread cluster.
     369 * For both the local and the reference VSL, it takes the VSL lock before scanning the VSL.
     370 *********************************************************************************************
     371 * @ process   : [in] pointer on process descriptor.
     372 * @ vaddr     : [in] virtual address.
     373 * @ vseg      : [out] local pointer on local vseg.
     374 * @ returns 0 if success / returns -1 if user error
    364375 ********************************************************************************************/
    365376error_t vmm_get_vseg( struct process_s  * process,
     
    395406 * This function is called by the generic exception handler in case of WRITE violation event,
    396407 * detected for a given <vpn>. The <process> argument is used to access the relevant VMM.
    397  * It returns a kernel panic if VPN is not in a registered vseg or is not mapped.
     408 * It returns a kernel panic if the faulty VPN is not in a registered vseg, or is not mapped.
    398409 * For a legal mapped vseg there is two cases:
    399410 * 1) If the missing VPN belongs to a private vseg (STACK), it access only the local GPT.
Note: See TracChangeset for help on using the changeset viewer.