From c547e91df7083007c87615ac1e37b6f223e575e9 Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Tue, 8 Dec 2020 17:50:45 -0800 Subject: svm: split fifo into private and shared structs Type: improvement Signed-off-by: Florin Coras Change-Id: Id8e77e8b2623be719fd43a95e181eaa5b7df2b6e --- src/svm/fifo_types.h | 64 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 26 deletions(-) (limited to 'src/svm/fifo_types.h') diff --git a/src/svm/fifo_types.h b/src/svm/fifo_types.h index e839e7eaab7..434b2c38b4c 100644 --- a/src/svm/fifo_types.h +++ b/src/svm/fifo_types.h @@ -59,59 +59,65 @@ typedef struct u32 action; } svm_fifo_trace_elem_t; -typedef struct _svm_fifo +typedef struct svm_fifo_shr_ { - CLIB_CACHE_LINE_ALIGN_MARK (shared_first); - fifo_segment_header_t *fs_hdr;/**< fifo segment header for fifo */ + CLIB_CACHE_LINE_ALIGN_MARK (shared); svm_fifo_chunk_t *start_chunk;/**< first chunk in fifo chunk list */ svm_fifo_chunk_t *end_chunk; /**< end chunk in fifo chunk list */ + volatile u32 has_event; /**< non-zero if deq event exists */ u32 min_alloc; /**< min chunk alloc if space available */ u32 size; /**< size of the fifo in bytes */ - u8 flags; /**< fifo flags */ - u8 slice_index; /**< segment slice for fifo */ - - CLIB_CACHE_LINE_ALIGN_MARK (shared_second); - volatile u32 has_event; /**< non-zero if deq event exists */ u32 master_session_index; /**< session layer session index */ u32 client_session_index; /**< app session index */ - u8 master_thread_index; /**< session layer thread index */ - u8 client_thread_index; /**< app worker index */ - i8 refcnt; /**< reference count */ - u32 segment_manager; /**< session layer segment manager index */ - u32 segment_index; /**< segment index in segment manager */ - struct _svm_fifo *next; /**< next in freelist/active chain */ - struct _svm_fifo *prev; /**< prev in active chain */ - - CLIB_CACHE_LINE_ALIGN_MARK (consumer); - rb_tree_t ooo_deq_lookup; /**< rbtree for ooo deq chunk lookup */ + u8 slice_index; /**< segment slice for fifo */ + struct svm_fifo_shr_ *next; /**< next in freelist/active chain */ + + CLIB_CACHE_LINE_ALIGN_MARK (consumer); svm_fifo_chunk_t *head_chunk; /**< tracks chunk where head lands */ - svm_fifo_chunk_t *ooo_deq; /**< last chunk used for ooo dequeue */ u32 head; /**< fifo head position/byte */ volatile u32 want_deq_ntf; /**< producer wants nudge */ volatile u32 has_deq_ntf; - CLIB_CACHE_LINE_ALIGN_MARK (producer); - rb_tree_t ooo_enq_lookup; /**< rbtree for ooo enq chunk lookup */ + CLIB_CACHE_LINE_ALIGN_MARK (producer); u32 tail; /**< fifo tail position/byte */ - u32 ooos_list_head; /**< Head of out-of-order linked-list */ svm_fifo_chunk_t *tail_chunk; /**< tracks chunk where tail lands */ + volatile u8 n_subscribers; /**< Number of subscribers for io events */ + u8 subscribers[SVM_FIFO_MAX_EVT_SUBSCRIBERS]; +} svm_fifo_shared_t; + +typedef struct _svm_fifo +{ + CLIB_CACHE_LINE_ALIGN_MARK (cacheline); + svm_fifo_shared_t *shr; /**< shared fifo in fifo segment memory */ + fifo_segment_header_t *fs_hdr; /**< fifo segment header for fifo */ + rb_tree_t ooo_enq_lookup; /**< rbtree for ooo enq chunk lookup */ + rb_tree_t ooo_deq_lookup; /**< rbtree for ooo deq chunk lookup */ + svm_fifo_chunk_t *ooo_deq; /**< last chunk used for ooo dequeue */ svm_fifo_chunk_t *ooo_enq; /**< last chunk used for ooo enqueue */ ooo_segment_t *ooo_segments; /**< Pool of ooo segments */ + u32 ooos_list_head; /**< Head of out-of-order linked-list */ u32 ooos_newest; /**< Last segment to have been updated */ - volatile u8 n_subscribers; /**< Number of subscribers for io events */ - u8 subscribers[SVM_FIFO_MAX_EVT_SUBSCRIBERS]; + + u8 flags; /**< fifo flags */ + u8 master_thread_index; /**< session layer thread index */ + u8 client_thread_index; /**< app worker index */ + i8 refcnt; /**< reference count */ + u32 segment_manager; /**< session layer segment manager index */ + u32 segment_index; /**< segment index in segment manager */ + + struct _svm_fifo *next; /**< prev in active chain */ + struct _svm_fifo *prev; /**< prev in active chain */ #if SVM_FIFO_TRACE svm_fifo_trace_elem_t *trace; #endif - } svm_fifo_t; typedef struct fifo_segment_slice_ { svm_fifo_chunk_t *free_chunks[FS_CHUNK_VEC_LEN]; /**< Free chunks by size */ svm_fifo_t *fifos; /**< Linked list of active RX fifos */ - svm_fifo_t *free_fifos; /**< Freelists by fifo size */ + svm_fifo_shared_t *free_fifos; /**< Freelists of fifo shared hdrs */ uword n_fl_chunk_bytes; /**< Chunk bytes on freelist */ uword virtual_mem; /**< Slice sum of all fifo sizes */ u32 num_chunks[FS_CHUNK_VEC_LEN]; /**< Allocated chunks by chunk size */ @@ -120,6 +126,12 @@ typedef struct fifo_segment_slice_ u32 chunk_lock; } fifo_segment_slice_t; +typedef struct fifo_slice_private_ +{ + clib_mem_bulk_handle_t fifos; /**< Bulk fifo allocator */ + uword virtual_mem; /**< Slice sum of all fifo sizes */ +} fifo_slice_private_t; + struct fifo_segment_header_ { uword n_cached_bytes; /**< Cached bytes */ -- cgit 1.2.3-korg