Changeset 635 for trunk/kernel/mm/kcm.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/kcm.h

    r619 r635  
    11/*
    2  * kcm.h - Per-cluster Kernel Cache Manager definition.
     2 * kcm.h - Kernel Cache Manager definition.
    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
     
    3332#include <kmem.h>
    3433
     34
     35#define KCM_PAGE_FULL     0
     36#define KCM_PAGE_EMPTY    1
     37#define KCM_PAGE_ACTIVE   2
     38
    3539/****************************************************************************************
    3640 * This structure defines a generic Kernel Cache Manager, that is a block allocator,
    37  * for fixed size objects. It exists a specific KCM allocator for each object type.
    38  * The actual allocated block size is the smallest multiple of the KCM slot, that
    39  * contain one single object. The KCM slot is 64 bytes, as it must be large enough
    40  * to store the kcm_page descriptor, defined below.
    41  * The various KCM allocators themselves are not statically allocated in the cluster
    42  * manager, but are dynamically allocated when required, using the embedded KCM
    43  * allocator defined in the cluster manager, to allocate the other ones...
     41 * for fixed size objects. It exists in each cluster a specific KCM allocator for
     42 * the following block sizes: 64, 128, 256, 512, 1024, 2048 bytes.
     43 * These six KCM allocators are initialized by the cluster_init() function.
     44 *
     45 * Each KCM cache is implemented as a set o 4 Kbytes pages. A kcm_page is split in slots,
     46 * where each slot can contain one block. in each kcm_page, the first slot (that cannot
     47 * be smaller than 64 bytes) contains the kcm page descriptor, defined below
     48 *
     49 * To allow any thread running in any cluster to directly access the KCM of any cluster,
     50 * ALMOS-MKH defines two sets of access functions, for local or remote access.
    4451 ***************************************************************************************/
    4552
    4653typedef struct kcm_s
    4754{
    48         busylock_t           lock;             /*! protect KCM ammocator                   */
    49         uint32_t             block_size;       /*! rounded block size (bytes)              */
    50         uint32_t             blocks_nr;        /*! max number of blocks per page           */
     55        remote_busylock_t    lock;             /*! protect KCM allocator                   */
    5156
     57        list_entry_t         full_root;        /*! root of full pages list                 */
    5258        list_entry_t         active_root;      /*! root of active pages list               */
    53         list_entry_t         busy_root;        /*! root of busy pages list                 */
    54         list_entry_t         free_root;        /*! root of free pages list                 */
    5559
    56         uint32_t             free_pages_nr;    /*! number of free pages                    */
    57         uint32_t             busy_pages_nr;    /*! number of busy pages                    */
     60        uint32_t             full_pages_nr;    /*! number of busy pages                    */
    5861        uint32_t             active_pages_nr;  /*! number of active pages                  */
    5962
    60         uint32_t             type;             /*! KCM type                                */
     63        uint32_t             order;            /*! ln( block_size )                        */
     64        uint32_t             max_blocks;       /*! max number of blocks per page           */
    6165}
    6266kcm_t;
     
    6569/****************************************************************************************
    6670 * This structure defines a KCM-page descriptor.
    67  * A KCM-page contains at most (CONFIG_PPM_PAGE_SIZE / CONFIG_KCM_SLOT_SIZE) blocks.
    68  * This kcm page descriptor is stored in the first slot of the page.
     71 * A KCM-page contains at most (CONFIG_PPM_PAGE_SIZE / CONFIG_KCM_SLOT_SIZE) slots,
     72 * and each slot contains one block. The kcm page descriptor is stored in first slot.
     73 * The current allocation status is defined by the 64 bits "status" bit vector: each
     74 * non zero bit defines an allocated block / "counts is the number of allocated blocks.
     75 * Each kcm_page is registered in one of the two following page_list:
     76 * - full   : when count == max
     77 * - active : count < max
    6978 ***************************************************************************************/
    7079
    7180typedef struct kcm_page_s
    7281{
    73         uint32_t        bitmap[2];             /*! at most 64 blocks in a single page      */
    74         list_entry_t    list;                  /*! [active / busy / free] list member      */
    75         kcm_t         * kcm;                   /*! pointer on kcm allocator                */
    76         page_t        * page;                  /*! pointer on the physical page descriptor */
    77         uint32_t        count;                 /*! number of allocated blocks              */
    78         uint32_t        busy;                  /*! page busy if non zero                   */
    79         uint32_t        active;                /*! page active if non zero                 */
     82        uint64_t            status;            /*! bit vector: non-zero == allocated       */
     83        uint32_t            count;             /*! number of allocated blocks in page      */
     84        list_entry_t        list;              /*! [active / busy / free] list member      */
     85        kcm_t             * kcm;               /*! pointer on kcm allocator                */
     86        page_t            * page;              /*! pointer on the physical page descriptor */
    8087}
    8188kcm_page_t;
    8289
    8390/****************************************************************************************
    84  * This function initializes a generic Kernel Cache Manager.
     91 * This function must be called by a local thread.
     92 * It initializes a Kernel Cache Manager, depending on block size.
    8593 ****************************************************************************************
    8694 * @ kcm      : pointer on KCM manager to initialize.
    87  * @ type     : KCM allocator type.
     95 * @ order    : ln(block_size).
    8896 ***************************************************************************************/
    8997void kcm_init( kcm_t    * kcm,
    90                uint32_t   type );
     98               uint32_t   order );
    9199
    92100/****************************************************************************************
    93  * This function releases all memory allocated to a generic Kernel Cache Manager.
     101 * This function must be called by a local thread.
     102 * It releases all memory allocated to a Kernel Cache Manager.
    94103 ****************************************************************************************
    95104 * @ kcm      : pointer on KCM manager to destroy.
     
    98107
    99108/****************************************************************************************
    100  * This function allocates one single object from a Kernel Cache Manager
    101  * The object size must be smaller than one page size.
     109 * This function must be called by a local thread.
     110 * It allocates one block from the local Kernel Cache Manager.
    102111 ****************************************************************************************
    103  * @ kcm      :  pointer on the selected KCM allocator
     112 * @ order     :  ln( block-size ) == KCM allocator identifier.
    104113 * @ return pointer on allocated block if success / return NULL if failure
    105114 ***************************************************************************************/
    106 void * kcm_alloc( kcm_t * kcm );
     115void * kcm_alloc( uint32_t order );
    107116
    108117/****************************************************************************************
    109  * This function releases a previouly allocated block containing one object.
     118 * This function must be called by a local thread.
     119 * It releases a previouly allocated block to the local Kernel Cache Manager.
    110120 ****************************************************************************************
    111  * @ ptr   : local pointer on the allocated buffer.
     121 * @ block_ptr   : local pointer on the released block.
    112122 ***************************************************************************************/
    113 void kcm_free( void * ptr );
     123void kcm_free( void    * block_ptr );
    114124
    115125/****************************************************************************************
    116  * This function prints KCM allocator state (for debug only).
     126 * This function can be called by any thread running in any cluster.
     127 * It allocates one fixed size block from a remote Kernel Cache Manager.
    117128 ****************************************************************************************
    118  * @ kcm   : local pointer on the selected KCM allocator.
     129 * @ kcm_cxy   : remote KCM cluster identifier.
     130 * @ order     :  ln( block-size ) == KCM allocator identifier.
     131 * @ return a local pointer on allocated block if success / return NULL if failure
    119132 ***************************************************************************************/
    120 void kcm_print( kcm_t * kcm );
     133void * kcm_remote_alloc( cxy_t    kcm_cxy,
     134                         uint32_t order );
     135
     136/****************************************************************************************
     137 * This function can be called by any thread running in any cluster.
     138 * It releases a previouly allocated block to a remote Kernel Cache Manager.
     139 ****************************************************************************************
     140 * @ kcm_cxy     : remote KCM cluster identifier.
     141 * @ block_ptr   : local pointer on the released buffer in remote cluster.
     142 ***************************************************************************************/
     143void kcm_remote_free( cxy_t     kcm_cxy,
     144                      void    * block_ptr );
     145
     146/****************************************************************************************
     147 * This debug function can be called by any thread running in any cluster.
     148 * It diplays on TXT0 the current state of a local KCM allocator.
     149 ****************************************************************************************
     150 * @ kcm_cxy : remote KCM cluster identifier.
     151 * @ kcm_ptr : local pointer on remote KCM.
     152 ***************************************************************************************/
     153void kcm_remote_display( cxy_t   kcm_cxy,
     154                         kcm_t * kcm_ptr );
    121155
    122156#endif  /* _KCM_H_ */
Note: See TracChangeset for help on using the changeset viewer.