]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: add tracepoints for *malloc, list ops
authorQuentin Young <qlyoung@nvidia.com>
Thu, 17 Sep 2020 18:57:36 +0000 (14:57 -0400)
committerQuentin Young <qlyoung@nvidia.com>
Fri, 23 Oct 2020 19:13:51 +0000 (15:13 -0400)
- Add tracepoints for FRR malloc and free
- Add tracepoints for basic list operations

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
lib/linklist.c
lib/memory.c
lib/subdir.am
lib/trace.h

index 84dc6e1419705f3d3a5666c27fc9520f2b56852b..19a8514cd6c90ebef5a910cd017bee766965b157 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "linklist.h"
 #include "memory.h"
+#include "trace.h"
 
 DEFINE_MTYPE_STATIC(LIB, LINK_LIST, "Link List")
 DEFINE_MTYPE_STATIC(LIB, LINK_NODE, "Link Node")
@@ -66,6 +67,8 @@ static void listnode_free(struct list *list, struct listnode *node)
 
 struct listnode *listnode_add(struct list *list, void *val)
 {
+       tracepoint(frr_libfrr, list_add, list, val);
+
        struct listnode *node;
 
        assert(val != NULL);
@@ -281,6 +284,8 @@ void listnode_move_to_tail(struct list *l, struct listnode *n)
 
 void listnode_delete(struct list *list, const void *val)
 {
+       tracepoint(frr_libfrr, list_remove, list, val);
+
        struct listnode *node = listnode_lookup(list, val);
 
        if (node)
@@ -360,6 +365,8 @@ struct listnode *listnode_lookup_nocheck(struct list *list, void *data)
 
 void list_delete_node(struct list *list, struct listnode *node)
 {
+       tracepoint(frr_libfrr, list_delete_node, list, node);
+
        if (node->prev)
                node->prev->next = node->next;
        else
@@ -374,6 +381,8 @@ void list_delete_node(struct list *list, struct listnode *node)
 
 void list_sort(struct list *list, int (*cmp)(const void **, const void **))
 {
+       tracepoint(frr_libfrr, list_sort, list);
+
        struct listnode *ln, *nn;
        int i = -1;
        void *data;
index 2c902d123b5826bffe85701047e435eec77195db..219ddcb638dfd50f5b7e07ad61c4a41ebcafae03 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "memory.h"
 #include "log.h"
+#include "trace.h"
 
 static struct memgroup *mg_first = NULL;
 struct memgroup **mg_insert = &mg_first;
@@ -77,6 +78,8 @@ static inline void mt_count_alloc(struct memtype *mt, size_t size, void *ptr)
 
 static inline void mt_count_free(struct memtype *mt, void *ptr)
 {
+       tracepoint(frr_libfrr, memfree, mt, ptr);
+
        assert(mt->n_alloc);
        atomic_fetch_sub_explicit(&mt->n_alloc, 1, memory_order_relaxed);
 
@@ -89,6 +92,8 @@ static inline void mt_count_free(struct memtype *mt, void *ptr)
 
 static inline void *mt_checkalloc(struct memtype *mt, void *ptr, size_t size)
 {
+       tracepoint(frr_libfrr, memalloc, mt, ptr, size);
+
        if (__builtin_expect(ptr == NULL, 0)) {
                if (size) {
                        /* malloc(0) is allowed to return NULL */
index 5f764f8a5546945436d56018958acfa6bb402a83..54fdf429fcaa300a2267ca33755082980a979482 100644 (file)
@@ -403,7 +403,7 @@ lib_grammar_sandbox_LDADD = \
 
 lib_clippy_CPPFLAGS = $(AM_CPPFLAGS) -D_GNU_SOURCE -DBUILDING_CLIPPY
 lib_clippy_CFLAGS = $(PYTHON_CFLAGS)
-lib_clippy_LDADD = $(PYTHON_LIBS)
+lib_clippy_LDADD = $(PYTHON_LIBS) $(UST_LIBS)
 lib_clippy_LDFLAGS = -export-dynamic
 lib_clippy_SOURCES = \
        lib/clippy.c \
@@ -415,6 +415,7 @@ lib_clippy_SOURCES = \
        lib/graph.c \
        lib/memory.c \
        lib/vector.c \
+       lib/trace.c \
        # end
 
 # (global) clippy rules for all directories
index 753a25f4a575cb9160240ea79eed0861c2f1cf86..989361e66cd5e175b33a42030f0996bdf838ecb6 100644 (file)
@@ -37,6 +37,8 @@
 
 #include "hash.h"
 #include "thread.h"
+#include "memory.h"
+#include "linklist.h"
 
 /* clang-format off */
 
@@ -141,6 +143,82 @@ TRACEPOINT_EVENT(
        )
 )
 
+TRACEPOINT_EVENT(
+       frr_libfrr,
+       memalloc,
+       TP_ARGS(
+               struct memtype *, mt, void *, ptr, size_t, size
+       ),
+       TP_FIELDS(
+               ctf_string(memtype, mt->name)
+               ctf_integer(size_t, size, size)
+               ctf_integer_hex(intptr_t, ptr, ptr)
+       )
+)
+
+TRACEPOINT_EVENT(
+       frr_libfrr,
+       memfree,
+       TP_ARGS(
+               struct memtype *, mt, void *, ptr
+       ),
+       TP_FIELDS(
+               ctf_string(memtype, mt->name)
+               ctf_integer_hex(intptr_t, ptr, ptr)
+       )
+)
+
+TRACEPOINT_EVENT(
+       frr_libfrr,
+       list_add,
+       TP_ARGS(
+               struct list *, list, const void *, ptr
+       ),
+       TP_FIELDS(
+               ctf_integer_hex(intptr_t, list, list)
+               ctf_integer(unsigned int, count, list->count)
+               ctf_integer_hex(intptr_t, ptr, ptr)
+       )
+)
+
+TRACEPOINT_EVENT(
+       frr_libfrr,
+       list_remove,
+       TP_ARGS(
+               struct list *, list, const void *, ptr
+       ),
+       TP_FIELDS(
+               ctf_integer_hex(intptr_t, list, list)
+               ctf_integer(unsigned int, count, list->count)
+               ctf_integer_hex(intptr_t, ptr, ptr)
+       )
+)
+
+TRACEPOINT_EVENT(
+       frr_libfrr,
+       list_delete_node,
+       TP_ARGS(
+               struct list *, list, const void *, node
+       ),
+       TP_FIELDS(
+               ctf_integer_hex(intptr_t, list, list)
+               ctf_integer(unsigned int, count, list->count)
+               ctf_integer_hex(intptr_t, node, node)
+       )
+)
+
+TRACEPOINT_EVENT(
+       frr_libfrr,
+       list_sort,
+       TP_ARGS(
+               struct list *, list
+       ),
+       TP_FIELDS(
+               ctf_integer_hex(intptr_t, list, list)
+               ctf_integer(unsigned int, count, list->count)
+       )
+)
+
 /* clang-format on */
 
 #include <lttng/tracepoint-event.h>