Skip to content

Commit

Permalink
pinctrl: Use ovs_mutex_trylock() in the pinctrl thread.
Browse files Browse the repository at this point in the history
When the ovn-controller main thread has locked the pinctrl mutex,
pinctrl thread will not be able to process packet-ins (like DHCP,
DNS and few others) since it tries to acquire this mutex for
other purposes (besides packet-in processing) - like ip_mcast
snoop run and svc monitor runs etc.  So its better to try
acquiring this mutex so that we don't block processing the
packet-ins which don't require this mutex.

Signed-off-by: Numan Siddique <[email protected]>
  • Loading branch information
Numan Siddique committed Dec 13, 2024
1 parent b52ba50 commit 6436f68
Showing 1 changed file with 39 additions and 26 deletions.
65 changes: 39 additions & 26 deletions controller/pinctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3885,10 +3885,14 @@ pinctrl_handler(void *arg_)

while (!latch_is_set(&pctrl->pinctrl_thread_exit)) {
long long int bfd_time = LLONG_MAX;
bool lock_failed = false;

ovs_mutex_lock(&pinctrl_mutex);
ip_mcast_snoop_run();
ovs_mutex_unlock(&pinctrl_mutex);
if (!ovs_mutex_trylock(&pinctrl_mutex)) {
ip_mcast_snoop_run();
ovs_mutex_unlock(&pinctrl_mutex);
} else {
lock_failed = true;
}

rconn_run(swconn);
new_seq = seq_read(pinctrl_handler_seq);
Expand All @@ -3913,35 +3917,44 @@ pinctrl_handler(void *arg_)
}

if (may_inject_pkts()) {
ovs_mutex_lock(&pinctrl_mutex);
send_garp_rarp_run(swconn, &send_garp_rarp_time);
send_ipv6_ras(swconn, &send_ipv6_ra_time);
send_ipv6_prefixd(swconn, &send_prefixd_time);
send_mac_binding_buffered_pkts(swconn);
bfd_monitor_send_msg(swconn, &bfd_time);
ovs_mutex_unlock(&pinctrl_mutex);

if (!ovs_mutex_trylock(&pinctrl_mutex)) {
send_garp_rarp_run(swconn, &send_garp_rarp_time);
send_ipv6_ras(swconn, &send_ipv6_ra_time);
send_ipv6_prefixd(swconn, &send_prefixd_time);
send_mac_binding_buffered_pkts(swconn);
bfd_monitor_send_msg(swconn, &bfd_time);
ovs_mutex_unlock(&pinctrl_mutex);
} else {
lock_failed = true;
}
ip_mcast_querier_run(swconn, &send_mcast_query_time);
}

ovs_mutex_lock(&pinctrl_mutex);
svc_monitors_run(swconn, &svc_monitors_next_run_time);
ovs_mutex_unlock(&pinctrl_mutex);
if (!ovs_mutex_trylock(&pinctrl_mutex)) {
svc_monitors_run(swconn, &svc_monitors_next_run_time);
ovs_mutex_unlock(&pinctrl_mutex);
} else {
lock_failed = true;
}
}

rconn_run_wait(swconn);
rconn_recv_wait(swconn);
if (rconn_is_connected(swconn)) {
send_garp_rarp_wait(send_garp_rarp_time);
ipv6_ra_wait(send_ipv6_ra_time);
ip_mcast_querier_wait(send_mcast_query_time);
svc_monitors_wait(svc_monitors_next_run_time);
ipv6_prefixd_wait(send_prefixd_time);
bfd_monitor_wait(bfd_time);
}
seq_wait(pinctrl_handler_seq, new_seq);
if (lock_failed) {
poll_immediate_wake();
} else {
rconn_run_wait(swconn);
rconn_recv_wait(swconn);
if (rconn_is_connected(swconn)) {
send_garp_rarp_wait(send_garp_rarp_time);
ipv6_ra_wait(send_ipv6_ra_time);
ip_mcast_querier_wait(send_mcast_query_time);
svc_monitors_wait(svc_monitors_next_run_time);
ipv6_prefixd_wait(send_prefixd_time);
bfd_monitor_wait(bfd_time);
}
seq_wait(pinctrl_handler_seq, new_seq);

latch_wait(&pctrl->pinctrl_thread_exit);
latch_wait(&pctrl->pinctrl_thread_exit);
}
poll_block();
}

Expand Down

0 comments on commit 6436f68

Please sign in to comment.