[PATCH v3] alloc_tag: expose profiling and compression states
Abhishek Bapat <[email protected]> Mon, 3 Aug 2026 21:54:55 +0000
| Newsgroups | org.kvack.linux-mm,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <d635115cfafcd35c8e3344b418acb1020aba1052.1785794035.git.abhishekbapat@google.com> |
Currently, userspace has limited visibility into the exact active
runtime state of memory allocation profiling and its page extension
compression ('sysctl.vm.mem_profiling={0|1|never}[,compressed]').
While reading the sysctl provides basic on/off status, it is currently
impossible for userspace to natively determine whether page-tag
compression was successfully enabled without scraping dmesg boot logs.
Resolve this ambiguity by exposing the active compression state by
adding a new read-only sysctl `vm.mem_profiling_compressed` to output the
state.
v3 change:
- Added documentation about the behaviour details of the new sysctl.
v2 change:
- Moved from displaying the state in /proc/allocinfo to a new read-only
sysctl.
Signed-off-by: Abhishek Bapat <[email protected]>
---
Documentation/mm/allocation-profiling.rst | 13 +++++++++++++
mm/alloc_tag.c | 6 ++++++
2 files changed, 19 insertions(+)
diff --git a/Documentation/mm/allocation-profiling.rst b/Documentation/mm/allocation-profiling.rst
index c3a28467955f..3ad1e9aacb9a 100644
--- a/Documentation/mm/allocation-profiling.rst
+++ b/Documentation/mm/allocation-profiling.rst
@@ -43,6 +43,19 @@ sysctl:
warnings produced by allocations made while profiling is disabled and freed
when it's enabled.
+ /proc/sys/vm/mem_profiling_compressed
+
+ 1: Page extension compression is enabled.
+
+ 0: Page extension compression is disabled.
+
+ This control is read-only and reflects the compression status initialized at boot.
+ Note that, unlike `mem_profiling`, which represents the current state of profiling,
+ `mem_profiling_compressed` represents the state configured at boot time. Turning off
+ profiling at runtime will implicitly make this sysctl effectively dormant. However, if
+ profiling is toggled off and then toggled on again, it will resume with compression
+ still enabled as long as the value of `mem_profiling_compressed` is 1.
+
Runtime info:
/proc/allocinfo
diff --git a/mm/alloc_tag.c b/mm/alloc_tag.c
index 52aece27b00e..877068241f06 100644
--- a/mm/alloc_tag.c
+++ b/mm/alloc_tag.c
@@ -1303,6 +1303,12 @@ static const struct ctl_table memory_allocation_profiling_sysctls[] = {
.mode = 0644,
.proc_handler = proc_mem_profiling_handler,
},
+ {
+ .procname = "mem_profiling_compressed",
+ .data = &mem_profiling_compressed,
+ .mode = 0444,
+ .proc_handler = proc_do_static_key,
+ },
};
static void __init sysctl_init(void)
base-commit: 94f9b3980dd446b56acf1dfed649e9b32a9f3813
--
2.55.0.508.g3f0d502094-goog