library: eliminate extra stack header space provisions

With the new perspective on potential uses of a 'noop'
enumerator (or whatever we decide to call it) there is
no longer a need to provide for any extra 'user' space
in the stack header structures used by slab & meminfo.

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2015-07-22 00:00:00 -05:00 committed by Craig Small
parent 02b25a2eec
commit ae4b686745
5 changed files with 7 additions and 16 deletions

View File

@ -68,7 +68,6 @@ struct stack_vectors {
struct stacks_anchor {
int depth;
int header_size;
struct stack_vectors *vectors;
struct stacks_anchor *self;
struct stacks_anchor *next;
@ -433,7 +432,6 @@ static void stacks_validate (struct meminfo_stack **v, const char *who)
++n;
}
fprintf(stderr, "%s: found %d stack(s), each %d bytes (including eos)\n", __func__, x, (int)sizeof(struct meminfo_result) * t);
fprintf(stderr, "%s: this header size = %2d\n", __func__, (int)p->owner->header_size);
fprintf(stderr, "%s: sizeof(struct meminfo_stack) = %2d\n", __func__, (int)sizeof(struct meminfo_stack));
fprintf(stderr, "%s: sizeof(struct meminfo_result) = %2d\n", __func__, (int)sizeof(struct meminfo_result));
fputc('\n', stderr);
@ -486,7 +484,6 @@ static int stack_items_valid (
static struct meminfo_stack **procps_meminfo_stacks_alloc (
struct procps_meminfo *info,
int maxstacks,
int stack_extra,
int maxitems,
enum meminfo_item *items)
{
@ -507,7 +504,7 @@ static struct meminfo_stack **procps_meminfo_stacks_alloc (
vect_size = sizeof(struct stack_vectors); // address vector struct
vect_size += sizeof(void *) * maxstacks; // plus vectors themselves
vect_size += sizeof(void *); // plus NULL delimiter
head_size = sizeof(struct meminfo_stack) + stack_extra; // a head struct + user stuff
head_size = sizeof(struct meminfo_stack); // a head struct
list_size = sizeof(struct meminfo_result) * maxitems; // a results stack
blob_size = sizeof(struct stacks_anchor); // the anchor itself
blob_size += vect_size; // all vectors + delims
@ -523,7 +520,6 @@ static struct meminfo_stack **procps_meminfo_stacks_alloc (
p_blob->next = info->stacked;
info->stacked = p_blob;
p_blob->self = p_blob;
p_blob->header_size = head_size;
p_blob->vectors = (void *)p_blob + sizeof(struct stacks_anchor);
p_vect = p_blob->vectors;
p_vect->owner = p_blob->self;
@ -559,7 +555,7 @@ PROCPS_EXPORT struct meminfo_stack *procps_meminfo_stack_alloc (
{
struct meminfo_stack **v;
v = procps_meminfo_stacks_alloc(info, 1, 0, maxitems, items);
v = procps_meminfo_stacks_alloc(info, 1, maxitems, items);
if (!v)
return NULL;
stacks_validate(v, __func__);

View File

@ -88,7 +88,6 @@ struct stack_vectors {
struct stacks_anchor {
int depth;
int inuse;
int header_size;
struct stack_vectors *vectors;
struct stacks_anchor *self;
struct stacks_anchor *next;
@ -659,7 +658,6 @@ static void stacks_validate (struct slabnode_stack **v, const char *who)
}
fprintf(stderr, "%s: found %d stack(s), each %d bytes (including eos)\n", __func__, x, (int)sizeof(struct slab_result) * t);
fprintf(stderr, "%s: found %d stack(s)\n", __func__, x);
fprintf(stderr, "%s: this header size = %2d\n", __func__, (int)p->owner->header_size);
fprintf(stderr, "%s: sizeof(struct slabnode_stack) = %2d\n", __func__, (int)sizeof(struct slabnode_stack));
fprintf(stderr, "%s: sizeof(struct slab_result) = %2d\n", __func__, (int)sizeof(struct slab_result));
fputc('\n', stderr);
@ -715,7 +713,6 @@ static int stack_items_valid (
PROCPS_EXPORT struct slabnode_stack **procps_slabnode_stacks_alloc (
struct procps_slabinfo *info,
int maxstacks,
int stack_extra,
int maxitems,
enum slabnode_item *items)
{
@ -736,7 +733,7 @@ PROCPS_EXPORT struct slabnode_stack **procps_slabnode_stacks_alloc (
vect_size = sizeof(struct stack_vectors); // address vector struct
vect_size += sizeof(void *) * maxstacks; // plus vectors themselves
vect_size += sizeof(void *); // plus NULL delimiter
head_size = sizeof(struct slabnode_stack) + stack_extra; // a head struct + user stuff
head_size = sizeof(struct slabnode_stack); // a head struct
list_size = sizeof(struct slab_result) * maxitems; // a results stack
blob_size = sizeof(struct stacks_anchor); // the anchor itself
blob_size += vect_size; // all vectors + delims
@ -752,7 +749,6 @@ PROCPS_EXPORT struct slabnode_stack **procps_slabnode_stacks_alloc (
p_blob->next = info->stacked;
info->stacked = p_blob;
p_blob->self = p_blob;
p_blob->header_size = head_size;
p_blob->vectors = (void *)p_blob + sizeof(struct stacks_anchor);
p_vect = p_blob->vectors;
p_vect->owner = p_blob->self;
@ -790,7 +786,7 @@ PROCPS_EXPORT struct slabnode_stack *procps_slabnode_stack_alloc (
if (info == NULL || items == NULL || maxitems < 1)
return NULL;
v = procps_slabnode_stacks_alloc(info, 1, 0, maxitems, items);
v = procps_slabnode_stacks_alloc(info, 1, maxitems, items);
if (!v)
return NULL;
stacks_validate(v, __func__);

View File

@ -119,7 +119,6 @@ struct slabnode_stack *procps_slabnode_stack_alloc (
struct slabnode_stack **procps_slabnode_stacks_alloc (
struct procps_slabinfo *info,
int maxstacks,
int stack_extra,
int maxitems,
enum slabnode_item *items);

View File

@ -293,7 +293,7 @@ int main(int argc, char *argv[])
if (procps_slabinfo_new(&Slab_info) < 0)
xerrx(EXIT_FAILURE, _("Unable to create slabinfo structure"));
if (!(v = procps_slabnode_stacks_alloc(Slab_info, CHAINS_ALLOC, 0, MAX_ITEMS, Node_items)))
if (!(v = procps_slabnode_stacks_alloc(Slab_info, CHAINS_ALLOC, MAX_ITEMS, Node_items)))
xerrx(EXIT_FAILURE, _("Unable to allocate slabinfo nodes"));
if (!Run_once) {

View File

@ -624,7 +624,7 @@ static void slabformat (void)
if (procps_slabinfo_new(&slab_info) < 0)
xerrx(EXIT_FAILURE, _("Unable to create slabinfo structure"));
if (!(v = procps_slabnode_stacks_alloc(slab_info, CHAINS_ALLOC, 0, MAX_ITEMS, node_items)))
if (!(v = procps_slabnode_stacks_alloc(slab_info, CHAINS_ALLOC, MAX_ITEMS, node_items)))
xerrx(EXIT_FAILURE, _("Unable to allocate slabinfo nodes"));
if (!moreheaders)