[PATCH v1 1/2] mm/execmem: Print size, align and caller on allocation failure

From: Tiezhu Yang

Date: Fri Jul 17 2026 - 03:59:00 EST


The current execmem_vmalloc() function reports an allocation failure
with a simplistic "unable to allocate memory" message. This notifies
the user that an error occurred, but it acts as a black box during
debugging.

Enhance pr_warn_ratelimited() within execmem_vmalloc() to explicitly
print the requested allocation size, alignment constraints, and the
symbolic caller.

This diagnostic visibility is valuable for analyzing the root cause
of allocation failures and tracking misbehaving subsystems without
inducing log pollution.

Signed-off-by: Tiezhu Yang <yangtiezhu@xxxxxxxxxxx>
---
mm/execmem.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mm/execmem.c b/mm/execmem.c
index 084a207e4278..f3bc68e0eb98 100644
--- a/mm/execmem.c
+++ b/mm/execmem.c
@@ -50,7 +50,9 @@ static void *execmem_vmalloc(struct execmem_range *range, size_t size,
}

if (!p) {
- pr_warn_ratelimited("unable to allocate memory\n");
+ pr_warn_ratelimited("unable to allocate memory, "
+ "size=%zu, align=%u, caller is %pS\n",
+ size, align, __builtin_return_address(0));
return NULL;
}

--
2.42.0