summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2024-02-21 23:15:39 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2024-05-08 15:09:37 -0400
commitb7a963a18accfeee7da159cb49fd0303f798c5a7 (patch)
tree159e3efb4000d5d257a30355fd943e912d15bf4b /include/linux
parentde0f32d02f83e61be850b8626ee8da87eb6e711f (diff)
codetag: rcu-ify idx to codetag lookupmemalloc-prof-v7
This substantially reworks how we store and iterate over codetags in multiple modules. We now provide a stable index for each codetag, which doesn't change as modules are loaded and unloaded - meaning on module load, we find a free range of indices for the new module. Index-to-codetag lookup uses an eytzinger tree, and we use RCU for the eytzinger tree for lockless lookup. The eytzinger tree has one entry per module, where entries store the starting index for each module's range. After eytzinger lookup we use eytzinger_to_inorder(), as the codetag_modules are still a flat array. With the new stable indices, iteration becomes simpler; the iterator just stores the current index and peek() finds the first codetag >= the current index. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/codetag.h28
1 files changed, 22 insertions, 6 deletions
diff --git a/include/linux/codetag.h b/include/linux/codetag.h
index c2a579ccd455..6aa8cf22d88b 100644
--- a/include/linux/codetag.h
+++ b/include/linux/codetag.h
@@ -7,7 +7,7 @@
#include <linux/types.h>
-struct codetag_iterator;
+struct codetag_iter;
struct codetag_type;
struct codetag_module;
struct seq_buf;
@@ -39,11 +39,10 @@ struct codetag_type_desc {
struct codetag_module *cmod);
};
-struct codetag_iterator {
+struct codetag_iter {
struct codetag_type *cttype;
struct codetag_module *cmod;
- unsigned long mod_id;
- struct codetag *ct;
+ unsigned idx;
};
#ifdef MODULE
@@ -60,10 +59,27 @@ struct codetag_iterator {
.flags = 0, \
}
+struct codetag *idx_to_codetag(struct codetag_type *cttype, unsigned idx);
+
void codetag_lock_module_list(struct codetag_type *cttype, bool lock);
bool codetag_trylock_module_list(struct codetag_type *cttype);
-struct codetag_iterator codetag_get_ct_iter(struct codetag_type *cttype);
-struct codetag *codetag_next_ct(struct codetag_iterator *iter);
+
+static inline struct codetag_iter codetag_iter_init(struct codetag_type *cttype, unsigned idx)
+{
+ return (struct codetag_iter) { .cttype = cttype, .idx = idx };
+}
+
+static inline void codetag_iter_advance(struct codetag_iter *iter)
+{
+ iter->idx++;
+}
+
+struct codetag *codetag_iter_peek(struct codetag_iter *);
+
+#define for_each_codetag(_cttype, _iter, _ct) \
+ for (struct codetag_iter _iter = codetag_iter_init(_cttype, 0); \
+ (_ct = codetag_iter_peek(&_iter)); \
+ codetag_iter_advance(&_iter))
void codetag_to_text(struct seq_buf *out, struct codetag *ct);