From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-188.mta1.migadu.com (out-188.mta1.migadu.com [95.215.58.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3F79B3BE646 for ; Mon, 8 Jun 2026 18:50:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780944605; cv=none; b=tAYDcYr0Nn9xw8l26P38+PGpbSoOPAUWjntqvrwR7ATijf6VeUIDJoTepRnHus18dM9dif7bOIMUBWqCxwyNfSvzRtgHCJybIOz5jV36Tle0kviBJdmchAL5w1DYerAXaoKZdQv5YoTd3tB0rIKJvLSx7SL5UcLakQ2zcIYGlP8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780944605; c=relaxed/simple; bh=LwfIz6iXR7NN2daStq7duJMR8t9kdvL5FmNgxj3mQ6c=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=V8bw4pZouC4qjUJGQtfBCIdp+A7EaqH22WKvakh2vrVE2FU+AKSiz4b82WYUKOzg0SIAHv1vvt8GO3gO30JPDX4mN3jzUaOovhHV7GOr3FXuzGwg2KzbEohYrX9cL1iNvLiwxZ78kmqJc5hJMH4v6JrsEu1tNIHgrZhNre9FljA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=YseYA4z0; arc=none smtp.client-ip=95.215.58.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="YseYA4z0" Message-ID: <750406a5-1819-4ca6-81d8-5a1d82e0644b@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1780944600; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y+Xv9Q4t+VBlyLKwVnG1Hwd1DVGfe/IlAI+bIJKn/kY=; b=YseYA4z0xkuimnZBzr7HwrTpuIwRhRMoR7nDDCVmtZEvN60r60+llojre6LHAPsMTuymtp YvcM76NKcaUybZAzzxK9JSMd3ArtO3Jf2tRugc7739wWDyiMx9wrEWlK16/d1X8zE5qIuI l6ZNEenxMW5xpCW6OVvZGK3AJcoHGy4= Date: Mon, 8 Jun 2026 19:49:45 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH 0/2] mm/vmpressure: reduce CPU, memory and code overhead on cgroup v2 To: Shakeel Butt Cc: Andrew Morton , david@kernel.org, linux-mm@kvack.org, hannes@cmpxchg.org, tj@kernel.org, mkoutny@suse.com, roman.gushchin@linux.dev, liam@infradead.org, linux-kernel@vger.kernel.org, ljs@kernel.org, mhocko@suse.com, rppt@kernel.org, surenb@google.com, vbabka@kernel.org, kernel-team@meta.com References: <20260606114158.3126210-1-usama.arif@linux.dev> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Usama Arif In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 08/06/2026 18:05, Shakeel Butt wrote: > On Sat, Jun 06, 2026 at 04:41:32AM -0700, Usama Arif wrote: >> The vmpressure subsystem has two distinct consumers, gated by the >> @tree argument: >> >> tree=false : in-kernel socket pressure, consumed by TCP/SCTP. This >> is cgroup v2 only; v1 sockets read memcg->tcpmem_pressure >> instead. > > We should really move v2 away from vmpressure. > >> tree=true : cgroup v1 userspace eventfd notifications via the >> memory.pressure_level / cgroup.event_control interface. >> v2 has no equivalent (userspace gets reclaim signals >> through memory.pressure / PSI, which doesn't touch >> vmpressure). >> >> So of the four (hierarchy, tree) combinations, only two carry data >> that anyone reads. The existing early return in vmpressure() covered >> v1 + tree=false; the symmetric v2 + tree=true case was falling through >> and doing the full lock / accumulate / schedule_work / parent-walk >> dance, even though the events list it eventually iterates is empty >> on cgroup v2 (vmpressure_register_event() is wired up only through the >> v1 cftype "memory.pressure_level" and can't be reached from a v2 >> memcg). >> >> Patch 1 extends the existing early return to also skip v2 + tree=true. >> On a v2-only host this eliminates a contended path where reclaimers >> can serialize on a single global sr_lock. bpftrace on a 176-core production >> host (cgroup v2, 285 memcgs, sustained reclaim) showed ~16,200 such calls >> per minute with tree = true. > > This is good. > Thanks! >> >> Patch 2 follows up with a cleanup: it splits the v1 userspace eventfd >> interface (struct vmpressure_event, the events list and its mutex, the >> work_struct and its handler, the parent walk, >> vmpressure_register_event / unregister_event, and vmpressure_prio) >> into a new mm/vmpressure-v1.c built only when CONFIG_MEMCG_V1=y, >> behind small no-op stubs in the header. mm/vmpressure.c keeps the >> shared bits and the tree=false socket-pressure path. The size of >> vmpressure.c goes down to half and the code is much more simpler. >> The only #ifdef CONFIG_MEMCG_V1 remaining in source is around the >> v1-only fields inside struct vmpressure itself. Memory savings on >> CONFIG_MEMCG_V1=n: >> struct vmpressure : 112B -> 24B >> struct mem_cgroup : 1664B -> 1536B > > For this, I am wondering if we should just go ahead and work towards making > vmpressure memcg-v1 only unless we foresee a lot of or complex work is needed > for that and only then patch 2 makes sense. > I think there might be a transition needed? Because vmpressure and PSI do not work out to be the same and people might notice a regression with increased memory usage or a hit in networking performance and might want to opt out? A solution might be to switch socket pressure to PSI while keeping vmpressure around gated by a defconfig. And then in a few releases remove it completely for cgroup v2 if no one complaints. If we go down that path, we would need patch 2 for the medium term.