diff --git a/proc/diskstats.c b/proc/diskstats.c index c72369c2..e2b36930 100644 --- a/proc/diskstats.c +++ b/proc/diskstats.c @@ -111,7 +111,7 @@ struct diskstats_info { // ___ Results 'Set' Support |||||||||||||||||||||||||||||||||||||||||||||||||| -#define setNAME(e) set_results_ ## e +#define setNAME(e) set_diskstats_ ## e #define setDECL(e) static void setNAME(e) \ (struct diskstats_result *R, struct dev_node *N) @@ -166,7 +166,7 @@ struct sort_parms { enum diskstats_sort_order order; }; -#define srtNAME(t) sort_results_ ## t +#define srtNAME(t) sort_diskstats_ ## t #define srtDECL(t) static int srtNAME(t) \ (const struct diskstats_stack **A, const struct diskstats_stack **B, struct sort_parms *P) @@ -412,7 +412,7 @@ static int node_update ( // ___ Private Functions |||||||||||||||||||||||||||||||||||||||||||||||||||||| // --- generalized support ---------------------------------------------------- -static inline void assign_results ( +static inline void diskstats_assign_results ( struct diskstats_stack *stack, struct dev_node *node) { @@ -426,10 +426,10 @@ static inline void assign_results ( ++this; } return; -} // end: assign_results +} // end: diskstats_assign_results -static inline void cleanup_stack ( +static inline void diskstats_cleanup_stack ( struct diskstats_result *this) { for (;;) { @@ -439,10 +439,10 @@ static inline void cleanup_stack ( this->result.ul_int = 0; ++this; } -} // end: cleanup_stack +} // end: diskstats_cleanup_stack -static inline void cleanup_stacks_all ( +static inline void diskstats_cleanup_stacks_all ( struct ext_support *this) { struct stacks_extent *ext = this->extents; @@ -450,14 +450,14 @@ static inline void cleanup_stacks_all ( while (ext) { for (i = 0; ext->stacks[i]; i++) - cleanup_stack(ext->stacks[i]->head); + diskstats_cleanup_stack(ext->stacks[i]->head); ext = ext->next; }; this->dirty_stacks = 0; -} // end: cleanup_stacks_all +} // end: diskstats_cleanup_stacks_all -static void extents_free_all ( +static void diskstats_extents_free_all ( struct ext_support *this) { while (this->extents) { @@ -465,10 +465,10 @@ static void extents_free_all ( this->extents = this->extents->next; free(p); }; -} // end: extents_free_all +} // end: diskstats_extents_free_all -static inline struct diskstats_result *itemize_stack ( +static inline struct diskstats_result *diskstats_itemize_stack ( struct diskstats_result *p, int depth, enum diskstats_item *items) @@ -482,10 +482,10 @@ static inline struct diskstats_result *itemize_stack ( ++p; } return p_sav; -} // end: itemize_stack +} // end: diskstats_itemize_stack -static void itemize_stacks_all ( +static void diskstats_itemize_stacks_all ( struct ext_support *this) { struct stacks_extent *ext = this->extents; @@ -493,14 +493,14 @@ static void itemize_stacks_all ( while (ext) { int i; for (i = 0; ext->stacks[i]; i++) - itemize_stack(ext->stacks[i]->head, this->numitems, this->items); + diskstats_itemize_stack(ext->stacks[i]->head, this->numitems, this->items); ext = ext->next; }; this->dirty_stacks = 0; -} // end: static void itemize_stacks_all +} // end: diskstats_itemize_stacks_all -static inline int items_check_failed ( +static inline int diskstats_items_check_failed ( struct ext_support *this, enum diskstats_item *items, int numitems) @@ -528,11 +528,11 @@ static inline int items_check_failed ( } return 0; -} // end: items_check_failed +} // end: diskstats_items_check_failed /* - * read_diskstats_failed: + * diskstats_read_failed: * * @info: info structure created at procps_diskstats_new * @@ -541,7 +541,7 @@ static inline int items_check_failed ( * * Returns: 0 on success, negative on error */ -static int read_diskstats_failed ( +static int diskstats_read_failed ( struct diskstats_info *info) { static const char *fmtstr = "%d %d %" STRINGIFY(DISKSTATS_NAME_LEN) \ @@ -591,10 +591,21 @@ static int read_diskstats_failed ( } return 0; -} //end: read_diskstats_failed +} // end: diskstats_read_failed -static struct stacks_extent *stacks_alloc ( +/* + * diskstats_stacks_alloc(): + * + * Allocate and initialize one or more stacks each of which is anchored in an + * associated context structure. + * + * All such stacks will have their result structures properly primed with + * 'items', while the result itself will be zeroed. + * + * Returns a stacks_extent struct anchoring the 'heads' of each new stack. + */ +static struct stacks_extent *diskstats_stacks_alloc ( struct ext_support *this, int maxstacks) { @@ -634,17 +645,17 @@ static struct stacks_extent *stacks_alloc ( for (i = 0; i < maxstacks; i++) { p_head = (struct diskstats_stack *)v_head; - p_head->head = itemize_stack((struct diskstats_result *)v_list, this->numitems, this->items); + p_head->head = diskstats_itemize_stack((struct diskstats_result *)v_list, this->numitems, this->items); p_blob->stacks[i] = p_head; v_list += list_size; v_head += head_size; } p_blob->ext_numstacks = maxstacks; return p_blob; -} // end: stacks_alloc +} // end: diskstats_stacks_alloc -static int stacks_fetch ( +static int diskstats_stacks_fetch ( struct diskstats_info *info) { #define n_alloc info->fetch.n_alloc @@ -660,13 +671,13 @@ static int stacks_fetch ( n_alloc = STACKS_INCR; } if (!info->fetch_ext.extents) { - if (!(ext = stacks_alloc(&info->fetch_ext, n_alloc))) + if (!(ext = diskstats_stacks_alloc(&info->fetch_ext, n_alloc))) return -ENOMEM; memset(info->fetch.anchor, 0, sizeof(void *) * n_alloc); memcpy(info->fetch.anchor, ext->stacks, sizeof(void *) * n_alloc); - itemize_stacks_all(&info->fetch_ext); + diskstats_itemize_stacks_all(&info->fetch_ext); } - cleanup_stacks_all(&info->fetch_ext); + diskstats_cleanup_stacks_all(&info->fetch_ext); // iterate stuff -------------------------------------- n_inuse = 0; @@ -675,11 +686,11 @@ static int stacks_fetch ( if (!(n_inuse < n_alloc)) { n_alloc += STACKS_INCR; if ((!(info->fetch.anchor = realloc(info->fetch.anchor, sizeof(void *) * n_alloc))) - || (!(ext = stacks_alloc(&info->fetch_ext, STACKS_INCR)))) + || (!(ext = diskstats_stacks_alloc(&info->fetch_ext, STACKS_INCR)))) return -1; memcpy(info->fetch.anchor + n_inuse, ext->stacks, sizeof(void *) * STACKS_INCR); } - assign_results(info->fetch.anchor[n_inuse], node); + diskstats_assign_results(info->fetch.anchor[n_inuse], node); ++n_inuse; node = node->next; } @@ -702,15 +713,15 @@ static int stacks_fetch ( #undef n_alloc #undef n_inuse #undef n_saved -} // end: stacks_fetch +} // end: diskstats_stacks_fetch -static int stacks_reconfig_maybe ( +static int diskstats_stacks_reconfig_maybe ( struct ext_support *this, enum diskstats_item *items, int numitems) { - if (items_check_failed(this, items, numitems)) + if (diskstats_items_check_failed(this, items, numitems)) return -EINVAL; /* is this the first time or have things changed since we were last called? if so, gotta' redo all of our stacks stuff ... */ @@ -723,11 +734,11 @@ static int stacks_reconfig_maybe ( this->items[numitems] = DISKSTATS_logical_end; this->numitems = numitems + 1; if (this->extents) - extents_free_all(this); + diskstats_extents_free_all(this); return 1; } return 0; -} // end: stacks_reconfig_maybe +} // end: diskstats_stacks_reconfig_maybe // ___ Public Functions ||||||||||||||||||||||||||||||||||||||||||||||||||||||| @@ -759,7 +770,7 @@ PROCPS_EXPORT int procps_diskstats_new ( /* do a priming read here for the following potential benefits: | 1) ensure there will be no problems with subsequent access | 2) make delta results potentially useful, even if 1st time | */ - if ((rc = read_diskstats_failed(p))) { + if ((rc = diskstats_read_failed(p))) { procps_diskstats_unref(&p); return rc; } @@ -801,7 +812,7 @@ PROCPS_EXPORT int procps_diskstats_unref ( free(p); } if ((*info)->select_ext.extents) - extents_free_all((&(*info)->select_ext)); + diskstats_extents_free_all((&(*info)->select_ext)); if ((*info)->select_ext.items) free((*info)->select_ext.items); @@ -811,7 +822,7 @@ PROCPS_EXPORT int procps_diskstats_unref ( free((*info)->fetch.results.stacks); if ((*info)->fetch_ext.extents) - extents_free_all(&(*info)->fetch_ext); + diskstats_extents_free_all(&(*info)->fetch_ext); if ((*info)->fetch_ext.items) free((*info)->fetch_ext.items); @@ -843,7 +854,7 @@ PROCPS_EXPORT struct diskstats_result *procps_diskstats_get ( a granularity of 1 second between reads ... */ cur_secs = time(NULL); if (1 <= cur_secs - info->new_stamp) { - if (read_diskstats_failed(info)) + if (diskstats_read_failed(info)) return NULL; } @@ -875,15 +886,15 @@ PROCPS_EXPORT struct diskstats_reap *procps_diskstats_reap ( if (info == NULL || items == NULL) return NULL; - if (0 > stacks_reconfig_maybe(&info->fetch_ext, items, numitems)) + if (0 > diskstats_stacks_reconfig_maybe(&info->fetch_ext, items, numitems)) return NULL; if (info->fetch_ext.dirty_stacks) - cleanup_stacks_all(&info->fetch_ext); + diskstats_cleanup_stacks_all(&info->fetch_ext); - if (read_diskstats_failed(info)) + if (diskstats_read_failed(info)) return NULL; - stacks_fetch(info); + diskstats_stacks_fetch(info); info->fetch_ext.dirty_stacks = 1; return &info->fetch.results; @@ -908,22 +919,22 @@ PROCPS_EXPORT struct diskstats_stack *procps_diskstats_select ( if (info == NULL || items == NULL) return NULL; - if (0 > stacks_reconfig_maybe(&info->select_ext, items, numitems)) + if (0 > diskstats_stacks_reconfig_maybe(&info->select_ext, items, numitems)) return NULL; if (!info->select_ext.extents - && !(stacks_alloc(&info->select_ext, 1))) + && !(diskstats_stacks_alloc(&info->select_ext, 1))) return NULL; if (info->select_ext.dirty_stacks) - cleanup_stacks_all(&info->select_ext); + diskstats_cleanup_stacks_all(&info->select_ext); - if (read_diskstats_failed(info)) + if (diskstats_read_failed(info)) return NULL; if (!(node = node_get(info, name))) return NULL; - assign_results(info->select_ext.extents->stacks[0], node); + diskstats_assign_results(info->select_ext.extents->stacks[0], node); info->select_ext.dirty_stacks = 1; return info->select_ext.extents->stacks[0]; diff --git a/proc/meminfo.c b/proc/meminfo.c index b939bf71..0882a493 100644 --- a/proc/meminfo.c +++ b/proc/meminfo.c @@ -122,7 +122,7 @@ struct meminfo_info { // ___ Results 'Set' Support |||||||||||||||||||||||||||||||||||||||||||||||||| -#define setNAME(e) set_results_ ## e +#define setNAME(e) set_meminfo_ ## e #define setDECL(e) static void setNAME(e) \ (struct meminfo_result *R, struct mem_hist *H) @@ -368,7 +368,7 @@ enum meminfo_item MEMINFO_logical_end = MEMINFO_SWAP_USED + 1; // ___ Private Functions |||||||||||||||||||||||||||||||||||||||||||||||||||||| -static inline void assign_results ( +static inline void meminfo_assign_results ( struct meminfo_stack *stack, struct mem_hist *hist) { @@ -382,10 +382,10 @@ static inline void assign_results ( ++this; } return; -} // end: assign_results +} // end: meminfo_assign_results -static inline void cleanup_stack ( +static inline void meminfo_cleanup_stack ( struct meminfo_result *this) { for (;;) { @@ -395,10 +395,10 @@ static inline void cleanup_stack ( this->result.ul_int = 0; ++this; } -} // end: cleanup_stack +} // end: meminfo_cleanup_stack -static inline void cleanup_stacks_all ( +static inline void meminfo_cleanup_stacks_all ( struct meminfo_info *info) { struct stacks_extent *ext = info->extents; @@ -406,14 +406,14 @@ static inline void cleanup_stacks_all ( while (ext) { for (i = 0; ext->stacks[i]; i++) - cleanup_stack(ext->stacks[i]->head); + meminfo_cleanup_stack(ext->stacks[i]->head); ext = ext->next; }; info->dirty_stacks = 0; -} // end: cleanup_stacks_all +} // end: meminfo_cleanup_stacks_all -static void extents_free_all ( +static void meminfo_extents_free_all ( struct meminfo_info *info) { while (info->extents) { @@ -421,10 +421,10 @@ static void extents_free_all ( info->extents = info->extents->next; free(p); }; -} // end: extents_free_all +} // end: meminfo_extents_free_all -static inline struct meminfo_result *itemize_stack ( +static inline struct meminfo_result *meminfo_itemize_stack ( struct meminfo_result *p, int depth, enum meminfo_item *items) @@ -438,10 +438,10 @@ static inline struct meminfo_result *itemize_stack ( ++p; } return p_sav; -} // end: itemize_stack +} // end: meminfo_itemize_stack -static inline int items_check_failed ( +static inline int meminfo_items_check_failed ( int numitems, enum meminfo_item *items) { @@ -468,10 +468,10 @@ static inline int items_check_failed ( } return 0; -} // end: items_check_failed +} // end: meminfo_items_check_failed -static int make_hash_failed ( +static int meminfo_make_hash_failed ( struct meminfo_info *info) { #define htVAL(f) e.key = STRINGIFY(f) ":"; e.data = &info->hist.new. f; \ @@ -542,16 +542,16 @@ static int make_hash_failed ( return 0; #undef htVAL #undef htXTRA -} // end: make_hash_failed +} // end: meminfo_make_hash_failed /* - * read_meminfo_failed(): + * meminfo_read_failed(): * * Read the data out of /proc/meminfo putting the information * into the supplied info structure */ -static int read_meminfo_failed ( +static int meminfo_read_failed ( struct meminfo_info *info) { /* a 'memory history reference' macro for readability, @@ -651,21 +651,21 @@ static int read_meminfo_failed ( } return 0; #undef mHr -} // end: read_meminfo_failed +} // end: meminfo_read_failed /* - * stacks_alloc(): + * meminfo_stacks_alloc(): * * Allocate and initialize one or more stacks each of which is anchored in an - * associated meminfo_stack structure. + * associated context structure. * * All such stacks will have their result structures properly primed with * 'items', while the result itself will be zeroed. * * Returns a stacks_extent struct anchoring the 'heads' of each new stack. */ -static struct stacks_extent *stacks_alloc ( +static struct stacks_extent *meminfo_stacks_alloc ( struct meminfo_info *info, int maxstacks) { @@ -705,14 +705,14 @@ static struct stacks_extent *stacks_alloc ( for (i = 0; i < maxstacks; i++) { p_head = (struct meminfo_stack *)v_head; - p_head->head = itemize_stack((struct meminfo_result *)v_list, info->numitems, info->items); + p_head->head = meminfo_itemize_stack((struct meminfo_result *)v_list, info->numitems, info->items); p_blob->stacks[i] = p_head; v_list += list_size; v_head += head_size; } p_blob->ext_numstacks = maxstacks; return p_blob; -} // end: stacks_alloc +} // end: meminfo_stacks_alloc // ___ Public Functions ||||||||||||||||||||||||||||||||||||||||||||||||||||||| @@ -744,7 +744,7 @@ PROCPS_EXPORT int procps_meminfo_new ( p->refcount = 1; p->meminfo_fd = -1; - if ((rc = make_hash_failed(p))) { + if ((rc = meminfo_make_hash_failed(p))) { free(p); return rc; } @@ -774,7 +774,7 @@ PROCPS_EXPORT int procps_meminfo_unref ( if ((*info)->refcount == 0) { if ((*info)->extents) - extents_free_all((*info)); + meminfo_extents_free_all((*info)); if ((*info)->items) free((*info)->items); hdestroy_r(&(*info)->hashtab); @@ -804,7 +804,7 @@ PROCPS_EXPORT struct meminfo_result *procps_meminfo_get ( a granularity of 1 second between reads ... */ cur_secs = time(NULL); if (1 <= cur_secs - sav_secs) { - if (read_meminfo_failed(info)) + if (meminfo_read_failed(info)) return NULL; sav_secs = cur_secs; } @@ -833,7 +833,7 @@ PROCPS_EXPORT struct meminfo_stack *procps_meminfo_select ( { if (info == NULL || items == NULL) return NULL; - if (items_check_failed(numitems, items)) + if (meminfo_items_check_failed(numitems, items)) return NULL; /* is this the first time or have things changed since we were last called? @@ -847,18 +847,18 @@ PROCPS_EXPORT struct meminfo_stack *procps_meminfo_select ( info->items[numitems] = MEMINFO_logical_end; info->numitems = numitems + 1; if (info->extents) - extents_free_all(info); + meminfo_extents_free_all(info); } if (!info->extents - && !(stacks_alloc(info, 1))) + && !(meminfo_stacks_alloc(info, 1))) return NULL; if (info->dirty_stacks) - cleanup_stacks_all(info); + meminfo_cleanup_stacks_all(info); - if (read_meminfo_failed(info)) + if (meminfo_read_failed(info)) return NULL; - assign_results(info->extents->stacks[0], &info->hist); + meminfo_assign_results(info->extents->stacks[0], &info->hist); info->dirty_stacks = 1; return info->extents->stacks[0]; diff --git a/proc/pids.c b/proc/pids.c index 96afbc78..2976fd72 100644 --- a/proc/pids.c +++ b/proc/pids.c @@ -91,7 +91,7 @@ struct pids_info { // ___ Results 'Set' Support |||||||||||||||||||||||||||||||||||||||||||||||||| -static char** vectorize_this (const char* src) { +static char** pids_vectorize_this (const char* src) { #define pSZ (sizeof(char*)) char *cpy, **vec; int adj, tot; @@ -106,10 +106,10 @@ static char** vectorize_this (const char* src) { *(vec+1) = NULL; // null ptr 'list' delimit return vec; // ==> free(*vec) to dealloc #undef pSZ -} // end: vectorize_this +} // end: pids_vectorize_this -#define setNAME(e) set_results_ ## e +#define setNAME(e) set_pids_ ## e #define setDECL(e) static void setNAME(e) \ (struct pids_info *I, struct pids_result *R, proc_t *P) @@ -131,7 +131,7 @@ static char** vectorize_this (const char* src) { some sort of hint that they duplicated this char ** item ... */ #define VEC_set(e,x) setDECL(e) { \ (void)I; if (NULL != P-> x) { R->result.strv = P-> x; P-> x = NULL; } \ - else R->result.strv = vectorize_this("[ duplicate " STRINGIFY(e) " ]"); } + else R->result.strv = pids_vectorize_this("[ duplicate " STRINGIFY(e) " ]"); } setDECL(noop) { (void)I; (void)R; (void)P; return; } @@ -266,7 +266,7 @@ setDECL(WCHAN_NAME) { (void)I; R->result.str = strdup(lookup_wchan(P->tid)); // ___ Free Storage Support ||||||||||||||||||||||||||||||||||||||||||||||||||| -#define freNAME(t) free_results_ ## t +#define freNAME(t) free_pids_ ## t static void freNAME(str) (struct pids_result *R) { if (R->result.str) free(R->result.str); @@ -284,7 +284,7 @@ struct sort_parms { enum pids_sort_order order; }; -#define srtNAME(t) sort_results_ ## t +#define srtNAME(t) sort_pids_ ## t #define srtDECL(t) static int srtNAME(t) \ (const struct pids_stack **A, const struct pids_stack **B, struct sort_parms *P) @@ -576,7 +576,7 @@ struct history_info { }; -static void config_history ( +static void pids_config_history ( struct pids_info *info) { int i; @@ -587,10 +587,10 @@ static void config_history ( memcpy(Hr(HHash_two), Hr(HHash_nul), sizeof(Hr(HHash_nul))); Hr(PHash_sav) = Hr(HHash_one); // alternating 'old/new' hash tables Hr(PHash_new) = Hr(HHash_two); -} // end: config_history +} // end: pids_config_history -static inline HST_t *histget ( +static inline HST_t *pids_histget ( struct pids_info *info, int pid) { @@ -602,10 +602,10 @@ static inline HST_t *histget ( V = Hr(PHist_sav[V].lnk); } return NULL; -} // end: histget +} // end: pids_histget -static inline void histput ( +static inline void pids_histput ( struct pids_info *info, unsigned this) { @@ -613,12 +613,12 @@ static inline void histput ( Hr(PHist_new[this].lnk) = Hr(PHash_new[V]); Hr(PHash_new[V] = this); -} // end: histput +} // end: pids_histput #undef _HASH_PID_ -static int make_hist ( +static inline int pids_make_hist ( struct pids_info *info, proc_t *p) { @@ -638,9 +638,9 @@ static int make_hist ( Hr(PHist_new[nSLOT].min) = p->min_flt; Hr(PHist_new[nSLOT].tics) = tics = (p->utime + p->stime); - histput(info, nSLOT); + pids_histput(info, nSLOT); - if ((h = histget(info, p->tid))) { + if ((h = pids_histget(info, p->tid))) { p->pcpu = tics - h->tics; p->maj_delta = p->maj_flt - h->maj; p->min_delta = p->min_flt - h->min; @@ -649,10 +649,10 @@ static int make_hist ( nSLOT++; return 0; #undef nSLOT -} // end: make_hist +} // end: pids_make_hist -static inline void toggle_history ( +static inline void pids_toggle_history ( struct pids_info *info) { void *v; @@ -667,11 +667,11 @@ static inline void toggle_history ( memcpy(Hr(PHash_new), Hr(HHash_nul), sizeof(Hr(HHash_nul))); info->hist->num_tasks = 0; -} // end: toggle_history +} // end: pids_toggle_history #ifdef UNREF_RPTHASH -static void unref_rpthash ( +static void pids_unref_rpthash ( struct pids_info *info) { int i, j, pop, total_occupied, maxdepth, maxdepth_sav, numdepth @@ -752,7 +752,7 @@ static void unref_rpthash ( fprintf(stderr, "\n"); } } -} // end: unref_rpthash +} // end: pids_unref_rpthash #endif // UNREF_RPTHASH #undef Hr @@ -761,7 +761,7 @@ static void unref_rpthash ( // ___ Standard Private Functions ||||||||||||||||||||||||||||||||||||||||||||| -static inline void assign_results ( +static inline void pids_assign_results ( struct pids_info *info, struct pids_stack *stack, proc_t *p) @@ -777,10 +777,10 @@ static inline void assign_results ( ++this; } return; -} // end: assign_results +} // end: pids_assign_results -static inline void cleanup_stack ( +static inline void pids_cleanup_stack ( struct pids_result *this) { for (;;) { @@ -793,10 +793,10 @@ static inline void cleanup_stack ( this->result.ull_int = 0; ++this; } -} // end: cleanup_stack +} // end: pids_cleanup_stack -static inline void cleanup_stacks_all ( +static inline void pids_cleanup_stacks_all ( struct pids_info *info) { struct stacks_extent *ext = info->extents; @@ -804,18 +804,18 @@ static inline void cleanup_stacks_all ( while (ext) { for (i = 0; ext->stacks[i]; i++) - cleanup_stack(ext->stacks[i]->head); + pids_cleanup_stack(ext->stacks[i]->head); ext = ext->next; }; info->dirty_stacks = 0; -} // end: cleanup_stacks_all +} // end: pids_cleanup_stacks_all /* * This routine exists in case we ever want to offer something like * 'static' or 'invarient' results stacks. By unsplicing an extent * from the info anchor it will be isolated from future reset/free. */ -static struct stacks_extent *extent_cut ( +static struct stacks_extent *pids_extent_cut ( struct pids_info *info, struct stacks_extent *ext) { @@ -835,21 +835,10 @@ static struct stacks_extent *extent_cut ( } while (p); } return NULL; -} // end: extent_cut +} // end: pids_extent_cut -static void extents_free_all ( - struct pids_info *info) -{ - while (info->extents) { - struct stacks_extent *p = info->extents; - info->extents = info->extents->next; - free(p); - }; -} // end: extents_free_all - - -static inline struct pids_result *itemize_stack ( +static inline struct pids_result *pids_itemize_stack ( struct pids_result *p, int depth, enum pids_item *items) @@ -863,10 +852,10 @@ static inline struct pids_result *itemize_stack ( ++p; } return p_sav; -} // end: itemize_stack +} // end: pids_itemize_stack -static void itemize_stacks_all ( +static void pids_itemize_stacks_all ( struct pids_info *info) { struct stacks_extent *ext = info->extents; @@ -874,14 +863,14 @@ static void itemize_stacks_all ( while (ext) { int i; for (i = 0; ext->stacks[i]; i++) - itemize_stack(ext->stacks[i]->head, info->curitems, info->items); + pids_itemize_stack(ext->stacks[i]->head, info->curitems, info->items); ext = ext->next; }; info->dirty_stacks = 0; -} // end: itemize_stacks_all +} // end: pids_itemize_stacks_all -static inline int items_check_failed ( +static inline int pids_items_check_failed ( enum pids_item *items, int numitems) { @@ -907,10 +896,10 @@ static inline int items_check_failed ( } } return 0; -} // end: items_check_failed +} // end: pids_items_check_failed -static inline void libflags_set ( +static inline void pids_libflags_set ( struct pids_info *info) { enum pids_item e; @@ -928,20 +917,20 @@ static inline void libflags_set ( info->oldflags |= f_status; } return; -} // end: libflags_set +} // end: pids_libflags_set -static inline void oldproc_close ( +static inline void pids_oldproc_close ( PROCTAB **this) { if (*this != NULL) { closeproc(*this); *this = NULL; } -} // end: oldproc_close +} // end: pids_oldproc_close -static inline int oldproc_open ( +static inline int pids_oldproc_open ( PROCTAB **this, unsigned flags, ...) @@ -959,10 +948,10 @@ static inline int oldproc_open ( return 0; } return 1; -} // end: oldproc_open +} // end: pids_oldproc_open -static inline int proc_tally ( +static inline int pids_proc_tally ( struct pids_info *info, struct pids_counts *counts, proc_t *p) @@ -987,23 +976,23 @@ static inline int proc_tally ( ++counts->total; if (info->history_yes) - return !make_hist(info, p); + return !pids_make_hist(info, p); return 1; -} // end: proc_tally +} // end: pids_proc_tally /* - * stacks_alloc(): + * pids_stacks_alloc(): * * Allocate and initialize one or more stacks each of which is anchored in an - * associated pids_stack structure. + * associated context structure. * * All such stacks will will have their result structures properly primed with * 'items', while the result itself will be zeroed. * * Returns an array of pointers representing the 'heads' of each new stack. */ -static struct stacks_extent *stacks_alloc ( +static struct stacks_extent *pids_stacks_alloc ( struct pids_info *info, int maxstacks) { @@ -1043,17 +1032,17 @@ static struct stacks_extent *stacks_alloc ( for (i = 0; i < maxstacks; i++) { p_head = (struct pids_stack *)v_head; - p_head->head = itemize_stack((struct pids_result *)v_list, info->curitems, info->items); + p_head->head = pids_itemize_stack((struct pids_result *)v_list, info->curitems, info->items); p_blob->stacks[i] = p_head; v_list += list_size; v_head += head_size; } p_blob->ext_numstacks = maxstacks; return p_blob; -} // end: stacks_alloc +} // end: pids_stacks_alloc -static int stacks_fetch ( +static int pids_stacks_fetch ( struct pids_info *info) { #define n_alloc info->fetch.n_alloc @@ -1069,14 +1058,14 @@ static int stacks_fetch ( n_alloc = MEMORY_INCR; } if (!info->extents) { - if (!(ext = stacks_alloc(info, n_alloc))) + if (!(ext = pids_stacks_alloc(info, n_alloc))) return -ENOMEM; memset(info->fetch.anchor, 0, sizeof(void *) * n_alloc); memcpy(info->fetch.anchor, ext->stacks, sizeof(void *) * n_alloc); - itemize_stacks_all(info); + pids_itemize_stacks_all(info); } - cleanup_stacks_all(info); - toggle_history(info); + pids_cleanup_stacks_all(info); + pids_toggle_history(info); memset(&info->fetch.counts, 0, sizeof(struct pids_counts)); // iterate stuff -------------------------------------- @@ -1085,13 +1074,13 @@ static int stacks_fetch ( if (!(n_inuse < n_alloc)) { n_alloc += MEMORY_INCR; if ((!(info->fetch.anchor = realloc(info->fetch.anchor, sizeof(void *) * n_alloc))) - || (!(ext = stacks_alloc(info, MEMORY_INCR)))) + || (!(ext = pids_stacks_alloc(info, MEMORY_INCR)))) return -1; memcpy(info->fetch.anchor + n_inuse, ext->stacks, sizeof(void *) * MEMORY_INCR); } - if (!proc_tally(info, &info->fetch.counts, &task)) + if (!pids_proc_tally(info, &info->fetch.counts, &task)) return -1; - assign_results(info, info->fetch.anchor[n_inuse++], &task); + pids_assign_results(info, info->fetch.anchor[n_inuse++], &task); } // finalize stuff ------------------------------------- @@ -1111,7 +1100,7 @@ static int stacks_fetch ( #undef n_alloc #undef n_inuse #undef n_saved -} // end: stacks_fetch +} // end: pids_stacks_fetch // ___ Public Functions ||||||||||||||||||||||||||||||||||||||||||||||||||||||| @@ -1144,7 +1133,7 @@ PROCPS_EXPORT int procps_pids_new ( /* if we're without items or numitems, a later call to procps_pids_reset() will become mandatory */ if (items && numitems) { - if (items_check_failed(items, numitems)) { + if (pids_items_check_failed(items, numitems)) { free(p); return -EINVAL; } @@ -1157,7 +1146,7 @@ PROCPS_EXPORT int procps_pids_new ( memcpy(p->items, items, sizeof(enum pids_item) * numitems); p->items[numitems] = PIDS_logical_end; p->curitems = p->maxitems; - libflags_set(p); + pids_libflags_set(p); } if (!(p->hist = calloc(MEMORY_INCR, sizeof(struct history_info)))) { @@ -1165,7 +1154,7 @@ PROCPS_EXPORT int procps_pids_new ( free(p); return -ENOMEM; } - config_history(p); + pids_config_history(p); pgsz = getpagesize(); while (pgsz > 1024) { pgsz >>= 1; p->pgs2k_shift++; } @@ -1202,10 +1191,10 @@ PROCPS_EXPORT int procps_pids_unref ( (*info)->refcount--; if ((*info)->refcount == 0) { #ifdef UNREF_RPTHASH - unref_rpthash(*info); + pids_unref_rpthash(*info); #endif if ((*info)->extents) { - cleanup_stacks_all(*info); + pids_cleanup_stacks_all(*info); do { struct stacks_extent *p = (*info)->extents; (*info)->extents = (*info)->extents->next; @@ -1216,7 +1205,7 @@ PROCPS_EXPORT int procps_pids_unref ( struct stacks_extent *nextext, *ext = (*info)->otherexts; while (ext) { nextext = ext->next; - cleanup_stack(ext->stacks[0]->head); + pids_cleanup_stack(ext->stacks[0]->head); free(ext); ext = nextext; }; @@ -1265,14 +1254,14 @@ PROCPS_EXPORT struct pids_stack *fatal_proc_unmounted ( if (!info->curitems) return NULL; - if (!(ext = stacks_alloc(info, 1))) + if (!(ext = pids_stacks_alloc(info, 1))) return NULL; - if (!extent_cut(info, ext)) + if (!pids_extent_cut(info, ext)) return NULL; ext->next = info->otherexts; info->otherexts = ext; - assign_results(info, ext->stacks[0], &self); + pids_assign_results(info, ext->stacks[0], &self); return ext->stacks[0]; } // end: fatal_proc_unmounted @@ -1297,28 +1286,28 @@ PROCPS_EXPORT struct pids_stack *procps_pids_get ( fresh_start: if (!info->get_ext) { - if (!(info->get_ext = stacks_alloc(info, 1))) + if (!(info->get_ext = pids_stacks_alloc(info, 1))) return NULL; - if (!oldproc_open(&info->get_PT, info->oldflags)) + if (!pids_oldproc_open(&info->get_PT, info->oldflags)) return NULL; info->get_type = which; info->read_something = which ? readeither : readproc; } if (info->get_type != which) { - oldproc_close(&info->get_PT); - cleanup_stack(info->get_ext->stacks[0]->head); - if (extent_cut(info, info->get_ext)) + pids_oldproc_close(&info->get_PT); + pids_cleanup_stack(info->get_ext->stacks[0]->head); + if (pids_extent_cut(info, info->get_ext)) free(info->get_ext); info->get_ext = NULL; goto fresh_start; } - cleanup_stack(info->get_ext->stacks[0]->head); + pids_cleanup_stack(info->get_ext->stacks[0]->head); if (NULL == info->read_something(info->get_PT, &task)) return NULL; - assign_results(info, info->get_ext->stacks[0], &task); + pids_assign_results(info, info->get_ext->stacks[0], &task); return info->get_ext->stacks[0]; } // end: procps_pids_get @@ -1346,13 +1335,13 @@ PROCPS_EXPORT struct pids_fetch *procps_pids_reap ( if (!info->curitems) return NULL; - if (!oldproc_open(&info->fetch_PT, info->oldflags)) + if (!pids_oldproc_open(&info->fetch_PT, info->oldflags)) return NULL; info->read_something = which ? readeither : readproc; - rc = stacks_fetch(info); + rc = pids_stacks_fetch(info); - oldproc_close(&info->fetch_PT); + pids_oldproc_close(&info->fetch_PT); // we better have found at least 1 pid return (rc > 0) ? &info->fetch.results : NULL; } // end: procps_pids_reap @@ -1365,7 +1354,7 @@ PROCPS_EXPORT int procps_pids_reset ( { if (info == NULL || newitems == NULL) return -EINVAL; - if (items_check_failed(newitems, newnumitems)) + if (pids_items_check_failed(newitems, newnumitems)) return -EINVAL; /* shame on this caller, they didn't change anything. and unless they have @@ -1376,24 +1365,28 @@ PROCPS_EXPORT int procps_pids_reset ( if (info->maxitems < newnumitems + 1) { if (info->dirty_stacks) - cleanup_stacks_all(info); + pids_cleanup_stacks_all(info); + while (info->extents) { + struct stacks_extent *p = info->extents; + info->extents = p->next; + free(p); + }; // allow for our PIDS_logical_end info->maxitems = newnumitems + 1; if (!(info->items = realloc(info->items, sizeof(enum pids_item) * info->maxitems))) return -ENOMEM; - extents_free_all(info); } if (info->dirty_stacks) - cleanup_stacks_all(info); + pids_cleanup_stacks_all(info); memcpy(info->items, newitems, sizeof(enum pids_item) * newnumitems); info->items[newnumitems] = PIDS_logical_end; // account for above PIDS_logical_end info->curitems = newnumitems + 1; - itemize_stacks_all(info); - libflags_set(info); + pids_itemize_stacks_all(info); + pids_libflags_set(info); return 0; } // end: procps_pids_reset @@ -1430,13 +1423,13 @@ PROCPS_EXPORT struct pids_fetch *procps_pids_select ( memcpy(ids, these, sizeof(unsigned) * numthese); ids[numthese] = 0; - if (!oldproc_open(&info->fetch_PT, (info->oldflags | which), ids, numthese)) + if (!pids_oldproc_open(&info->fetch_PT, (info->oldflags | which), ids, numthese)) return NULL; info->read_something = readproc; - rc = stacks_fetch(info); + rc = pids_stacks_fetch(info); - oldproc_close(&info->fetch_PT); + pids_oldproc_close(&info->fetch_PT); // no guarantee any pids/uids were found return (rc > -1) ? &info->fetch.results : NULL; } // end: procps_pids_select diff --git a/proc/slabinfo.c b/proc/slabinfo.c index afad3086..eb5bc7fb 100644 --- a/proc/slabinfo.c +++ b/proc/slabinfo.c @@ -136,7 +136,7 @@ struct slabinfo_info { // ___ Results 'Set' Support |||||||||||||||||||||||||||||||||||||||||||||||||| -#define setNAME(e) set_results_ ## e +#define setNAME(e) set_slabinfo_ ## e #define setDECL(e) static void setNAME(e) \ (struct slabinfo_result *R, struct slabs_hist *S, struct slabs_node *N) @@ -199,7 +199,7 @@ struct sort_parms { enum slabinfo_sort_order order; }; -#define srtNAME(t) sort_results_ ## t +#define srtNAME(t) sort_slabinfo_ ## t #define srtDECL(t) static int srtNAME(t) \ (const struct slabinfo_stack **A, const struct slabinfo_stack **B, struct sort_parms *P) @@ -506,7 +506,7 @@ static int read_slabinfo_failed ( // ___ Private Functions |||||||||||||||||||||||||||||||||||||||||||||||||||||| // --- generalized support ---------------------------------------------------- -static inline void assign_results ( +static inline void slabinfo_assign_results ( struct slabinfo_stack *stack, struct slabs_hist *summ, struct slabs_node *node) @@ -521,10 +521,10 @@ static inline void assign_results ( ++this; } return; -} // end: assign_results +} // end: slabinfo_assign_results -static inline void cleanup_stack ( +static inline void slabinfo_cleanup_stack ( struct slabinfo_result *this) { for (;;) { @@ -534,10 +534,10 @@ static inline void cleanup_stack ( this->result.ul_int = 0; ++this; } -} // end: cleanup_stack +} // end: slabinfo_cleanup_stack -static inline void cleanup_stacks_all ( +static inline void slabinfo_cleanup_stacks_all ( struct ext_support *this) { struct stacks_extent *ext = this->extents; @@ -545,14 +545,14 @@ static inline void cleanup_stacks_all ( while (ext) { for (i = 0; ext->stacks[i]; i++) - cleanup_stack(ext->stacks[i]->head); + slabinfo_cleanup_stack(ext->stacks[i]->head); ext = ext->next; }; this->dirty_stacks = 0; -} // end: cleanup_stacks_all +} // end: slabinfo_cleanup_stacks_all -static void extents_free_all ( +static void slabinfo_extents_free_all ( struct ext_support *this) { while (this->extents) { @@ -560,10 +560,10 @@ static void extents_free_all ( this->extents = this->extents->next; free(p); }; -} // end: extents_free_all +} // end: slabinfo_extents_free_all -static inline struct slabinfo_result *itemize_stack ( +static inline struct slabinfo_result *slabinfo_itemize_stack ( struct slabinfo_result *p, int depth, enum slabinfo_item *items) @@ -577,10 +577,10 @@ static inline struct slabinfo_result *itemize_stack ( ++p; } return p_sav; -} // end: itemize_stack +} // end: slabinfo_itemize_stack -static void itemize_stacks_all ( +static void slabinfo_itemize_stacks_all ( struct ext_support *this) { struct stacks_extent *ext = this->extents; @@ -588,14 +588,14 @@ static void itemize_stacks_all ( while (ext) { int i; for (i = 0; ext->stacks[i]; i++) - itemize_stack(ext->stacks[i]->head, this->numitems, this->items); + slabinfo_itemize_stack(ext->stacks[i]->head, this->numitems, this->items); ext = ext->next; }; this->dirty_stacks = 0; -} // end: static void itemize_stacks_all +} // end: slabinfo_itemize_stacks_all -static inline int items_check_failed ( +static inline int slabinfo_items_check_failed ( struct ext_support *this, enum slabinfo_item *items, int numitems) @@ -632,10 +632,21 @@ static inline int items_check_failed ( } return 0; -} // end: items_check_failed +} // end: slabinfo_items_check_failed -static struct stacks_extent *stacks_alloc ( +/* + * slabinfo_stacks_alloc(): + * + * Allocate and initialize one or more stacks each of which is anchored in an + * associated context structure. + * + * All such stacks will have their result structures properly primed with + * 'items', while the result itself will be zeroed. + * + * Returns a stacks_extent struct anchoring the 'heads' of each new stack. + */ +static struct stacks_extent *slabinfo_stacks_alloc ( struct ext_support *this, int maxstacks) { @@ -675,17 +686,17 @@ static struct stacks_extent *stacks_alloc ( for (i = 0; i < maxstacks; i++) { p_head = (struct slabinfo_stack *)v_head; - p_head->head = itemize_stack((struct slabinfo_result *)v_list, this->numitems, this->items); + p_head->head = slabinfo_itemize_stack((struct slabinfo_result *)v_list, this->numitems, this->items); p_blob->stacks[i] = p_head; v_list += list_size; v_head += head_size; } p_blob->ext_numstacks = maxstacks; return p_blob; -} // end: stacks_alloc +} // end: slabinfo_stacks_alloc -static int stacks_fetch ( +static int slabinfo_stacks_fetch ( struct slabinfo_info *info) { #define n_alloc info->fetch.n_alloc @@ -700,13 +711,13 @@ static int stacks_fetch ( n_alloc = STACKS_INCR; } if (!info->fetch_ext.extents) { - if (!(ext = stacks_alloc(&info->fetch_ext, n_alloc))) + if (!(ext = slabinfo_stacks_alloc(&info->fetch_ext, n_alloc))) return -ENOMEM; memset(info->fetch.anchor, 0, sizeof(void *) * n_alloc); memcpy(info->fetch.anchor, ext->stacks, sizeof(void *) * n_alloc); - itemize_stacks_all(&info->fetch_ext); + slabinfo_itemize_stacks_all(&info->fetch_ext); } - cleanup_stacks_all(&info->fetch_ext); + slabinfo_cleanup_stacks_all(&info->fetch_ext); // iterate stuff -------------------------------------- n_inuse = 0; @@ -714,11 +725,11 @@ static int stacks_fetch ( if (!(n_inuse < n_alloc)) { n_alloc += STACKS_INCR; if ((!(info->fetch.anchor = realloc(info->fetch.anchor, sizeof(void *) * n_alloc))) - || (!(ext = stacks_alloc(&info->fetch_ext, STACKS_INCR)))) + || (!(ext = slabinfo_stacks_alloc(&info->fetch_ext, STACKS_INCR)))) return -1; memcpy(info->fetch.anchor + n_inuse, ext->stacks, sizeof(void *) * STACKS_INCR); } - assign_results(info->fetch.anchor[n_inuse], &info->hist, &info->nodes[n_inuse]); + slabinfo_assign_results(info->fetch.anchor[n_inuse], &info->hist, &info->nodes[n_inuse]); ++n_inuse; } @@ -740,15 +751,15 @@ static int stacks_fetch ( #undef n_alloc #undef n_inuse #undef n_saved -} // end: stacks_fetch +} // end: slabinfo_stacks_fetch -static int stacks_reconfig_maybe ( +static int slabinfo_stacks_reconfig_maybe ( struct ext_support *this, enum slabinfo_item *items, int numitems) { - if (items_check_failed(this, items, numitems)) + if (slabinfo_items_check_failed(this, items, numitems)) return -EINVAL; /* is this the first time or have things changed since we were last called? if so, gotta' redo all of our stacks stuff ... */ @@ -761,11 +772,11 @@ static int stacks_reconfig_maybe ( this->items[numitems] = SLABINFO_logical_end; this->numitems = numitems + 1; if (this->extents) - extents_free_all(this); + slabinfo_extents_free_all(this); return 1; } return 0; -} // end: stacks_reconfig_maybe +} // end: slabinfo_stacks_reconfig_maybe // ___ Public Functions ||||||||||||||||||||||||||||||||||||||||||||||||||||||| @@ -838,7 +849,7 @@ PROCPS_EXPORT int procps_slabinfo_unref ( (*info)->slabinfo_fp = NULL; } if ((*info)->select_ext.extents) - extents_free_all((&(*info)->select_ext)); + slabinfo_extents_free_all((&(*info)->select_ext)); if ((*info)->select_ext.items) free((*info)->select_ext.items); @@ -848,7 +859,7 @@ PROCPS_EXPORT int procps_slabinfo_unref ( free((*info)->fetch.results.stacks); if ((*info)->fetch_ext.extents) - extents_free_all(&(*info)->fetch_ext); + slabinfo_extents_free_all(&(*info)->fetch_ext); if ((*info)->fetch_ext.items) free((*info)->fetch_ext.items); @@ -911,15 +922,15 @@ PROCPS_EXPORT struct slabinfo_reap *procps_slabinfo_reap ( if (info == NULL || items == NULL) return NULL; - if (0 > stacks_reconfig_maybe(&info->fetch_ext, items, numitems)) + if (0 > slabinfo_stacks_reconfig_maybe(&info->fetch_ext, items, numitems)) return NULL; if (info->fetch_ext.dirty_stacks) - cleanup_stacks_all(&info->fetch_ext); + slabinfo_cleanup_stacks_all(&info->fetch_ext); if (read_slabinfo_failed(info)) return NULL; - stacks_fetch(info); + slabinfo_stacks_fetch(info); info->fetch_ext.dirty_stacks = 1; return &info->fetch.results; @@ -941,19 +952,19 @@ PROCPS_EXPORT struct slabinfo_stack *procps_slabinfo_select ( if (info == NULL || items == NULL) return NULL; - if (0 > stacks_reconfig_maybe(&info->select_ext, items, numitems)) + if (0 > slabinfo_stacks_reconfig_maybe(&info->select_ext, items, numitems)) return NULL; if (!info->select_ext.extents - && !(stacks_alloc(&info->select_ext, 1))) + && !(slabinfo_stacks_alloc(&info->select_ext, 1))) return NULL; if (info->select_ext.dirty_stacks) - cleanup_stacks_all(&info->select_ext); + slabinfo_cleanup_stacks_all(&info->select_ext); if (read_slabinfo_failed(info)) return NULL; - assign_results(info->select_ext.extents->stacks[0], &info->hist, &info->nul_node); + slabinfo_assign_results(info->select_ext.extents->stacks[0], &info->hist, &info->nul_node); info->select_ext.dirty_stacks = 1; return info->select_ext.extents->stacks[0]; diff --git a/proc/stat.c b/proc/stat.c index 43665aac..9ca42fc7 100644 --- a/proc/stat.c +++ b/proc/stat.c @@ -137,7 +137,7 @@ struct stat_info { // ___ Results 'Set' Support |||||||||||||||||||||||||||||||||||||||||||||||||| -#define setNAME(e) set_results_ ## e +#define setNAME(e) set_stat_ ## e #define setDECL(e) static void setNAME(e) \ (struct stat_result *R, struct hist_sys *S, struct hist_tic *T) @@ -209,7 +209,7 @@ struct sort_parms { enum stat_sort_order order; }; -#define srtNAME(t) sort_results_ ## t +#define srtNAME(t) sort_stat_ ## t #define srtDECL(t) static int srtNAME(t) \ (const struct stat_stack **A, const struct stat_stack **B, struct sort_parms *P) @@ -339,7 +339,7 @@ static int fake_node_of_cpu (int n) { return (1 == (n % 4)) ? 0 : (n % 4); } #endif -static inline void assign_results ( +static inline void stat_assign_results ( struct stat_stack *stack, struct hist_sys *sys_hist, struct hist_tic *tic_hist) @@ -354,10 +354,10 @@ static inline void assign_results ( ++this; } return; -} // end: assign_results +} // end: stat_assign_results -static inline void cleanup_stack ( +static inline void stat_cleanup_stack ( struct stat_result *this) { for (;;) { @@ -367,10 +367,10 @@ static inline void cleanup_stack ( this->result.ull_int = 0; ++this; } -} // end: cleanup_stack +} // end: stat_cleanup_stack -static inline void cleanup_stacks_all ( +static inline void stat_cleanup_stacks_all ( struct ext_support *this) { struct stacks_extent *ext = this->extents; @@ -378,14 +378,14 @@ static inline void cleanup_stacks_all ( while (ext) { for (i = 0; ext->stacks[i]; i++) - cleanup_stack(ext->stacks[i]->head); + stat_cleanup_stack(ext->stacks[i]->head); ext = ext->next; }; this->dirty_stacks = 0; -} // end: cleanup_stacks_all +} // end: stat_cleanup_stacks_all -static void extents_free_all ( +static void stat_extents_free_all ( struct ext_support *this) { while (this->extents) { @@ -393,10 +393,10 @@ static void extents_free_all ( this->extents = this->extents->next; free(p); }; -} // end: extents_free_all +} // end: stat_extents_free_all -static inline struct stat_result *itemize_stack ( +static inline struct stat_result *stat_itemize_stack ( struct stat_result *p, int depth, enum stat_item *items) @@ -410,10 +410,10 @@ static inline struct stat_result *itemize_stack ( ++p; } return p_sav; -} // end: itemize_stack +} // end: stat_itemize_stack -static inline int items_check_failed ( +static inline int stat_items_check_failed ( int numitems, enum stat_item *items) { @@ -440,10 +440,10 @@ static inline int items_check_failed ( } } return 0; -} // end: items_check_failed +} // end: stat_items_check_failed -static int make_numa_hist ( +static int stat_make_numa_hist ( struct stat_info *info) { #ifndef NUMA_DISABLE @@ -507,10 +507,10 @@ static int make_numa_hist ( #else return 0; #endif -} // end: make_numa_hist +} // end: stat_make_numa_hist -static int read_stat_failed ( +static int stat_read_failed ( struct stat_info *info) { struct hist_tic *sum_ptr, *cpu_ptr; @@ -574,7 +574,7 @@ reap_em_again: bp = 1 + strchr(bp, '\n'); // remember this cpu from last time around memcpy(&cpu_ptr->old, &cpu_ptr->new, sizeof(struct stat_jifs)); - // next can be overridden under 'make_numa_hist' + // next can be overridden under 'stat_make_numa_hist' cpu_ptr->numa_node = STAT_NODE_INVALID; if (8 > (rc = sscanf(bp, "cpu%d %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu" @@ -644,21 +644,21 @@ reap_em_again: info->stat_was_read = 1; } return 0; -} // end: read_stat_failed +} // end: stat_read_failed /* - * stacks_alloc(): + * stat_stacks_alloc(): * * Allocate and initialize one or more stacks each of which is anchored in an - * associated stat_stack structure. + * associated context structure. * * All such stacks will have their result structures properly primed with * 'items', while the result itself will be zeroed. * * Returns a stack_extent struct anchoring the 'heads' of each new stack. */ -static struct stacks_extent *stacks_alloc ( +static struct stacks_extent *stat_stacks_alloc ( struct ext_support *this, int maxstacks) { @@ -698,17 +698,17 @@ static struct stacks_extent *stacks_alloc ( for (i = 0; i < maxstacks; i++) { p_head = (struct stat_stack *)v_head; - p_head->head = itemize_stack((struct stat_result *)v_list, this->items->num, this->items->enums); + p_head->head = stat_itemize_stack((struct stat_result *)v_list, this->items->num, this->items->enums); p_blob->stacks[i] = p_head; v_list += list_size; v_head += head_size; } p_blob->ext_numstacks = maxstacks; return p_blob; -} // end: stacks_alloc +} // end: stat_stacks_alloc -static int stacks_fetch_tics ( +static int stat_stacks_fetch ( struct stat_info *info, struct reap_support *this) { @@ -728,24 +728,24 @@ static int stacks_fetch_tics ( n_alloc = STACKS_INCR; } if (!this->fetch.extents) { - if (!(ext = stacks_alloc(&this->fetch, n_alloc))) + if (!(ext = stat_stacks_alloc(&this->fetch, n_alloc))) return -ENOMEM; memcpy(this->anchor, ext->stacks, sizeof(void *) * n_alloc); } if (this->fetch.dirty_stacks) - cleanup_stacks_all(&this->fetch); + stat_cleanup_stacks_all(&this->fetch); // iterate stuff -------------------------------------- for (i = 0; i < n_inuse; i++) { if (!(i < n_alloc)) { n_alloc += STACKS_INCR; if ((!(this->anchor = realloc(this->anchor, sizeof(void *) * n_alloc))) - || (!(ext = stacks_alloc(&this->fetch, STACKS_INCR)))) { + || (!(ext = stat_stacks_alloc(&this->fetch, STACKS_INCR)))) { return -ENOMEM; } memcpy(this->anchor + i, ext->stacks, sizeof(void *) * STACKS_INCR); } - assign_results(this->anchor[i], &info->sys_hist, &this->hist.tics[i]); + stat_assign_results(this->anchor[i], &info->sys_hist, &this->hist.tics[i]); } // finalize stuff ------------------------------------- @@ -768,15 +768,15 @@ static int stacks_fetch_tics ( #undef n_alloc #undef n_inuse #undef n_saved -} // end: stacks_fetch_tics +} // end: stat_stacks_fetch -static int stacks_reconfig_maybe ( +static int stat_stacks_reconfig_maybe ( struct ext_support *this, enum stat_item *items, int numitems) { - if (items_check_failed(numitems, items)) + if (stat_items_check_failed(numitems, items)) return -EINVAL; /* is this the first time or have things changed since we were last called? @@ -789,29 +789,29 @@ static int stacks_reconfig_maybe ( memcpy(this->items->enums, items, sizeof(enum stat_item) * numitems); this->items->enums[numitems] = STAT_logical_end; this->items->num = numitems + 1; - extents_free_all(this); + stat_extents_free_all(this); return 1; } return 0; -} // end: stacks_reconfig_maybe +} // end: stat_stacks_reconfig_maybe -static struct stat_stack *update_single_stack ( +static struct stat_stack *stat_update_single_stack ( struct stat_info *info, struct ext_support *this) { if (!this->extents - && !(stacks_alloc(this, 1))) + && !(stat_stacks_alloc(this, 1))) return NULL; if (this->dirty_stacks) - cleanup_stacks_all(this); + stat_cleanup_stacks_all(this); - assign_results(this->extents->stacks[0], &info->sys_hist, &info->cpu_hist); + stat_assign_results(this->extents->stacks[0], &info->sys_hist, &info->cpu_hist); this->dirty_stacks = 1; return this->extents->stacks[0]; -} // end: update_single_stack +} // end: stat_update_single_stack #if defined(PRETEND_NUMA) && defined(NUMA_DISABLE) @@ -910,7 +910,7 @@ PROCPS_EXPORT int procps_stat_unref ( if ((*info)->cpus.hist.tics) free((*info)->cpus.hist.tics); if ((*info)->cpus.fetch.extents) - extents_free_all(&(*info)->cpus.fetch); + stat_extents_free_all(&(*info)->cpus.fetch); if ((*info)->nodes.anchor) free((*info)->nodes.anchor); @@ -919,13 +919,13 @@ PROCPS_EXPORT int procps_stat_unref ( if ((*info)->nodes.hist.tics) free((*info)->nodes.hist.tics); if ((*info)->nodes.fetch.extents) - extents_free_all(&(*info)->nodes.fetch); + stat_extents_free_all(&(*info)->nodes.fetch); if ((*info)->cpu_summary.extents) - extents_free_all(&(*info)->cpu_summary); + stat_extents_free_all(&(*info)->cpu_summary); if ((*info)->select.extents) - extents_free_all(&(*info)->select); + stat_extents_free_all(&(*info)->select); if ((*info)->reap_items.enums) free((*info)->reap_items.enums); @@ -964,7 +964,7 @@ PROCPS_EXPORT struct stat_result *procps_stat_get ( a granularity of 1 second between reads ... */ cur_secs = time(NULL); if (1 <= cur_secs - sav_secs) { - if (read_stat_failed(info)) + if (stat_read_failed(info)) return NULL; sav_secs = cur_secs; } @@ -1009,16 +1009,16 @@ PROCPS_EXPORT struct stat_reaped *procps_stat_reap ( } #endif - if (0 > (rc = stacks_reconfig_maybe(&info->cpu_summary, items, numitems))) + if (0 > (rc = stat_stacks_reconfig_maybe(&info->cpu_summary, items, numitems))) return NULL; if (rc) { - extents_free_all(&info->cpus.fetch); - extents_free_all(&info->nodes.fetch); + stat_extents_free_all(&info->cpus.fetch); + stat_extents_free_all(&info->nodes.fetch); } - if (read_stat_failed(info)) + if (stat_read_failed(info)) return NULL; - info->results.summary = update_single_stack(info, &info->cpu_summary); + info->results.summary = stat_update_single_stack(info, &info->cpu_summary); /* unlike the other 'reap' functions, provides for two separate | stacks pointer arrays exposed to callers. Thus, to keep our promise | @@ -1031,20 +1031,20 @@ PROCPS_EXPORT struct stat_reaped *procps_stat_reap ( switch (what) { case STAT_REAP_CPUS_ONLY: - if (!stacks_fetch_tics(info, &info->cpus)) + if (!stat_stacks_fetch(info, &info->cpus)) return NULL; break; case STAT_REAP_CPUS_AND_NODES: #ifndef NUMA_DISABLE - /* note: if we are doing numa at all, we must call make_numa_hist | + /* note: if we are doing numa at all, we must call stat_make_numa_hist | before we build (fetch) the cpu stacks since the read_stat guy | will have marked (temporarily) all the cpu node ids as invalid | */ - if (0 > make_numa_hist(info)) + if (0 > stat_make_numa_hist(info)) return NULL; // tolerate an unexpected absence of libnuma.so ... - stacks_fetch_tics(info, &info->nodes); + stat_stacks_fetch(info, &info->nodes); #endif - if (!stacks_fetch_tics(info, &info->cpus)) + if (!stat_stacks_fetch(info, &info->cpus)) return NULL; break; default: @@ -1070,13 +1070,13 @@ PROCPS_EXPORT struct stat_stack *procps_stat_select ( if (info == NULL || items == NULL) return NULL; - if (0 > stacks_reconfig_maybe(&info->select, items, numitems)) + if (0 > stat_stacks_reconfig_maybe(&info->select, items, numitems)) return NULL; - if (read_stat_failed(info)) + if (stat_read_failed(info)) return NULL; - return update_single_stack(info, &info->select); + return stat_update_single_stack(info, &info->select); } // end: procps_stat_select diff --git a/proc/vmstat.c b/proc/vmstat.c index 6cf8c52d..62d480eb 100644 --- a/proc/vmstat.c +++ b/proc/vmstat.c @@ -195,7 +195,7 @@ struct vmstat_info { // ___ Results 'Set' Support |||||||||||||||||||||||||||||||||||||||||||||||||| -#define setNAME(e) set_results_ ## e +#define setNAME(e) set_vmstat_ ## e #define setDECL(e) static void setNAME(e) \ (struct vmstat_result *R, struct vmstat_hist *H) @@ -723,7 +723,7 @@ enum vmstat_item VMSTAT_logical_end = VMSTAT_DELTA_ZONE_RECLAIM_FAILED + 1; // ___ Private Functions |||||||||||||||||||||||||||||||||||||||||||||||||||||| -static inline void assign_results ( +static inline void vmstat_assign_results ( struct vmstat_stack *stack, struct vmstat_hist *hist) { @@ -737,10 +737,10 @@ static inline void assign_results ( ++this; } return; -} // end: assign_results +} // end: vmstat_assign_results -static inline void cleanup_stack ( +static inline void vmstat_cleanup_stack ( struct vmstat_result *this) { for (;;) { @@ -750,10 +750,10 @@ static inline void cleanup_stack ( this->result.ul_int = 0; ++this; } -} // end: cleanup_stack +} // end: vmstat_cleanup_stack -static inline void cleanup_stacks_all ( +static inline void vmstat_cleanup_stacks_all ( struct vmstat_info *info) { struct stacks_extent *ext = info->extents; @@ -761,14 +761,14 @@ static inline void cleanup_stacks_all ( while (ext) { for (i = 0; ext->stacks[i]; i++) - cleanup_stack(ext->stacks[i]->head); + vmstat_cleanup_stack(ext->stacks[i]->head); ext = ext->next; }; info->dirty_stacks = 0; -} // end: cleanup_stacks_all +} // end: vmstat_cleanup_stacks_all -static void extents_free_all ( +static void vmstat_extents_free_all ( struct vmstat_info *info) { while (info->extents) { @@ -776,10 +776,10 @@ static void extents_free_all ( info->extents = info->extents->next; free(p); }; -} // end: extents_free_all +} // end: vmstat_extents_free_all -static inline struct vmstat_result *itemize_stack ( +static inline struct vmstat_result *vmstat_itemize_stack ( struct vmstat_result *p, int depth, enum vmstat_item *items) @@ -793,10 +793,10 @@ static inline struct vmstat_result *itemize_stack ( ++p; } return p_sav; -} // end: itemize_stack +} // end: vmstat_itemize_stack -static inline int items_check_failed ( +static inline int vmstat_items_check_failed ( int numitems, enum vmstat_item *items) { @@ -823,10 +823,10 @@ static inline int items_check_failed ( } return 0; -} // end: items_check_failed +} // end: vmstat_items_check_failed -static int make_hash_failed ( +static int vmstat_make_hash_failed ( struct vmstat_info *info) { #define htVAL(f) e.key = STRINGIFY(f); e.data = &info->hist.new. f; \ @@ -959,16 +959,16 @@ static int make_hash_failed ( return 0; #undef htVAL -} // end: make_hash_failed +} // end: vmstat_make_hash_failed /* - * read_vmstat_failed(): + * vmstat_read_failed(): * * Read the data out of /proc/vmstat putting the information * into the supplied info structure */ -static int read_vmstat_failed ( +static int vmstat_read_failed ( struct vmstat_info *info) { char buf[8192]; @@ -1035,21 +1035,21 @@ static int read_vmstat_failed ( info->vmstat_was_read = 1; } return 0; -} // end: read_vmstat_failed +} // end: vmstat_read_failed /* - * stacks_alloc(): + * vmstat_stacks_alloc(): * * Allocate and initialize one or more stacks each of which is anchored in an - * associated vmstat_stack structure. + * associated context structure. * * All such stacks will have their result structures properly primed with * 'items', while the result itself will be zeroed. * * Returns a stacks_extent struct anchoring the 'heads' of each new stack. */ -static struct stacks_extent *stacks_alloc ( +static struct stacks_extent *vmstat_stacks_alloc ( struct vmstat_info *info, int maxstacks) { @@ -1089,14 +1089,14 @@ static struct stacks_extent *stacks_alloc ( for (i = 0; i < maxstacks; i++) { p_head = (struct vmstat_stack *)v_head; - p_head->head = itemize_stack((struct vmstat_result *)v_list, info->numitems, info->items); + p_head->head = vmstat_itemize_stack((struct vmstat_result *)v_list, info->numitems, info->items); p_blob->stacks[i] = p_head; v_list += list_size; v_head += head_size; } p_blob->ext_numstacks = maxstacks; return p_blob; -} // end: stacks_alloc +} // end: vmstat_stacks_alloc // ___ Public Functions ||||||||||||||||||||||||||||||||||||||||||||||||||||||| @@ -1128,7 +1128,7 @@ PROCPS_EXPORT int procps_vmstat_new ( p->refcount = 1; p->vmstat_fd = -1; - if ((rc = make_hash_failed(p))) { + if ((rc = vmstat_make_hash_failed(p))) { free(p); return rc; } @@ -1158,7 +1158,7 @@ PROCPS_EXPORT int procps_vmstat_unref ( if ((*info)->refcount == 0) { if ((*info)->extents) - extents_free_all((*info)); + vmstat_extents_free_all((*info)); if ((*info)->items) free((*info)->items); hdestroy_r(&(*info)->hashtab); @@ -1188,7 +1188,7 @@ PROCPS_EXPORT struct vmstat_result *procps_vmstat_get ( a granularity of 1 second between reads ... */ cur_secs = time(NULL); if (1 <= cur_secs - sav_secs) { - if (read_vmstat_failed(info)) + if (vmstat_read_failed(info)) return NULL; sav_secs = cur_secs; } @@ -1217,7 +1217,7 @@ PROCPS_EXPORT struct vmstat_stack *procps_vmstat_select ( { if (info == NULL || items == NULL) return NULL; - if (items_check_failed(numitems, items)) + if (vmstat_items_check_failed(numitems, items)) return NULL; /* is this the first time or have things changed since we were last called? @@ -1231,18 +1231,18 @@ PROCPS_EXPORT struct vmstat_stack *procps_vmstat_select ( info->items[numitems] = VMSTAT_logical_end; info->numitems = numitems + 1; if (info->extents) - extents_free_all(info); + vmstat_extents_free_all(info); } if (!info->extents - && !(stacks_alloc(info, 1))) + && !(vmstat_stacks_alloc(info, 1))) return NULL; if (info->dirty_stacks) - cleanup_stacks_all(info); + vmstat_cleanup_stacks_all(info); - if (read_vmstat_failed(info)) + if (vmstat_read_failed(info)) return NULL; - assign_results(info->extents->stacks[0], &info->hist); + vmstat_assign_results(info->extents->stacks[0], &info->hist); info->dirty_stacks = 1; return info->extents->stacks[0];