Changeset 635 for trunk/kernel/mm/kmem.h


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.

File:
1 edited

Legend:

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

    r619 r635  
    22 * kmem.h - kernel unified memory allocator interface
    33 *
    4  * Authors  Ghassan Almaless (2008,2009,2010,2011,2012)
    5  *          Alain Greiner (2016,2017,2018)
     4 * Authors  Alain Greiner (2016,2017,2018,2019)
    65 *
    76 * Copyright (c) UPMC Sorbonne Universites
     
    3029
    3130/*************************************************************************************
    32  * This enum defines the Kernel Memory Types for dynamically allocated objects.
    33  * WARNING : this enum must be kepts consistent with use in kmem.c file.
     31 * This enum defines the three Kernel Memory Allocaror types:
    3432 ************************************************************************************/
    3533
    3634enum
    3735{
    38     KMEM_PAGE             = 0,   /*! reserved for PPM allocator                     */
    39     KMEM_GENERIC          = 1,   /*! reserved for KHM allocator                     */
    40     KMEM_KCM              = 2,   /*! kcm_t                                          */
    41     KMEM_VSEG             = 3,   /*! vseg_t                                         */
    42     KMEM_DEVICE           = 4,   /*! device_t                                       */
    43     KMEM_MAPPER           = 5,   /*! mapper_t                                       */
    44     KMEM_PROCESS          = 6,   /*! process_t                                      */
    45     KMEM_CPU_CTX          = 7,   /*! hal_cpu_context_t                              */
    46     KMEM_FPU_CTX          = 8,   /*! hal_fpu_context_t                              */
    47     KMEM_GEN_BARRIER      = 9,   /*! generi_cbarrier_t                              */
    48 
    49     KMEM_SMP_BARRIER      = 10,  /*! simple_barrier_t                               */
    50     KMEM_DEVFS_CTX        = 11,  /*! fatfs_inode_t                                  */
    51     KMEM_FATFS_CTX        = 12,  /*! fatfs_ctx_t                                    */
    52     KMEM_VFS_CTX          = 13,  /*! vfs_context_t                                  */
    53     KMEM_VFS_INODE        = 14,  /*! vfs_inode_t                                    */
    54     KMEM_VFS_DENTRY       = 15,  /*! vfs_dentry_t                                   */
    55     KMEM_VFS_FILE         = 16,  /*! vfs_file_t                                     */
    56     KMEM_SEM              = 17,  /*! remote_sem_t                                   */
    57     KMEM_CONDVAR          = 18,  /*! remote_condvar_t                               */
    58     KMEM_MUTEX            = 19,  /*! remote_mutex_t                                 */
    59 
    60     KMEM_DIR              = 20,  /*! remote_dir_t                                   */
    61     KMEM_512_BYTES        = 21,  /*! 512 bytes aligned                              */
    62 
    63     KMEM_TYPES_NR         = 22,
     36    KMEM_PPM              = 0,   /*! PPM allocator                                  */
     37    KMEM_KCM              = 1,   /*! KCM allocator                                  */
     38    KMEM_KHM              = 2,   /*! KHM allocator                                  */
    6439};
    6540
     
    7954typedef struct kmem_req_s
    8055{
    81     uint32_t      type;   /*! request type                                          */
    82     uint32_t      size;   /*! ln2(nb_pages) if PPM / bytes if KHM / unused by KCM   */
     56    uint32_t      type;   /*! KMEM_PPM / KMEM_KCM / KMEM_KHM                        */
     57    uint32_t      order;  /*! PPM: ln2(pages) / KCM: ln2(bytes) / KHM: bytes        */
    8358    uint32_t      flags;  /*! request attributes                                    */
    8459    void        * ptr;    /*! local pointer on allocated buffer (only used by free) */
     
    8762
    8863/*************************************************************************************
    89  * This generic function allocates physical memory in the local cluster
    90  * as specified by the request descriptor.
    91  * It uses three specialised physical memory allocators, depending on request type:
    92  * - PPM (Physical Pages Manager) allocates N contiguous physical pages,
    93  *       N must be a power of 2.
    94  * - KHM (Kernel Heap Manager) allocates a physical memory buffer,
    95  *       that can have any size.
    96  * - KCM (Kernel Cache Manager) allocates various fixed size objects,
    97  *       handling a dedicated cache for each object type.
     64 * These two functions allocate physical memory in a local or remote cluster
     65 * as specified by the kmem_req_t request descriptor, and return a local pointer
     66 * on the allocated buffer. It uses three specialised physical memory allocators:
     67 * - PPM (Physical Pages Manager) allocates N contiguous small physical pages.
     68 *       N is a power of 2, and req.order = ln(N). Implement the buddy algorithm.
     69 * - KCM (Kernel Cache Manager) allocates aligned blocks of M bytes from a cache.
     70 *       M is a power of 2, and req.order = ln( M ). One cache per block size.
     71 * - KHM (Kernel Heap Manager) allocates physical memory buffers of M bytes,
     72 *       M can have any value, and req.order = M.
    9873 *************************************************************************************
    99  * @ req   : local pointer to allocation request.
    100  * @ return a local pointer on page descriptor if KMEM_PAGE.
    101  *   return a local pointer to allocated buffer if KCM or KHM.
    102  *   return NULL if no physical memory available.
     74 * @ cxy   : target cluster identifier for a remote access.
     75 * @ req   : local pointer on allocation request.
     76 * @ return local pointer on allocated buffer if success / return NULL if no memory.
    10377 ************************************************************************************/
    10478void * kmem_alloc( kmem_req_t * req );
    10579
     80void * kmem_remote_alloc( cxy_t        cxy,
     81                          kmem_req_t * req );
     82
    10683/*************************************************************************************
    107  * This function releases previously allocated physical memory, as specified
    108  * by the "type" and "ptr" fiels of the kmem-req_t request.
     84 * These two functions release previously allocated physical memory, as specified
     85 * by the <type> and <ptr> fields of the kmem_req_t request descriptor.
    10986 *************************************************************************************
     87 * @ cxy   : target cluster identifier for a remote access.
    11088 * @ req : local pointer to request descriptor.
    11189 ************************************************************************************/
    11290void  kmem_free ( kmem_req_t * req );
    11391
    114 /*************************************************************************************
    115  * This function returns a printable string for a kmem object type.
    116  *************************************************************************************
    117  * @ type   : kmem object type.
    118  ************************************************************************************/
    119 char * kmem_type_str( uint32_t type );
    120 
    121 /*************************************************************************************
    122  * This function returns the size (bytes) for a kmem object type.
    123  *************************************************************************************
    124  * @ type   : kmem object type.
    125  ************************************************************************************/
    126 uint32_t kmem_type_size( uint32_t type );
    127 
    128 /*************************************************************************************
    129  * This function displays the content of the KCM pointers Table
    130  ************************************************************************************/
    131 void kmem_print_kcm_table( void );
     92void  kmem_remote_free( cxy_t        cxy,
     93                        kmem_req_t * req );
    13294
    13395
Note: See TracChangeset for help on using the changeset viewer.