Skip to content

Commit

Permalink
issue: 3925885 Adjusting XLIO default allocation logic
Browse files Browse the repository at this point in the history
Modified the default ring allocation logic from ‘ring per interface’ to ‘ring per thread’.
Adjusted the MCE_SPEC_NGINX_DPU and MCE_SPEC_NGINX by setting
ring_allocation_logic_tx/rx to ‘ring per interface’.
Fixed a minor side-effect in the ring_allocation_logic constructor.

Signed-off-by: Bashar Abdelgafer  <babdelgafer@nvidia.com>
  • Loading branch information
BasharRadya authored and galnoam committed Jul 8, 2024
1 parent f9bfd4b commit 4f9e224
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
3 changes: 2 additions & 1 deletion src/core/dev/net_device_val.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@
#define nd_logfunc __log_info_func
#define nd_logfuncall __log_info_funcall

// The value given in this constructor is later always overriden
ring_alloc_logic_attr::ring_alloc_logic_attr()
: m_ring_alloc_logic(RING_LOGIC_PER_INTERFACE)
: m_ring_alloc_logic(RING_LOGIC_PER_THREAD)
, m_use_locks(true)
, m_user_id_key(0)
{
Expand Down
8 changes: 2 additions & 6 deletions src/core/dev/ring_allocation_logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,12 @@ ring_allocation_logic::ring_allocation_logic()
{
}

ring_allocation_logic::ring_allocation_logic(ring_logic_t allocation_logic,
int ring_migration_ratio, source_t source,
resource_allocation_key &ring_profile)
ring_allocation_logic::ring_allocation_logic(int ring_migration_ratio, source_t source,
const resource_allocation_key &ring_profile)
: m_ring_migration_ratio(ring_migration_ratio)
, m_migration_try_count(ring_migration_ratio)
, m_source(source)
{
if (ring_profile.get_ring_alloc_logic() == RING_LOGIC_PER_INTERFACE) {
ring_profile.set_ring_alloc_logic(allocation_logic);
}
m_res_key = resource_allocation_key(ring_profile);
m_migration_candidate = 0;
m_res_key.set_user_id_key(calc_res_key_by_logic());
Expand Down
10 changes: 4 additions & 6 deletions src/core/dev/ring_allocation_logic.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ class source_t {
class ring_allocation_logic {
protected:
ring_allocation_logic();
ring_allocation_logic(ring_logic_t ring_allocation_logic, int ring_migration_ratio,
source_t source, resource_allocation_key &ring_profile);
ring_allocation_logic(int ring_migration_ratio, source_t source,
const resource_allocation_key &ring_profile);

void debug_print_type(const char *type);

Expand Down Expand Up @@ -121,8 +121,7 @@ class ring_allocation_logic_rx : public ring_allocation_logic {
debug_print_type("Rx");
}
ring_allocation_logic_rx(source_t source, resource_allocation_key &ring_profile)
: ring_allocation_logic(safe_mce_sys().ring_allocation_logic_rx,
safe_mce_sys().ring_migration_ratio_rx, source, ring_profile)
: ring_allocation_logic(safe_mce_sys().ring_migration_ratio_rx, source, ring_profile)
{
debug_print_type("Rx");
}
Expand All @@ -136,8 +135,7 @@ class ring_allocation_logic_tx : public ring_allocation_logic {
debug_print_type("Tx");
}
ring_allocation_logic_tx(source_t source, resource_allocation_key &ring_profile)
: ring_allocation_logic(safe_mce_sys().ring_allocation_logic_tx,
safe_mce_sys().ring_migration_ratio_tx, source, ring_profile)
: ring_allocation_logic(safe_mce_sys().ring_migration_ratio_tx, source, ring_profile)
{
debug_print_type("Tx");
}
Expand Down
4 changes: 4 additions & 0 deletions src/core/util/sys_vars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,8 @@ void mce_sys_var::get_env_params()

#ifdef DEFINED_NGINX
case MCE_SPEC_NGINX:
ring_allocation_logic_tx = RING_LOGIC_PER_INTERFACE;
ring_allocation_logic_rx = RING_LOGIC_PER_INTERFACE;
memory_limit = (app.workers_num > 16 ? 3072LU : 4096LU) * 1024 * 1024;
memory_limit *= std::max(app.workers_num, 1);
rx_bufs_batch = 8; // MCE_DEFAULT_RX_BUFS_BATCH (64), RX buffers batch size.
Expand Down Expand Up @@ -1081,6 +1083,8 @@ void mce_sys_var::get_env_params()
break;

case MCE_SPEC_NGINX_DPU:
ring_allocation_logic_tx = RING_LOGIC_PER_INTERFACE;
ring_allocation_logic_rx = RING_LOGIC_PER_INTERFACE;
// The top part is different from NGINX SPEC
memory_limit = (app.workers_num == 16 ? 512LU : 1024LU) * 1024 * 1024;
memory_limit *= std::max(app.workers_num, 1);
Expand Down
4 changes: 2 additions & 2 deletions src/core/util/sys_vars.h
Original file line number Diff line number Diff line change
Expand Up @@ -727,8 +727,8 @@ extern mce_sys_var &safe_mce_sys();
#define MCE_DEFAULT_HANDLE_SIGINTR (true)
#define MCE_DEFAULT_HANDLE_SIGFAULT (false)
#define MCE_DEFAULT_STATS_FD_NUM 0
#define MCE_DEFAULT_RING_ALLOCATION_LOGIC_TX (RING_LOGIC_PER_INTERFACE)
#define MCE_DEFAULT_RING_ALLOCATION_LOGIC_RX (RING_LOGIC_PER_INTERFACE)
#define MCE_DEFAULT_RING_ALLOCATION_LOGIC_TX (RING_LOGIC_PER_THREAD)
#define MCE_DEFAULT_RING_ALLOCATION_LOGIC_RX (RING_LOGIC_PER_THREAD)
#define MCE_DEFAULT_RING_MIGRATION_RATIO_TX (-1)
#define MCE_DEFAULT_RING_MIGRATION_RATIO_RX (-1)
#define MCE_DEFAULT_RING_LIMIT_PER_INTERFACE (0)
Expand Down

0 comments on commit 4f9e224

Please sign in to comment.