Skip to content

Commit be42337

Browse files
committed
CM7-fix: init lcore_conf for all lcores in thread_mode
init_lcore_conf loops over all lcores to set rx_queue_list/tx_queue_id/ nb_rx_queue/nb_tx_port/socket_id in thread_mode=1. init_mem_pool uses nb_threads for capacity. main_loop return 0 workaround removed. thread_mode=0 zero-regression; thread_mode=1 curl x10 100% stable.
1 parent fea49af commit be42337

1 file changed

Lines changed: 34 additions & 12 deletions

File tree

lib/ff_dpdk_if.c

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -414,15 +414,41 @@ init_lcore_conf(void)
414414
ff_global_cfg.dpdk.max_portid);
415415
}
416416

417-
ff_cur_lcore_conf()->port_cfgs = ff_global_cfg.dpdk.port_cfgs;
418417
if (ff_global_cfg.dpdk.thread_mode) {
419418
int ti;
420-
for (ti = 0; ti < ff_global_cfg.dpdk.nb_threads; ti++)
421-
lcore_conf[ff_global_cfg.dpdk.proc_lcore[ti]].proc_id = ti;
422-
} else {
423-
ff_cur_lcore_conf()->proc_id = ff_global_cfg.dpdk.proc_id;
419+
for (ti = 0; ti < ff_global_cfg.dpdk.nb_threads; ti++) {
420+
uint16_t lcore_id = ff_global_cfg.dpdk.proc_lcore[ti];
421+
struct lcore_conf *lc = &lcore_conf[lcore_id];
422+
lc->port_cfgs = ff_global_cfg.dpdk.port_cfgs;
423+
lc->proc_id = ti;
424+
lc->socket_id = numa_on ? rte_lcore_to_socket_id(lcore_id) : 0;
425+
if (!rte_lcore_is_enabled(lcore_id))
426+
rte_exit(EXIT_FAILURE, "lcore %u unavailable\n", lcore_id);
427+
int j;
428+
for (j = 0; j < ff_global_cfg.dpdk.nb_ports; ++j) {
429+
uint16_t port_id = ff_global_cfg.dpdk.portid_list[j];
430+
struct ff_port_cfg *pconf = &ff_global_cfg.dpdk.port_cfgs[port_id];
431+
int queueid = -1, i;
432+
for (i = 0; i < pconf->nb_lcores; i++)
433+
if (pconf->lcore_list[i] == lcore_id) queueid = i;
434+
if (queueid < 0) continue;
435+
lc->rx_queue_list[lc->nb_rx_queue].port_id = port_id;
436+
lc->rx_queue_list[lc->nb_rx_queue].queue_id = queueid;
437+
lc->nb_rx_queue++;
438+
lc->tx_queue_id[port_id] = queueid;
439+
lc->tx_port_id[lc->nb_tx_port] = port_id;
440+
lc->nb_tx_port++;
441+
lc->nb_queue_list[port_id] = pconf->nb_lcores;
442+
}
443+
if (lc->nb_rx_queue == 0)
444+
rte_exit(EXIT_FAILURE, "lcore %u has nothing to do\n", lcore_id);
445+
}
446+
return 0;
424447
}
425448

449+
ff_cur_lcore_conf()->port_cfgs = ff_global_cfg.dpdk.port_cfgs;
450+
ff_cur_lcore_conf()->proc_id = ff_global_cfg.dpdk.proc_id;
451+
426452
uint16_t socket_id = 0;
427453
if (numa_on) {
428454
socket_id = rte_lcore_to_socket_id(rte_lcore_id());
@@ -492,7 +518,8 @@ static int
492518
init_mem_pool(void)
493519
{
494520
uint8_t nb_ports = ff_global_cfg.dpdk.nb_ports;
495-
uint32_t nb_lcores = ff_global_cfg.dpdk.nb_procs;
521+
uint32_t nb_lcores = ff_global_cfg.dpdk.thread_mode
522+
? ff_global_cfg.dpdk.nb_threads : ff_global_cfg.dpdk.nb_procs;
496523
uint32_t nb_tx_queue = nb_lcores;
497524
uint32_t nb_rx_queue = ff_cur_lcore_conf()->nb_rx_queue * nb_lcores;
498525
uint16_t max_portid = ff_global_cfg.dpdk.max_portid;
@@ -2598,14 +2625,9 @@ main_loop(void *arg)
25982625

25992626
/* CM5-A: per-thread stack init. thread_mode=0 main thread is already
26002627
* initialized (ff_freebsd_init) and skips here (zero regression);
2601-
* thread_mode=1 workers init here. Lcores without RX queues (e.g.
2602-
* non-owner threads in a 1-queue config) return after init to avoid
2603-
* interfering with the owner thread's main loop. */
2628+
* thread_mode=1 workers init here. */
26042629
ff_stack_thread_init();
26052630

2606-
if (ff_global_cfg.dpdk.thread_mode && qconf->nb_rx_queue == 0)
2607-
return 0;
2608-
26092631
while (1) {
26102632

26112633
if (unlikely(stop_loop)) {

0 commit comments

Comments
 (0)