int numitems; // includes 'logical_end' delimiter
enum diskstats_item *items; // includes 'logical_end' delimiter
struct stacks_extent *extents; // anchor for these extents
- int dirty_stacks;
};
struct fetch_support {
#define HST_set(e,t,x) setDECL(e) { R->result. t = ( N->new . x - N->old. x ); }
setDECL(noop) { (void)R; (void)N; }
-setDECL(extra) { (void)R; (void)N; }
+setDECL(extra) { (void)N; R->result.ul_int = 0; }
DEV_set(DISKSTATS_NAME, str, name)
DEV_set(DISKSTATS_TYPE, s_int, type)
} // end: diskstats_assign_results
-static inline void diskstats_cleanup_stack (
- struct diskstats_result *this)
-{
- for (;;) {
- if (this->item >= DISKSTATS_logical_end)
- break;
- if (this->item > DISKSTATS_noop)
- this->result.ul_int = 0;
- ++this;
- }
-} // end: diskstats_cleanup_stack
-
-
-static inline void diskstats_cleanup_stacks_all (
- struct ext_support *this)
-{
- struct stacks_extent *ext = this->extents;
- int i;
-
- while (ext) {
- for (i = 0; ext->stacks[i]; i++)
- diskstats_cleanup_stack(ext->stacks[i]->head);
- ext = ext->next;
- };
- this->dirty_stacks = 0;
-} // end: diskstats_cleanup_stacks_all
-
-
static void diskstats_extents_free_all (
struct ext_support *this)
{
for (i = 0; i < depth; i++) {
p->item = items[i];
- p->result.ul_int = 0;
++p;
}
return p_sav;
return -1; // here, errno was set to ENOMEM
memcpy(info->fetch.anchor, ext->stacks, sizeof(void *) * n_alloc);
}
- diskstats_cleanup_stacks_all(&info->fetch_ext);
// iterate stuff --------------------------------------
n_inuse = 0;
return NULL; // here, errno may be overridden with ENOMEM
errno = 0;
- if (info->fetch_ext.dirty_stacks)
- diskstats_cleanup_stacks_all(&info->fetch_ext);
-
if (diskstats_read_failed(info))
return NULL;
if (0 > diskstats_stacks_fetch(info))
return NULL;
- info->fetch_ext.dirty_stacks = 1;
return &info->fetch.results;
} // end: procps_diskstats_reap
&& (!diskstats_stacks_alloc(&info->select_ext, 1)))
return NULL;
- if (info->select_ext.dirty_stacks)
- diskstats_cleanup_stacks_all(&info->select_ext);
-
if (diskstats_read_failed(info))
return NULL;
if (!(node = node_get(info, name))) {
}
diskstats_assign_results(info->select_ext.extents->stacks[0], node);
- info->select_ext.dirty_stacks = 1;
return info->select_ext.extents->stacks[0];
} // end: procps_diskstats_select
struct meminfo_info {
int refcount;
int meminfo_fd;
- int dirty_stacks;
struct mem_hist hist;
int numitems;
enum meminfo_item *items;
// delta assignment
#define HST_set(e,t,x) setDECL(e) { R->result. t = ( H->new . x - H->old. x ); }
-setDECL(noop) { (void)R; (void)H; }
-setDECL(extra) { (void)R; (void)H; }
+setDECL(noop) { (void)R; (void)H; }
+setDECL(extra) { (void)H; R->result.ul_int = 0; }
MEM_set(MEM_ACTIVE, ul_int, Active)
MEM_set(MEM_ACTIVE_ANON, ul_int, Active_anon)
} // end: meminfo_assign_results
-static inline void meminfo_cleanup_stack (
- struct meminfo_result *this)
-{
- for (;;) {
- if (this->item >= MEMINFO_logical_end)
- break;
- if (this->item > MEMINFO_noop)
- this->result.ul_int = 0;
- ++this;
- }
-} // end: meminfo_cleanup_stack
-
-
-static inline void meminfo_cleanup_stacks_all (
- struct meminfo_info *info)
-{
- struct stacks_extent *ext = info->extents;
- int i;
-
- while (ext) {
- for (i = 0; ext->stacks[i]; i++)
- meminfo_cleanup_stack(ext->stacks[i]->head);
- ext = ext->next;
- };
- info->dirty_stacks = 0;
-} // end: meminfo_cleanup_stacks_all
-
-
static void meminfo_extents_free_all (
struct meminfo_info *info)
{
for (i = 0; i < depth; i++) {
p->item = items[i];
- p->result.ul_int = 0;
++p;
}
return p_sav;
&& (!meminfo_stacks_alloc(info, 1)))
return NULL;
- if (info->dirty_stacks)
- meminfo_cleanup_stacks_all(info);
-
if (meminfo_read_failed(info))
return NULL;
meminfo_assign_results(info->extents->stacks[0], &info->hist);
- info->dirty_stacks = 1;
return info->extents->stacks[0];
} // end: procps_meminfo_select
struct fetch_support fetch; // support for procps_pids_reap & select
int history_yes; // need historical data
struct history_info *hist; // pointer to historical support data
- int dirty_stacks; // stacks results need attention
proc_t*(*read_something)(PROCTAB*, proc_t*); // readproc/readeither via which
unsigned pgs2k_shift; // to convert some proc vaules
unsigned oldflags; // the old library PROC_FILL flagss
};
+// ___ Free Storage Support |||||||||||||||||||||||||||||||||||||||||||||||||||
+
+#define freNAME(t) free_pids_ ## t
+
+static void freNAME(str) (struct pids_result *R) {
+ if (R->result.str) free(R->result.str);
+}
+
+static void freNAME(strv) (struct pids_result *R) {
+ if (R->result.strv && *R->result.strv) free(*R->result.strv);
+}
+
+
// ___ Results 'Set' Support ||||||||||||||||||||||||||||||||||||||||||||||||||
#define setNAME(e) set_pids_ ## e
R->result. t = (long)(P-> x) << I -> pgs2k_shift; }
/* strdup of a static char array */
#define DUP_set(e,x) setDECL(e) { \
+ freNAME(str)(R); \
if (!(R->result.str = strdup(P-> x))) I->seterr = 1; }
/* regular assignment copy */
#define REG_set(e,t,x) setDECL(e) { \
/* take ownership of a normal single string if possible, else return
some sort of hint that they duplicated this char * item ... */
#define STR_set(e,x) setDECL(e) { \
+ freNAME(str)(R); \
if (NULL != P-> x) { R->result.str = P-> x; P-> x = NULL; } \
else { R->result.str = strdup("[ duplicate " STRINGIFY(e) " ]"); \
if (!R->result.str) I->seterr = 1; } }
/* take ownership of true vectorized strings if possible, else return
some sort of hint that they duplicated this char ** item ... */
#define VEC_set(e,x) setDECL(e) { \
+ freNAME(strv)(R); \
if (NULL != P-> x) { R->result.strv = P-> x; P-> x = NULL; } \
else { R->result.strv = vectorize_this_str("[ duplicate " STRINGIFY(e) " ]"); \
if (!R->result.str) I->seterr = 1; } }
-setDECL(noop) { (void)I; (void)R; (void)P; return; }
-setDECL(extra) { (void)I; (void)R; (void)P; return; }
+setDECL(noop) { (void)I; (void)R; (void)P; }
+setDECL(extra) { (void)I; (void)P; R->result.ull_int = 0; }
+
REG_set(ADDR_END_CODE, ul_int, end_code)
REG_set(ADDR_KSTK_EIP, ul_int, kstk_eip)
REG_set(ADDR_KSTK_ESP, ul_int, kstk_esp)
setDECL(TIME_ELAPSED) { unsigned long long t = P->start_time / I->hertz; R->result.ull_int = I->boot_seconds >= t ? (I->boot_seconds - t) : 0; }
REG_set(TIME_START, ull_int, start_time)
REG_set(TTY, s_int, tty)
-setDECL(TTY_NAME) { char buf[64]; dev_to_tty(buf, sizeof(buf), P->tty, P->tid, ABBREV_DEV); if (!(R->result.str = strdup(buf))) I->seterr = 1; }
-setDECL(TTY_NUMBER) { char buf[64]; dev_to_tty(buf, sizeof(buf), P->tty, P->tid, ABBREV_DEV|ABBREV_TTY|ABBREV_PTS); if (!(R->result.str = strdup(buf))) I->seterr = 1; }
+setDECL(TTY_NAME) { char buf[64]; freNAME(str)(R); dev_to_tty(buf, sizeof(buf), P->tty, P->tid, ABBREV_DEV); if (!(R->result.str = strdup(buf))) I->seterr = 1; }
+setDECL(TTY_NUMBER) { char buf[64]; freNAME(str)(R); dev_to_tty(buf, sizeof(buf), P->tty, P->tid, ABBREV_DEV|ABBREV_TTY|ABBREV_PTS); if (!(R->result.str = strdup(buf))) I->seterr = 1; }
REG_set(VM_DATA, ul_int, vm_data)
REG_set(VM_EXE, ul_int, vm_exe)
REG_set(VM_LIB, ul_int, vm_lib)
REG_set(VM_SWAP, ul_int, vm_swap)
setDECL(VM_USED) { (void)I; R->result.ul_int = P->vm_swap + P->vm_rss; }
REG_set(VSIZE_PGS, ul_int, vsize)
-setDECL(WCHAN_NAME) { if (!(R->result.str = strdup(lookup_wchan(P->tid)))) I->seterr = 1;; }
+setDECL(WCHAN_NAME) { freNAME(str)(R); if (!(R->result.str = strdup(lookup_wchan(P->tid)))) I->seterr = 1;; }
#undef setDECL
#undef CVT_set
#undef VEC_set
-// ___ Free Storage Support |||||||||||||||||||||||||||||||||||||||||||||||||||
-
-#define freNAME(t) free_pids_ ## t
-
-static void freNAME(str) (struct pids_result *R) {
- if (R->result.str) free(R->result.str);
-}
-
-static void freNAME(strv) (struct pids_result *R) {
- if (R->result.strv && *R->result.strv) free(*R->result.strv);
-}
-
-
// ___ Sorting Support ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
struct sort_parms {
break;
if (Item_table[item].freefunc)
Item_table[item].freefunc(this);
- if (item > PIDS_noop)
- this->result.ull_int = 0;
+ this->result.ull_int = 0;
++this;
}
} // end: pids_cleanup_stack
pids_cleanup_stack(ext->stacks[i]->head);
ext = ext->next;
};
- info->dirty_stacks = 0;
} // end: pids_cleanup_stacks_all
for (i = 0; i < depth; i++) {
p->item = items[i];
- p->result.ull_int = 0;
++p;
}
return p_sav;
pids_itemize_stack(ext->stacks[i]->head, info->curitems, info->items);
ext = ext->next;
};
- info->dirty_stacks = 0;
} // end: pids_itemize_stacks_all
memcpy(info->fetch.anchor, ext->stacks, sizeof(void *) * STACKS_INCR);
n_alloc = STACKS_INCR;
}
- pids_cleanup_stacks_all(info);
pids_toggle_history(info);
memset(&info->fetch.counts, 0, sizeof(struct pids_counts));
}
memcpy(info->fetch.results.stacks, info->fetch.anchor, sizeof(void *) * n_inuse);
info->fetch.results.stacks[n_inuse] = NULL;
- info->dirty_stacks = 1;
return n_inuse; // callers beware, this might be zero !
#undef n_alloc
}
errno = 0;
- pids_cleanup_stack(info->get_ext->stacks[0]->head);
-
if (NULL == info->read_something(info->get_PT, &task))
return NULL;
if (!pids_assign_results(info, info->get_ext->stacks[0], &task))
if (pids_items_check_failed(newitems, newnumitems))
return -EINVAL;
- if (info->dirty_stacks)
- pids_cleanup_stacks_all(info);
+ pids_cleanup_stacks_all(info);
/* shame on this caller, they didn't change anything. and unless they have
altered the depth of the stacks we're not gonna change anything either! */
// account for above PIDS_logical_end
info->curitems = newnumitems + 1;
+ // if extents freed above, pids_stacks_alloc() will itemize ...
pids_itemize_stacks_all(info);
pids_libflags_set(info);
enum slabinfo_item lowest; // range of allowable enums
enum slabinfo_item highest;
#endif
- int dirty_stacks;
};
struct fetch_support {
#define HST_set(e,t,x) setDECL(e) { (void)N; R->result. t = (signed long)S->new . x - S->old. x; }
setDECL(noop) { (void)R; (void)S; (void)N; }
-setDECL(extra) { (void)R; (void)S; (void)N; }
+setDECL(extra) { (void)S; (void)N; R->result.ul_int = 0; }
NOD_set(SLAB_NAME, str, name)
NOD_set(SLAB_NUM_OBJS, u_int, nr_objs)
} // end: slabinfo_assign_results
-static inline void slabinfo_cleanup_stack (
- struct slabinfo_result *this)
-{
- for (;;) {
- if (this->item >= SLABINFO_logical_end)
- break;
- if (this->item > SLABINFO_noop)
- this->result.ul_int = 0;
- ++this;
- }
-} // end: slabinfo_cleanup_stack
-
-
-static inline void slabinfo_cleanup_stacks_all (
- struct ext_support *this)
-{
- struct stacks_extent *ext = this->extents;
- int i;
-
- while (ext) {
- for (i = 0; ext->stacks[i]; i++)
- slabinfo_cleanup_stack(ext->stacks[i]->head);
- ext = ext->next;
- };
- this->dirty_stacks = 0;
-} // end: slabinfo_cleanup_stacks_all
-
-
static void slabinfo_extents_free_all (
struct ext_support *this)
{
for (i = 0; i < depth; i++) {
p->item = items[i];
- p->result.ul_int = 0;
++p;
}
return p_sav;
return -1; // here, errno was set to ENOMEM
memcpy(info->fetch.anchor, ext->stacks, sizeof(void *) * n_alloc);
}
- slabinfo_cleanup_stacks_all(&info->fetch_ext);
// iterate stuff --------------------------------------
n_inuse = 0;
return NULL; // here, errno may be overridden with ENOMEM
errno = 0;
- if (info->fetch_ext.dirty_stacks)
- slabinfo_cleanup_stacks_all(&info->fetch_ext);
-
if (slabinfo_read_failed(info))
return NULL;
if (0 > slabinfo_stacks_fetch(info))
return NULL;
- info->fetch_ext.dirty_stacks = 1;
return &info->fetch.results;
} // end: procps_slabinfo_reap
&& (!slabinfo_stacks_alloc(&info->select_ext, 1)))
return NULL;
- if (info->select_ext.dirty_stacks)
- slabinfo_cleanup_stacks_all(&info->select_ext);
-
if (slabinfo_read_failed(info))
return NULL;
slabinfo_assign_results(info->select_ext.extents->stacks[0], &info->slabs, &info->nul_node);
- info->select_ext.dirty_stacks = 1;
return info->select_ext.extents->stacks[0];
} // end: procps_slabinfo_select
struct ext_support {
struct item_support *items; // how these stacks are configured
struct stacks_extent *extents; // anchor for these extents
- int dirty_stacks;
};
struct tic_support {
(void)T; R->result. t = ( S->new . x - S->old. x ); \
if (R->result. t < 0) R->result. t = 0; }
-setDECL(noop) { (void)R; (void)S; (void)T; }
-setDECL(extra) { (void)R; (void)S; (void)T; }
+setDECL(noop) { (void)R; (void)S; (void)T; }
+setDECL(extra) { (void)S; (void)T; R->result.ull_int = 0; }
setDECL(TIC_ID) { (void)S; R->result.s_int = T->id; }
setDECL(TIC_NUMA_NODE) { (void)S; R->result.s_int = T->numa_node; }
} // end: stat_assign_results
-static inline void stat_cleanup_stack (
- struct stat_result *this)
-{
- for (;;) {
- if (this->item >= STAT_logical_end)
- break;
- if (this->item > STAT_noop)
- this->result.ull_int = 0;
- ++this;
- }
-} // end: stat_cleanup_stack
-
-
-static inline void stat_cleanup_stacks_all (
- struct ext_support *this)
-{
- struct stacks_extent *ext = this->extents;
- int i;
-
- while (ext) {
- for (i = 0; ext->stacks[i]; i++)
- stat_cleanup_stack(ext->stacks[i]->head);
- ext = ext->next;
- };
- this->dirty_stacks = 0;
-} // end: stat_cleanup_stacks_all
-
-
static inline void stat_derive_unique (
struct hist_tic *this)
{
for (i = 0; i < depth; i++) {
p->item = items[i];
- p->result.ull_int = 0;
++p;
}
return p_sav;
return -1; // here, errno was set to ENOMEM
memcpy(this->anchor, ext->stacks, sizeof(void *) * n_alloc);
}
- if (this->fetch.dirty_stacks)
- stat_cleanup_stacks_all(&this->fetch);
// iterate stuff --------------------------------------
for (i = 0; i < n_inuse; i++) {
memcpy(this->result.stacks, this->anchor, sizeof(void *) * i);
this->result.stacks[i] = NULL;
this->result.total = i;
- this->fetch.dirty_stacks = 1;
// callers beware, this might be zero (maybe no libnuma.so) ...
return this->result.total;
&& !(stat_stacks_alloc(this, 1)))
return NULL;
- if (this->dirty_stacks)
- stat_cleanup_stacks_all(this);
-
stat_assign_results(this->extents->stacks[0], &info->sys_hist, &info->cpu_hist);
- this->dirty_stacks = 1;
return this->extents->stacks[0];
} // end: stat_update_single_stack
struct vmstat_info {
int refcount;
int vmstat_fd;
- int dirty_stacks;
struct vmstat_hist hist;
int numitems;
enum vmstat_item *items;
// delta assignment
#define HST_set(e,x) setDECL(e) { R->result.sl_int = ( H->new . x - H->old. x ); }
-setDECL(noop) { (void)R; (void)H; }
-setDECL(extra) { (void)R; (void)H; }
+setDECL(noop) { (void)R; (void)H; }
+setDECL(extra) { (void)H; R->result.ul_int = 0; }
REG_set(ALLOCSTALL_DMA, allocstall_dma)
REG_set(ALLOCSTALL_DMA32, allocstall_dma32)
} // end: vmstat_assign_results
-static inline void vmstat_cleanup_stack (
- struct vmstat_result *this)
-{
- for (;;) {
- if (this->item >= VMSTAT_logical_end)
- break;
- if (this->item > VMSTAT_noop)
- this->result.ul_int = 0;
- ++this;
- }
-} // end: vmstat_cleanup_stack
-
-
-static inline void vmstat_cleanup_stacks_all (
- struct vmstat_info *info)
-{
- struct stacks_extent *ext = info->extents;
- int i;
-
- while (ext) {
- for (i = 0; ext->stacks[i]; i++)
- vmstat_cleanup_stack(ext->stacks[i]->head);
- ext = ext->next;
- };
- info->dirty_stacks = 0;
-} // end: vmstat_cleanup_stacks_all
-
-
static void vmstat_extents_free_all (
struct vmstat_info *info)
{
for (i = 0; i < depth; i++) {
p->item = items[i];
- p->result.ul_int = 0;
++p;
}
return p_sav;
&& (!vmstat_stacks_alloc(info, 1)))
return NULL;
- if (info->dirty_stacks)
- vmstat_cleanup_stacks_all(info);
-
if (vmstat_read_failed(info))
return NULL;
vmstat_assign_results(info->extents->stacks[0], &info->hist);
- info->dirty_stacks = 1;
return info->extents->stacks[0];
} // end: procps_vmstat_select