diff options
author | Damjan Marion <damarion@cisco.com> | 2018-03-04 17:19:08 +0100 |
---|---|---|
committer | Damjan Marion <damarion@cisco.com> | 2018-03-05 11:34:16 +0100 |
commit | 1ba0fa4bfa3dcc9bd754b8b0b6a7c5045f9ba0dd (patch) | |
tree | 240c195346d726c7833e33b2b12f1648b4dc77d3 /src/vlib/buffer.c | |
parent | d5ded2df0ff06fe9178696657ee53a31f7e4c81c (diff) |
vlib: vfio code rework
Change-Id: I99cf3e7cc991aa7d32385a155c707a6516516117
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vlib/buffer.c')
-rw-r--r-- | src/vlib/buffer.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/vlib/buffer.c b/src/vlib/buffer.c index 6b20a542ca1..1b975163e62 100644 --- a/src/vlib/buffer.c +++ b/src/vlib/buffer.c @@ -564,15 +564,14 @@ vlib_buffer_fill_free_list_internal (vlib_main_t * vm, n_alloc = 0; while (n_remaining > 0) { - n_this_chunk = clib_min (n_remaining, 16); + vlib_buffer_pool_t *bp = &vm->buffer_main->buffer_pools[0]; + n_this_chunk = clib_min (n_remaining, bp->alloc_chunk_size); n_bytes = n_this_chunk * (sizeof (b[0]) + fl->n_data_bytes); /* drb: removed power-of-2 ASSERT */ buffers = - vm->os_physmem_alloc_aligned (vm, - vm->buffer_main-> - buffer_pools[0].physmem_region, n_bytes, + vm->os_physmem_alloc_aligned (vm, bp->physmem_region, n_bytes, sizeof (vlib_buffer_t)); if (!buffers) return n_alloc; @@ -960,6 +959,7 @@ vlib_buffer_add_physmem_region (vlib_main_t * vm, p->start = start; p->size = size; p->physmem_region = pri; + p->alloc_chunk_size = (pr->log2_page_size > 18) ? 16 : 1; return p - bm->buffer_pools; } @@ -1056,6 +1056,8 @@ vlib_buffer_main_init (struct vlib_main_t * vm) /* allocate default region */ error = vlib_physmem_region_alloc (vm, "buffers", vlib_buffer_physmem_sz, 0, + VLIB_PHYSMEM_F_SHARED | + VLIB_PHYSMEM_F_HUGETLB | VLIB_PHYSMEM_F_INIT_MHEAP, &pri); if (error == 0) @@ -1063,13 +1065,13 @@ vlib_buffer_main_init (struct vlib_main_t * vm) clib_error_free (error); - /* we my be running unpriviledged, so try to allocate fake physmem */ - error = vlib_physmem_region_alloc (vm, "buffers (fake)", + error = vlib_physmem_region_alloc (vm, "buffers", vlib_buffer_physmem_sz, 0, - VLIB_PHYSMEM_F_FAKE | + VLIB_PHYSMEM_F_SHARED | VLIB_PHYSMEM_F_INIT_MHEAP, &pri); done: - vlib_buffer_add_physmem_region (vm, pri); + if (error == 0) + vlib_buffer_add_physmem_region (vm, pri); return error; } |