From 8a5add5c00479d337e4d3428d7c98de4d843c0d3 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Mon, 17 Mar 2025 15:51:59 +0100 Subject: vlib: add new node type - SCHED nodes SCHED nodes are new type of nodes, similar to input nodes but they are scheduled to be run from timing wheel. SCHED nodes work both on main and worker threads. Typically SCHED nodes can be scheduled to be run in two ways: - vlib_node_set_interrupt_pending() - from any thread, run ASAP - vlib_node_schedule() - from own thread, afer sepcific interval Type: feature Change-Id: Id29a66532328d9b3c454e65d09495e8fb479cedf Signed-off-by: Damjan Marion --- src/vlib/unix/input.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/vlib/unix/input.c') diff --git a/src/vlib/unix/input.c b/src/vlib/unix/input.c index e96cd902466..302d1eb1194 100644 --- a/src/vlib/unix/input.c +++ b/src/vlib/unix/input.c @@ -130,6 +130,17 @@ linux_epoll_file_update (clib_file_t * f, clib_file_update_type_t update_type) } } +static int +is_int_pending (vlib_node_main_t *nm) +{ + + for (int nt = 0; nt < VLIB_N_NODE_TYPE; nt++) + if (nm->node_interrupts[nt] && + clib_interrupt_is_any_pending (nm->node_interrupts[nt])) + return 1; + return 0; +} + static_always_inline uword linux_epoll_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame, u32 thread_index) @@ -174,8 +185,8 @@ linux_epoll_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node, else if (is_main && vector_rate < 2 && vm->api_queue_nonempty == 0 && nm->input_node_counts_by_state[VLIB_NODE_STATE_POLLING] == 0) { - ticks_until_expiration = TW (tw_timer_first_expires_in_ticks) - ((TWT (tw_timer_wheel) *) nm->timing_wheel); + ticks_until_expiration = TW (tw_timer_first_expires_in_ticks) ( + (TWT (tw_timer_wheel) *) vm->timing_wheel); /* Nothing on the fast wheel, sleep 10ms */ if (ticks_until_expiration == TW_SLOTS_PER_RING) @@ -250,10 +261,7 @@ linux_epoll_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node, while (nanosleep (&ts, &tsrem) < 0) ts = tsrem; if (*vlib_worker_threads->wait_at_barrier || - clib_interrupt_is_any_pending ( - nm->input_node_interrupts) || - clib_interrupt_is_any_pending ( - nm->pre_input_node_interrupts)) + is_int_pending (nm)) goto done; } } -- cgit 1.2.3-korg