X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fsvm%2Fsvm_fifo.c;h=c8fd263c09485cb26199ba3ac8e0a5423262e254;hb=b095a3cd221a142f7d2b4897b812b2781de05d29;hp=eafe497eec17081cb25ef8a08d63005f854852db;hpb=403e3ba1507750df463d7179494c14d03864b810;p=vpp.git diff --git a/src/svm/svm_fifo.c b/src/svm/svm_fifo.c index eafe497eec1..c8fd263c094 100644 --- a/src/svm/svm_fifo.c +++ b/src/svm/svm_fifo.c @@ -298,7 +298,9 @@ svm_fifo_init (svm_fifo_t * f, u32 size) f->head_chunk = f->tail_chunk = f->ooo_enq = f->ooo_deq = f->start_chunk; } -/** create an svm fifo, in the current heap. Fails vs blow up the process */ +/** + * Creates a fifo in the current heap. Fails vs blow up the process + */ svm_fifo_t * svm_fifo_create (u32 data_size_in_bytes) { @@ -317,6 +319,27 @@ svm_fifo_create (u32 data_size_in_bytes) return f; } +/** + * Creates a fifo chunk in the current heap + */ +svm_fifo_chunk_t * +svm_fifo_chunk_alloc (u32 size) +{ + svm_fifo_chunk_t *c; + u32 rounded_size; + + /* round chunk size to the next highest power-of-two */ + rounded_size = (1 << (max_log2 (size))); + c = clib_mem_alloc_aligned_or_null (sizeof (*c) + rounded_size, + CLIB_CACHE_LINE_BYTES); + if (c == 0) + return 0; + + clib_memset (c, 0, sizeof (*c)); + c->length = rounded_size; + return c; +} + static inline void svm_fifo_size_update (svm_fifo_t * f, svm_fifo_chunk_t * c) { @@ -461,6 +484,18 @@ svm_fifo_find_chunk (svm_fifo_t * f, u32 pos) return 0; } +void +svm_fifo_free_chunk_lookup (svm_fifo_t * f) +{ + rb_tree_free_nodes (&f->chunk_lookup); +} + +void +svm_fifo_free_ooo_data (svm_fifo_t * f) +{ + pool_free (f->ooo_segments); +} + void svm_fifo_free (svm_fifo_t * f) { @@ -468,7 +503,8 @@ svm_fifo_free (svm_fifo_t * f) if (--f->refcnt == 0) { - pool_free (f->ooo_segments); + /* ooo data is not allocated on segment heap */ + svm_fifo_free_chunk_lookup (f); clib_mem_free (f); } }