Skip to contentSkip to conversation

alloc_tag: check mem_profiling_support in alloc_tag_init

PATCH Superseded Casey Chen 2 participants 2 messages May 7, 2025 – May 8, 2025

Subsystems (2)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Casey Chen

author
#0 lore raw

PATCH 1/1 alloc_tag: check mem_profiling_support in alloc_tag_init

If mem_profiling_support is false, for example, when sysctl.vm.mem_profiling=never, alloc_tag_init should skip allocating module tags and other operations.

---
 lib/alloc_tag.c | 5 +++++
 1 file changed, 5 insertions(+)
lib/alloc_tag.c +5 -0
index 25ecc1334b67..232082085a95 100644
@@ -762,6 +762,11 @@ static int __init alloc_tag_init(void)
 	};
 	int res;
 
+	if (!mem_profiling_support) {
+		pr_info("Memory allocation profiling is not supported!\n");
+		return 0;
+	}
+
 	res = alloc_mod_tags_mem();
 	if (res)
 		return res;
Signature · 1 line
2.49.0
#1 lore raw
Quoted 4 lines · Casey Chen

If mem_profiling_support is false, for example, when sysctl.vm.mem_profiling=never, alloc_tag_init should skip allocating module tags and other operations.

Makes sense except we still want to have sysctl_init() call executed so that userspace is able to read the state of mem_profiling.

Quoted 26 lines
---
 lib/alloc_tag.c | 5 +++++
 1 file changed, 5 insertions(+)
lib/alloc_tag.c +5 -1
index 25ecc1334b67..232082085a95 100644
@@ -762,6 +762,11 @@ static int __init alloc_tag_init(void)
        };
        int res;
 
+       if (!mem_profiling_support) {
+               pr_info("Memory allocation profiling is not supported!\n");
+               return 0;
+       }
+
        res = alloc_mod_tags_mem();
        if (res)
                return res;
--

2.49.0