summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2021-08-10 16:56:34 -0700
committerDave Barach <openvpp@barachs.net>2021-08-11 14:41:32 +0000
commitafbb33aaf254ebfe6ebf2477b1a4859cec40e34b (patch)
tree7f8e82585c7e64f3b8058aa6b5720db3dfcf65e4 /src
parenta70b015ceeee158eac0d9b33d12c596e1af409b3 (diff)
svm: make more fifo segment header fields private
Type: improvement Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: Idab0f455b52a38efd2cf3781497d8cc7f57bfa42
Diffstat (limited to 'src')
-rw-r--r--src/svm/fifo_segment.c36
-rw-r--r--src/svm/fifo_segment.h26
-rw-r--r--src/svm/fifo_types.h3
-rw-r--r--src/vnet/session/segment_manager.c8
4 files changed, 28 insertions, 45 deletions
diff --git a/src/svm/fifo_segment.c b/src/svm/fifo_segment.c
index 6ab07974ff7..2ff272e2f88 100644
--- a/src/svm/fifo_segment.c
+++ b/src/svm/fifo_segment.c
@@ -105,13 +105,14 @@ fsh_n_active_fifos (fifo_segment_header_t * fsh)
}
static inline uword
-fsh_virtual_mem (fifo_segment_header_t * fsh)
+fs_virtual_mem (fifo_segment_t *fs)
{
+ fifo_segment_header_t *fsh = fs->h;
fifo_segment_slice_t *fss;
uword total_vm = 0;
int i;
- for (i = 0; i < fsh->n_slices; i++)
+ for (i = 0; i < fs->n_slices; i++)
{
fss = fsh_slice_get (fsh, i);
total_vm += clib_atomic_load_relax_n (&fss->virtual_mem);
@@ -1376,16 +1377,16 @@ fifo_segment_size (fifo_segment_t * fs)
return fs->h->max_byte_index - fs->h->n_reserved_bytes;
}
-u8
-fsh_has_reached_mem_limit (fifo_segment_header_t * fsh)
+static u8
+fs_has_reached_mem_limit (fifo_segment_t *fs)
{
- return (fsh->flags & FIFO_SEGMENT_F_MEM_LIMIT) ? 1 : 0;
+ return (fs->flags & FIFO_SEGMENT_F_MEM_LIMIT) ? 1 : 0;
}
-void
-fsh_reset_mem_limit (fifo_segment_header_t * fsh)
+static void
+fs_reset_mem_limit (fifo_segment_t *fs)
{
- fsh->flags &= ~FIFO_SEGMENT_F_MEM_LIMIT;
+ fs->flags &= ~FIFO_SEGMENT_F_MEM_LIMIT;
}
void *
@@ -1460,26 +1461,26 @@ fifo_segment_get_mem_usage (fifo_segment_t * fs)
}
fifo_segment_mem_status_t
-fifo_segment_determine_status (fifo_segment_header_t * fsh, u8 usage)
+fifo_segment_determine_status (fifo_segment_t *fs, u8 usage)
{
- if (!fsh->high_watermark || !fsh->low_watermark)
+ if (!fs->high_watermark || !fs->low_watermark)
return MEMORY_PRESSURE_NO_PRESSURE;
/* once the no-memory is detected, the status continues
* until memory usage gets below the high watermark
*/
- if (fsh_has_reached_mem_limit (fsh))
+ if (fs_has_reached_mem_limit (fs))
{
- if (usage >= fsh->high_watermark)
+ if (usage >= fs->high_watermark)
return MEMORY_PRESSURE_NO_MEMORY;
else
- fsh_reset_mem_limit (fsh);
+ fs_reset_mem_limit (fs);
}
- if (usage >= fsh->high_watermark)
+ if (usage >= fs->high_watermark)
return MEMORY_PRESSURE_HIGH_PRESSURE;
- else if (usage >= fsh->low_watermark)
+ else if (usage >= fs->low_watermark)
return MEMORY_PRESSURE_LOW_PRESSURE;
return MEMORY_PRESSURE_NO_PRESSURE;
@@ -1488,10 +1489,9 @@ fifo_segment_determine_status (fifo_segment_header_t * fsh, u8 usage)
fifo_segment_mem_status_t
fifo_segment_get_mem_status (fifo_segment_t * fs)
{
- fifo_segment_header_t *fsh = fs->h;
u8 usage = fifo_segment_get_mem_usage (fs);
- return fifo_segment_determine_status (fsh, usage);
+ return fifo_segment_determine_status (fs, usage);
}
u8 *
@@ -1598,7 +1598,7 @@ format_fifo_segment (u8 * s, va_list * args)
in_use = fifo_segment_size (fs) - est_free_seg_bytes - tracked_cached_bytes;
usage = (100.0 * in_use) / allocated;
mem_st = fifo_segment_get_mem_status (fs);
- virt = fsh_virtual_mem (fsh);
+ virt = fs_virtual_mem (fs);
reserved = fsh->n_reserved_bytes;
s = format (s, "\n%Useg free bytes: %U (%lu) estimated: %U (%lu) reserved:"
diff --git a/src/svm/fifo_segment.h b/src/svm/fifo_segment.h
index f76798fed90..de4622f6a2a 100644
--- a/src/svm/fifo_segment.h
+++ b/src/svm/fifo_segment.h
@@ -69,10 +69,13 @@ typedef struct
{
ssvm_private_t ssvm; /**< ssvm segment data */
fifo_segment_header_t *h; /**< fifo segment data */
- uword max_byte_index;
- u8 n_slices; /**< number of fifo segment slices */
fifo_slice_private_t *slices; /**< private slice information */
svm_msg_q_t *mqs; /**< private vec of attached mqs */
+ uword max_byte_index; /**< max byte index for segment */
+ u8 n_slices; /**< number of fifo segment slices */
+ u8 flags; /**< private fifo segment flags */
+ u8 high_watermark; /**< memory pressure watermark high */
+ u8 low_watermark; /**< memory pressure watermark low */
} fifo_segment_t;
typedef struct
@@ -91,7 +94,7 @@ typedef struct
u32 *new_segment_indices; /**< return vec of new seg indices */
} fifo_segment_create_args_t;
-#define fifo_segment_flags(_fs) _fs->h->flags
+#define fifo_segment_flags(_fs) _fs->flags
int fifo_segment_init (fifo_segment_t * fs);
int fifo_segment_create (fifo_segment_main_t * sm,
@@ -263,21 +266,6 @@ void fsh_collect_chunks (fifo_segment_header_t * fsh, u32 slice_index,
svm_fifo_chunk_t * c);
/**
- * Fifo segment has reached mem limit
- *
- * @param fsh fifo segment header
- * @return 1 (if reached) or 0 (otherwise)
- */
-u8 fsh_has_reached_mem_limit (fifo_segment_header_t * fsh);
-
-/**
- * Fifo segment reset mem limit flag
- *
- * @param fs fifo segment
- */
-void fsh_reset_mem_limit (fifo_segment_header_t * fsh);
-
-/**
* Fifo segment reset mem limit flag
*
* @param fs fifo segment
@@ -349,8 +337,6 @@ uword fifo_segment_chunk_offset (fifo_segment_t *fs, svm_fifo_chunk_t *c);
u32 fifo_segment_num_free_chunks (fifo_segment_t * fs, u32 size);
u8 fifo_segment_get_mem_usage (fifo_segment_t * fs);
-fifo_segment_mem_status_t fifo_segment_determine_status
- (fifo_segment_header_t * fsh, u8 usage);
fifo_segment_mem_status_t fifo_segment_get_mem_status (fifo_segment_t * fs);
void fifo_segment_main_init (fifo_segment_main_t * sm, u64 baseva,
diff --git a/src/svm/fifo_types.h b/src/svm/fifo_types.h
index aa8c3616317..3787e5d5831 100644
--- a/src/svm/fifo_types.h
+++ b/src/svm/fifo_types.h
@@ -140,10 +140,7 @@ struct fifo_segment_header_
u32 n_active_fifos; /**< Number of active fifos */
u32 n_reserved_bytes; /**< Bytes not to be allocated */
u32 max_log2_fifo_size; /**< Max log2(chunk size) for fs */
- u8 flags; /**< Segment flags */
u8 n_slices; /**< Number of slices */
- u8 high_watermark; /**< Memory pressure watermark high */
- u8 low_watermark; /**< Memory pressure watermark low */
u8 pct_first_alloc; /**< Pct of fifo size to alloc */
u8 n_mqs; /**< Num mqs for mqs segment */
CLIB_CACHE_LINE_ALIGN_MARK (allocator);
diff --git a/src/vnet/session/segment_manager.c b/src/vnet/session/segment_manager.c
index c7a06d8b636..e04f626eab2 100644
--- a/src/vnet/session/segment_manager.c
+++ b/src/vnet/session/segment_manager.c
@@ -158,11 +158,11 @@ segment_manager_add_segment_inline (segment_manager_t *sm, uword segment_size,
/*
* Set watermarks in segment
*/
- fs->h->high_watermark = sm->high_watermark;
- fs->h->low_watermark = sm->low_watermark;
+ fs->high_watermark = sm->high_watermark;
+ fs->low_watermark = sm->low_watermark;
+ fs->flags = flags;
+ fs->flags &= ~FIFO_SEGMENT_F_MEM_LIMIT;
fs->h->pct_first_alloc = props->pct_first_alloc;
- fs->h->flags = flags;
- fs->h->flags &= ~FIFO_SEGMENT_F_MEM_LIMIT;
if (notify_app)
{