Skip to content

Commit

Permalink
issue: 2247939 Add option VMA_VMAD_ENABLED
Browse files Browse the repository at this point in the history
This option allows to disable vmad functionality in VMA. Running vmad process
can lead to performance degradation in case of multiple TCP socket state
changes.

Signed-off-by: Dmytro Podgornyi <[email protected]>
  • Loading branch information
pasis committed Jul 27, 2020
1 parent 825994a commit f35c38c
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 10 deletions.
5 changes: 5 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ Example:
VMA DETAILS: Stats File [VMA_STATS_FILE]
VMA DETAILS: Stats shared memory directory /tmp/ [VMA_STATS_SHMEM_DIR]
VMA DETAILS: VMAD output directory /tmp/vma/ [VMA_VMAD_NOTIFY_DIR]
VMA DETAILS: VMAD support Enabled [VMA_VMAD_ENABLED]
VMA DETAILS: Stats FD Num (max) 100 [VMA_STATS_FD_NUM]
VMA DETAILS: Conf File /etc/libvma.conf [VMA_CONFIG_FILE]
VMA DETAILS: Application ID VMA_DEFAULT_APPLICATION_ID [VMA_APPLICATION_ID]
Expand Down Expand Up @@ -324,6 +325,10 @@ Set the directory path for VMA to write files used by vmad.
Default value is /tmp/vma/
Note: when used vmad must be run with --notify-dir directing the same folder.

VMA_VMAD_ENABLED
When this option is disabled VMA won't communicate with vmad.
Default vale is 1 (Enabled)

VMA_STATS_FD_NUM
Max number of sockets monitored by VMA statistic mechanism.
Value range is 0 to 1024.
Expand Down
10 changes: 10 additions & 0 deletions src/vma/dev/ring_tap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ ring_tap::ring_tap(int if_index, ring* parent):
if_indextoname(get_if_index(), tap_if_name);
memcpy(m_p_ring_stat->tap.s_tap_name, tap_if_name, IFNAMSIZ);

if (!safe_mce_sys().vmad_enabled) {
ring_logwarn("vmad is disabled, but required for TAP devices. Consider using VMA_VMAD_ENABLED=1.");
}

