bgpd: Make sure bgp_dest lock/unlock tracepoints works for LTTng as well

Tested with both UDST and LTTng, both are OK.

```
[13:57:31.346131253] (+?.?????????) home-spine1.donatas.net frr_bgp:bgp_dest_lock: { cpu_id = 1 }, { prefix = "10.0.2.0/24", count = 3 }
[13:57:31.346154756] (+0.000023503) home-spine1.donatas.net frr_bgp:bgp_dest_lock: { cpu_id = 1 }, { prefix = "192.168.0.0/24", count = 3 }
[13:57:31.346156699] (+0.000001943) home-spine1.donatas.net frr_bgp:bgp_dest_lock: { cpu_id = 1 }, { prefix = "192.168.10.0/24", count = 2 }
[13:57:31.346157570] (+0.000000871) home-spine1.donatas.net frr_bgp:bgp_dest_lock: { cpu_id = 1 }, { prefix = "192.168.100.1/32", count = 2 }
[13:57:31.346158521] (+0.000000951) home-spine1.donatas.net frr_bgp:bgp_dest_lock: { cpu_id = 1 }, { prefix = "192.168.100.2/32", count = 2 }
[13:57:31.356149109] (+0.009990588) home-spine1.donatas.net frr_bgp:bgp_dest_lock: { cpu_id = 1 }, { prefix = "10.0.2.0/24", count = 3 }
[13:57:31.356155889] (+0.000006780) home-spine1.donatas.net frr_bgp:bgp_dest_lock: { cpu_id = 1 }, { prefix = "192.168.0.0/24", count = 3 }
[13:57:31.356156840] (+0.000000951) home-spine1.donatas.net frr_bgp:bgp_dest_lock: { cpu_id = 1 }, { prefix = "192.168.10.0/24", count = 2 }
[13:57:31.356157751] (+0.000000911) home-spine1.donatas.net frr_bgp:bgp_dest_lock: { cpu_id = 1 }, { prefix = "192.168.100.1/32", count = 2 }
[13:57:31.356158683] (+0.000000932) home-spine1.donatas.net frr_bgp:bgp_dest_lock: { cpu_id = 1 }, { prefix = "192.168.100.2/32", count = 2 }
[13:57:34.508252238] (+3.152093555) home-spine1.donatas.net frr_bgp:bgp_dest_lock: { cpu_id = 2 }, { prefix = "172.16.16.1/32", count = 2 }
[13:57:34.508289549] (+0.000037311) home-spine1.donatas.net frr_bgp:bgp_dest_lock: { cpu_id = 2 }, { prefix = "172.16.16.2/32", count = 2 }
[13:57:34.508307544] (+0.000017995) home-spine1.donatas.net frr_bgp:bgp_dest_lock: { cpu_id = 2 }, { prefix = "172.16.16.3/32", count = 2 }
[13:57:34.508433878] (+0.000126334) home-spine1.donatas.net frr_bgp:bgp_dest_lock: { cpu_id = 2 }, { prefix = "10.0.2.0/24", count = 2 }
[13:57:34.508435891] (+0.000002013) home-spine1.donatas.net frr_bgp:bgp_dest_lock: { cpu_id = 2 }, { prefix = "10.0.2.0/24", count = 2 }
[13:57:34.508458182] (+0.000022291) home-spine1.donatas.net frr_bgp:bgp_dest_lock: { cpu_id = 2 }, { prefix = "192.168.0.0/24", count = 2 }
[13:57:34.508458852] (+0.000000670) home-spine1.donatas.net frr_bgp:bgp_dest_lock: { cpu_id = 2 }, { prefix = "192.168.0.0/24", count = 2 }
[13:57:34.508472821] (+0.000013969) home-spine1.donatas.net frr_bgp:bgp_dest_lock: { cpu_id = 2 }, { prefix = "192.168.10.0/24", count = 1 }
[13:57:34.508473482] (+0.000000661) home-spine1.donatas.net frr_bgp:bgp_dest_lock: { cpu_id = 2 }, { prefix = "192.168.10.0/24", count = 1 }
[13:57:34.508487041] (+0.000013559) home-spine1.donatas.net frr_bgp:bgp_dest_lock: { cpu_id = 2 }, { prefix = "192.168.100.1/32", count = 1 }
[13:57:34.508487792] (+0.000000751) home-spine1.donatas.net frr_bgp:bgp_dest_lock: { cpu_id = 2 }, { prefix = "192.168.100.1/32", count = 1 }
```

Converting bgp_dest_lock_node/bgp_dest_unlock_node to non-inlined function
because LTTng can't work properly with inlined and the compiler does not like
it.

Not sure how it would be with the performance, but let's see.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
This commit is contained in:
Donatas Abraitis 2021-09-23 16:59:08 +03:00
parent d03c8a8e06
commit 63836a9647
3 changed files with 65 additions and 22 deletions

View File

