library: most function names now more profile friendly
This patch will begin some refinements associated with gprof. Initially, functions names have been changed to help in identifying potential bottlenecks. This effort also included the obscure set, free and sort routines. Plus the following additional modifications were made: . the stacks_alloc prologue was generalized plus added to a couple of modules where it had not yet propagated . a couple of the '// end ...' comments were corrected . some functions have been formally tagged as 'inline' Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user