summaryrefslogtreecommitdiffstats
path: root/collectors/ebpf.plugin/ebpf_hardirq.c
diff options
context:
space:
mode:
authorthiagoftsm <thiagoftsm@gmail.com>2022-07-18 12:09:02 +0000
committerGitHub <noreply@github.com>2022-07-18 12:09:02 +0000
commit7f7225dfaa81a928df5e46db5274d18875c880cf (patch)
tree3b00c4533b25cdea846979b4b4ce981f3325d4e2 /collectors/ebpf.plugin/ebpf_hardirq.c
parent9dc631e50ab9d63fad2fbe724aaaf2ffd7c657d3 (diff)
Fix chart update ebpf.plugin (#13351)
Diffstat (limited to 'collectors/ebpf.plugin/ebpf_hardirq.c')
-rw-r--r--collectors/ebpf.plugin/ebpf_hardirq.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/collectors/ebpf.plugin/ebpf_hardirq.c b/collectors/ebpf.plugin/ebpf_hardirq.c
index 21383f2aa1..3af64148dc 100644
--- a/collectors/ebpf.plugin/ebpf_hardirq.c
+++ b/collectors/ebpf.plugin/ebpf_hardirq.c
@@ -433,26 +433,21 @@ static void hardirq_collector(ebpf_module_t *em)
pthread_mutex_unlock(&lock);
// loop and read from published data until ebpf plugin is closed.
- int update_every = em->update_every;
- int counter = update_every - 1;
+ heartbeat_t hb;
+ heartbeat_init(&hb);
+ usec_t step = em->update_every * USEC_PER_SEC;
while (!close_ebpf_plugin) {
- pthread_mutex_lock(&collect_data_mutex);
- pthread_cond_wait(&collect_data_cond_var, &collect_data_mutex);
+ (void)heartbeat_next(&hb, step);
- if (++counter == update_every) {
- counter = 0;
- pthread_mutex_lock(&lock);
+ pthread_mutex_lock(&lock);
- // write dims now for all hitherto discovered IRQs.
- write_begin_chart(NETDATA_EBPF_SYSTEM_GROUP, "hardirq_latency");
- avl_traverse_lock(&hardirq_pub, hardirq_write_dims, NULL);
- hardirq_write_static_dims();
- write_end_chart();
-
- pthread_mutex_unlock(&lock);
- }
+ // write dims now for all hitherto discovered IRQs.
+ write_begin_chart(NETDATA_EBPF_SYSTEM_GROUP, "hardirq_latency");
+ avl_traverse_lock(&hardirq_pub, hardirq_write_dims, NULL);
+ hardirq_write_static_dims();
+ write_end_chart();
- pthread_mutex_unlock(&collect_data_mutex);
+ pthread_mutex_unlock(&lock);
}
}