@ -31,6 +31,7 @@
#include "bgpd/bgpd.h" #include "bgpd/bgpd.h"
#include "bgpd/bgp_table.h" #include "bgpd/bgp_table.h"
#include "bgp_addpath.h" #include "bgp_addpath.h"
#include "bgp_trace.h"
void bgp_table_lock(struct bgp_table *rt) void bgp_table_lock(struct bgp_table *rt)
{ {
@ -60,6 +61,42 @@ void bgp_table_finish(struct bgp_table **rt)
} }
} }
/*
* bgp_dest_unlock_node
*/
void bgp_dest_unlock_node(struct bgp_dest *dest)
{
frrtrace(1, frr_bgp, bgp_dest_unlock, dest);
bgp_delete_listnode(dest);
route_unlock_node(bgp_dest_to_rnode(dest));
}
/*
* bgp_dest_lock_node
*/
struct bgp_dest *bgp_dest_lock_node(struct bgp_dest *dest)
{
frrtrace(1, frr_bgp, bgp_dest_lock, dest);
struct route_node *rn = route_lock_node(bgp_dest_to_rnode(dest));
return bgp_dest_from_rnode(rn);
}
/*
* bgp_dest_get_prefix_str
*/
const char *bgp_dest_get_prefix_str(struct bgp_dest *dest)
{
const struct prefix *p = NULL;
char str[PREFIX_STRLEN] = {0};
p = bgp_dest_get_prefix(dest);
if (p)
return prefix2str(p, str, sizeof(str));
return NULL;
}
/* /*
* bgp_node_create * bgp_node_create
*/ */

View File

@ -31,7 +31,6 @@
#include "linklist.h" #include "linklist.h"
#include "bgpd.h" #include "bgpd.h"
#include "bgp_advertise.h" #include "bgp_advertise.h"
#include "bgpd/bgp_trace.h"
struct bgp_table { struct bgp_table {
/* table belongs to this instance */ /* table belongs to this instance */
@ -135,6 +134,9 @@ extern struct bgp_table *bgp_table_init(struct bgp *bgp, afi_t, safi_t);
extern void bgp_table_lock(struct bgp_table *); extern void bgp_table_lock(struct bgp_table *);
extern void bgp_table_unlock(struct bgp_table *); extern void bgp_table_unlock(struct bgp_table *);
extern void bgp_table_finish(struct bgp_table **); extern void bgp_table_finish(struct bgp_table **);
extern void bgp_dest_unlock_node(struct bgp_dest *dest);
extern struct bgp_dest *bgp_dest_lock_node(struct bgp_dest *dest);
extern const char *bgp_dest_get_prefix_str(struct bgp_dest *dest);
/* /*
@ -179,16 +181,6 @@ static inline struct bgp_dest *bgp_dest_parent_nolock(struct bgp_dest *dest)
return bgp_dest_from_rnode(rn); return bgp_dest_from_rnode(rn);
} }
/*
* bgp_dest_unlock_node
*/
static inline void bgp_dest_unlock_node(struct bgp_dest *dest)
{
frrtrace(1, frr_bgp, bgp_dest_unlock, dest);
bgp_delete_listnode(dest);
route_unlock_node(bgp_dest_to_rnode(dest));
}
/* /*
* bgp_table_top_nolock * bgp_table_top_nolock
* *
@ -253,17 +245,6 @@ bgp_node_lookup(const struct bgp_table *const table, const struct prefix *p)
return bgp_dest_from_rnode(rn); return bgp_dest_from_rnode(rn);
} }
/*
* bgp_dest_lock_node
*/
static inline struct bgp_dest *bgp_dest_lock_node(struct bgp_dest *dest)
{
frrtrace(1, frr_bgp, bgp_dest_lock, dest);
struct route_node *rn = route_lock_node(bgp_dest_to_rnode(dest));
return bgp_dest_from_rnode(rn);
}
/* /*
* bgp_node_match * bgp_node_match
*/ */

View File

@ -218,6 +218,31 @@ TRACEPOINT_EVENT(
TRACEPOINT_LOGLEVEL(frr_bgp, bmp_process, TRACE_DEBUG) TRACEPOINT_LOGLEVEL(frr_bgp, bmp_process, TRACE_DEBUG)
/*
* bgp_dest_lock/bgp_dest_unlock
*/
TRACEPOINT_EVENT(
frr_bgp,
bgp_dest_lock,
TP_ARGS(struct bgp_dest *, dest),
TP_FIELDS(
ctf_string(prefix, bgp_dest_get_prefix_str(dest))
ctf_integer(unsigned int, count, bgp_dest_get_lock_count(dest))
)
)
TRACEPOINT_LOGLEVEL(frr_bgp, bgp_dest_lock, TRACE_INFO)
TRACEPOINT_EVENT(
frr_bgp,
bgp_dest_unlock,
TP_ARGS(struct bgp_dest *, dest),
TP_FIELDS(
ctf_string(prefix, bgp_dest_get_prefix_str(dest))
ctf_integer(unsigned int, count, bgp_dest_get_lock_count(dest))
)
)
TRACEPOINT_LOGLEVEL(frr_bgp, bgp_dest_unlock, TRACE_INFO)
/* clang-format on */ /* clang-format on */
#include <lttng/tracepoint-event.h> #include <lttng/tracepoint-event.h>