source: trunk/kernel/kern/cluster.h @ 562

Last change on this file since 562 was 562, checked in by nicolas.van.phan@…, 6 years ago

Disable DQDT and remove y_max FOR GOOD

File size: 16.6 KB
RevLine 
[1]1/*
2 * cluster.h - Cluster-Manager definition
[19]3 *
[1]4 * authors  Ghassan Almaless (2008,2009,2010,2011,2012)
5 *          Mohamed Lamine Karaoui (2015)
[437]6 *          Alain Greiner (2016,2017,2018)
[1]7 *
8 * Copyright (c) UPMC Sorbonne Universites
9 *
10 * This file is part of ALMOS-MKH.
11 *
12 * ALMOS-MKH is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; version 2.0 of the License.
15 *
16 * ALMOS-MKH is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
23 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 */
25
26#ifndef _CLUSTER_H_
27#define _CLUSTER_H_
28
[14]29#include <kernel_config.h>
[457]30#include <hal_kernel_types.h>
[1]31#include <bits.h>
32#include <spinlock.h>
33#include <readlock.h>
34#include <remote_barrier.h>
35#include <list.h>
36#include <xlist.h>
37#include <dqdt.h>
38#include <kmem.h>
39#include <hal_atomic.h>
40#include <ppm.h>
41#include <kcm.h>
42#include <khm.h>
43#include <rpc.h>
44#include <core.h>
45#include <process.h>
46
47/**** Forward declarations  ****/
48
49struct core_s;
50struct process_s;
51
52
53/*******************************************************************************************
54 * This structure defines the process manager, that is part of the cluster manager.
55 * For any process P, the process descriptor is replicated in all clusters containing
[19]56 * at least one thread of process P, but only the "reference" cluster descriptor contains
[23]57 * the reference (complete) GPT, VSL, and FDT structures.
58 * The "owner" cluster K is in charge to allocate a lpid (local process index),
59 * to the owned processes, and to register the "reference" cluster for these processes.
[1]60 *
[19]61 * Warning : the "owner" cluster, and the "reference" cluster can be different clusters.
[1]62 *
[443]63 * The process manager of a cluster K maintains three sets of process descriptors:
64 *
65 * 1) pref_tbl[] is an array indexed by lpid. There is one entry per owned process.
[1]66 *    Each entry contains an extended pointer on the reference process descriptor.
[23]67 *
[443]68 * 2) The local_root is the root of the local list of all process descriptors in cluster K.
[1]69 *    A process descriptor P is present in K, as soon as P has a thread in cluster K.
[23]70 *
71 * 3) The copies_root[] array is indexed by lpid. There is one entry per owned process,
72 *    and each each entry contains the root of the xlist of copies for this process.
[1]73 ******************************************************************************************/
74
75typedef struct process_manager_s
76{
77        xptr_t            pref_tbl[CONFIG_MAX_PROCESS_PER_CLUSTER];  /*! reference  process   */
78        spinlock_t        pref_lock;              /*! lock protecting lpid allocation/release */
79    uint32_t          pref_nr;                /*! number of processes owned by cluster    */
80
[23]81    xlist_entry_t     local_root;             /*! root of list of process in cluster      */
82    remote_spinlock_t local_lock;             /*! lock protecting access to local list    */
[1]83    uint32_t          local_nr;               /*! number of process in cluster            */
84
[19]85    xlist_entry_t     copies_root[CONFIG_MAX_PROCESS_PER_CLUSTER];  /*! roots of lists    */
[1]86    remote_spinlock_t copies_lock[CONFIG_MAX_PROCESS_PER_CLUSTER];  /*! one lock per list */
87    uint32_t          copies_nr[CONFIG_MAX_PROCESS_PER_CLUSTER];    /*! number of copies  */
88}
89pmgr_t;
90
91/*******************************************************************************************
92 * This structure defines a cluster manager.
[19]93 * It contains both global platform information, and cluster specific resources
[279]94 * controled by the local kernel instance.
[1]95 ******************************************************************************************/
96
97typedef struct cluster_s
98{
[440]99        spinlock_t      kcm_lock;          /*! local, protect creation of KCM allocators      */
[1]100
101    // global parameters
[440]102        uint32_t        paddr_width;       /*! numer of bits in physical address              */
103    uint32_t        x_width;           /*! number of bits to code x_size  (can be 0)      */
104    uint32_t        y_width;           /*! number of bits to code y_size  (can be 0)      */
105        uint32_t        x_size;            /*! number of clusters in a row    (can be 1)      */
106        uint32_t        y_size;            /*! number of clusters in a column (can be 1)      */
[557]107    uint32_t        cluster_info[CONFIG_MAX_CLUSTERS_X][CONFIG_MAX_CLUSTERS_Y];
[440]108        cxy_t           io_cxy;            /*! io cluster identifier                          */
109    uint32_t        dqdt_root_level;   /*! index of root node in dqdt_tbl[]               */
110    uint32_t        nb_txt_channels;   /*! number of TXT channels                         */
111    uint32_t        nb_nic_channels;   /*! number of NIC channels                         */
112    uint32_t        nb_ioc_channels;   /*! number of IOC channels                         */
113    uint32_t        nb_fbf_channels;   /*! number of FBF channels                         */
[1]114
115    // local parameters
[440]116        uint32_t        cores_nr;          /*! actual number of cores in cluster              */
117    uint32_t        ram_size;          /*! physical memory size                           */
118    uint32_t        ram_base;          /*! physical memory base (local address)           */
[279]119
[440]120        core_t          core_tbl[CONFIG_MAX_LOCAL_CORES];    /*! embedded cores               */
[1]121
[440]122        list_entry_t    dev_root;          /*! root of list of devices in cluster             */
[279]123
124    // memory allocators
[440]125        ppm_t           ppm;               /*! embedded kernel page manager                   */
126        khm_t           khm;               /*! embedded kernel heap manager                   */
127        kcm_t           kcm;               /*! embedded kernel KCMs manager                   */
[428]128
[440]129    kcm_t         * kcm_tbl[KMEM_TYPES_NR];              /*! pointers on allocated KCMs   */
[1]130
[279]131    // RPC
[440]132        remote_fifo_t   rpc_fifo[CONFIG_MAX_LOCAL_CORES];    /*! one RPC FIFO per core        */
133    uint32_t        rpc_threads[CONFIG_MAX_LOCAL_CORES]; /*! RPC threads per core         */
[1]134
[279]135    // DQDT
[440]136        dqdt_node_t     dqdt_tbl[CONFIG_DQDT_LEVELS_NR];     /*! embedded DQDT nodes          */
[1]137
[279]138    // Local process manager
[440]139    pmgr_t          pmgr;              /*! embedded process manager                       */
[188]140
[440]141    void          * pic_extend;        /*! PIC implementation specific extension          */
[19]142}
[1]143cluster_t;
144
145/******************************************************************************************
146 * This global variable is allocated in the kernel_init.c file.
[19]147 * There is one cluster_manager per cluster, with the same local address,
148 * but different content, in all clusters containing a kernel instance.
[1]149 *****************************************************************************************/
150
151extern cluster_t cluster_manager;
152
153/******************************************************************************************
154 * This macro returns a local pointer on the local cluster manager.
155 *****************************************************************************************/
156
157#define LOCAL_CLUSTER    (&cluster_manager)
158
159/******************************************************************************************
[19]160 * This generic function initialises the local cluster manager from information found
[1]161 * in the local boot-info structure. It initializes the following local resources:
162 * - the global platform parameters,
163 * - the specific cluster parameters,
164 * - the lock protecting KCM creation,
165 * - the local DQDT nodes,
166 * - the PPM, KHM, and KCM allocators,
167 * - the local core descriptors,
168 * - the local RPC FIFO,
169 * - the process manager.
170 * It does NOT initialise the local device descriptors.
171 ******************************************************************************************
172 * @ info : pointer on the local boot_info_t structure build by the bootloader.
173 *****************************************************************************************/
[19]174error_t cluster_init( boot_info_t * info );
[1]175
[561]176/******************************************************************************************
177 * This function randomly selects a cluster.
178 ******************************************************************************************
179 * @ returns the selected cluster identifier.
180 *****************************************************************************************/
181cxy_t cluster_random_select( void );
182
[1]183/******************************************************************************************
[407]184 * This function checks the validity of a cluster identifier.
[1]185 ******************************************************************************************
186 * @ cxy    : cluster identifier to be checked.
187 * @ returns true if the identified cluster does not exist.
188 *****************************************************************************************/
189bool_t cluster_is_undefined( cxy_t cxy );
190
191
192/*****************************************************************************************/
193/***************   Process Management Operations   ***************************************/
194/*****************************************************************************************/
195
196/******************************************************************************************
[433]197 * This function returns an extended pointer on the process descriptor in owner cluster
[443]198 * from the process <pid>. This PID can be be different from the calling process PID.
[433]199 * It can be called by any thread running in any cluster,
200 ******************************************************************************************
201 * @ pid  : process identifier.
202 * @ return extended pointer on owner process if found / XPTR_NULL if not found.
203 *****************************************************************************************/
204xptr_t cluster_get_owner_process_from_pid( pid_t pid );
205
206/******************************************************************************************
[1]207 * This function returns an extended pointer on the reference process descriptor
[443]208 * from the process <pid>. This PID can be be different from the calling process PID.
[23]209 * It can be called by any thread running in any cluster,
[1]210 ******************************************************************************************
211 * @ pid  : process identifier.
[433]212 * @ return extended pointer on reference process if found / XPTR_NULL if not found.
[1]213 *****************************************************************************************/
214xptr_t cluster_get_reference_process_from_pid( pid_t pid );
215
[19]216/******************************************************************************************
[443]217 * This function returns an extended pointer on the process descriptor copy for the
218 * process identified by <pid> in cluster defined by <cxy> argument.
219 * This PID can be be different from the calling process PID.
220 * It can be called by any thread running in any cluster,
221 ******************************************************************************************
222 * @ cxy  : target cluster identifier.
223 * @ pid  : process identifier.
224 * @ return extended pointer on reference process if found / XPTR_NULL if not found.
225 *****************************************************************************************/
226xptr_t cluster_get_process_from_pid_in_cxy( cxy_t cxy,
227                                            pid_t pid );
228
229/******************************************************************************************
[1]230 * This function allocates a new PID in local cluster, that becomes the process owner.
[19]231 * It registers the process descriptor extended pointer in the local processs manager
[428]232 * pref_tbl[] array. The process descriptor itself is not modified.
233 * This function is called by the process_make_fork() function,
[416]234 * by the process_make_exec() function, and by the process_init_create() function.
[1]235 ******************************************************************************************
[416]236 * @ process    : pointer on process descriptor.
[1]237 * @ pid        : [out] allocated PID.
[416]238 * @ return 0 if success / return -1 if no PID slot available.
[1]239 *****************************************************************************************/
[416]240error_t cluster_pid_alloc( struct process_s * process,
241                           pid_t            * pid );
[1]242
[19]243/******************************************************************************************
[1]244 * This function removes a PID from the local process manager pref_tbl[] array.
245 * It checks that removed process is owned by the local cluster and the lpid is legal.
246 * No memory is released by this function.
247 ******************************************************************************************
248 * @ pid        : allocated PID.
249 *****************************************************************************************/
250void cluster_pid_release( pid_t  pid );
251
252/******************************************************************************************
253 * This function returns a pointer on the local process descriptor from the PID.
254 * It uses the RPC
255 * to create a local process descriptor copy if it does not exist yet.
256 ******************************************************************************************
257 * @ pid     : searched process identifier.
258 * @ returns process descriptor pointer if found / returns NULL if not found.
259 *****************************************************************************************/
260struct process_s * cluster_get_local_process_from_pid( pid_t pid );
261
262/******************************************************************************************
263 * This function registers a local process descriptor in the process manager local_list.
264 ******************************************************************************************
265 * @ process     : pointer on local process descriptor.
266 *****************************************************************************************/
[19]267void cluster_process_local_link( struct process_s * process );
[1]268
269/******************************************************************************************
270 * This function removes a local process descriptor from the process manager local_list.
271 ******************************************************************************************
272 * @ process     : pointer on local process descriptor.
273 *****************************************************************************************/
[19]274void cluster_process_local_unlink( struct process_s * process );
[1]275
276/******************************************************************************************
277 * This function registers a local process descriptor in the owner process manager
278 * copies_list, that can be in a remote cluster.
279 ******************************************************************************************
280 * @ process     : pointer on local process descriptor.
281 *****************************************************************************************/
[19]282void cluster_process_copies_link( struct process_s * process );
[1]283
284/******************************************************************************************
285 * This function removes a local process descriptor from the owner process manager
286 * copies_list, that can be in a remote cluster.
287 ******************************************************************************************
288 * @ process     : pointer on local process descriptor.
289 *****************************************************************************************/
[19]290void cluster_process_copies_unlink( struct process_s * process );
[1]291
[428]292/*********************************************************************************************
293 * This function displays on the kernel terminal TXT0 all user processes registered
294 * in the cluster defined by the <cxy> argument.
295 * It can be called by a thread running in any cluster, because is use remote accesses
296 * to scan the xlist of registered processes.
297 *********************************************************************************************
298 * @ cxy   : cluster identifier.
299 ********************************************************************************************/
300void cluster_processes_display( cxy_t cxy );
[1]301
302
[428]303
[1]304/*****************************************************************************************/
305/***************   Cores Management Operations   *****************************************/
306/*****************************************************************************************/
307
308/******************************************************************************************
309 * This function returns the core local index that has the lowest usage in local cluster.
310 *****************************************************************************************/
[485]311lid_t cluster_select_local_core( void );
[1]312
313#endif  /* _CLUSTER_H_ */
Note: See TracBrowser for help on using the repository browser.