// ___ 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)
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)
// ___ Private Functions ||||||||||||||||||||||||||||||||||||||||||||||||||||||
// --- generalized support ----------------------------------------------------
-static inline void assign_results (
+static inline void diskstats_assign_results (
struct diskstats_stack *stack,
struct dev_node *node)
{
++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 (;;) {
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;
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) {
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)
++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;
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)
}
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
*
*
* 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) \
}
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)
{
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
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;
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;
}
#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 ... */
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 |||||||||||||||||||||||||||||||||||||||||||||||||||||||
/* 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;
}
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);
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);
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;
}
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;
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];
// ___ 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)
// ___ Private Functions ||||||||||||||||||||||||||||||||||||||||||||||||||||||
-static inline void assign_results (
+static inline void meminfo_assign_results (
struct meminfo_stack *stack,
struct mem_hist *hist)
{
++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 (;;) {
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;
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) {
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)
++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)
{
}
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; \
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,
}
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)
{
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 |||||||||||||||||||||||||||||||||||||||||||||||||||||||
p->refcount = 1;
p->meminfo_fd = -1;
- if ((rc = make_hash_failed(p))) {
+ if ((rc = meminfo_make_hash_failed(p))) {
free(p);
return rc;
}
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);
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;
}
{
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?
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];
// ___ 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;
*(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)
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; }
// ___ 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);
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)
};
-static void config_history (
+static void pids_config_history (
struct pids_info *info)
{
int i;
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)
{
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)
{
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)
{
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;
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;
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
fprintf(stderr, "\n");
}
}
-} // end: unref_rpthash
+} // end: pids_unref_rpthash
#endif // UNREF_RPTHASH
#undef Hr
// ___ 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)
++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 (;;) {
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;
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)
{
} 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)
++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;
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)
{
}
}
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;
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,
...)
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)
++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)
{
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
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 --------------------------------------
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 -------------------------------------
#undef n_alloc
#undef n_inuse
#undef n_saved
-} // end: stacks_fetch
+} // end: pids_stacks_fetch
// ___ Public Functions |||||||||||||||||||||||||||||||||||||||||||||||||||||||
/* 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;
}
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)))) {
free(p);
return -ENOMEM;
}
- config_history(p);
+ pids_config_history(p);
pgsz = getpagesize();
while (pgsz > 1024) { pgsz >>= 1; p->pgs2k_shift++; }
(*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;
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;
};
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
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
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
{
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
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
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
// ___ 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)
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)
// ___ 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)
++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 (;;) {
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;
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) {
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)
++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;
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)
}
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)
{
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
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;
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;
}
#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 ... */
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 |||||||||||||||||||||||||||||||||||||||||||||||||||||||
(*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);
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);
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;
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];
// ___ 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)
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)
#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)
++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 (;;) {
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;
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) {
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)
++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)
{
}
}
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
#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;
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"
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)
{
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)
{
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 -------------------------------------
#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?
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)
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);
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);
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;
}
}
#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, <stat> provides for two separate |
stacks pointer arrays exposed to callers. Thus, to keep our promise |
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:
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
// ___ 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)
// ___ Private Functions ||||||||||||||||||||||||||||||||||||||||||||||||||||||
-static inline void assign_results (
+static inline void vmstat_assign_results (
struct vmstat_stack *stack,
struct vmstat_hist *hist)
{
++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 (;;) {
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;
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) {
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)
++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)
{
}
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; \
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];
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)
{
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 |||||||||||||||||||||||||||||||||||||||||||||||||||||||
p->refcount = 1;
p->vmstat_fd = -1;
- if ((rc = make_hash_failed(p))) {
+ if ((rc = vmstat_make_hash_failed(p))) {
free(p);
return rc;
}
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);
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;
}
{
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?
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];