Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-29 09:21:44

0001 /*
0002  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
0003  *                         University Research and Technology
0004  *                         Corporation.  All rights reserved.
0005  * Copyright (c) 2004-2006 The University of Tennessee and The University
0006  *                         of Tennessee Research Foundation.  All rights
0007  *                         reserved.
0008  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
0009  *                         University of Stuttgart.  All rights reserved.
0010  * Copyright (c) 2004-2005 The Regents of the University of California.
0011  *                         All rights reserved.
0012  * Copyright (c) 2007-2020 Cisco Systems, Inc.  All rights reserved
0013  * Copyright (c) 2019      Intel, Inc.  All rights reserved.
0014  * Copyright (c) 2021-2025 Nanook Consulting  All rights reserved.
0015  * $COPYRIGHT$
0016  *
0017  * Additional copyrights may follow
0018  *
0019  * $HEADER$
0020  *
0021  */
0022 
0023 #ifndef PMIX_PSTAT_BASE_H
0024 #define PMIX_PSTAT_BASE_H
0025 
0026 #include "pmix_config.h"
0027 #include "src/include/pmix_globals.h"
0028 #include "src/include/pmix_types.h"
0029 #include "src/mca/base/pmix_mca_base_framework.h"
0030 #include "src/mca/pstat/pstat.h"
0031 
0032 /*
0033  * Global functions for MCA overall pstat open and close
0034  */
0035 
0036 BEGIN_C_DECLS
0037 
0038 /**
0039  * Framework structure declaration for this framework
0040  */
0041 PMIX_EXPORT extern pmix_mca_base_framework_t pmix_pstat_base_framework;
0042 
0043 /**
0044  * Select an available component.
0045  *
0046  * @return PMIX_SUCCESS Upon success.
0047  * @return PMIX_NOT_FOUND If no component can be selected.
0048  * @return PMIX_ERROR Upon other failure.
0049  *
0050  * At the end of this process, we'll either have a single
0051  * component that is selected and initialized, or no component was
0052  * selected.  If no component was selected, subsequent invocation
0053  * of the pstat functions will return an error indicating no data
0054  * could be obtained
0055  */
0056 PMIX_EXPORT int pmix_pstat_base_select(void);
0057 
0058 PMIX_EXPORT extern pmix_pstat_base_component_t *pmix_pstat_base_component;
0059 
0060 typedef struct {
0061     pmix_event_base_t *evbase;
0062     pmix_list_t ops;
0063 } pmix_pstat_base_t;
0064 
0065 PMIX_EXPORT extern pmix_pstat_base_t pmix_pstat_base;
0066 
0067 typedef struct {
0068     bool cmdline;
0069     bool pctcpu;
0070     bool state;
0071     bool time;
0072     bool pri;
0073     bool nthreads;
0074     bool cpu;
0075     bool vsize;
0076     bool pkvsize;
0077     bool rss;
0078     bool pss;
0079 } pmix_procstats_t;
0080 #define PMIX_PROCSTATS_INIT(a) \
0081     memset(a, 0, sizeof(pmix_procstats_t))
0082 
0083 #define PMIX_PROCSTATS_ALL(a) \
0084     memset(a, 1, sizeof(pmix_procstats_t))
0085 
0086 typedef struct {
0087     bool rdcompleted;
0088     bool rdmerged;
0089     bool rdsectors;
0090     bool rdms;
0091     bool wrtcompleted;
0092     bool wrtmerged;
0093     bool wrtsectors;
0094     bool wrtms;
0095     bool ioprog;
0096     bool ioms;
0097     bool ioweight;
0098 } pmix_dkstats_t;
0099 #define PMIX_DKSTATS_INIT(a) \
0100     memset(a, 0, sizeof(pmix_dkstats_t))
0101 
0102 #define PMIX_DKSTATS_ALL(a) \
0103     memset(a, 1, sizeof(pmix_dkstats_t))
0104 
0105 typedef struct {
0106     bool rcvdb;
0107     bool rcvdp;
0108     bool rcvde;
0109     bool sntb;
0110     bool sntp;
0111     bool snte;
0112 } pmix_netstats_t;
0113 #define PMIX_NETSTATS_INIT(a) \
0114     memset(a, 0, sizeof(pmix_netstats_t))
0115 
0116 #define PMIX_NETSTATS_ALL(a) \
0117     memset(a, 1, sizeof(pmix_netstats_t))
0118 
0119 typedef struct {
0120     bool la;
0121     bool la5;
0122     bool la15;
0123     bool mtot;
0124     bool mfree;
0125     bool mbuf;
0126     bool mcached;
0127     bool mswapcached;
0128     bool mswaptot;
0129     bool mswapfree;
0130     bool mmap;
0131 } pmix_ndstats_t;
0132 #define PMIX_NDSTATS_INIT(a) \
0133     memset(a, 0, sizeof(pmix_ndstats_t))
0134 
0135 #define PMIX_NDSTATS_ALL(a) \
0136     memset(a, 1, sizeof(pmix_ndstats_t))
0137 
0138 
0139 typedef struct {
0140     pmix_list_item_t super;
0141     pmix_proc_t requestor;
0142     char *id;
0143     pmix_event_t ev;
0144     struct timeval tv;
0145     bool active;
0146     uint32_t rate;
0147     pmix_status_t eventcode;
0148     pmix_list_t peers;
0149     char **disks;
0150     char **nets;
0151     pmix_procstats_t pstats;
0152     pmix_dkstats_t dkstats;
0153     pmix_netstats_t netstats;
0154     pmix_ndstats_t ndstats;
0155     pmix_cb_t *cb;
0156 } pmix_pstat_op_t;
0157 PMIX_CLASS_DECLARATION(pmix_pstat_op_t);
0158 
0159 // p - pmix_pstat_op_t*
0160 // s - time in seconds
0161 // cb - callback function that will execute the collection
0162 #define PMIX_PSTAT_OP_START(p, s, cb)                                           \
0163     do {                                                                        \
0164         pmix_event_evtimer_set(pmix_pstat_base.evbase, &(p)->ev, (cb), (p));    \
0165         (p)->tv.tv_sec = (s);                                                   \
0166         (p)->tv.tv_usec = 0;                                                    \
0167         PMIX_OUTPUT_VERBOSE((1, pmix_pstat_base_framework.framework_output,     \
0168                              "defining pstat event: %ld sec at %s:%d",          \
0169                              (long) (p)->tv.tv_sec, __FILE__, __LINE__));       \
0170         PMIX_POST_OBJECT(p);                                                    \
0171         (p)->active = true;                                                     \
0172         pmix_event_evtimer_add(&(p)->ev, &(p)->tv);                             \
0173     } while (0);
0174 
0175 #define PMIX_PSTAT_APPEND_PEER_UNIQUE(pl, pr)                   \
0176     do {                                                        \
0177         bool f = false;                                         \
0178         pmix_peerlist_t *_p;                                    \
0179         PMIX_LIST_FOREACH(_p, pl, pmix_peerlist_t) {            \
0180             if (_p->peer == (pr)) {                             \
0181                 f = true;                                       \
0182                 break;                                          \
0183             }                                                   \
0184         }                                                       \
0185         if (!f) {                                               \
0186             _p = PMIX_NEW(pmix_peerlist_t);                     \
0187             _p->peer = (pr);                                    \
0188             pmix_list_append(pl, &(_p->super));                 \
0189         }                                                       \
0190     } while(0)
0191 
0192 PMIX_EXPORT void pmix_pstat_parse_procstats(pmix_procstats_t *pst,
0193                                             pmix_info_t *info, size_t sz);
0194 
0195 PMIX_EXPORT void pmix_pstat_parse_dkstats(char ***disks, pmix_dkstats_t *dkst,
0196                                           pmix_info_t *info, size_t sz);
0197 
0198 PMIX_EXPORT void pmix_pstat_parse_netstats(char ***nets, pmix_netstats_t *netst,
0199                                            pmix_info_t *info, size_t sz);
0200 
0201 PMIX_EXPORT void pmix_pstat_parse_ndstats(pmix_ndstats_t *ndst,
0202                                           pmix_info_t *info, size_t sz);
0203 
0204 END_C_DECLS
0205 
0206 #endif /* PMIX_BASE_PSTAT_H */