From 615e9116b55950ff0892a63aa182627e33d0210e Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Mon, 13 Mar 2023 15:40:16 -0400 Subject: fixup! lib: add allocation tagging support for memory allocation profiling --- lib/alloc_tag.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c index 5b6b41080ed2..adf8b5da18db 100644 --- a/lib/alloc_tag.c +++ b/lib/alloc_tag.c @@ -373,8 +373,11 @@ static void alloc_tag_module_unload(struct codetag_type *cttype, struct codetag_ codetag_init_iter(&iter, cttype); for (ct = codetag_next_ct(&iter); ct; ct = codetag_next_ct(&iter)) { struct alloc_tag *tag = ct_to_alloc_tag(ct); + size_t bytes = lazy_percpu_counter_read(&tag->bytes_allocated); - lazy_percpu_counter_exit(&tag->bytes_allocated); + if (!WARN(bytes, "%s:%u module %s func:%s has %zu allocated at module unload", + ct->filename, ct->lineno, ct->modname, ct->function)) + lazy_percpu_counter_exit(&tag->bytes_allocated); } } -- cgit v1.2.3