🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #8194

Re: [RFC PATCH 0/2] memcg_ext: dynamic memory.low and memory.min protection

#8194
From: "Hui Zhu"
Date: Wed, 28 Oct 2026 10:27
90 lines
14179 bytes
"Tejun Heo" <tj@kernel.org mailto:tj@kernel.org?to=%22Tejun%20Heo%22%20%3Ctj%40kernel.org%3E > :


> 
> Hello, Hui.
> 
> On Tue, Oct 27, 2026 at 05:11:58PM +0800, Hui Zhu wrote:
> 
> > 
> > Why it matters: memory.low and memory.min protect a cgroup by a fixed
> >  threshold and have no idea whether it is using the memory. A
> >  high-priority cgroup that holds a large working set and then goes idle
> >  keeps suppressing reclaim on its siblings, and that memory is wasted.
> >  A policy program sees the real activity - page faults, charges - and
> >  can grant or withdraw protection as it changes.
> > 
> This doesn't justify the changes. Why can't the same be achieved by
> adjusting memory.low and memory.min from userspace? The arguments made
> so far are neither convincing nor proven.
> 
> Thanks.
> 
> --
> tejun
>

Hi Tejun,

Thanks for taking a look.

You are right about that paragraph.  It describes what dynamic
protection does rather than saying why it has to happen in the kernel,
and at the timescale I described a userspace agent writing memory.low
would keep up fine.  I will drop it.

Let me try to say what I was reaching for, from the code rather than
from a benchmark - a comparison between BPF and a userspace agent would
say at least as much about how well I wrote the agent as about the
interface, so I am not sure it would settle much.

memory.low is a request, and what reclaim honors is elow, which
page_counter_calculate_protection() derives on each pass from the
parent's elow, the siblings' requests and the tree's usage.  At the
first level below the reclaim root that comes out equal to what was
written, and there the knob is enough.  Deeper down it is capped by the
parent's budget and shared out between siblings according to what they
claimed and what they use, so what a cgroup wrote and what it ends up
with can differ.  As far as I can tell none of that is visible from
userspace: memory.low reads back the declared value, and I could not
find anything that exports elow.

Exporting elow would not help, because elow is not a property of the
cgroup alone.  It depends on the reclaim root as well, which is why
page_counter_calculate_protection() warns that it is not stateless and
is only valid as part of a top-down tree iteration, and why
mem_cgroup_protection() carries the example of a concurrent global and
targeted reclaim driving a child's elow to zero.  A file would show
whichever value the last reclaim happened to leave there.

So the derived value seems to be usable only where it is derived,
inside the check, and that is where low_policy() sits: it is evaluated
per pass and is handed that pass's own inputs - the memcg, the reclaim
target, the elow just computed, the usage - instead of being state that
is read at the check.

The other half is what a policy can key on.  memory.low has one
dimension, bytes.  A policy program is not limited to the ctx it is
handed; it can also use state that other BPF programs keep, so
protection can be a function of activity rather than of size - a
workingset refault rate, for instance.  [1] reads those counters from
BPF and acts on them; it drives reclaim rather than answering a
protection hook, but the signal it reads is the one such a policy would
want.  The limit is on the output rather than the input: the hook
returns a boolean, so it cannot grant anything memory.low cannot.

I would be interested in how you see this - in particular whether the
nested case is worth supporting at all, and if it is, whether this is
the right shape for it.  I am happy to rework the patches, and to add a
demonstration of one concrete policy if that would make it easier to
judge.

[1] https://github.com/teawater/memcg-async-reclaim/tree/memcg_ext_plus

Thanks,
Hui
Technical Details
Message-ID: <c652f3e6198b143fcf29f5540a769228f3d8470c@linux.dev>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-352811-linux-kernel-netdev=dewy.ru
References: <cover.1793086858.git.zhuhui@kylinos.cn> <769e80ffa618327ac03c13c4657e7229@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-352811-linux-kernel-netdev=dewy.ru
From: hui.zhu@linux.dev ("Hui Zhu")
Newsgroups: linux.kernel.netdev
Subject: Re: [RFC PATCH 0/2] memcg_ext: dynamic memory.low and memory.min
 protection
Date: Wed, 28 Oct 2026 10:27:33 +0000
Organization: Usenet Network
Message-ID: <c652f3e6198b143fcf29f5540a769228f3d8470c@linux.dev>
References: <cover.1793086858.git.zhuhui@kylinos.cn>
 <769e80ffa618327ac03c13c4657e7229@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
	logging-data="1748824"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:IvQ1k7sq6E3HhYUUZs3L63fU39c= sha256:86ZOY1CFk4sc2ZIDvGfu3fu92rzjNCU0kqF2YiW3lTA=
	sha1:Ib6uo9JeZJLtTlaWjtHAAZv9EoQ= sha256:ev0oIVM+I0FKSuIl7dFoFPGh1OIpcrZlaTCOC4deVIQ=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 1DC8A125C35; Wed, 28 Oct 2026 13:28:23 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.05
