From 344ce4277885e448912fdfc35bcfaf130c74d086 Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Fri, 3 May 2019 11:46:55 -0700 Subject: session/svm: apis for fifo shrinking Change-Id: Ie519683bb90aae6fb95f2a09e251cded1890ed41 Signed-off-by: Florin Coras --- src/svm/fifo_segment.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/svm/fifo_segment.c') diff --git a/src/svm/fifo_segment.c b/src/svm/fifo_segment.c index 9c332d6f1fa..0263d1a57cc 100644 --- a/src/svm/fifo_segment.c +++ b/src/svm/fifo_segment.c @@ -570,6 +570,35 @@ fifo_segment_grow_fifo (fifo_segment_t * fs, svm_fifo_t * f, u32 chunk_size) return 0; } +int +fifo_segment_collect_fifo_chunks (fifo_segment_t * fs, svm_fifo_t * f) +{ + svm_fifo_chunk_t *cur, *next; + ssvm_shared_header_t *sh; + void *oldheap; + int fl_index; + + sh = fs->ssvm.sh; + ssvm_lock_non_recursive (sh, 1); + + oldheap = ssvm_push_heap (sh); + cur = svm_fifo_collect_chunks (f); + + while (cur) + { + next = cur->next; + fl_index = fs_free_list_for_size (cur->length); + cur->next = fs->h->free_chunks[fl_index]; + fs->h->free_chunks[fl_index] = cur; + cur = next; + } + + ssvm_pop_heap (oldheap); + ssvm_unlock_non_recursive (sh); + + return 0; +} + /** * Get number of active fifos */ -- cgit 1.2.3-korg