Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Shakeel Butt" <shakeel.butt@linux.dev>,
	"Tejun Heo" <tj@kernel.org>,
	"Andrew Morton" <akpm@linux-foundation.org>
Cc: "Johannes Weiner" <hannes@cmpxchg.org>,
	"Michal Koutny" <mkoutny@suse.com>,
	"Christian Brauner" <brauner@kernel.org>,
	"Michal Hocko" <mhocko@kernel.org>,
	"Roman Gushchin" <roman.gushchin@linux.dev>,
	"Muchun Song" <muchun.song@linux.dev>, "Jan Kara" <jack@suse.cz>,
	"Matthew Wilcox" <willy@infradead.org>,
	"David Hildenbrand" <david@kernel.org>,
	"Vlastimil Babka" <vbabka@kernel.org>, "Zi Yan" <ziy@nvidia.com>,
	"Baolin Wang" <baolin.wang@linux.alibaba.com>,
	"Nico Pache" <nico.pache@linux.dev>,
	"Usama Arif" <usama.arif@linux.dev>,
	"Kiryl Shutsemau" <kas@kernel.org>,
	"Lorenzo Stoakes" <ljs@kernel.org>,
	"Suren Baghdasaryan" <surenb@google.com>,
	"Meta kernel team" <kernel-team@meta.com>,
	linux-mm@kvack.org, dsterba@suse.cz
Subject: Re: [RFC PATCH 6/7] memcg: remove synchronous memory.high enforcement
Date: Sun, 22 Nov 2026 03:06:06 +0000	[thread overview]
Message-ID: <sashiko-outbox-227661@kernel.org> (raw)
In-Reply-To: <20261122024737.2741569-7-shakeel.butt@linux.dev>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] memcg: memcg_enforce_high() leaves vhost_task PF_USER_WORKER
  threads unthrottled
--

commit dfb4aaa1098cc7070f618d5995322b418d647d3c
Author: Shakeel Butt <shakeel.butt@linux.dev>

memcg: remove synchronous memory.high enforcement

This commit removes synchronous memory.high enforcement from
memcg_enforce_high() so that pending high overages are handled on return
to userspace or at explicit throttling points in long-running operations,
and updates the cgroup v2 documentation accordingly.

> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 6d147153bd06b..4771730e017a5 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
[ ... ]
> @@ -2765,15 +2766,6 @@ static void memcg_enforce_high(struct mem_cgroup *memcg, unsigned int nr_pages,
>  		current->memcg_nr_pages_over_high += nr_pages;
>  		set_notify_resume(current);
>  	}
> -
> -	/*
> -	 * 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 &&
> -	    gfpflags_allow_blocking(gfp_mask))
> -		__mem_cgroup_handle_over_high(gfp_mask);
>  }

[Severity: High]
Does removing the synchronous __mem_cgroup_handle_over_high() call leave
vhost_task worker threads completely unthrottled by memory.high and
memory.swap.high?

vhost_task_create() clones workers with CLONE_VM and args.user_worker = 1,
setting PF_USER_WORKER rather than PF_KTHREAD while sharing the owner's mm.
In memcg_enforce_high(), use_high_work checks current->flags & PF_KTHREAD,
so it evaluates to false for vhost workers and only increments
current->memcg_nr_pages_over_high and calls set_notify_resume(current).

Unlike io_uring PF_USER_WORKER threads, which check TIF_NOTIFY_RESUME and
call resume_user_mode_work(), vhost_task_fn() loops in kernel space until
exit without ever returning to userspace or handling notify-resume work:

kernel/vhost_task.c:vhost_task_fn() {
	for (;;) {
		...
		did_work = vtsk->fn(vtsk->data);
		if (!did_work)
			schedule();
	}

	do_exit(0);
}

Previously, blocking charges from vhost workers (such as guest memory
faults or skb allocations) were caught by the synchronous
__mem_cgroup_handle_over_high() check here once memcg_nr_pages_over_high
exceeded MEMCG_CHARGE_BATCH.  Without it, vhost workers neither schedule
high_work nor run return-to-userspace reclaim, bypassing memory.high and
memory.swap.high for the lifetime of the worker while
memcg_nr_pages_over_high overflows.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261122024737.2741569-1-shakeel.butt@linux.dev?part=6


  reply	other threads:[~2026-11-22  3:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-22  2:47 [RFC PATCH 0/7] memcg: effective high limit that avoids isolation issues Shakeel Butt
2026-11-22  2:47 ` [RFC PATCH 1/7] memcg: add helpers to handle memory.high overage in long operations Shakeel Butt
2026-11-22  2:47 ` [RFC PATCH 2/7] mm/gup: handle memory.high overage while populating Shakeel Butt
2026-11-22  3:06   ` sashiko-bot
2026-11-22  2:47 ` [RFC PATCH 3/7] mm, fs: handle memory.high overage in buffered reads and writes Shakeel Butt
2026-11-22  3:06   ` sashiko-bot
2026-11-22  2:47 ` [RFC PATCH 4/7] mm/shmem: handle memory.high overage in fallocate and reads Shakeel Butt
2026-11-22  2:47 ` [RFC PATCH 5/7] mm/khugepaged: handle memory.high overage in MADV_COLLAPSE Shakeel Butt
2026-11-22  2:47 ` [RFC PATCH 6/7] memcg: remove synchronous memory.high enforcement Shakeel Butt
2026-11-22  3:06   ` sashiko-bot [this message]
2026-11-22  2:47 ` [RFC PATCH 7/7] selftests/cgroup: make test_memcg_high_sync check that throttling holds Shakeel Butt

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=sashiko-outbox-227661@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=brauner@kernel.org \
    --cc=david@kernel.org \
    --cc=dsterba@suse.cz \
    --cc=hannes@cmpxchg.org \
    --cc=jack@suse.cz \
    --cc=kas@kernel.org \
    --cc=kernel-team@meta.com \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@kernel.org \
    --cc=mkoutny@suse.com \
    --cc=muchun.song@linux.dev \
    --cc=nico.pache@linux.dev \
    --cc=roman.gushchin@linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=shakeel.butt@linux.dev \
    --cc=surenb@google.com \
    --cc=tj@kernel.org \
    --cc=usama.arif@linux.dev \
    --cc=vbabka@kernel.org \
    --cc=willy@infradead.org \
    --cc=ziy@nvidia.com \
    /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