summaryrefslogtreecommitdiffstats
path: root/src/vlib
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2023-11-03 21:57:42 +0000
committerDamjan Marion <damarion@cisco.com>2023-11-03 22:56:29 +0000
commit7f75e80f087d3ff1f5ebcb9eb6a117115baee011 (patch)
treea05daac2f541cf9cca7cb3350206c4b65cea2603 /src/vlib
parent236fae462a4ee799b3f05d4b2aff641d5c9486a6 (diff)
vppinfra: refactor interrupt code
Type: improvement Change-Id: Ie6987736faf7d8a641762e276775da8ee0c03ea4 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vlib')
-rw-r--r--src/vlib/main.c19
-rw-r--r--src/vlib/node.h1
-rw-r--r--src/vlib/node_funcs.h2
-rw-r--r--src/vlib/unix/input.c5
4 files changed, 9 insertions, 18 deletions
diff --git a/src/vlib/main.c b/src/vlib/main.c
index 9d34aa1d948..219ed220007 100644
--- a/src/vlib/main.c
+++ b/src/vlib/main.c
@@ -1471,8 +1471,6 @@ vlib_main_or_worker_loop (vlib_main_t * vm, int is_main)
else
cpu_time_now = clib_cpu_time_now ();
- nm->pending_interrupts = 0;
-
/* Pre-allocate expired nodes. */
if (!nm->polling_threshold_vector_length)
nm->polling_threshold_vector_length = 10;
@@ -1504,7 +1502,6 @@ vlib_main_or_worker_loop (vlib_main_t * vm, int is_main)
while (1)
{
vlib_node_runtime_t *n;
- u8 pending_interrupts;
if (PREDICT_FALSE (_vec_len (vm->pending_rpc_requests) > 0))
{
@@ -1552,19 +1549,14 @@ vlib_main_or_worker_loop (vlib_main_t * vm, int is_main)
/* frame */ 0,
cpu_time_now);
- pending_interrupts =
- __atomic_load_n (&nm->pending_interrupts, __ATOMIC_ACQUIRE);
-
- if (pending_interrupts)
+ if (clib_interrupt_is_any_pending (nm->pre_input_node_interrupts))
{
int int_num = -1;
- nm->pending_interrupts = 0;
- while ((int_num = clib_interrupt_get_next (
+ while ((int_num = clib_interrupt_get_next_and_clear (
nm->pre_input_node_interrupts, int_num)) != -1)
{
vlib_node_runtime_t *n;
- clib_interrupt_clear (nm->pre_input_node_interrupts, int_num);
n = vec_elt_at_index (
nm->nodes_by_type[VLIB_NODE_TYPE_PRE_INPUT], int_num);
cpu_time_now = dispatch_node (vm, n, VLIB_NODE_TYPE_PRE_INPUT,
@@ -1584,15 +1576,14 @@ vlib_main_or_worker_loop (vlib_main_t * vm, int is_main)
if (PREDICT_TRUE (is_main && vm->queue_signal_pending == 0))
vm->queue_signal_callback (vm);
- if (pending_interrupts)
+ if (clib_interrupt_is_any_pending (nm->input_node_interrupts))
{
int int_num = -1;
- while ((int_num = clib_interrupt_get_next (nm->input_node_interrupts,
- int_num)) != -1)
+ while ((int_num = clib_interrupt_get_next_and_clear (
+ nm->input_node_interrupts, int_num)) != -1)
{
vlib_node_runtime_t *n;
- clib_interrupt_clear (nm->input_node_interrupts, int_num);
n = vec_elt_at_index (nm->nodes_by_type[VLIB_NODE_TYPE_INPUT],
int_num);
cpu_time_now = dispatch_node (vm, n, VLIB_NODE_TYPE_INPUT,
diff --git a/src/vlib/node.h b/src/vlib/node.h
index 955ffb98600..68813c2c3e1 100644
--- a/src/vlib/node.h
+++ b/src/vlib/node.h
@@ -692,7 +692,6 @@ typedef struct
/* Node runtime indices for input nodes with pending interrupts. */
void *input_node_interrupts;
void *pre_input_node_interrupts;
- volatile u8 pending_interrupts;
/* Input nodes are switched from/to interrupt to/from polling mode
when average vector length goes above/below polling/interrupt
diff --git a/src/vlib/node_funcs.h b/src/vlib/node_funcs.h
index 37f7538d70a..1beac33cf9b 100644
--- a/src/vlib/node_funcs.h
+++ b/src/vlib/node_funcs.h
@@ -268,8 +268,6 @@ vlib_node_set_interrupt_pending (vlib_main_t *vm, u32 node_index)
clib_interrupt_set_atomic (interrupts, n->runtime_index);
else
clib_interrupt_set (interrupts, n->runtime_index);
-
- __atomic_store_n (&nm->pending_interrupts, 1, __ATOMIC_RELEASE);
}
always_inline vlib_process_t *
diff --git a/src/vlib/unix/input.c b/src/vlib/unix/input.c
index 39c124cf8df..6d244b049c9 100644
--- a/src/vlib/unix/input.c
+++ b/src/vlib/unix/input.c
@@ -250,7 +250,10 @@ 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 ||
- nm->pending_interrupts)
+ clib_interrupt_is_any_pending (
+ nm->input_node_interrupts) ||
+ clib_interrupt_is_any_pending (
+ nm->pre_input_node_interrupts))
goto done;
}
}