[PATCH v5] alloc_tag: expose boot-time compression configuration

Abhishek Bapat posted 1 patch 2 weeks, 5 days ago
Documentation/mm/allocation-profiling.rst | 11 +++++++++++
mm/alloc_tag.c                            |  6 ++++++
2 files changed, 17 insertions(+)
[PATCH v5] alloc_tag: expose boot-time compression configuration
Posted by Abhishek Bapat 2 weeks, 5 days ago
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.

Add a new read-only sysctl representing how compression was configured
at boot time.

Signed-off-by: Abhishek Bapat <abhishekbapat@google.com>
---
v5 change:
- More documentation and commit message refactoring.

v4 change:
- Documentation and commit message refactor.

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.

 Documentation/mm/allocation-profiling.rst | 11 +++++++++++
 mm/alloc_tag.c                            |  6 ++++++
 2 files changed, 17 insertions(+)

diff --git a/Documentation/mm/allocation-profiling.rst b/Documentation/mm/allocation-profiling.rst
index c3a28467955f..b2ebcef8af6f 100644
--- a/Documentation/mm/allocation-profiling.rst
+++ b/Documentation/mm/allocation-profiling.rst
@@ -43,6 +43,17 @@ sysctl:
   warnings produced by allocations made while profiling is disabled and freed
   when it's enabled.
 
+  /proc/sys/vm/mem_profiling_compressed
+
+  1: Page alloc tag compression is enabled.
+
+  0: Page alloc tag compression is disabled.
+
+  This reflects a static boot-time configuration of how page allocation tags are
+  stored (in page flags when compression is enabled and in page_ext when disabled).
+  Toggling ``mem_profiling`` at runtime does not change the state of
+  ``mem_profiling_compressed``.
+
 Runtime info:
   /proc/allocinfo
 
diff --git a/mm/alloc_tag.c b/mm/alloc_tag.c
index 84c5c3783ca4..b33410310477 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: a946fa1d96648b92c9f37f0488e0e47a85f9e235
-- 
2.55.0.508.g3f0d502094-goog
Re: [PATCH v5] alloc_tag: expose boot-time compression configuration
Posted by Suren Baghdasaryan 2 weeks, 5 days ago
On Wed, Aug 5, 2026 at 10:29 AM Abhishek Bapat <abhishekbapat@google.com> wrote:
>
> 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.
>
> Add a new read-only sysctl representing how compression was configured
> at boot time.
>
> Signed-off-by: Abhishek Bapat <abhishekbapat@google.com>

Acked-by: Suren Baghdasaryan <surenb@google.com>

> ---
> v5 change:
> - More documentation and commit message refactoring.
>
> v4 change:
> - Documentation and commit message refactor.
>
> 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.
>
>  Documentation/mm/allocation-profiling.rst | 11 +++++++++++
>  mm/alloc_tag.c                            |  6 ++++++
>  2 files changed, 17 insertions(+)
>
> diff --git a/Documentation/mm/allocation-profiling.rst b/Documentation/mm/allocation-profiling.rst
> index c3a28467955f..b2ebcef8af6f 100644
> --- a/Documentation/mm/allocation-profiling.rst
> +++ b/Documentation/mm/allocation-profiling.rst
> @@ -43,6 +43,17 @@ sysctl:
>    warnings produced by allocations made while profiling is disabled and freed
>    when it's enabled.
>
> +  /proc/sys/vm/mem_profiling_compressed
> +
> +  1: Page alloc tag compression is enabled.
> +
> +  0: Page alloc tag compression is disabled.
> +
> +  This reflects a static boot-time configuration of how page allocation tags are
> +  stored (in page flags when compression is enabled and in page_ext when disabled).
> +  Toggling ``mem_profiling`` at runtime does not change the state of
> +  ``mem_profiling_compressed``.
> +
>  Runtime info:
>    /proc/allocinfo
>
> diff --git a/mm/alloc_tag.c b/mm/alloc_tag.c
> index 84c5c3783ca4..b33410310477 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: a946fa1d96648b92c9f37f0488e0e47a85f9e235
> --
> 2.55.0.508.g3f0d502094-goog
>