summaryrefslogtreecommitdiffstats
path: root/src/collectors/ebpf.plugin/ebpf_cachestat.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-11-25 17:33:56 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-11-25 17:34:10 +0000
commit83ba6762cc43d9db581b979bb5e3445669e46cc2 (patch)
tree2e69833b43f791ed253a7a20318b767ebe56cdb8 /src/collectors/ebpf.plugin/ebpf_cachestat.c
parentReleasing debian version 1.47.5-1. (diff)
downloadnetdata-83ba6762cc43d9db581b979bb5e3445669e46cc2.tar.xz
netdata-83ba6762cc43d9db581b979bb5e3445669e46cc2.zip
Merging upstream version 2.0.3+dfsg (Closes: #923993, #1042533, #1045145).
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/collectors/ebpf.plugin/ebpf_cachestat.c')
-rw-r--r--src/collectors/ebpf.plugin/ebpf_cachestat.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/src/collectors/ebpf.plugin/ebpf_cachestat.c b/src/collectors/ebpf.plugin/ebpf_cachestat.c
index 8c0260d51..49a5d98a1 100644
--- a/src/collectors/ebpf.plugin/ebpf_cachestat.c
+++ b/src/collectors/ebpf.plugin/ebpf_cachestat.c
@@ -43,11 +43,7 @@ ebpf_local_maps_t cachestat_maps[] = {{.name = "cstat_global", .internal_input =
#endif
}};
-struct config cachestat_config = { .first_section = NULL,
- .last_section = NULL,
- .mutex = NETDATA_MUTEX_INITIALIZER,
- .index = { .avl_tree = { .root = NULL, .compar = appconfig_section_compare },
- .rwlock = AVL_LOCK_INITIALIZER } };
+struct config cachestat_config = APPCONFIG_INITIALIZER;
netdata_ebpf_targets_t cachestat_targets[] = { {.name = "add_to_page_cache_lru", .mode = EBPF_LOAD_TRAMPOLINE},
{.name = "mark_page_accessed", .mode = EBPF_LOAD_TRAMPOLINE},
@@ -716,9 +712,8 @@ static inline void cachestat_save_pid_values(netdata_publish_cachestat_t *out, n
* Read the apps table and store data inside the structure.
*
* @param maps_per_core do I need to read all cores?
- * @param max_period limit of iterations without updates before remove data from hash table
*/
-static void ebpf_read_cachestat_apps_table(int maps_per_core, uint32_t max_period)
+static void ebpf_read_cachestat_apps_table(int maps_per_core)
{
netdata_cachestat_pid_t *cv = cachestat_vector;
int fd = cachestat_maps[NETDATA_CACHESTAT_PID_STATS].map_fd;
@@ -842,28 +837,25 @@ void ebpf_resume_apps_data()
*/
void *ebpf_read_cachestat_thread(void *ptr)
{
- heartbeat_t hb;
- heartbeat_init(&hb);
-
ebpf_module_t *em = (ebpf_module_t *)ptr;
int maps_per_core = em->maps_per_core;
int update_every = em->update_every;
- uint32_t max_period = EBPF_CLEANUP_FACTOR;
int counter = update_every - 1;
uint32_t lifetime = em->lifetime;
uint32_t running_time = 0;
- usec_t period = update_every * USEC_PER_SEC;
pids_fd[EBPF_PIDS_CACHESTAT_IDX] = cachestat_maps[NETDATA_CACHESTAT_PID_STATS].map_fd;
+ heartbeat_t hb;
+ heartbeat_init(&hb, update_every * USEC_PER_SEC);
while (!ebpf_plugin_stop() && running_time < lifetime) {
- (void)heartbeat_next(&hb, period);
+ (void)heartbeat_next(&hb);
if (ebpf_plugin_stop() || ++counter != update_every)
continue;
pthread_mutex_lock(&collect_data_mutex);
- ebpf_read_cachestat_apps_table(maps_per_core, max_period);
+ ebpf_read_cachestat_apps_table(maps_per_core);
ebpf_resume_apps_data();
pthread_mutex_unlock(&collect_data_mutex);
@@ -1407,7 +1399,7 @@ static void cachestat_collector(ebpf_module_t *em)
int update_every = em->update_every;
int maps_per_core = em->maps_per_core;
heartbeat_t hb;
- heartbeat_init(&hb);
+ heartbeat_init(&hb, USEC_PER_SEC);
int counter = update_every - 1;
//This will be cancelled by its parent
uint32_t running_time = 0;
@@ -1415,7 +1407,7 @@ static void cachestat_collector(ebpf_module_t *em)
netdata_idx_t *stats = em->hash_table_stats;
memset(stats, 0, sizeof(em->hash_table_stats));
while (!ebpf_plugin_stop() && running_time < lifetime) {
- (void)heartbeat_next(&hb, USEC_PER_SEC);
+ (void)heartbeat_next(&hb);
if (ebpf_plugin_stop() || ++counter != update_every)
continue;