Cleanup ARAL code when NETDATA_ARAL_INTERNAL_CHECKS is enabled (#22581)
Cleanup ARAL code when NETDATA_ARAL_INTERNAL_CHECKS is enabled (dev only). May need additional cleanup in a future PR to be more useful
Stelios Fragkakis committed
May 28, 2026 at 22:17 UTC
04e23162803709592f7b38ae31c0717a5d1e4275
1 file changed
+8
-24
src/libnetdata/aral/aral.c
+8
-24
@@ -433,20 +433,20 @@ static inline struct free_space check_free_space___aral_lock_needed(ARAL *ar, AR
433
f.max_page_elements = aral_max_allocation_size(ar) / ar->config.element_size;
434
for(f.p = *aral_pages_head_free(ar, marked); f.p ; f.lp = f.p, f.p = f.p->aral_lock.next) {
435
f.pages++;
436
- internal_fatal(!f.p->aral_lock.free_elements, "page is in the free list, but does not have any elements free");
437
- internal_fatal(f.p->marked != marked, "page is in the wrong mark list");
436
+ internal_fatal(!f.p->page_lock.free_elements, "page is in the free list, but does not have any elements free");
437
+ internal_fatal(f.p->aral_lock.marked != marked, "page is in the wrong mark list");
438
439
- if(f.p != my_page && f.max_free_elements_on_a_page < f.p->aral_lock.free_elements)
440
- f.max_free_elements_on_a_page = f.p->aral_lock.free_elements;
439
+ if(f.p != my_page && f.max_free_elements_on_a_page < f.p->page_lock.free_elements)
440
+ f.max_free_elements_on_a_page = f.p->page_lock.free_elements;
441
442
- f.free_elements += f.p->aral_lock.free_elements;
442
+ f.free_elements += f.p->page_lock.free_elements;
443
f.pages_with_free_elements++;
444
}
445
446
for(f.p = *aral_pages_head_full(ar, marked); f.p ; f.lp = f.p, f.p = f.p->aral_lock.next) {
447
f.pages++;
448
- internal_fatal(f.p->aral_lock.free_elements, "found page with free items in a full page");
449
- internal_fatal(f.p->marked != marked, "page is in the wrong mark list");
448
+ internal_fatal(f.p->page_lock.free_elements, "found page with free items in a full page");
449
+ internal_fatal(f.p->aral_lock.marked != marked, "page is in the wrong mark list");
450
}
451
452
return f;
@@ -885,18 +885,13 @@ static ALWAYS_INLINE ARAL_PAGE *aral_get_first_page_with_a_free_slot(ARAL *ar, b
885
size_t idx = mark_to_idx(marked);
886
__atomic_add_fetch(&ar->ops[idx].atomic.allocators, 1, __ATOMIC_RELAXED);
887
888
-#ifdef NETDATA_ARAL_INTERNAL_CHECKS
889
- // bool added = false;
890
- struct free_space f1, f2;
891
-#endif
892
-
888
ARAL_PAGE *page = NULL;
889
890
retry_acquisition:
891
892
while(!(page = aral_acquire_first_page(ar, marked))) {
893
#ifdef NETDATA_ARAL_INTERNAL_CHECKS
899
- f1 = check_free_space___aral_lock_needed(ar, NULL, marked);
894
+ (void)check_free_space___aral_lock_needed(ar, NULL, marked);
895
#endif
896
897
bool can_add = false;
@@ -926,10 +921,6 @@ retry_acquisition:
921
page->aral_lock.head_ptr = head_ptr_free;
922
aral_unlock(ar);
923
929
- //#ifdef NETDATA_ARAL_INTERNAL_CHECKS
930
- // added = true;
931
- //#endif
932
-
924
aral_adders_lock(ar, marked);
925
ar->ops[idx].adders.allocating_elements -= aral_elements_in_page_size(ar, page_allocation_size);
926
aral_adders_unlock(ar, marked);
@@ -949,13 +940,6 @@ retry_acquisition:
940
// it is acquired
941
// and aral is NOT locked
942
952
- //#ifdef NETDATA_ARAL_INTERNAL_CHECKS
953
- // if(added) {
954
- // f2 = check_free_space___aral_lock_needed(ar, page, marked);
955
- // internal_fatal(f2.failed, "hey!");
956
- // }
957
- //#endif
958
-
943
internal_fatal(!page,
944
"ARAL: '%s' failed to find a page with a free element",
945
ar->config.name);