summaryrefslogtreecommitdiff
path: root/lib/thread.c
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@nvidia.com>2020-09-14 18:04:33 -0400
committerQuentin Young <qlyoung@nvidia.com>2020-10-23 15:13:51 -0400
commitabf96a87f3f2f9527885ee78930787ecb4068530 (patch)
treea249c8c015366cfaca7c57fbacf32b04ad055e8e /lib/thread.c
parent0cbcadccf741fe679ce16ad051f1970c46323580 (diff)
lib: add tracepoints for hash ops, thread events
Define some initial tracepoints for hash table operations, thread schedules, and thread cancels Signed-off-by: Quentin Young <qlyoung@nvidia.com>
Diffstat (limited to 'lib/thread.c')
-rw-r--r--lib/thread.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/thread.c b/lib/thread.c
index db35a3f031..8679454367 100644
--- a/lib/thread.c
+++ b/lib/thread.c
@@ -35,6 +35,7 @@
#include "frratomic.h"
#include "frr_pthread.h"
#include "lib_errors.h"
+#include "trace.h"
DEFINE_MTYPE_STATIC(LIB, THREAD, "Thread")
DEFINE_MTYPE_STATIC(LIB, THREAD_MASTER, "Thread master")
@@ -787,6 +788,13 @@ struct thread *funcname_thread_add_read_write(int dir, struct thread_master *m,
struct thread *thread = NULL;
struct thread **thread_array;
+ if (dir == THREAD_READ)
+ tracepoint(frr_libfrr, schedule_read, m, funcname, schedfrom,
+ fromln, t_ptr, fd, 0, arg, 0);
+ else
+ tracepoint(frr_libfrr, schedule_write, m, funcname, schedfrom,
+ fromln, t_ptr, fd, 0, arg, 0);
+
assert(fd >= 0 && fd < m->fd_limit);
frr_with_mutex(&m->mtx) {
if (t_ptr && *t_ptr)
@@ -861,6 +869,9 @@ funcname_thread_add_timer_timeval(struct thread_master *m,
assert(type == THREAD_TIMER);
assert(time_relative);
+ tracepoint(frr_libfrr, schedule_timer, m, funcname, schedfrom, fromln,
+ t_ptr, 0, 0, arg, (long)time_relative->tv_sec);
+
frr_with_mutex(&m->mtx) {
if (t_ptr && *t_ptr)
/* thread is already scheduled; don't reschedule */
@@ -939,6 +950,9 @@ struct thread *funcname_thread_add_event(struct thread_master *m,
{
struct thread *thread = NULL;
+ tracepoint(frr_libfrr, schedule_event, m, funcname, schedfrom, fromln,
+ t_ptr, 0, val, arg, 0);
+
assert(m != NULL);
frr_with_mutex(&m->mtx) {
@@ -1167,6 +1181,11 @@ void thread_cancel(struct thread *thread)
{
struct thread_master *master = thread->master;
+ tracepoint(frr_libfrr, thread_cancel, master, thread->funcname,
+ thread->schedfrom, thread->schedfrom_line, NULL,
+ thread->u.fd, thread->u.val, thread->arg,
+ thread->u.sands.tv_sec);
+
assert(master->owner == pthread_self());
frr_with_mutex(&master->mtx) {
@@ -1206,6 +1225,17 @@ void thread_cancel_async(struct thread_master *master, struct thread **thread,
void *eventobj)
{
assert(!(thread && eventobj) && (thread || eventobj));
+
+ if (thread && *thread)
+ tracepoint(frr_libfrr, thread_cancel_async, master,
+ (*thread)->funcname, (*thread)->schedfrom,
+ (*thread)->schedfrom_line, NULL, (*thread)->u.fd,
+ (*thread)->u.val, (*thread)->arg,
+ (*thread)->u.sands.tv_sec);
+ else
+ tracepoint(frr_libfrr, thread_cancel_async, master, NULL, NULL,
+ 0, NULL, 0, 0, eventobj, 0);
+
assert(master->owner != pthread_self());
frr_with_mutex(&master->mtx) {
@@ -1581,6 +1611,11 @@ void thread_call(struct thread *thread)
GETRUSAGE(&before);
thread->real = before.real;
+ tracepoint(frr_libfrr, thread_call, thread->master, thread->funcname,
+ thread->schedfrom, thread->schedfrom_line, NULL,
+ thread->u.fd, thread->u.val, thread->arg,
+ thread->u.sands.tv_sec);
+
pthread_setspecific(thread_current, thread);
(*thread->func)(thread);
pthread_setspecific(thread_current, NULL);