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 5A92537B032 for ; Sat, 6 Jun 2026 11:42:14 +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=1780746136; cv=none; b=GTD/S3C983SlYMX0cZHqYiXMmHt2D8zNQ+2Ox4N1IapOSKW4aSqfiHA32ogjw/T0/li97unoPHcTseZHjjkTY/wBcEhOINVEIpwTPZ2WYpLJ4A3+FlZJtNn0AnF2mE7NhhQgkrJ4c6c85EScLSlFuE7p+Y1FmKaXu2HzlNfs4Xk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780746136; c=relaxed/simple; bh=5yxmcLq/tCH6kesRB9vbjX8rEt6h5g24XbaeQq3ZlvI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ien3r6z/vLids9vHDBbXEx+gMjq7dgrPQSAuihdE+/pTYDxkCZVfNl0Z9/BphV7VBfI/5FNbhFE+Of8iAD3iPZy2nmHaf9m/DdNNg1VPpXBVlTzPGYOwA5Er45iNRRimxeNKJEVslYJ0lL078omhIMcOlZVUK+mjvRaayx/heQ4= 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=UwI35iNn; 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="UwI35iNn" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1780746131; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=LXjmm9+ZvSlFJvfC2SPtLS5CK8YMB/c2K6dwL+Jj4J0=; b=UwI35iNnA4SH3IlinQwmGId/xrYwI4DKBtBSgf4Py4hWUGiO5ZRk0HFKOXfWKce1OzuaG0 HOCulQNOVifWQ/evGv8So4wJT/rCMBmTyyG1fxjSAiIA/vfNlSi7TufIsKkqn9Iu4WQx2P s52pEDBcwizSSZQaTC479XHAsP/xUCM= From: Usama Arif To: Andrew Morton , david@kernel.org, linux-mm@kvack.org Cc: hannes@cmpxchg.org, tj@kernel.org, mkoutny@suse.com, shakeel.butt@linux.dev, 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, Usama Arif Subject: [PATCH 0/2] mm/vmpressure: reduce CPU, memory and code overhead on cgroup v2 Date: Sat, 6 Jun 2026 04:41:32 -0700 Message-ID: <20260606114158.3126210-1-usama.arif@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT 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. 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. 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 Usama Arif (2): mm/vmpressure: skip tree=true accounting on cgroup v2 mm/vmpressure: split v1 userspace eventfd code into vmpressure-v1.c include/linux/vmpressure.h | 46 +++++- mm/Makefile | 2 +- mm/vmpressure-v1.c | 305 +++++++++++++++++++++++++++++++++++++ mm/vmpressure.c | 303 +++--------------------------------- 4 files changed, 364 insertions(+), 292 deletions(-) create mode 100644 mm/vmpressure-v1.c -- 2.52.0