5c3542c4e1
With this patch, we will be close to an implementation which will be needed when accommodating tasks/threads. The following explanation was from an earlier message: 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 this patch expands the API to provide dynamic chain allocation plus allow sorting of those dynamic chains. While specific to slab needs (nodes, not global stats) it is not too early to begin to think of newlib chains as the opaque replacement for a deprecated old proc_t. Better yet, any newlib chain is inherently variable in length, something the old proc_t couldn't claim to be. Of course, as we get to PIDs we'll want to grow/shrink chains (easily accomplished with a special item enum). And we'll want to grow/shrink those **head arrays too. But these minor details don't seem insurmountable now. Signed-off-by: Jim Warner <james.warner@comcast.net>
139 lines
3.5 KiB
C
139 lines
3.5 KiB
C
/*
|
|
* slab.h - slab related functions for libproc
|
|
*
|
|
* Copyright (C) 1998-2005 Albert Cahalan
|
|
* Copyright (C) 2015 Craig Small <csmall@enc.com.au>
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
#ifndef _PROC_SLAB_H
|
|
#define _PROC_SLAB_H
|
|
|
|
__BEGIN_DECLS
|
|
|
|
enum slabs_item {
|
|
PROCPS_SLABS_OBJS,
|
|
PROCPS_SLABS_AOBJS,
|
|
PROCPS_SLABS_PAGES,
|
|
PROCPS_SLABS_SLABS,
|
|
PROCPS_SLABS_ASLABS,
|
|
PROCPS_SLABS_CACHES,
|
|
PROCPS_SLABS_ACACHES,
|
|
PROCPS_SLABS_SIZE_AVG,
|
|
PROCPS_SLABS_SIZE_MIN,
|
|
PROCPS_SLABS_SIZE_MAX,
|
|
PROCPS_SLABS_SIZE_TOTAL,
|
|
PROCPS_SLABS_SIZE_ACTIVE,
|
|
PROCPS_SLABS_noop
|
|
};
|
|
|
|
enum slabnode_item {
|
|
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,
|
|
PROCPS_SLABNODE_NAME,
|
|
PROCPS_SLABNODE_noop
|
|
};
|
|
|
|
struct procps_slabinfo;
|
|
|
|
struct slabs_result {
|
|
enum slabs_item item;
|
|
unsigned long result;
|
|
struct slabs_result *next;
|
|
};
|
|
|
|
struct slabnode_chain {
|
|
struct slabnode_result *head;
|
|
};
|
|
|
|
struct slabnode_result {
|
|
enum slabnode_item item;
|
|
union {
|
|
unsigned long num;
|
|
char *str;
|
|
} result;
|
|
struct 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_slabs_get (
|
|
struct procps_slabinfo *info,
|
|
enum slabs_item item);
|
|
|
|
int procps_slabs_getchain (
|
|
struct procps_slabinfo *info,
|
|
struct slabs_result *these);
|
|
|
|
int procps_slabnode_count (const struct procps_slabinfo *info);
|
|
|
|
const char *procps_slabnode_getname (
|
|
struct procps_slabinfo *info,
|
|
int nodeid);
|
|
|
|
unsigned long procps_slabnode_get (
|
|
struct procps_slabinfo *info,
|
|
enum slabnode_item item,
|
|
int nodeid);
|
|
|
|
int procps_slabnode_getchain (
|
|
struct procps_slabinfo *info,
|
|
struct slabnode_result *these,
|
|
int nodeid);
|
|
|
|
int procps_slabnode_chain_fill (
|
|
struct procps_slabinfo *info,
|
|
struct slabnode_chain *chain,
|
|
int nodeid);
|
|
|
|
int procps_slabnode_chains_fill (
|
|
struct procps_slabinfo *info,
|
|
struct slabnode_chain **chains,
|
|
int maxchains);
|
|
|
|
struct slabnode_chain *procps_slabnode_chain_alloc (
|
|
struct procps_slabinfo *info,
|
|
int maxitems,
|
|
enum slabnode_item *items);
|
|
|
|
struct slabnode_chain **procps_slabnode_chains_alloc (
|
|
struct procps_slabinfo *info,
|
|
int maxchains,
|
|
int chain_extra,
|
|
int maxitems,
|
|
enum slabnode_item *items);
|
|
|
|
struct slabnode_chain **procps_slabnode_chains_sort (
|
|
struct procps_slabinfo *info,
|
|
struct slabnode_chain **chains,
|
|
int numchained,
|
|
enum slabnode_item sort);
|
|
|
|
__END_DECLS
|
|
|
|
#endif /* _PROC_SLAB_H */
|