summaryrefslogtreecommitdiffstats
path: root/libnetdata
diff options
context:
space:
mode:
authorStelios Fragkakis <52996999+stelfrag@users.noreply.github.com>2022-07-11 20:40:26 +0300
committerGitHub <noreply@github.com>2022-07-11 20:40:26 +0300
commit87e9700b2fb93731154eb59cbb53c69e55fbcc6b (patch)
tree50752e1a96f9c3d982834bf1212f16ecba5f9768 /libnetdata
parent0c954d2257fe3f87cb928fbc35841d07ce3a3fea (diff)
Detect stored metric size by page type (#13334)
* Report unknown page only once Get metric storage size by the page type Verify validity of the page and skip problematic ones * Change PAGE_SIZE to PAGE_POINT_SIZE_BYTES * Add bitmap256 and unittests * Fix unit test tier_page_type array page_type_size arrays * Add another counter to not rely on uint8_t overflow to stop the test loop
Diffstat (limited to 'libnetdata')
-rw-r--r--libnetdata/libnetdata.c16
-rw-r--r--libnetdata/libnetdata.h6
2 files changed, 22 insertions, 0 deletions
diff --git a/libnetdata/libnetdata.c b/libnetdata/libnetdata.c
index 2997ce19e4..212eceb824 100644
--- a/libnetdata/libnetdata.c
+++ b/libnetdata/libnetdata.c
@@ -1534,3 +1534,19 @@ char *find_and_replace(const char *src, const char *find, const char *replace, c
return value;
}
+
+
+bool bitmap256_get_bit(BITMAP256 *ptr, uint8_t idx) {
+ if (unlikely(!ptr))
+ return false;
+ return (ptr->data[idx / 64] & (1 << (idx % 64)));
+}
+
+void bitmap256_set_bit(BITMAP256 *ptr, uint8_t idx, bool value) {
+ if (unlikely(!ptr))
+ return;
+ if (likely(value))
+ ptr->data[idx / 64] |= (1U << (idx % 64));
+ else
+ ptr->data[idx / 64] &= ~(1U << (idx % 64));
+}
diff --git a/libnetdata/libnetdata.h b/libnetdata/libnetdata.h
index 4e0b45426c..e88e5978a8 100644
--- a/libnetdata/libnetdata.h
+++ b/libnetdata/libnetdata.h
@@ -311,6 +311,12 @@ extern char *find_and_replace(const char *src, const char *find, const char *rep
// Taken from linux kernel
#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
+typedef struct bitmap256 {
+ uint64_t data[4];
+} BITMAP256;
+
+extern bool bitmap256_get_bit(BITMAP256 *ptr, uint8_t idx);
+extern void bitmap256_set_bit(BITMAP256 *ptr, uint8_t idx, bool value);
extern void netdata_cleanup_and_exit(int ret) NORETURN;
extern void send_statistics(const char *action, const char *action_result, const char *action_data);