aboutsummaryrefslogtreecommitdiffstats
path: root/src/svm/fifo_segment.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-06-25 18:14:13 -0700
committerDave Barach <openvpp@barachs.net>2019-06-26 15:29:45 +0000
commit1c91c77307dc120ac11e0d1a649aa4db58348f1b (patch)
treeae8719b73f0189079c3ffa3a78115d4db8c91840 /src/svm/fifo_segment.c
parentc118a220e57a88c1acbaddf66cbe5028709094e0 (diff)
svm: fix fifo segment free chunk bytes accounting
Type:fix Change-Id: Icab89337eb3dbdc93d0fb453cfd34090026072b7 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/svm/fifo_segment.c')
-rw-r--r--src/svm/fifo_segment.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/svm/fifo_segment.c b/src/svm/fifo_segment.c
index 6d62d37933b..d47c8534d14 100644
--- a/src/svm/fifo_segment.c
+++ b/src/svm/fifo_segment.c
@@ -248,7 +248,7 @@ fs_try_alloc_fifo_freelist_multi_chunk (fifo_segment_t * fs, u32 data_bytes)
last = c;
c->next = first;
first = c;
- n_alloc += c->length;
+ n_alloc += fl_size;
c->length = clib_min (fl_size, data_bytes);
data_bytes -= c->length;
}
@@ -468,6 +468,9 @@ fifo_segment_free_fifo (fifo_segment_t * fs, svm_fifo_t * f)
}
while (cur != f->start_chunk);
+ f->start_chunk = f->end_chunk = f->new_chunks = 0;
+ f->head_chunk = f->tail_chunk = f->ooo_enq = f->ooo_deq = 0;
+
oldheap = ssvm_push_heap (sh);
svm_fifo_free_chunk_lookup (f);
ssvm_pop_heap (oldheap);
@@ -632,7 +635,7 @@ fifo_segment_grow_fifo (fifo_segment_t * fs, svm_fifo_t * f, u32 chunk_size)
if (!fs_chunk_size_is_valid (chunk_size))
{
clib_warning ("chunk size out of range %d", chunk_size);
- return 0;
+ return -1;
}
fl_index = fs_freelist_for_size (chunk_size);
@@ -651,6 +654,7 @@ fifo_segment_grow_fifo (fifo_segment_t * fs, svm_fifo_t * f, u32 chunk_size)
if (!c)
{
ssvm_pop_heap (oldheap);
+ ssvm_unlock_non_recursive (sh);
return -1;
}
}
@@ -658,6 +662,7 @@ fifo_segment_grow_fifo (fifo_segment_t * fs, svm_fifo_t * f, u32 chunk_size)
{
fs->h->free_chunks[fl_index] = c->next;
c->next = 0;
+ fs->h->n_fl_chunk_bytes -= fs_freelist_index_to_size (fl_index);
}
svm_fifo_add_chunk (f, c);
@@ -783,7 +788,7 @@ fifo_segment_free_bytes (fifo_segment_t * fs)
}
u32
-fifo_segment_chunk_prealloc_bytes (fifo_segment_t * fs)
+fifo_segment_fl_chunk_bytes (fifo_segment_t * fs)
{
return fs->h->n_fl_chunk_bytes;
}