/* create egress rule (redirect traffic from tap device to physical interface) */
rc = prepare_flow_message(data, VMA_MSG_FLOW_ADD);
if (rc != 0) {
Expand Down Expand Up @@ -371,6 +375,9 @@ int ring_tap::prepare_flow_message(vma_msg_flow& data, msg_flow_t flow_action,
{
int rc = 0;

if (unlikely(!safe_mce_sys().vmad_enabled))
return 0;

memset(&data, 0, sizeof(data));
data.hdr.code = VMA_MSG_FLOW;
data.hdr.ver = VMA_AGENT_VER;
Expand Down Expand Up @@ -400,6 +407,9 @@ int ring_tap::prepare_flow_message(vma_msg_flow& data, msg_flow_t flow_action)
{
int rc = 0;

if (unlikely(!safe_mce_sys().vmad_enabled))
return 0;

memset(&data, 0, sizeof(data));
data.hdr.code = VMA_MSG_FLOW;
data.hdr.ver = VMA_AGENT_VER;
Expand Down
11 changes: 8 additions & 3 deletions src/vma/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ void print_vma_global_settings()
VLOG_STR_PARAM_STRING("Stats File", safe_mce_sys().stats_filename, MCE_DEFAULT_STATS_FILE, SYS_VAR_STATS_FILENAME, safe_mce_sys().stats_filename);
VLOG_STR_PARAM_STRING("Stats shared memory directory", safe_mce_sys().stats_shmem_dirname, MCE_DEFAULT_STATS_SHMEM_DIR, SYS_VAR_STATS_SHMEM_DIRNAME, safe_mce_sys().stats_shmem_dirname);
VLOG_STR_PARAM_STRING("VMAD output directory", safe_mce_sys().vmad_notify_dir, MCE_DEFAULT_VMAD_FOLDER, SYS_VAR_VMAD_DIR, safe_mce_sys().vmad_notify_dir);
VLOG_PARAM_STRING("VMAD support", safe_mce_sys().vmad_enabled, MCE_DEFAULT_VMAD_ENABLED, SYS_VAR_VMAD_ENABLED, safe_mce_sys().vmad_enabled ? "Enabled" : "Disabled");
VLOG_PARAM_NUMBER("Stats FD Num (max)", safe_mce_sys().stats_fd_num_max, MCE_DEFAULT_STATS_FD_NUM, SYS_VAR_STATS_FD_NUM);
VLOG_STR_PARAM_STRING("Conf File", safe_mce_sys().conf_filename, MCE_DEFAULT_CONF_FILE, SYS_VAR_CONF_FILENAME, safe_mce_sys().conf_filename);
VLOG_STR_PARAM_STRING("Application ID", safe_mce_sys().app_id, MCE_DEFAULT_APP_ID, SYS_VAR_APPLICATION_ID, safe_mce_sys().app_id);
Expand Down Expand Up @@ -674,9 +675,13 @@ static void do_global_ctors_helper()
g_is_forked_child = false;

/* Open communication with daemon */
NEW_CTOR(g_p_agent, agent());
vlog_printf(VLOG_DEBUG,"Agent setup state: g_p_agent=%p active=%d\n",
g_p_agent, (g_p_agent ? g_p_agent->state() : -1));
if (safe_mce_sys().vmad_enabled) {
NEW_CTOR(g_p_agent, agent());
vlog_printf(VLOG_DEBUG, "Agent setup state: g_p_agent=%p active=%d\n",
g_p_agent, (g_p_agent ? g_p_agent->state() : -1));
} else {
vlog_printf(VLOG_DEBUG, "Agent is disabled");
}

// Create all global managment objects
NEW_CTOR(g_p_event_handler_manager, event_handler_manager());
Expand Down
17 changes: 11 additions & 6 deletions src/vma/sock/sockinfo_tcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ sockinfo_tcp::sockinfo_tcp(int fd):
m_sysvar_buffer_batching_mode(safe_mce_sys().buffer_batching_mode),
m_sysvar_tcp_ctl_thread(safe_mce_sys().tcp_ctl_thread),
m_sysvar_internal_thread_tcp_timer_handling(safe_mce_sys().internal_thread_tcp_timer_handling),
m_sysvar_rx_poll_on_tx_tcp(safe_mce_sys().rx_poll_on_tx_tcp)
m_sysvar_rx_poll_on_tx_tcp(safe_mce_sys().rx_poll_on_tx_tcp),
m_agent_enabled(safe_mce_sys().vmad_enabled)
{
si_tcp_logfuncall("");

Expand Down Expand Up @@ -313,7 +314,9 @@ sockinfo_tcp::sockinfo_tcp(int fd):
}

si_tcp_logdbg("TCP PCB FLAGS: 0x%x", m_pcb.flags);
g_p_agent->register_cb((agent_cb_t)&sockinfo_tcp::put_agent_msg, (void *)this);
if (m_agent_enabled) {
g_p_agent->register_cb((agent_cb_t)&sockinfo_tcp::put_agent_msg, (void *)this);
}
si_tcp_logfunc("done");
}

Expand Down Expand Up @@ -356,8 +359,9 @@ sockinfo_tcp::~sockinfo_tcp()
si_tcp_logerr("not all buffers were freed. protocol=TCP. m_n_rx_pkt_ready_list_count=%d, m_rx_ready_byte_count=%d, m_rx_pkt_ready_list.size()=%d, m_rx_ring_map.size()=%d, m_rx_reuse_buff.n_buff_num=%d, m_rx_reuse_buff.rx_reuse.size=%d, m_rx_cb_dropped_list.size=%d, m_rx_ctl_packets_list.size=%d, m_rx_peer_packets.size=%d, m_rx_ctl_reuse_list.size=%d",
m_n_rx_pkt_ready_list_count, m_rx_ready_byte_count, (int)m_rx_pkt_ready_list.size() ,(int)m_rx_ring_map.size(), m_rx_reuse_buff.n_buff_num, m_rx_reuse_buff.rx_reuse.size(), m_rx_cb_dropped_list.size(), m_rx_ctl_packets_list.size(), m_rx_peer_packets.size(), m_rx_ctl_reuse_list.size());

g_p_agent->unregister_cb((agent_cb_t)&sockinfo_tcp::put_agent_msg, (void *)this);

if (m_agent_enabled) {
g_p_agent->unregister_cb((agent_cb_t)&sockinfo_tcp::put_agent_msg, (void *)this);
}
si_tcp_logdbg("sock closed");
}

Expand Down Expand Up @@ -1159,7 +1163,7 @@ err_t sockinfo_tcp::ip_output_syn_ack(struct pbuf *p, void* v_p_conn, int is_rex
p_si_tcp->m_p_socket_stats->tcp_state = new_state;

/* Update daemon about actual state for offloaded connection */
if (likely(p_si_tcp->m_sock_offload == TCP_SOCK_LWIP)) {
if (p_si_tcp->m_agent_enabled && likely(p_si_tcp->m_sock_offload == TCP_SOCK_LWIP)) {
p_si_tcp->put_agent_msg((void *)p_si_tcp);
}
}
Expand Down Expand Up @@ -4733,7 +4737,8 @@ void tcp_timers_collection::handle_timer_expired(void* user_data)
m_n_location = (m_n_location + 1) % m_n_intervals_size;

/* Processing all messages for the daemon */
g_p_agent->progress();
if (safe_mce_sys().vmad_enabled)
g_p_agent->progress();
}

void tcp_timers_collection::add_new_timer(timer_node_t* node, timer_handler* handler, void* user_data)
Expand Down
1 change: 1 addition & 0 deletions src/vma/sock/sockinfo_tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ class sockinfo_tcp : public sockinfo, public timer_handler
static const unsigned TX_CONSECUTIVE_EAGAIN_THREASHOLD = 10;
unsigned m_tx_consecutive_eagain_count;
bool m_sysvar_rx_poll_on_tx_tcp;
bool m_agent_enabled;

inline void init_pbuf_custom(mem_buf_desc_t *p_desc);

Expand Down
5 changes: 5 additions & 0 deletions src/vma/util/sys_vars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ void mce_sys_var::get_env_params()
handle_sigintr = MCE_DEFAULT_HANDLE_SIGINTR;
handle_segfault = MCE_DEFAULT_HANDLE_SIGFAULT;
stats_fd_num_max = MCE_DEFAULT_STATS_FD_NUM;
vmad_enabled = MCE_DEFAULT_VMAD_ENABLED;

ring_allocation_logic_tx= MCE_DEFAULT_RING_ALLOCATION_LOGIC_TX;
ring_allocation_logic_rx= MCE_DEFAULT_RING_ALLOCATION_LOGIC_RX;
Expand Down Expand Up @@ -804,6 +805,10 @@ void mce_sys_var::get_env_params()
read_env_variable_with_pid(vmad_notify_dir, sizeof(vmad_notify_dir), env_ptr);
}

if ((env_ptr = getenv(SYS_VAR_VMAD_ENABLED)) != NULL){
vmad_enabled = atoi(env_ptr) ? true : false;
}

if ((env_ptr = getenv(SYS_VAR_LOG_LEVEL)) != NULL)
log_level = log_level::from_str(env_ptr, VLOG_DEFAULT);

Expand Down
5 changes: 4 additions & 1 deletion src/vma/util/sys_vars.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ struct mce_sys_var {
char stats_shmem_dirname[PATH_MAX];
char conf_filename[PATH_MAX];
char vmad_notify_dir[PATH_MAX];
bool vmad_enabled;
bool log_colors;
bool handle_sigintr;
bool handle_segfault;
Expand Down Expand Up @@ -457,6 +458,7 @@ extern mce_sys_var & safe_mce_sys();
#define SYS_VAR_LOG_FILENAME "VMA_LOG_FILE"
#define SYS_VAR_STATS_FILENAME "VMA_STATS_FILE"
#define SYS_VAR_VMAD_DIR "VMA_VMAD_NOTIFY_DIR"
#define SYS_VAR_VMAD_ENABLED "VMA_VMAD_ENABLED"
#define SYS_VAR_STATS_SHMEM_DIRNAME "VMA_STATS_SHMEM_DIR"
#define SYS_VAR_CONF_FILENAME "VMA_CONFIG_FILE"
#define SYS_VAR_LOG_COLORS "VMA_LOG_COLORS"
Expand Down Expand Up @@ -575,7 +577,8 @@ extern mce_sys_var & safe_mce_sys();
#define MCE_DEFAULT_LOG_FILE ("")
#define MCE_DEFAULT_CONF_FILE ("/etc/libvma.conf")
#define MCE_DEFAULT_STATS_FILE ("")
#define MCE_DEFAULT_VMAD_FOLDER (VMA_AGENT_PATH)
#define MCE_DEFAULT_VMAD_FOLDER (VMA_AGENT_PATH)
#define MCE_DEFAULT_VMAD_ENABLED (true)
#define MCE_DEFAULT_STATS_SHMEM_DIR ("/tmp/")
#define MCE_DEFAULT_LOG_DETAILS (0)
#define MCE_DEFAULT_LOG_COLORS (true)
Expand Down

0 comments on commit f35c38c

Please sign in to comment.