]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
lib/ukalloc: Iterator for per-library statistics
authorSimon Kuenzer <simon.kuenzer@neclab.eu>
Tue, 17 Nov 2020 15:48:24 +0000 (16:48 +0100)
committerUnikraft <monkey@unikraft.io>
Tue, 22 Jun 2021 13:14:08 +0000 (13:14 +0000)
Provides the `uk_alloc_foreach_libstats()` helper macro that can be used
to iterate over the available library allocator statistics.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #229

lib/ukalloc/include/uk/alloc.h
lib/ukalloc/libstats.ld

index 869928a02922e71c91635ea3338ddedb4c040ce1..2f3e9ae451f1dcbd6afcf218f3db7d28c9d229a4 100644 (file)
@@ -324,6 +324,16 @@ struct uk_alloc_libstats_entry {
        const char *libname;
        struct uk_alloc *a; /* default allocator wrapper for the library */
 };
+
+extern struct uk_alloc_libstats_entry _uk_alloc_libstats_start[];
+extern struct uk_alloc_libstats_entry _uk_alloc_libstats_end;
+
+#define uk_alloc_foreach_libstats(iter)                                        \
+       for ((iter) = _uk_alloc_libstats_start;                         \
+            (iter) < &_uk_alloc_libstats_end;                          \
+            (iter) = (struct uk_alloc_libstats_entry *) ((__uptr)(iter) \
+                     + ALIGN_UP(sizeof(struct uk_alloc_libstats_entry), 8)))
+
 #endif /* CONFIG_LIBUKALLOC_IFSTATS_PERLIB */
 #endif /* CONFIG_LIBUKALLOC_IFSTATS */
 
index 79a0a83753f7957ab5b5b72ceb957f0dad143529..d38aecf243b1c562b9de719e0a3a2160e236f744 100644 (file)
@@ -1,7 +1,9 @@
 SECTIONS
 {
        .uk_alloc_libstats : {
+               PROVIDE(_uk_alloc_libstats_start = .);
                KEEP (*(.uk_alloc_libstats))
+               PROVIDE(_uk_alloc_libstats_end = .);
        }
 }
 INSERT BEFORE .data;