aboutsummaryrefslogtreecommitdiffstats
path: root/src/svm/fifo_segment.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/svm/fifo_segment.c')
-rw-r--r--src/svm/fifo_segment.c65
1 files changed, 47 insertions, 18 deletions
diff --git a/src/svm/fifo_segment.c b/src/svm/fifo_segment.c
index 4ffec7c86d0..fdcf84ea8d7 100644
--- a/src/svm/fifo_segment.c
+++ b/src/svm/fifo_segment.c
@@ -200,6 +200,32 @@ fss_chunk_free_list_pop (fifo_segment_header_t *fsh, fifo_segment_slice_t *fss,
return c;
}
+static void
+fss_fifo_free_list_push (fifo_segment_header_t *fsh, fifo_segment_slice_t *fss,
+ svm_fifo_shared_t *sf)
+{
+ sf->next = fss->free_fifos;
+ fss->free_fifos = fs_sptr (fsh, sf);
+}
+
+static void
+fss_fifo_free_list_push_list (fifo_segment_header_t *fsh,
+ fifo_segment_slice_t *fss,
+ svm_fifo_shared_t *head, svm_fifo_shared_t *tail)
+{
+ tail->next = fss->free_fifos;
+ fss->free_fifos = fs_sptr (fsh, head);
+}
+
+svm_fifo_shared_t *
+fss_fifo_free_list_pop (fifo_segment_header_t *fsh, fifo_segment_slice_t *fss)
+{
+ svm_fifo_shared_t *sf;
+ sf = fs_ptr (fsh, fss->free_fifos);
+ fss->free_fifos = sf->next;
+ return sf;
+}
+
static inline void
pfss_fifo_add_active_list (fifo_slice_private_t *pfss, svm_fifo_t *f)
{
@@ -499,7 +525,7 @@ static int
fsh_try_alloc_fifo_hdr_batch (fifo_segment_header_t * fsh,
fifo_segment_slice_t * fss, u32 batch_size)
{
- svm_fifo_shared_t *f;
+ svm_fifo_shared_t *f, *head = 0, *tail;
uword size;
u8 *fmem;
int i;
@@ -513,15 +539,18 @@ fsh_try_alloc_fifo_hdr_batch (fifo_segment_header_t * fsh,
return -1;
/* Carve fifo hdr space */
+ tail = f = (svm_fifo_shared_t *) fmem;
for (i = 0; i < batch_size; i++)
{
- f = (svm_fifo_shared_t *) fmem;
- memset (f, 0, sizeof (*f));
- f->next = fss->free_fifos;
- fss->free_fifos = f;
+ clib_memset (f, 0, sizeof (*f));
+ f->next = fs_sptr (fsh, head);
+ head = f;
fmem += sizeof (*f);
+ f = (svm_fifo_shared_t *) fmem;
}
+ fss_fifo_free_list_push_list (fsh, fss, head, tail);
+
return 0;
}
@@ -579,7 +608,7 @@ fs_try_alloc_fifo_batch (fifo_segment_header_t * fsh,
static svm_fifo_shared_t *
fsh_try_alloc_fifo_hdr (fifo_segment_header_t *fsh, fifo_segment_slice_t *fss)
{
- svm_fifo_shared_t *f;
+ svm_fifo_shared_t *sf;
if (!fss->free_fifos)
{
@@ -588,10 +617,10 @@ fsh_try_alloc_fifo_hdr (fifo_segment_header_t *fsh, fifo_segment_slice_t *fss)
return 0;
}
- f = fss->free_fifos;
- fss->free_fifos = f->next;
- memset (f, 0, sizeof (*f));
- return f;
+ sf = fss_fifo_free_list_pop (fsh, fss);
+ clib_memset (sf, 0, sizeof (*sf));
+
+ return sf;
}
static svm_fifo_chunk_t *
@@ -684,8 +713,7 @@ fs_try_alloc_fifo (fifo_segment_header_t *fsh, u32 slice_index, u32 data_bytes)
c = fsh_try_alloc_chunk (fsh, fss, min_size);
if (!c)
{
- sf->next = fss->free_fifos;
- fss->free_fifos = sf;
+ fss_fifo_free_list_push (fsh, fss, sf);
return 0;
}
@@ -872,8 +900,9 @@ fifo_segment_free_fifo (fifo_segment_t * fs, svm_fifo_t * f)
sf->head_chunk = sf->tail_chunk = 0;
/* Add to free list */
- sf->next = fss->free_fifos;
- fss->free_fifos = sf;
+ fss_fifo_free_list_push (fsh, fss, sf);
+ // sf->next = fss->free_fifos;
+ // fss->free_fifos = fs_sptr (fsh, sf);
fss->virtual_mem -= svm_fifo_size (f);
@@ -1131,18 +1160,18 @@ fifo_segment_num_fifos (fifo_segment_t * fs)
}
static u32
-fs_slice_num_free_fifos (fifo_segment_slice_t * fss)
+fs_slice_num_free_fifos (fifo_segment_header_t *fsh, fifo_segment_slice_t *fss)
{
svm_fifo_shared_t *f;
u32 count = 0;
- f = fss->free_fifos;
+ f = fs_ptr (fsh, fss->free_fifos);
if (f == 0)
return 0;
while (f)
{
- f = f->next;
+ f = fs_ptr (fsh, f->next);
count++;
}
return count;
@@ -1159,7 +1188,7 @@ fifo_segment_num_free_fifos (fifo_segment_t * fs)
for (slice_index = 0; slice_index < fs->n_slices; slice_index++)
{
fss = fsh_slice_get (fsh, slice_index);
- count += fs_slice_num_free_fifos (fss);
+ count += fs_slice_num_free_fifos (fsh, fss);
}
return count;
}