cf6c2155dc
This was Craig's original patch, referenced below, but it was never pushed to newlib. It has now been rebased on top of some diskstat stuff to serve as a beginning. The original effort was perfectly serviceable (after a memory leak was fixed) but the approach would not have served future PID needs when that proc_t went bye bye. The slabtop requirements are similar to those of PIDs. One must accommodate the variable number of slab nodes (PIDs) while also accepting different data (char * and unsigned long). Furthermore, some generalized means to sort all that acquired stuff must somehow be provided. So I wanted to try a different approach that seemed to hold potential for satisfying future top and ps needs. Subsequent commits will make that attempt, building on Craig's original patch whose commit msg appears below. ------------------------------------------------------ All of the /proc/slabinfo related calls have been changed here. They follow the same procps_slabinfo_* format. Made both the slabtop and vmstat programs use the new API as one was using the old one and one was just sort of trying to do its own thing. Sorting of slabnodes is also possible via the library. Reference(s): http://www.freelists.org/post/procps/Sorting-slabsprocesses,3 http://www.freelists.org/post/procps/library-rework-slabinfo-calls Signed-off-by: Craig Small <csmall@enc.com.au> Signed-off-by: Jim Warner <james.warner@comcast.net>
78 lines
2.2 KiB
C
78 lines
2.2 KiB
C
#ifndef _PROC_SLAB_H
|
|
#define _PROC_SLAB_H
|
|
|
|
__BEGIN_DECLS
|
|
|
|
enum procps_slabinfo_stat {
|
|
PROCPS_SLABINFO_OBJS,
|
|
PROCPS_SLABINFO_AOBJS,
|
|
PROCPS_SLABINFO_PAGES,
|
|
PROCPS_SLABINFO_SLABS,
|
|
PROCPS_SLABINFO_ASLABS,
|
|
PROCPS_SLABINFO_CACHES,
|
|
PROCPS_SLABINFO_ACACHES,
|
|
PROCPS_SLABINFO_SIZE_AVG,
|
|
PROCPS_SLABINFO_SIZE_MIN,
|
|
PROCPS_SLABINFO_SIZE_MAX,
|
|
PROCPS_SLABINFO_SIZE_TOTAL,
|
|
PROCPS_SLABINFO_SIZE_ACTIVE,
|
|
};
|
|
|
|
enum procps_slabinfo_nodeitem {
|
|
PROCPS_SLABNODE_NAME,
|
|
PROCPS_SLABNODE_SIZE,
|
|
PROCPS_SLABNODE_OBJS,
|
|
PROCPS_SLABNODE_AOBJS,
|
|
PROCPS_SLABNODE_OBJ_SIZE,
|
|
PROCPS_SLABNODE_OBJS_PER_SLAB,
|
|
PROCPS_SLABNODE_PAGES_PER_SLAB,
|
|
PROCPS_SLABNODE_SLABS,
|
|
PROCPS_SLABNODE_ASLABS,
|
|
PROCPS_SLABNODE_USE
|
|
};
|
|
|
|
struct procps_slabinfo;
|
|
struct procps_slabnode;
|
|
|
|
struct procps_slabinfo_result {
|
|
enum procps_slabinfo_stat item;
|
|
unsigned long result;
|
|
struct procps_slabinfo_result *next;
|
|
};
|
|
|
|
struct procps_slabnode_result {
|
|
enum procps_slabinfo_nodeitem item;
|
|
unsigned long result;
|
|
struct procps_slabnode_result *next;
|
|
};
|
|
|
|
int procps_slabinfo_new (struct procps_slabinfo **info);
|
|
int procps_slabinfo_read (struct procps_slabinfo *info);
|
|
|
|
int procps_slabinfo_ref (struct procps_slabinfo *info);
|
|
int procps_slabinfo_unref (struct procps_slabinfo **info);
|
|
|
|
unsigned long procps_slabinfo_stat_get (struct procps_slabinfo *info,
|
|
enum procps_slabinfo_stat item);
|
|
|
|
int procps_slabinfo_stat_getchain (struct procps_slabinfo *info,
|
|
struct procps_slabinfo_result *result);
|
|
|
|
int procps_slabinfo_sort( struct procps_slabinfo *info,
|
|
const enum procps_slabinfo_nodeitem item);
|
|
|
|
int procps_slabinfo_node_count(const struct procps_slabinfo *info);
|
|
|
|
int procps_slabinfo_node_get (struct procps_slabinfo *info,
|
|
struct procps_slabnode **node);
|
|
int procps_slabinfo_node_getchain (struct procps_slabinfo *info,
|
|
struct procps_slabnode_result *result,
|
|
int nodeid);
|
|
|
|
char *procps_slabinfo_node_getname(struct procps_slabinfo *info,
|
|
int nodeid);
|
|
__END_DECLS
|
|
|
|
|
|
#endif /* _PROC_SLAB_H */
|