X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
	header.d=linux.dev
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id vEc23ZUU0avy;
	Wed, 28 Oct 2026 13:28:20 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-352811-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 2ADFF125C33; Wed, 28 Oct 2026 13:28:11 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 5DC51276EF; Wed, 28 Oct 2026 10:27:51 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1793183269;
	b=QVuXQfTQ+rBQvvU+MR3OU32UNqjjH1NOOJFsD7Oo33NCz/O/0R3+L7lkNuGrPdGGKuEq
	 oJH7WUDnTPTQz4GoPkegxDjbaar7f0+cQBXoKx9toxitIDj8SHWR2cN55B6rO04nB0Gko
	 RjEYZlGLxjJ2G/7BJymwhmliCdz4k8DRZMPNCVDfXX54Hn0WS/mOBoBIhPYsfwST2t9xu
	 7LKnGdRzoK/p+85j/lmdQW+FM7ILHpE65DjUcAXFJPJQvWvI0fNlxT3/3AGhXzC/Clc8r
	 1RYjT+uev+1o8aiCTcaoiCerJJluZS9pTmTh7jXRpqZiB02Q0TSuM8xo5RZf010g1BQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793183269;
	h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature:
	 X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:X-Mailing-List:
	 List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
	 List-Owner:Precedence:MIME-Version:Date:Content-Type:
	 Content-Transfer-Encoding:From:Message-ID:TLS-Required:Subject:To:Cc:
	 In-Reply-To:References;
	bh=CAsQNlvEQewVVFce1WqlpSDwej6JOKTiJP6Vd2oTTAg=;
	b=ErrGiwFzuKW82qRjzu6yYOWxGf/Q0PmZMnkdGWykuNmNGKbzhTLsqnSGLzskLiSC9XeX
	 /Z7P9BbhP8qLlf15DfCy1mpcrS4WMH65+mK2vkkHG/Veh3ECzyW90YybgJ5JrhK10P/nV
	 r1sAXVwnE4H6qJ562+1ISMMZifeb7gOWB67PwcLIlFk13LiHGp+zaJPqpAcLhEcmHi2nL
	 7+90uhe/LOPIyhM0Jtr5M4Ui7P0IyU+RxLzpbpqh61n5rrMtd0U57eo9MZj7LDzhT2Noz
	 CFymL8TVLdZWbp+rWWEU8eoEwGBtDP4RYEgQgL7v4ghG3vCBahjdqu7B8LCBiHBZvqA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b="Jmwex/kK";
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 047DE606A320;
	Wed, 28 Oct 2026 10:27:49 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=Jmwex/kK
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.47
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793183258;
	b=Q7srUxKY7GZI41M3gKUzEGqTiUIXhFZhal/MMcB+UpkM9iPJ3ZFA6bbImW0g5nuxynOs
	 m4OVm4xwNVs9aYr5frXjshf0g3CGW0UzsUBSKlvFN0OajDTw03G3ZeTJGx9pDEnT8nNR7
	 PO8mKvRyKWC3RxEuuve0qIWai2/kJ1fS6VWaUDbcBgtIR/t9G1JXd9Xvd4t4eZ0YP7/5k
	 QxoGaYpseEaPfiQBnlV852UCb1tW/hkyQlVbg+G1I3PMXAUZgy1fVaMzfM69p5I8DCzRr
	 hlEVJ9S5f4ylou5t/Yi0MLeD3bxFguD3mPjAzSH8OpTpHoTuGfmntTY+OjVZ3I42EEw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793183258;
	h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received:
	 X-Mizu-Trace-ID:X-Migadu-Flow:MIME-Version:Date:Content-Type:
	 Content-Transfer-Encoding:From:Message-ID:TLS-Required:Subject:To:Cc:
	 In-Reply-To:References;
	bh=CAsQNlvEQewVVFce1WqlpSDwej6JOKTiJP6Vd2oTTAg=;
	b=zJOUiioc91yy8k8VT45+SHf1AIORJrL3Jc3Vi7WNtiYW5HLfrW/IwICJXYL5hLpVZAGr
	 lDlmk7j61ycwG2P1p+GVr+h6Zs7nQrE92sSkw+m+Ne8fNsZP7WTw9kmbNIJzNLjRLwsdS
	 lUKZmsFhNMD2QdgpwwUc3MC2akygvADJcH56Y+N16oj95VOpnKeDP/58wky6TdY0CSPdi
	 g8KnMZ7cJ/BThac3dEObr9PqxrmCWCv22qowEgi4IkfyBibvvgK9dHrrOmEbwbj15IRMp
	 ovxzN1WxVdLtb7wrZNOb4+2OMkdW+H01yRI90mrwcDAAwL5EQsow2H8VVvxzSeq771Q==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b="Jmwex/kK";
	arc=none smtp.remote-ip=95.215.58.47
