library: rebase & make current initial slabinfo effort
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>
This commit is contained in:
96
proc/slab.h
96
proc/slab.h
@ -1,39 +1,77 @@
|
||||
#ifndef _PROC_SLAB_H
|
||||
#define _PROC_SLAB_H
|
||||
|
||||
#define SLAB_INFO_NAME_LEN 128
|
||||
__BEGIN_DECLS
|
||||
|
||||
struct slab_info {
|
||||
char name[SLAB_INFO_NAME_LEN]; /* name of this cache */
|
||||
struct slab_info *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 */
|
||||
unsigned obj_size; /* size of each object */
|
||||
unsigned objs_per_slab; /* number of objects per slab */
|
||||
unsigned pages_per_slab; /* number of pages per slab */
|
||||
unsigned nr_slabs; /* number of slabs in this cache */
|
||||
unsigned nr_active_slabs; /* number of active slabs */
|
||||
unsigned use; /* percent full: total / active */
|
||||
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,
|
||||
};
|
||||
|
||||
struct slab_stat {
|
||||
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 */
|
||||
unsigned nr_active_objs; /* number of active objects, among all caches */
|
||||
unsigned nr_pages; /* number of pages consumed by all objects */
|
||||
unsigned nr_slabs; /* number of slabs, among all caches */
|
||||
unsigned nr_active_slabs; /* number of active slabs, among all caches */
|
||||
unsigned nr_caches; /* number of caches */
|
||||
unsigned nr_active_caches; /* number of active caches */
|
||||
unsigned avg_obj_size; /* average object size */
|
||||
unsigned min_obj_size; /* size of smallest object */
|
||||
unsigned max_obj_size; /* size of largest object */
|
||||
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
|
||||
};
|
||||
|
||||
extern void put_slabinfo(struct slab_info *);
|
||||
extern void free_slabinfo(struct slab_info *);
|
||||
extern int get_slabinfo(struct slab_info **, struct slab_stat *);
|
||||
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 */
|
||||
|
Reference in New Issue
Block a user