aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/bfd/bfd_main.h
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2018-07-25 08:30:27 -0400
committerJohn Lo <loj@cisco.com>2018-08-29 22:41:35 +0000
commit1e3417f72f5b7b6a5b056f75477d6d536196c34a (patch)
tree092c468acb86917b085fb4c943dca44db08f34fe /src/vnet/bfd/bfd_main.h
parente6446a3cd5f4b4faab87127c1a310e3c7fbf0e60 (diff)
Address bfd rpc scale issues
Remove the expensive RPC call for every received packet and replace it with lock-protected direct calls. Reinstate RPC for the less frequent notification traffic. Adjust the wakeup event sending logic to minimize the number of events sent, by measuring the time it takes from sending the event to processing it, and subsequently not sending the event if the pending wake-up time is within 2x or the event propagation delay. Eventually: remove oingo / oingoes. Change-Id: I0b3d33c5d029527b54867a97ab07f35f346aaa3d Signed-off-by: Dave Barach <dave@barachs.net> Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com> Signed-off-by: Steve Shin <jonshin@cisco.com> Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
Diffstat (limited to 'src/vnet/bfd/bfd_main.h')
-rw-r--r--src/vnet/bfd/bfd_main.h63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/vnet/bfd/bfd_main.h b/src/vnet/bfd/bfd_main.h
index 9e2a12e1f9b..7808834644b 100644
--- a/src/vnet/bfd/bfd_main.h
+++ b/src/vnet/bfd/bfd_main.h
@@ -24,6 +24,7 @@
#include <vnet/bfd/bfd_protocol.h>
#include <vnet/bfd/bfd_udp.h>
#include <vlib/log.h>
+#include <vppinfra/os.h>
#define foreach_bfd_mode(F) \
F (asynchronous) \
@@ -260,6 +261,23 @@ typedef void (*bfd_notify_fn_t) (bfd_listen_event_e, const bfd_session_t *);
typedef struct
{
+ /** lock to protect data structures */
+ clib_spinlock_t lock;
+ int lock_recursion_count;
+ uword owner_thread_index;
+
+ /** Number of event wakeup RPCs in flight. Should be 0 or 1 */
+ int bfd_process_wakeup_events_in_flight;
+
+ /** The timestamp of last wakeup event being sent */
+ u64 bfd_process_wakeup_event_start_clocks;
+
+ /** The time it took the last wakeup event to make it to handling */
+ u64 bfd_process_wakeup_event_delay_clocks;
+
+ /** When the bfd process is supposed to wake up next */
+ u64 bfd_process_next_wakeup_clocks;
+
/** pool of bfd sessions context data */
bfd_session_t *sessions;
@@ -346,6 +364,51 @@ typedef CLIB_PACKED (struct {
}) bfd_echo_pkt_t;
/* *INDENT-ON* */
+static inline void
+bfd_lock (bfd_main_t * bm)
+{
+ uword my_thread_index = __os_thread_index;
+
+ if (bm->owner_thread_index == my_thread_index
+ && bm->lock_recursion_count > 0)
+ {
+ bm->lock_recursion_count++;
+ return;
+ }
+
+ clib_spinlock_lock_if_init (&bm->lock);
+ bm->lock_recursion_count = 1;
+ bm->owner_thread_index = my_thread_index;
+}
+
+static inline void
+bfd_unlock (bfd_main_t * bm)
+{
+ uword my_thread_index = __os_thread_index;
+ ASSERT (bm->owner_thread_index == my_thread_index);
+
+ if (bm->lock_recursion_count > 1)
+ {
+ bm->lock_recursion_count--;
+ return;
+ }
+ bm->lock_recursion_count = 0;
+ bm->owner_thread_index = ~0;
+ clib_spinlock_unlock_if_init (&bm->lock);
+}
+
+void oingo (void);
+
+static inline void
+bfd_lock_check (bfd_main_t * bm)
+{
+ if (PREDICT_FALSE (bm->lock_recursion_count < 1))
+ {
+ clib_warning ("lock check failure");
+ oingo ();
+ }
+}
+
u8 *bfd_input_format_trace (u8 * s, va_list * args);
bfd_session_t *bfd_get_session (bfd_main_t * bm, bfd_transport_e t);
void bfd_put_session (bfd_main_t * bm, bfd_session_t * bs);