X-Received: from mta1.migadu.com (out-47.mta1.migadu.com [95.215.58.47])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8BDF9606A31D
	for <netdev@vger.kernel.org>; Wed, 28 Oct 2026 10:27:36 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8BDF9606A31D
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev
X-Envelope-To: netdev@vger.kernel.org
X-DKIM-Signature: a=rsa-sha256; bh=OSNgAFP+VgQv9q7o9VlptAb+MUtYzG3jKiN7D8DtKj8=;
 c=simple/simple; d=linux.dev;
 h=from:to:subject:date:message-id:mime-version:content-type; s=key1;
 t=1793183254; v=1; x=1793788054;
 b=Jmwex/kK7FpuCV4bqSsS5FCwcMt+EqZgDLePJZ4dvcrpEr4L/YHoyx7QKjmO1CIocO5OCbGr
 tkZmoFbOPWPIzOshnL3/DpTiXzlghHbrudm38WhVc3KkL5yD0mKtIroNlIaYfbth6p94x+Qcx/Q
 vj7/M3C4X89z4qZWGeENzS/M=
X-Envelope-To: netdev@vger.kernel.org
X-Received: by smtp.migadu.com with ESMTPS id ee56cd7c32368443;
	Wed, 28 Oct 2026 10:27:33 +0000
X-Mizu-Trace-ID: ee56cd7c32368443
X-Migadu-Flow: FLOW_OUT
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-TLS-Required: No
X-Cc: "Alexei Starovoitov" <ast@kernel.org>, "Daniel Borkmann"
 <daniel@iogearbox.net>, "John Fastabend" <john.fastabend@gmail.com>,
 "Andrii Nakryiko" <andrii@kernel.org>, "Martin KaFai Lau"
 <martin.lau@linux.dev>, "Eduard Zingerman" <eddyz87@gmail.com>, "Kumar
 Kartikeya Dwivedi" <memxor@gmail.com>, "Song Liu" <song@kernel.org>,
 "Yonghong Song" <yonghong.song@linux.dev>, "Jiri Olsa"
 <jolsa@kernel.org>, "Johannes Weiner" <hannes@cmpxchg.org>, "Michal
 Hocko" <mhocko@kernel.org>, "Roman Gushchin" <roman.gushchin@linux.dev>,
 "Shakeel Butt" <shakeel.butt@linux.dev>, "Muchun Song"
 <muchun.song@linux.dev>, "JP Kobryn" <jp.kobryn@linux.dev>, "Andrew
 Morton" <akpm@linux-foundation.org>, "Shuah Khan" <shuah@kernel.org>,
 davem@davemloft.net, "Jakub Kicinski" <kuba@kernel.org>, "Jesper Dangaard
 Brouer" <hawk@kernel.org>, "Stanislav Fomichev" <sdf@fomichev.me>, "KP
 Singh" <kpsingh@kernel.org>, "Tao Chen" <chen.dylane@linux.dev>, "Mykyta
 Yatsenko" <yatsenko@meta.com>, "Leon Hwang" <leon.hwang@linux.dev>,
 "Anton Protopopov" <a.s.protopopov@gmail.com>, "Amery Hung"
 <ameryhung@gmail.com>, "Tobias Klauser" <tklauser@distanz.ch>, "Eyal
 Birger" <eyal.birger@gmail.com>, "Rong Tao" <rongtao@cestc.cn>, "Hao Luo"
 <haoluo@google.com>, "Peter Zijlstra" <peterz@infradead.org>, "Miguel
 Ojeda" <ojeda@kernel.org>, "Nathan Chancellor" <nathan@kernel.org>, "Kees
 Cook" <kees@kernel.org>, "Jeff Xu" <jeffxu@chromium.org>,
 mkoutny@suse.com, "Jan Hendrik Farr" <kernel@jfarr.cc>, "Christian
 Brauner" <brauner@kernel.org>, "Randy Dunlap" <rdunlap@infradead.org>,
 "Brian Gerst" <brgerst@gmail.com>, "Masahiro Yamada"
 <masahiroy@kernel.org>, "Willem de Bruijn" <willemb@google.com>, "Jason
 Xing" <kerneljasonxing@gmail.com>, "Paul Chaignon"
 <paul.chaignon@gmail.com>, "Lance Yang" <lance.yang@linux.dev>, "Jiayuan
 Chen" <jiayuan.chen@linux.dev>, "Emil Tsalapatis" <emil@etsalapatis.com>,
 "Ihor Solodrai" <ihor.solodrai@linux.dev>, "Barry Song"
 <baohua@kernel.org>, "Geliang Tang" <geliang@kernel.org>,
 linux-kernel@vger.kernel.org, bpf@vger.kernel.org,
 cgroups@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org,
 linux-kselftest@vger.kernel.org, "Hui Zhu" <zhuhui@kylinos.cn>
X-In-Reply-To: <769e80ffa618327ac03c13c4657e7229@kernel.org>