From: Dipendra Khadka <kdipendra88@gmail.com>
To: hannes@cmpxchg.org
Cc: akpm@linux-foundation.org, mhocko@kernel.org,
roman.gushchin@linux.dev, shakeel.butt@linux.dev,
muchun.song@linux.dev, cgroups@vger.kernel.org,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/memcg: reorder retry checks for clarity in try_charge_memcg
Date: Thu, 18 Dec 2025 07:25:41 +0000 [thread overview]
Message-ID: <20251218072543.5071-1-kdipendra88@gmail.com> (raw)
In-Reply-To: <20251215204624.GE905277@cmpxchg.org>
Hi Johannes,
Thank you for the feedback. Let me clarify the scenario this patch addresses.
The task_is_dying() check in try_charge_memcg() identifies when the
CURRENT task (the caller) is the OOM victim - not when some other
process was killed.
Two scenarios:
1. Normal allocator triggers OOM:
- Process A allocates → triggers OOM
- Process B is killed (victim)
- Process A continues with reset retries - task_is_dying() = false for A
→ Unchanged by my patch
2. Victim tries to allocate:
- Process B (victim, TIF_MEMDIE set) tries to allocate
- task_is_dying() = true
- Current code: wastes retries on hopeless reclaims
- My patch: exits immediately
→ Optimization for this case
The victim has three safety mechanisms that make the retries unnecessary:
1. oom_reaper proactively frees its memory
2. __alloc_pages_slowpath() grants reserves via oom_reserves_allowed()
3. Critical allocations with __GFP_NOFAIL still reach force: label
The retry loop for a dying victim is futile because:
- Reclaim won't help (victim is being killed to free memory!)
- Victim will exit regardless
- Just wastes CPU cycles
Would you like me to provide evidence showing the unnecessary retries,
or run specific tests to verify the safety mechanisms are sufficient?
Best Regards,
Dipendra
prev parent reply other threads:[~2025-12-18 7:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-15 14:54 Dipendra Khadka
2025-12-15 20:46 ` Johannes Weiner
2025-12-18 6:55 ` Dipendra Khadka
2025-12-18 7:06 ` Dipendra Khadka
2025-12-18 7:28 ` Shakeel Butt
2025-12-18 7:36 ` Dipendra Khadka
2025-12-18 8:08 ` Shakeel Butt
2025-12-18 7:25 ` Dipendra Khadka [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=20251218072543.5071-1-kdipendra88@gmail.com \
--to=kdipendra88@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--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=shakeel.butt@linux.dev \
/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