summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Small <csmall@enc.com.au>2012-11-11 07:51:44 +1100
committerCraig Small <csmall@enc.com.au>2012-11-11 07:51:44 +1100
commit8718885e4b2a5e751225652b831a0e14e6b516c8 (patch)
tree0fdb3c68c5ec973ba52c850f49566ba0173c3ffd
parentbf40b7fca753d6e535e96a1e175b10330ac452b2 (diff)
downloadprocps-ng-libproc1.tar.gz
slab info using new APIlibproc1
slabtop and the slab_info has first cut of new API.
-rw-r--r--proc/Makefile.am2
-rw-r--r--proc/libprocps.sym10
-rw-r--r--proc/slab.c211
-rw-r--r--proc/slab.h30
-rw-r--r--slabtop.c91
5 files changed, 205 insertions, 139 deletions
diff --git a/proc/Makefile.am b/proc/Makefile.am
index e646dca..271cda9 100644
--- a/proc/Makefile.am
+++ b/proc/Makefile.am
@@ -6,7 +6,7 @@ AM_CPPFLAGS = \
#
# See http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
-LIBprocps_CURRENT=1
+LIBprocps_CURRENT=2
LIBprocps_REVISION=0
LIBprocps_AGE=0
diff --git a/proc/libprocps.sym b/proc/libprocps.sym
index fc8e659..024b1c0 100644
--- a/proc/libprocps.sym
+++ b/proc/libprocps.sym
@@ -64,3 +64,13 @@ global:
local:
*;
};
+
+LIBPROCPS_2 {
+global:
+ procps_slabinfo_new;
+ procps_slabinfo_read;
+ procps_slabinfo_clear;
+ procps_slabinfo_free;
+local:
+ *;
+} LIBPROCPS_0;
diff --git a/proc/slab.c b/proc/slab.c
index b0bccaa..13cbbd3 100644
--- a/proc/slab.c
+++ b/proc/slab.c
@@ -27,6 +27,7 @@
#include <unistd.h>
#include <limits.h>
#include <ctype.h>
+#include <errno.h>
#include "slab.h"
#include "procps.h"
@@ -36,25 +37,65 @@
#define SLABINFO_VER_LEN 100
#define SLABINFO_FILE "/proc/slabinfo"
-static struct slab_info *free_index;
+/*
+ * procps_slabinfo_new:
+ * @slabinfo: procps slabinfo
+ *
+ * Create a new slabinfo structure
+ */
+int procps_slabinfo_new(struct procps_slabinfo **slabinfo)
+{
+ struct procps_slabinfo *si;
+ si = calloc(1, sizeof(struct procps_slabinfo));
+ if (!si)
+ return -ENOMEM;
+ *slabinfo = si;
+ return 0;
+}
+
+/*
+ * procps_slab_free:
+ * @slabinfo procps slabinfo strucutre
+ *
+ * Deallacate or free all memory in the slabinfo structure including in
+ * the lists
+ */
+void procps_slabinfo_free(struct procps_slabinfo *slabinfo)
+{
+ struct slab_node *curr, *next;
+
+ curr = slabinfo->slab_list;
+ while (curr) {
+ next = curr->next;
+ free(curr);
+ curr = next;
+ }
+ curr = slabinfo->free_head;
+ while (curr) {
+ next = curr->next;
+ free(curr);
+ curr = next;
+ }
+ free(slabinfo);
+}
/*
- * get_slabnode - allocate slab_info structures using a free list
+ * get_slabnode - allocate slab_node structures using a free list
*
* In the fast path, we simply return a node off the free list. In the slow
* list, we malloc() a new node. The free list is never automatically reaped,
* both for simplicity and because the number of slab caches is fairly
* constant.
*/
-static struct slab_info *get_slabnode(void)
+static struct slab_node *get_slabnode(struct procps_slabinfo *slabinfo)
{
- struct slab_info *node;
+ struct slab_node *node;
- if (free_index) {
- node = free_index;
- free_index = free_index->next;
+ if (slabinfo->free_next) {
+ node = slabinfo->free_next;
+ slabinfo->free_next = slabinfo->free_next->next;
} else {
- node = xmalloc(sizeof(struct slab_info));
+ node = xmalloc(sizeof(struct procps_slabinfo));
}
return node;
@@ -80,25 +121,18 @@ static int slab_badname_detect(const char *restrict buffer)
}
/*
- * put_slabinfo - return all allocated nodes to the free list
+ * procps_slabinfo_clear:
+ * @slabinfo: slab information
+ *
+ * Put all of the slabs into the free index
*/
-void put_slabinfo(struct slab_info *head)
+void procps_slabinfo_clear(struct procps_slabinfo *slabinfo)
{
- free_index = head;
+ slabinfo->free_head = slabinfo->slab_list;
+ slabinfo->free_next = slabinfo->free_head;
+ slabinfo->slab_list = NULL;
}
-/*
- * free_slabinfo - deallocate the memory associated with each node in the
- * slab_info linked list
- */
-void free_slabinfo(struct slab_info *list)
-{
- while (list) {
- struct slab_info *temp = list->next;
- free(list);
- list = temp;
- }
-}
// parse_slabinfo20 - actual parse routine for slabinfo 2.x (2.6 kernels)
// Note: difference between 2.0 and 2.1 is in the ": globalstat" part where version 2.1
@@ -129,16 +163,15 @@ void free_slabinfo(struct slab_info *list)
// : slabdata <active_slabs> <num_slabs> <sharedavail> \
// : globalstat <listallocs> <maxobjs> <grown> <reaped> <error> <maxfreeable> <freelimit> \
// : cpustat <allochit> <allocmiss> <freehit> <freemiss>
-static int parse_slabinfo20(struct slab_info **list, struct slab_stat *stats,
- FILE *f)
+static int parse_slabinfo20(struct procps_slabinfo *slabinfo, FILE *f)
{
- struct slab_info *curr = NULL, *prev = NULL;
+ struct slab_node *curr = NULL, *prev = NULL;
char buffer[SLABINFO_LINE_LEN];
int entries = 0;
int page_size = getpagesize();
- stats->min_obj_size = INT_MAX;
- stats->max_obj_size = 0;
+ slabinfo->min_obj_size = INT_MAX;
+ slabinfo->max_obj_size = 0;
while (fgets(buffer, SLABINFO_LINE_LEN, f)) {
int assigned;
@@ -146,12 +179,12 @@ static int parse_slabinfo20(struct slab_info **list, struct slab_stat *stats,
if (buffer[0] == '#')
continue;
- curr = get_slabnode();
+ curr = get_slabnode(slabinfo);
if (!curr)
break;
if (entries++ == 0)
- *list = curr;
+ slabinfo->slab_list = curr;
else
if (prev)
prev->next = curr;
@@ -170,26 +203,26 @@ static int parse_slabinfo20(struct slab_info **list, struct slab_stat *stats,
break;
}
- if (curr->obj_size < stats->min_obj_size)
- stats->min_obj_size = curr->obj_size;
- if (curr->obj_size > stats->max_obj_size)
- stats->max_obj_size = curr->obj_size;
+ if (curr->obj_size < slabinfo->min_obj_size)
+ slabinfo->min_obj_size = curr->obj_size;
+ if (curr->obj_size > slabinfo->max_obj_size)
+ slabinfo->max_obj_size = curr->obj_size;
curr->cache_size = (unsigned long)curr->nr_slabs * curr->pages_per_slab * page_size;
if (curr->nr_objs) {
curr->use = 100 * curr->nr_active_objs / curr->nr_objs;
- stats->nr_active_caches++;
+ slabinfo->nr_active_caches++;
} else
curr->use = 0;
- stats->nr_objs += curr->nr_objs;
- stats->nr_active_objs += curr->nr_active_objs;
- stats->total_size += (unsigned long)curr->nr_objs * curr->obj_size;
- stats->active_size += (unsigned long)curr->nr_active_objs * curr->obj_size;
- stats->nr_pages += curr->nr_slabs * curr->pages_per_slab;
- stats->nr_slabs += curr->nr_slabs;
- stats->nr_active_slabs += curr->nr_active_slabs;
+ slabinfo->nr_objs += curr->nr_objs;
+ slabinfo->nr_active_objs += curr->nr_active_objs;
+ slabinfo->total_size += (unsigned long)curr->nr_objs * curr->obj_size;
+ slabinfo->active_size += (unsigned long)curr->nr_active_objs * curr->obj_size;
+ slabinfo->nr_pages += curr->nr_slabs * curr->pages_per_slab;
+ slabinfo->nr_slabs += curr->nr_slabs;
+ slabinfo->nr_active_slabs += curr->nr_active_slabs;
prev = curr;
}
@@ -200,9 +233,9 @@ static int parse_slabinfo20(struct slab_info **list, struct slab_stat *stats,
}
curr->next = NULL;
- stats->nr_caches = entries;
- if (stats->nr_objs)
- stats->avg_obj_size = stats->total_size / stats->nr_objs;
+ slabinfo->nr_caches = entries;
+ if (slabinfo->nr_objs)
+ slabinfo->avg_obj_size = slabinfo->total_size / slabinfo->nr_objs;
return 0;
}
@@ -210,26 +243,25 @@ static int parse_slabinfo20(struct slab_info **list, struct slab_stat *stats,
/*
* parse_slabinfo11 - actual parsing routine for slabinfo 1.1 (2.4 kernels)
*/
-static int parse_slabinfo11(struct slab_info **list, struct slab_stat *stats,
- FILE *f)
+static int parse_slabinfo11(struct procps_slabinfo *slabinfo, FILE *f)
{
- struct slab_info *curr = NULL, *prev = NULL;
+ struct slab_node *curr = NULL, *prev = NULL;
char buffer[SLABINFO_LINE_LEN];
int entries = 0;
int page_size = getpagesize();
- stats->min_obj_size = INT_MAX;
- stats->max_obj_size = 0;
+ slabinfo->min_obj_size = INT_MAX;
+ slabinfo->max_obj_size = 0;
while (fgets(buffer, SLABINFO_LINE_LEN, f)) {
int assigned;
- curr = get_slabnode();
+ curr = get_slabnode(slabinfo);
if (!curr)
break;
if (entries++ == 0)
- *list = curr;
+ slabinfo->slab_list = curr;
else
if (prev)
prev->next = curr;
@@ -249,16 +281,16 @@ static int parse_slabinfo11(struct slab_info **list, struct slab_stat *stats,
break;
}
- if (curr->obj_size < stats->min_obj_size)
- stats->min_obj_size = curr->obj_size;
- if (curr->obj_size > stats->max_obj_size)
- stats->max_obj_size = curr->obj_size;
+ if (curr->obj_size < slabinfo->min_obj_size)
+ slabinfo->min_obj_size = curr->obj_size;
+ if (curr->obj_size > slabinfo->max_obj_size)
+ slabinfo->max_obj_size = curr->obj_size;
curr->cache_size = (unsigned long)curr->nr_slabs * curr->pages_per_slab * page_size;
if (curr->nr_objs) {
curr->use = 100 * curr->nr_active_objs / curr->nr_objs;
- stats->nr_active_caches++;
+ slabinfo->nr_active_caches++;
} else
curr->use = 0;
@@ -266,26 +298,26 @@ static int parse_slabinfo11(struct slab_info **list, struct slab_stat *stats,
curr->objs_per_slab = curr->pages_per_slab *
page_size / curr->obj_size;
- stats->nr_objs += curr->nr_objs;
- stats->nr_active_objs += curr->nr_active_objs;
- stats->total_size += (unsigned long)curr->nr_objs * curr->obj_size;
- stats->active_size += (unsigned long)curr->nr_active_objs * curr->obj_size;
- stats->nr_pages += curr->nr_slabs * curr->pages_per_slab;
- stats->nr_slabs += curr->nr_slabs;
- stats->nr_active_slabs += curr->nr_active_slabs;
+ slabinfo->nr_objs += curr->nr_objs;
+ slabinfo->nr_active_objs += curr->nr_active_objs;
+ slabinfo->total_size += (unsigned long)curr->nr_objs * curr->obj_size;
+ slabinfo->active_size += (unsigned long)curr->nr_active_objs * curr->obj_size;
+ slabinfo->nr_pages += curr->nr_slabs * curr->pages_per_slab;
+ slabinfo->nr_slabs += curr->nr_slabs;
+ slabinfo->nr_active_slabs += curr->nr_active_slabs;
prev = curr;
}
if (!curr) {
fprintf(stderr, "\rerror reading slabinfo!\n");
- return 1;
+ return -1;
}
curr->next = NULL;
- stats->nr_caches = entries;
- if (stats->nr_objs)
- stats->avg_obj_size = stats->total_size / stats->nr_objs;
+ slabinfo->nr_caches = entries;
+ if (slabinfo->nr_objs)
+ slabinfo->avg_obj_size = slabinfo->total_size / slabinfo->nr_objs;
return 0;
}
@@ -295,56 +327,59 @@ static int parse_slabinfo11(struct slab_info **list, struct slab_stat *stats,
*
* Not yet implemented. Please feel free.
*/
-static int parse_slabinfo10(struct slab_info **list, struct slab_stat *stats,
- FILE *f)
+static int parse_slabinfo10(struct procps_slabinfo *slabinfo, FILE *f)
{
- (void) list, (void) stats, (void) f;
fprintf(stderr, "slabinfo version 1.0 not yet supported\n");
- return 1;
+ return -1;
}
/*
- * slabinfo - parse the system's slabinfo and fill out both a linked list of
- * slab_info structures and the slab_stat structure
+ * procps_slabinfo_read:
+ * @slabinfo: structure to place data into
+ * @filename: optional filename instead of system default to read slab stats
*
- * The function returns zero on success, in which case 'list' and 'stats' are
- * valid. Nonzero is returned on failure and the state of 'list' and 'stats'
- * are undefined.
+ * The function returns zero on success
*/
-int get_slabinfo(struct slab_info **list, struct slab_stat *stats)
+int procps_slabinfo_read(struct procps_slabinfo *slabinfo, const char *filename)
{
FILE *slabfile;
char buffer[SLABINFO_VER_LEN];
int major, minor, ret = 0;
- slabfile = fopen(SLABINFO_FILE, "r");
- if (!slabfile) {
- perror("fopen " SLABINFO_FILE);
- return 1;
+ if (filename == NULL) {
+ slabfile = fopen(SLABINFO_FILE, "r");
+ if (!slabfile) {
+ return -errno;
+ }
+ } else {
+ slabfile = fopen(filename, "r");
+ if (!slabfile) {
+ return -errno;
+ }
}
if (!fgets(buffer, SLABINFO_VER_LEN, slabfile)) {
fprintf(stderr, "cannot read from slabinfo\n");
fclose(slabfile);
- return 1;
+ return -1;
}
if (sscanf(buffer, "slabinfo - version: %d.%d", &major, &minor) != 2) {
fprintf(stderr, "not the good old slabinfo we know\n");
fclose(slabfile);
- return 1;
+ return -1;
}
if (major == 2)
- ret = parse_slabinfo20(list, stats, slabfile);
+ ret = parse_slabinfo20(slabinfo, slabfile);
else if (major == 1 && minor == 1)
- ret = parse_slabinfo11(list, stats, slabfile);
+ ret = parse_slabinfo11(slabinfo, slabfile);
else if (major == 1 && minor == 0)
- ret = parse_slabinfo10(list, stats, slabfile);
+ ret = parse_slabinfo10(slabinfo, slabfile);
else {
fprintf(stderr, "unrecognizable slabinfo version\n");
fclose(slabfile);
- return 1;
+ return -1;
}
fclose(slabfile);
diff --git a/proc/slab.h b/proc/slab.h
index 09dbe00..3260a9d 100644
--- a/proc/slab.h
+++ b/proc/slab.h
@@ -3,9 +3,9 @@
#define SLAB_INFO_NAME_LEN 128
-struct slab_info {
+struct slab_node {
char name[SLAB_INFO_NAME_LEN]; /* name of this cache */
- struct slab_info *next;
+ struct slab_node *next;
unsigned long cache_size; /* size of entire cache */
unsigned nr_objs; /* number of objects in this cache */
unsigned nr_active_objs; /* number of active objects */
@@ -17,7 +17,13 @@ struct slab_info {
unsigned use; /* percent full: total / active */
};
-struct slab_stat {
+struct procps_slabinfo {
+ struct slab_node *slab_list; /* linked list of slab nodes */
+
+ struct slab_node *free_head; /* pool of free slab nodes */
+ struct slab_node *free_next; /* next available free slabnode */
+
+ /* overall stats */
unsigned long total_size; /* size of all objects */
unsigned long active_size; /* size of all active objects */
unsigned nr_objs; /* number of objects, among all caches */
@@ -32,8 +38,20 @@ struct slab_stat {
unsigned max_obj_size; /* size of largest object */
};
-extern void put_slabinfo(struct slab_info *);
-extern void free_slabinfo(struct slab_info *);
-extern int get_slabinfo(struct slab_info **, struct slab_stat *);
+int procps_slabinfo_new(struct procps_slabinfo **slabinfo);
+int procps_slabinfo_read(struct procps_slabinfo *slabinfo, const char *filename);
+void procps_slabinfo_clear(struct procps_slabinfo *slabinfo);
+void procps_slabinfo_free(struct procps_slabinfo *slabinfo);
+void procps_slabinfo_active_objs_get(const struct procps_slabinfo *slabinfo);
+void procps_slabinfo_objs_get(const struct procps_slabinfo *slabinfo);
+void procps_slabinfo_active_slabs_get(const struct procps_slabinfo *slabinfo);
+void procps_slabinfo_slabs_get(const struct procps_slabinfo *slabinfo);
+void procps_slabinfo_active_caches_get(const struct procps_slabinfo *slabinfo);
+void procps_slabinfo_caches_get(const struct procps_slabinfo *slabinfo);
+void procps_slabinfo_active_size_get(const struct procps_slabinfo *slabinfo);
+void procps_slabinfo_total_size_get(const struct procps_slabinfo *slabinfo);
+void procps_slabinfo_min_obj_size_get(const struct procps_slabinfo *slabinfo);
+void procps_slabinfo_avg_obj_size_get(const struct procps_slabinfo *slabinfo);
+void procps_slabinfo_max_obj_size_get(const struct procps_slabinfo *slabinfo);
#endif /* _PROC_SLAB_H */
diff --git a/slabtop.c b/slabtop.c
index 9e535d4..b5e7e25 100644
--- a/slabtop.c
+++ b/slabtop.c
@@ -50,12 +50,12 @@
static unsigned short cols, rows;
static struct termios saved_tty;
static long delay = 3;
-static int (*sort_func)(const struct slab_info *, const struct slab_info *);
+static int (*sort_func)(const struct slab_node *, const struct slab_node *);
-static struct slab_info *merge_objs(struct slab_info *a, struct slab_info *b)
+static struct slab_node *merge_objs(struct slab_node *a, struct slab_node *b)
{
- struct slab_info sorted_list;
- struct slab_info *curr = &sorted_list;
+ struct slab_node sorted_list;
+ struct slab_node *curr = &sorted_list;
while ((a != NULL) && (b != NULL)) {
if (sort_func(a, b)) {
@@ -74,11 +74,11 @@ static struct slab_info *merge_objs(struct slab_info *a, struct slab_info *b)
}
/*
- * slabsort - merge sort the slab_info linked list based on sort_func
+ * slabsort - merge sort the slab_node linked list based on sort_func
*/
-static struct slab_info *slabsort(struct slab_info *list)
+static struct slab_node *slabsort(struct slab_node *list)
{
- struct slab_info *a, *b;
+ struct slab_node *a, *b;
if ((list == NULL) || (list->next == NULL))
return list;
@@ -101,63 +101,63 @@ static struct slab_info *slabsort(struct slab_info *list)
* Sort Routines. Each of these should be associated with a command-line
* search option. The functions should fit the prototype:
*
- * int sort_foo(const struct slab_info *a, const struct slab_info *b)
+ * int sort_foo(const struct slab_node *a, const struct slab_node *b)
*
* They return one if the first parameter is larger than the second
* Otherwise, they return zero.
*/
-static int sort_name(const struct slab_info *a, const struct slab_info *b)
+static int sort_name(const struct slab_node *a, const struct slab_node *b)
{
return (strcmp(a->name, b->name) < 0) ? 1 : 0;
}
-static int sort_nr_objs(const struct slab_info *a, const struct slab_info *b)
+static int sort_nr_objs(const struct slab_node *a, const struct slab_node *b)
{
return (a->nr_objs > b->nr_objs);
}
-static int sort_nr_active_objs(const struct slab_info *a,
- const struct slab_info *b)
+static int sort_nr_active_objs(const struct slab_node *a,
+ const struct slab_node *b)
{
return (a->nr_active_objs > b->nr_active_objs);
}
-static int sort_obj_size(const struct slab_info *a, const struct slab_info *b)
+static int sort_obj_size(const struct slab_node *a, const struct slab_node *b)
{
return (a->obj_size > b->obj_size);
}
-static int sort_objs_per_slab(const struct slab_info *a,
- const struct slab_info *b)
+static int sort_objs_per_slab(const struct slab_node *a,
+ const struct slab_node *b)
{
return (a->objs_per_slab > b->objs_per_slab);
}
-static int sort_pages_per_slab(const struct slab_info *a,
- const struct slab_info *b)
+static int sort_pages_per_slab(const struct slab_node *a,
+ const struct slab_node *b)
{
return (a->pages_per_slab > b->pages_per_slab);
}
-static int sort_nr_slabs(const struct slab_info *a, const struct slab_info *b)
+static int sort_nr_slabs(const struct slab_node *a, const struct slab_node *b)
{
return (a->nr_slabs > b->nr_slabs);
}
-static int sort_nr_active_slabs(const struct slab_info *a,
- const struct slab_info *b)
+static int sort_nr_active_slabs(const struct slab_node *a,
+ const struct slab_node *b)
{
return (a->nr_active_slabs > b->nr_active_slabs);
}
-static int sort_use(const struct slab_info *a, const struct slab_info *b)
+static int sort_use(const struct slab_node *a, const struct slab_node *b)
{
return (a->use > b->use);
}
-static int sort_cache_size(const struct slab_info *a, const struct slab_info *b)
+static int sort_cache_size(const struct slab_node *a, const struct slab_node *b)
{
return (a->cache_size > b->cache_size);
}
@@ -288,7 +288,7 @@ int main(int argc, char *argv[])
{
int o;
unsigned short old_rows;
- struct slab_info *slab_list = NULL;
+ struct procps_slabinfo *slabinfo = NULL;
int run_once = 0, retval = EXIT_SUCCESS;
static const struct option longopts[] = {
@@ -318,8 +318,8 @@ int main(int argc, char *argv[])
_("delay must be positive integer"));
break;
case 's':
- sort_func = (int (*)(const struct slab_info*,
- const struct slab_info *)) set_sort_func(optarg[0]);
+ sort_func = (int (*)(const struct slab_node*,
+ const struct slab_node *)) set_sort_func(optarg[0]);
break;
case 'o':
run_once=1;
@@ -335,6 +335,9 @@ int main(int argc, char *argv[])
}
}
+ if (procps_slabinfo_new(&slabinfo) < 0)
+ return EXIT_FAILURE;
+
if (tcgetattr(STDIN_FILENO, &saved_tty) == -1)
xwarn(_("terminal setting retrieval"));
@@ -347,16 +350,16 @@ int main(int argc, char *argv[])
}
signal(SIGINT, sigint_handler);
+
do {
- struct slab_info *curr;
- struct slab_stat stats;
struct timeval tv;
fd_set readfds;
char c;
- int i;
- memset(&stats, 0, sizeof(struct slab_stat));
+ int i, readval;
+ struct slab_node *curr;
- if (get_slabinfo(&slab_list, &stats)) {
+ if ( (readval = procps_slabinfo_read(slabinfo, NULL)) < 0) {
+ fprintf(stderr, "Error opening slabinfo file %s\n", strerror(-readval));
retval = EXIT_FAILURE;
break;
}
@@ -375,22 +378,22 @@ int main(int argc, char *argv[])
/* Translation Hint: Next five strings must not
* exceed 35 length in characters. */
_("Active / Total Objects (% used)"),
- stats.nr_active_objs, stats.nr_objs,
- 100.0 * stats.nr_active_objs / stats.nr_objs,
+ slabinfo->nr_active_objs, slabinfo->nr_objs,
+ 100.0 * slabinfo->nr_active_objs / slabinfo->nr_objs,
_("Active / Total Slabs (% used)"),
- stats.nr_active_slabs, stats.nr_slabs,
- 100.0 * stats.nr_active_slabs / stats.nr_slabs,
+ slabinfo->nr_active_slabs, slabinfo->nr_slabs,
+ 100.0 * slabinfo->nr_active_slabs / slabinfo->nr_slabs,
_("Active / Total Caches (% used)"),
- stats.nr_active_caches, stats.nr_caches,
- 100.0 * stats.nr_active_caches / stats.nr_caches,
+ slabinfo->nr_active_caches, slabinfo->nr_caches,
+ 100.0 * slabinfo->nr_active_caches / slabinfo->nr_caches,
_("Active / Total Size (% used)"),
- stats.active_size / 1024.0, stats.total_size / 1024.0,
- 100.0 * stats.active_size / stats.total_size,
+ slabinfo->active_size / 1024.0, slabinfo->total_size / 1024.0,
+ 100.0 * slabinfo->active_size / slabinfo->total_size,
_("Minimum / Average / Maximum Object"),
- stats.min_obj_size / 1024.0, stats.avg_obj_size / 1024.0,
- stats.max_obj_size / 1024.0);
+ slabinfo->min_obj_size / 1024.0, slabinfo->avg_obj_size / 1024.0,
+ slabinfo->max_obj_size / 1024.0);
- slab_list = slabsort(slab_list);
+ slabinfo->slab_list = slabsort(slabinfo->slab_list);
attron(A_REVERSE);
/* Translation Hint: Please keep alignment of the
@@ -398,7 +401,7 @@ int main(int argc, char *argv[])
print_line("%-78s\n", _(" OBJS ACTIVE USE OBJ SIZE SLABS OBJ/SLAB CACHE SIZE NAME"));
attroff(A_REVERSE);
- curr = slab_list;
+ curr = slabinfo->slab_list;
for (i = 0; i < rows - 8 && curr->next; i++) {
print_line("%6u %6u %3u%% %7.2fK %6u %8u %9uK %-23s\n",
curr->nr_objs, curr->nr_active_objs, curr->use,
@@ -408,7 +411,7 @@ int main(int argc, char *argv[])
curr = curr->next;
}
- put_slabinfo(slab_list);
+ procps_slabinfo_clear(slabinfo);
if (!run_once) {
refresh();
FD_ZERO(&readfds);
@@ -424,7 +427,7 @@ int main(int argc, char *argv[])
} while (delay);
tcsetattr(STDIN_FILENO, TCSAFLUSH, &saved_tty);
- free_slabinfo(slab_list);
+ procps_slabinfo_free(slabinfo);
if (!run_once)
endwin();
return retval;