From ae4b6867452b3ce2509fbe3b99ba46db9f14662a Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Wed, 22 Jul 2015 00:00:00 -0500 Subject: [PATCH] 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 --- proc/meminfo.c | 8 ++------ proc/slab.c | 10 +++------- proc/slab.h | 1 - slabtop.c | 2 +- vmstat.c | 2 +- 5 files changed, 7 insertions(+), 16 deletions(-) diff --git a/proc/meminfo.c b/proc/meminfo.c index 1aa0f477..a7a392df 100644 --- a/proc/meminfo.c +++ b/proc/meminfo.c @@ -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__); diff --git a/proc/slab.c b/proc/slab.c index a400a469..359a63f1 100644 --- a/proc/slab.c +++ b/proc/slab.c @@ -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,9 +658,8 @@ 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)); + fprintf(stderr, "%s: sizeof(struct slab_result) = %2d\n", __func__, (int)sizeof(struct slab_result)); fputc('\n', stderr); return; #endif @@ -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__); diff --git a/proc/slab.h b/proc/slab.h index a41460c0..5f565ef3 100644 --- a/proc/slab.h +++ b/proc/slab.h @@ -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); diff --git a/slabtop.c b/slabtop.c index 36d7c536..0d48288b 100644 --- a/slabtop.c +++ b/slabtop.c @@ -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) { diff --git a/vmstat.c b/vmstat.c index 978d8a6e..81579449 100644 --- a/vmstat.c +++ b/vmstat.c @@ -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) -- 2.40.0