From: Shakeel Butt <shakeel.butt@linux.dev>
To: Michal Hocko <mhocko@suse.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Muchun Song <muchun.song@linux.dev>, Tejun Heo <tj@kernel.org>,
Meta kernel team <kernel-team@meta.com>,
cgroups@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH for-7.5 5/5] memcg: simplify high limit handling after a charge
Date: Wed, 14 Oct 2026 10:43:33 -0700 [thread overview]
Message-ID: <as-sE3hZqFA_Wb5B@linux.dev> (raw)
In-Reply-To: <as9rj8KoF1oKO8rE@tiehlicka>
On Wed, Oct 14, 2026 at 01:46:23PM +0200, Michal Hocko wrote:
> On Sat 10-10-26 14:09:57, Shakeel Butt wrote:
> [...]
> > - /* Interrupts, kernel threads, and remote chargers stop here. */
> > - if (use_worker)
> > + /*
> > + * Use a worker for interrupts, kernel threads, and tasks whose mm
> > + * does not match the charged hierarchy.
> > + */
> > + if (use_high_work) {
> > + if (!iter)
> > + return;
> > + if (allow_spinning)
> > + schedule_work(&iter->high_work);
> > + else
> > + irq_work_queue(&iter->high_irq_work);
> > return;
> > + }
> > +
> > + if (iter) {
>
> Would it be much simpler to bail out on iter==NULL (i.e. nothing over
> high limit) right after the loop?
>
I want this patch to not change any behavior. If we return here when iter is
NULL, we will skip a potential call to __mem_cgroup_handle_over_high() when
current->memcg_nr_pages_over_high > MEMCG_CHARGE_BATCH. Though I agree that is
very subtle and most probably unexpected. If we decide to remove it, we should
do it in a separate patch. Actually I am working on a followup series where I
plan to remove the sync enforcement of memory.high and put high enforcement on
the code paths which can potentially do a lot of allocation within a single
kernel entry.
> > + /*
> > + * Count the full batch so reclaim work and delay penalties scale
> > + * with the pages charged by this task.
> > + */
> > + current->memcg_nr_pages_over_high += nr_pages;
> > + set_notify_resume(current);
> > + }
> >
> > /*
> > - * Reclaim is set up above to be called from the userland
> > - * return path. But also attempt synchronous reclaim to avoid
> > - * excessive overrun while the task is still inside the
> > - * kernel. If this is successful, the return path will see it
> > - * when it rechecks the overage and simply bail out.
> > + * Earlier charges may have left high overage pending even if this charge
> > + * found no new overage. Handle it now if this charge can block, to limit
> > + * overrun while the task remains in the kernel.
> > */
> > if (current->memcg_nr_pages_over_high > MEMCG_CHARGE_BATCH &&
> > !(current->flags & PF_MEMALLOC) &&
> > --
> > 2.53.0-Meta
>
> --
> Michal Hocko
> SUSE Labs
next prev parent reply other threads:[~2026-10-14 17:43 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-10 21:09 [PATCH for-7.5 0/5] memcg: clean up memory.high enforcement Shakeel Butt
2026-10-10 21:09 ` [PATCH for-7.5 1/5] memcg: move memory.high enforcement out of try_charge_memcg() Shakeel Butt
2026-10-12 13:22 ` Harry Yoo
2026-10-12 17:13 ` Shakeel Butt
2026-10-14 11:13 ` Michal Hocko
2026-10-10 21:09 ` [PATCH for-7.5 2/5] memcg: use high_work for kernel threads Shakeel Butt
2026-10-14 11:21 ` Michal Hocko
2026-10-10 21:09 ` [PATCH for-7.5 3/5] memcg: use high_work for remote charges Shakeel Butt
2026-10-14 11:29 ` Michal Hocko
2026-10-10 21:09 ` [PATCH for-7.5 4/5] memcg: avoid queuing high_work from reclaim Shakeel Butt
2026-10-14 11:39 ` Michal Hocko
2026-10-14 16:06 ` Shakeel Butt
2026-10-14 16:59 ` Michal Hocko
2026-10-14 17:55 ` Shakeel Butt
2026-10-14 19:27 ` Michal Hocko
2026-10-14 19:36 ` Shakeel Butt
2026-10-10 21:09 ` [PATCH for-7.5 5/5] memcg: simplify high limit handling after a charge Shakeel Butt
2026-10-14 11:46 ` Michal Hocko
2026-10-14 17:43 ` Shakeel Butt [this message]
2026-10-14 19:30 ` Michal Hocko
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=as-sE3hZqFA_Wb5B@linux.dev \
--to=shakeel.butt@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=muchun.song@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=tj@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox