All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shakeel Butt <shakeel.butt@linux.dev>
To: Joe Damato <joe@dama.to>
Cc: linux-kernel@vger.kernel.org,
	Johannes Weiner <hannes@cmpxchg.org>,
	 Michal Hocko <mhocko@kernel.org>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	 Muchun Song <muchun.song@linux.dev>,
	Andrew Morton <akpm@linux-foundation.org>,
	 stable@vger.kernel.org, cgroups@vger.kernel.org,
	linux-mm@kvack.org, bpf@vger.kernel.org
Subject: Re: [PATCH v2] mm: memcontrol: raise MEMCG_MAX for charges that fail without reclaiming
Date: Mon, 31 Aug 2026 10:52:32 -0700	[thread overview]
Message-ID: <apW_N1urVjfCLmbZ@linux.dev> (raw)
In-Reply-To: <20260831174836.3102406-1-joe@dama.to>

On Mon, Aug 31, 2026 at 10:48:35AM -0700, Joe Damato wrote:
> Charges that exceed memory.max and return through the nomem label can
> raise no event and simply return -ENOMEM.
> 
> A non-blocking charge can hit the limit, get rejected, but is not
> visible in memory.events.
> 
> This was noticed in a production setting where bpf_mem_alloc() attempted
> to refill its per-cpu freelists, which triggered a non-blocking charge
> while at the limit.
> 
> Commit d6e103a757fa ("mm: memcontrol: do not miss MEMCG_MAX events for
> enforced allocations") added raised_max_event to cover charges that are
> force charged without ever reaching reclaim, but charges that are
> rejected outright were left out. Getting an allocation failure without
> the corresponding MEMCG_MAX event is unexpected and makes debugging and
> monitoring harder.
> 
> Raise the event on the way out for rejected charges as well, by routing
> the -ENOMEM return through the same exit path that already covers forced
> charges. The existing behavior of raising a MEMCG_MAX event on every
> charge/reclaim/retry iteration is left unchanged.
> 
> Tested with a module that performs accounted GFP_NOWAIT page allocations
> from a task in a cgroup at its memory.max, and measures the resulting
> memory.events:max delta. Without this patch the rejected charges raise
> no event at all; with it the delta matches the number of rejected charges
> exactly. A GFP_KERNEL|__GFP_NORETRY control, which reaches reclaim, raises
> the same two events per failed charge before and after, confirming the
> existing charge/reclaim/retry accounting is unchanged.
> 
> Fixes: d6e103a757fa ("mm: memcontrol: do not miss MEMCG_MAX events for enforced allocations")
> Cc: stable@vger.kernel.org
> Suggested-by: Shakeel Butt <shakeel.butt@linux.dev>
> Signed-off-by: Joe Damato <joe@dama.to>

Acked-by: Shakeel Butt <shakeel.butt@linux.dev>



      reply	other threads:[~2026-08-31 17:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31 17:48 [PATCH v2] mm: memcontrol: raise MEMCG_MAX for charges that fail without reclaiming Joe Damato
2026-08-31 17:52 ` Shakeel Butt [this message]

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=apW_N1urVjfCLmbZ@linux.dev \
    --to=shakeel.butt@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=bpf@vger.kernel.org \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=joe@dama.to \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=muchun.song@linux.dev \
    --cc=roman.gushchin@linux.dev \
    --cc=stable@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.