summaryrefslogtreecommitdiffstats
path: root/collectors/ebpf.plugin/ebpf_hardirq.c
diff options
context:
space:
mode:
authorthiagoftsm <thiagoftsm@gmail.com>2021-10-18 15:26:02 +0000
committerGitHub <noreply@github.com>2021-10-18 15:26:02 +0000
commit3ef5ae53e596f110bb87ae2cf5ec90915558f8c9 (patch)
treeba668475c512787973f373e2f6b82fadfc40cbe5 /collectors/ebpf.plugin/ebpf_hardirq.c
parent00e321516624e43c07c41c5584e280bd9e9fb6de (diff)
Fix interval usage and reduce I/O (#11662)
Diffstat (limited to 'collectors/ebpf.plugin/ebpf_hardirq.c')
-rw-r--r--collectors/ebpf.plugin/ebpf_hardirq.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/collectors/ebpf.plugin/ebpf_hardirq.c b/collectors/ebpf.plugin/ebpf_hardirq.c
index e1c52bcd29..ff649e9cd9 100644
--- a/collectors/ebpf.plugin/ebpf_hardirq.c
+++ b/collectors/ebpf.plugin/ebpf_hardirq.c
@@ -323,7 +323,7 @@ static void *hardirq_reader(void *ptr)
ebpf_module_t *em = (ebpf_module_t *)ptr;
- usec_t step = NETDATA_HARDIRQ_SLEEP_MS * em->update_time;
+ usec_t step = NETDATA_HARDIRQ_SLEEP_MS * em->update_every;
while (!close_ebpf_plugin) {
usec_t dt = heartbeat_next(&hb, step);
UNUSED(dt);
@@ -336,7 +336,7 @@ static void *hardirq_reader(void *ptr)
return NULL;
}
-static void hardirq_create_charts()
+static void hardirq_create_charts(int update_every)
{
ebpf_create_chart(
NETDATA_EBPF_SYSTEM_GROUP,
@@ -347,7 +347,7 @@ static void hardirq_create_charts()
NULL,
NETDATA_EBPF_CHART_TYPE_STACKED,
NETDATA_CHART_PRIO_HARDIRQ_LATENCY,
- NULL, NULL, 0,
+ NULL, NULL, 0, update_every,
NETDATA_EBPF_MODULE_NAME_HARDIRQ
);
@@ -426,23 +426,30 @@ static void hardirq_collector(ebpf_module_t *em)
// create chart and static dims.
pthread_mutex_lock(&lock);
- hardirq_create_charts();
+ hardirq_create_charts(em->update_every);
hardirq_create_static_dims();
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;
while (!close_ebpf_plugin) {
pthread_mutex_lock(&collect_data_mutex);
pthread_cond_wait(&collect_data_cond_var, &collect_data_mutex);
- 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();
+ if (++counter == update_every) {
+ counter = 0;
+ 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);
+ }
- pthread_mutex_unlock(&lock);
pthread_mutex_unlock(&collect_data_mutex);
}
}