Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Rapoport <rppt@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Tiezhu Yang <yangtiezhu@loongson.cn>,
	Huacai Chen <chenhuacai@kernel.org>,
	linux-mm@kvack.org, loongarch@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 1/2] mm/execmem: Print size, align and caller on allocation failure
Date: Sun, 19 Jul 2026 11:55:56 +0300	[thread overview]
Message-ID: <alyRHFN9T0FIDBl2@kernel.org> (raw)
In-Reply-To: <20260717113730.787867964b1c3a7c645bb0e0@linux-foundation.org>

On Fri, Jul 17, 2026 at 11:37:30AM -0700, Andrew Morton wrote:
> On Fri, 17 Jul 2026 15:57:14 +0800 Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
> 
> > 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.
> 
> Have you actually encountered this?  GFP_KERNEL allocation failures are
> supposed to be very rare.

Looking at the second patch, it's quite possible. The allocation is limited
to module addresses which was only 256M on loongarch and could have been
exhausted.

> > ...
> >
> > --- 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;
> >  	}
> 
> This seems to be duplicating the information which the page allocator
> can emit.  Perhaps we should remove the __GFP_NOWARN in there?

Right, page allocator/vmalloc reports would be more useful, for example

"vmalloc_node_range for size %lu failed: Address range restricted to %#lx - %#lx"

was most probably the cause of allocation failures.

But we cannot remove __GFP_NOWARN unconditionally though, because execmem has
fallbacks for some of the allocation failures and I don't think the
complexity required to detect when __GFP_NOWARN should be cleared does not
justify one-off case.

Besides, nowadays there are other tools (e.g. BPF based) except printk that
allow debugging such issue, so I don't see much value in extending this
error message or clearing __GFP_NOWARN sometimes.

-- 
Sincerely yours,
Mike.


  reply	other threads:[~2026-07-19  8:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260717075715.25513-1-yangtiezhu@loongson.cn>
     [not found] ` <20260717075715.25513-2-yangtiezhu@loongson.cn>
2026-07-17 18:37   ` [PATCH v1 1/2] mm/execmem: Print size, align and caller on allocation failure Andrew Morton
2026-07-19  8:55     ` Mike Rapoport [this message]
     [not found] ` <20260717075715.25513-3-yangtiezhu@loongson.cn>
2026-07-19  9:01   ` [PATCH v1 2/2] LoongArch: mm: Expand modules virtual address space to 2GB Mike Rapoport
2026-07-19 15:28     ` Xi Ruoyao
2026-07-20  7:16       ` Tiezhu Yang
2026-07-20 10:40       ` Tiezhu Yang
2026-07-21  4:56         ` Huacai Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alyRHFN9T0FIDBl2@kernel.org \
    --to=rppt@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=chenhuacai@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=loongarch@lists.linux.dev \
    --cc=yangtiezhu@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox