aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-04-12 13:04:16 -0700
committerDamjan Marion <dmarion@me.com>2019-04-14 14:45:57 +0000
commitc0818bce929b1fe4f494a360cdebb1afdc69e853 (patch)
tree649b0fe9e0c195ef22a821c528ae1d0e363e435f /src/vnet
parent2f3451992e6fa45be492abf173272cf513fc2842 (diff)
session: drop lock on segment allocation error VPP-1644
Change-Id: Ib346570daa3e40f4f53100a05e9355ce60d533a4 Signed-off-by: Florin Coras <fcoras@cisco.com> (cherry picked from commit bbf923fb52e8a9062ef4d740288cf5547c4dbde4)
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/session/segment_manager.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/vnet/session/segment_manager.c b/src/vnet/session/segment_manager.c
index 25b641de167..c8d4be5c113 100644
--- a/src/vnet/session/segment_manager.c
+++ b/src/vnet/session/segment_manager.c
@@ -195,7 +195,7 @@ int
segment_manager_add_segment (segment_manager_t * sm, u32 segment_size)
{
segment_manager_main_t *smm = &segment_manager_main;
- u32 rnd_margin = 128 << 10, seg_index, page_size;
+ u32 rnd_margin = 128 << 10, seg_index = ~0, page_size;
segment_manager_properties_t *props;
uword baseva = (uword) ~ 0ULL, alloc_size;
svm_fifo_segment_private_t *seg;
@@ -215,15 +215,9 @@ segment_manager_add_segment (segment_manager_t * sm, u32 segment_size)
* Allocate fifo segment and lock if needed
*/
if (vlib_num_workers ())
- {
- clib_rwlock_writer_lock (&sm->segments_rwlock);
- pool_get (sm->segments, seg);
- }
- else
- {
- pool_get (sm->segments, seg);
- }
- clib_memset (seg, 0, sizeof (*seg));
+ clib_rwlock_writer_lock (&sm->segments_rwlock);
+
+ pool_get_zero (sm->segments, seg);
/*
* Initialize ssvm segment and svm fifo private header
@@ -239,7 +233,8 @@ segment_manager_add_segment (segment_manager_t * sm, u32 segment_size)
if (!baseva)
{
clib_warning ("out of space for segments");
- return -1;
+ pool_put (sm->segments, seg);
+ goto done;
}
}
else
@@ -257,7 +252,7 @@ segment_manager_add_segment (segment_manager_t * sm, u32 segment_size)
if (props->segment_type != SSVM_SEGMENT_PRIVATE)
clib_valloc_free (&smm->va_allocator, baseva);
pool_put (sm->segments, seg);
- return (rv);
+ goto done;
}
svm_fifo_segment_init (seg);
@@ -267,6 +262,8 @@ segment_manager_add_segment (segment_manager_t * sm, u32 segment_size)
*/
seg_index = seg - sm->segments;
+done:
+
if (vlib_num_workers ())
clib_rwlock_writer_unlock (&sm->segments_rwlock);