session: enhance display for show app
Display segment manager information for show app <index> verbose Mark segment manager as listener if it is a listener segment. Type: improvement Change-Id: I8d91f4c2ed5b8f39620f2c8b06950c0e7ee2225e Signed-off-by: Steven Luong <sluong@cisco.com>
This commit is contained in:
parent
3d0b4ab20c
commit
fd896fc9fa
@ -18,6 +18,7 @@
|
||||
#include <vnet/session/application_namespace.h>
|
||||
#include <vnet/session/application_local.h>
|
||||
#include <vnet/session/session.h>
|
||||
#include <vnet/session/segment_manager.h>
|
||||
|
||||
static app_main_t app_main;
|
||||
|
||||
@ -1084,6 +1085,7 @@ application_alloc_worker_and_init (application_t * app, app_worker_t ** wrk)
|
||||
return rv;
|
||||
}
|
||||
sm->first_is_protected = 1;
|
||||
sm->flags |= SEG_MANAGER_F_CONNECTS;
|
||||
|
||||
/*
|
||||
* Setup app worker
|
||||
@ -1848,6 +1850,9 @@ format_application (u8 * s, va_list * args)
|
||||
const u8 *app_ns_name, *app_name;
|
||||
app_worker_map_t *wrk_map;
|
||||
app_worker_t *app_wrk;
|
||||
segment_manager_t *sm;
|
||||
u64 handle;
|
||||
u32 sm_index;
|
||||
|
||||
if (app == 0)
|
||||
{
|
||||
@ -1876,6 +1881,17 @@ format_application (u8 * s, va_list * args)
|
||||
pool_foreach (wrk_map, app->worker_maps) {
|
||||
app_wrk = app_worker_get (wrk_map->wrk_index);
|
||||
s = format (s, "%U", format_app_worker, app_wrk);
|
||||
if (verbose > 1)
|
||||
{
|
||||
sm = segment_manager_get (app_wrk->connects_seg_manager);
|
||||
s = format (s, "segment manager\n %U", format_segment_manager, sm,
|
||||
1 /* verbose */);
|
||||
hash_foreach (handle, sm_index, app_wrk->listeners_table, ({
|
||||
sm = segment_manager_get (sm_index);
|
||||
s = format (s, " %U\n", format_segment_manager, sm,
|
||||
1 /* verbose */);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
@ -2034,7 +2050,7 @@ show_app_command_fn (vlib_main_t * vm, unformat_input_t * input,
|
||||
if (!app)
|
||||
return clib_error_return (0, "No app with index %u", app_index);
|
||||
|
||||
vlib_cli_output (vm, "%U", format_application, app, /* verbose */ 1);
|
||||
vlib_cli_output (vm, "%U", format_application, app, ++verbose);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -252,6 +252,7 @@ app_worker_init_listener (app_worker_t * app_wrk, session_t * ls)
|
||||
|
||||
/* Once the first segment is mapped, don't remove it until unlisten */
|
||||
sm->first_is_protected = 1;
|
||||
sm->flags |= SEG_MANAGER_F_LISTENER;
|
||||
|
||||
/* Keep track of the segment manager for the listener or this worker */
|
||||
hash_set (app_wrk->listeners_table, listen_session_get_handle (ls),
|
||||
|
@ -1018,10 +1018,42 @@ segment_manager_main_init (void)
|
||||
}
|
||||
|
||||
static u8 *
|
||||
format_segment_manager_flags (u8 *s, va_list *args)
|
||||
{
|
||||
int flags = va_arg (*args, int);
|
||||
typedef struct sm_flags_struct
|
||||
{
|
||||
u8 bit;
|
||||
char *str;
|
||||
} sm_flags_struct_t;
|
||||
sm_flags_struct_t *entry;
|
||||
static sm_flags_struct_t sm_flags_array[] = {
|
||||
#define _(b, v, s) \
|
||||
{ \
|
||||
.bit = 1 << b, \
|
||||
.str = #s, \
|
||||
},
|
||||
foreach_seg_manager_flag
|
||||
#undef _
|
||||
{ .str = NULL }
|
||||
};
|
||||
|
||||
entry = sm_flags_array;
|
||||
while (entry->str)
|
||||
{
|
||||
if (flags & entry->bit)
|
||||
s = format (s, "%s ", entry->str, entry->bit);
|
||||
entry++;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
u8 *
|
||||
format_segment_manager (u8 *s, va_list *args)
|
||||
{
|
||||
segment_manager_t *sm = va_arg (*args, segment_manager_t *);
|
||||
int verbose = va_arg (*args, int);
|
||||
int indent = format_get_indent (s);
|
||||
app_worker_t *app_wrk;
|
||||
uword max_fifo_size;
|
||||
fifo_segment_t *seg;
|
||||
@ -1034,12 +1066,13 @@ format_segment_manager (u8 *s, va_list *args)
|
||||
max_fifo_size = sm->max_fifo_size;
|
||||
|
||||
s = format (s,
|
||||
"[%u] %v app-wrk: %u segs: %u max-fifo-sz: %U "
|
||||
"wmarks: %u %u %s flags: 0x%x",
|
||||
segment_manager_index (sm), app ? app->name : 0,
|
||||
sm->app_wrk_index, pool_elts (sm->segments), format_memory_size,
|
||||
max_fifo_size, sm->high_watermark, sm->low_watermark,
|
||||
custom_logic ? "custom-tuning" : "no-tuning", sm->flags);
|
||||
"%U[%u] %v app-wrk: %u segs: %u max-fifo-sz: %U "
|
||||
"wmarks: %u %u %s flags: %U",
|
||||
format_white_space, indent, segment_manager_index (sm),
|
||||
app ? app->name : 0, sm->app_wrk_index, pool_elts (sm->segments),
|
||||
format_memory_size, max_fifo_size, sm->high_watermark,
|
||||
sm->low_watermark, custom_logic ? "custom-tuning" : "no-tuning",
|
||||
format_segment_manager_flags, (int) sm->flags);
|
||||
|
||||
if (!verbose || !pool_elts (sm->segments))
|
||||
return s;
|
||||
@ -1047,7 +1080,10 @@ format_segment_manager (u8 *s, va_list *args)
|
||||
s = format (s, "\n\n");
|
||||
|
||||
segment_manager_foreach_segment_w_lock (
|
||||
seg, sm, ({ s = format (s, " *%U", format_fifo_segment, seg, verbose); }));
|
||||
seg, sm, ({
|
||||
s = format (s, "%U *%U", format_white_space, indent, format_fifo_segment,
|
||||
seg, verbose);
|
||||
}));
|
||||
|
||||
return s;
|
||||
}
|
||||
|
@ -43,10 +43,17 @@ typedef struct _segment_manager_props
|
||||
u8 huge_page; /**< use hugepage */
|
||||
} segment_manager_props_t;
|
||||
|
||||
#define foreach_seg_manager_flag \
|
||||
_ (0, DETACHED, detached) \
|
||||
_ (1, DETACHED_LISTENER, detached_listener) \
|
||||
_ (2, LISTENER, listener) \
|
||||
_ (3, CONNECTS, connects)
|
||||
|
||||
typedef enum seg_manager_flag_
|
||||
{
|
||||
SEG_MANAGER_F_DETACHED = 1 << 0,
|
||||
SEG_MANAGER_F_DETACHED_LISTENER = 1 << 1,
|
||||
#define _(b, v, s) SEG_MANAGER_F_##v = (1 << b),
|
||||
foreach_seg_manager_flag
|
||||
#undef _
|
||||
} seg_manager_flag_t;
|
||||
|
||||
typedef struct _segment_manager
|
||||
@ -196,6 +203,8 @@ segment_manager_parse_segment_handle (u64 segment_handle, u32 * sm_index,
|
||||
*segment_index = segment_handle & 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
extern u8 *format_segment_manager (u8 *s, va_list *args);
|
||||
|
||||
#endif /* SRC_VNET_SESSION_SEGMENT_MANAGER_H_ */
|
||||
/*
|
||||
* fd.io coding-style-patch-verification: ON
|
||||
|
Loading…
x
Reference in New Issue
Block a user