From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA3213A8721 for ; Tue, 30 Jun 2026 16:07:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782835649; cv=none; b=MAdIPSqiRS6l4Lu4T4XjOPdy5wXhcHP6MEq35ucY3pIpPG58Pc3tN9eGF9US4LhXmEVsA0hoOnPBwo171ahzdzqJmec0GVEvp3vG7Waq/INIBDrGnVu1qJy/s1+cGE1diCXiYVBzzXIKDu2SABs+h8vQjOxwDxEOlfcZRStC0Tw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782835649; c=relaxed/simple; bh=XpybvT9fI9hhneSZAfs/yvU443hUHLVLhgL8vHIsgNY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qvkfrUpdNqvPYXFdRnYMhbhO3HkC1cuSOIKYnPH8GUz51qSpyD2l+dKCabriAZ1p0UHsd2mMOldrHKvmloFkhpUvHfNVFnUasv2GrdguWrtWeiah3AVfaHTD0g5WrAHx9C8T8f5KruIDsrA2kCg7sztgsfBu3jfztkaL9pGp7Bc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org; spf=pass smtp.mailfrom=cmpxchg.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.b=vBAKbuaK; arc=none smtp.client-ip=209.85.222.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.b="vBAKbuaK" Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-9217d13c276so340479785a.1 for ; Tue, 30 Jun 2026 09:07:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg.org; s=google; t=1782835645; x=1783440445; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=NGWPvsKd5xy7dR4RHMj1I0r7F9MdH0Syh6+XpRuoCxQ=; b=vBAKbuaKtk3gFsWbyLUrGVZQixMrfkOTprSq3IKtC4nadCQRbuaj80FTf8weDnNgOp tmbIo9jMcHlXhq890Fp4mDz7w/g4/znzItrePSXo6KDig6ThZRFnUeLHBVwGK18AGBYX 1fUS0YSeGZJsO1UZfRU9d40rKa3wKSpu8Ykd6D1TheeNUvX+AplhF9OJMcGai19XA7zg XCBtOOY6928eO0rH5TWyfcXXwG/CLTbU55rcvAmHA/K/XGPT2pNBecz7KYBhgB7Sd/ry JuNUkMJfL70+oDp5YsEdEnXnidTVew7WhbaHB0zunK8V7IzJQmkzpggEr6EH0G+yFPeK nTUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782835645; x=1783440445; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NGWPvsKd5xy7dR4RHMj1I0r7F9MdH0Syh6+XpRuoCxQ=; b=Az22w55qZpim9ZaAS8BSvT0yigYjYcfCnHi6wXDN3WWhYVhPaBvxYXi+/2O5AoHTAB Bbkt3dBOzfA1sZkZYpoZLbBHc3MIYs5NIzsGOy0RgIW8mgqWJ24RZW2j/XPvAvIvzh75 /LqFEfpudOsmcvfRTP1dWlDTeqRPvt+d6co3SSTHqklb8seT3BgsFVlAbaPwB2C989sF 8da81KxRz6OfSrXv3BSKHy0PcnPB1+aKB84kTzzx0u7CbGhl5T5S1iUMUvw4E5+qUzLa gHO//iD2rBDA7tKzH+u9RF+IF/B8aK4KSHaon8ZPgpz27bbVmPOW5xF+A6j2dw0x7lEy 9DlA== X-Forwarded-Encrypted: i=1; AFNElJ9nIGr7oJWkSAS0sIYLF5bQfynFdxJ+u653gLERqveqLhMg+5LEJZo4lBo8AFI6Ps3pRPn0qEvtHjVmYCM=@vger.kernel.org X-Gm-Message-State: AOJu0YyOQihiJ3rjbLEKT7/LLh6sFylckx9Q28hdWj3st5vT5YUcSU/P nO15jAIxZ1LJS46pLmk/pIgcoEhCEA6R7+PR2evDnioj1UTKZjOTd6shReO1AWvM2xI= X-Gm-Gg: AfdE7ck+soZsSpb6ebLdgeGH/Ad5ttHJE4blz3yudk+9ZuBJcvV6uL4AxgWArzS4IhU UTa/Aknf4WPLXocmvHglAxdGjeCP+m2xkgxHNUkgXuOb/MPdytUpKYP1ElDR6X12UBg4PQ0p5rZ 8pM5ipT2a3gyKjfeimfFI+wODD4KonsXNVr4kEJayu2/hyaZezjYsQD/+mL4P9iMoNc+Q/toW87 gD269fXx/fPexoMJVak7wGt/oDDex1n6MVcH3Gyhg1Vam1fTx7ydcOykNtq2+lrNL2acXGM1w/9 wfqP+0w+g62/Jq1ZZmTSATRBsFxj9rerAQKpB91u9dEgGAJrmvYQuBYuDzzljSgoVSoo4VUUFHt ZsX3fWF4lGQXYeM5iMoQ+BRhyq92YP7Mv/51ud/P/eClmZ/m2OhXn56a53H29UKuTsTVrIO5wgT npqy/JCJtmiRs= X-Received: by 2002:a05:620a:4493:b0:92b:6805:91a9 with SMTP id af79cd13be357-92e62ab75e6mr685496985a.65.1782835639247; Tue, 30 Jun 2026 09:07:19 -0700 (PDT) Received: from localhost ([2603:7001:f100:500:365a:60ff:fe62:ff29]) by smtp.gmail.com with ESMTPSA id af79cd13be357-92e6213b953sm269848585a.2.2026.06.30.09.07.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2026 09:07:18 -0700 (PDT) Date: Tue, 30 Jun 2026 12:07:17 -0400 From: Johannes Weiner To: Usama Arif Cc: Andrew Morton , david@kernel.org, linux-mm@kvack.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 Subject: Re: [PATCH v3 1/2] mm/vmpressure: skip tree=true accounting on cgroup v2 Message-ID: References: <20260630112617.1198623-1-usama.arif@linux.dev> <20260630112617.1198623-2-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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260630112617.1198623-2-usama.arif@linux.dev> On Tue, Jun 30, 2026 at 04:23:32AM -0700, Usama Arif wrote: > vmpressure() has two outputs gated by the @tree argument: > > @tree=false drives in-kernel socket pressure (mem_cgroup_set_ > socket_pressure), consumed by TCP/SCTP. This only > applies on cgroup v2; on v1 socket memory is charged > separately via tcpmem and the consumer reads > memcg->tcpmem_pressure instead. > > @tree=true drives userspace eventfd notifications via the v1 > memory.pressure_level / cgroup.event_control interface. > v2 has no equivalent: userspace gets reclaim signals > through memory.pressure (PSI), which does not touch > vmpressure. > > The existing early return covered v1 + @tree=false. The symmetric > v2 + @tree=true case was falling through and doing the full lock / > accumulate / schedule_work / parent-walk dance for an events list > that can never be populated. bpftrace on a 176-core production host > (cgroup v2, CONFIG_MEMCG_V1=n, 285 memcgs, sustained reclaim) showed > ~16,200 @tree=true vmpressure() calls per minute. Add an early return > that skips cgroup v2 + tree = true which avoids us doing all this work. > On a v2-only host this also eliminates a lock contention path that can > serialise reclaimers on a single global sr_lock. > > Acked-by: Shakeel Butt > Signed-off-by: Usama Arif > --- > mm/vmpressure.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/mm/vmpressure.c b/mm/vmpressure.c > index f053554e5826..c82cee1ab43b 100644 > --- a/mm/vmpressure.c > +++ b/mm/vmpressure.c > @@ -246,11 +246,13 @@ void vmpressure(gfp_t gfp, int order, struct mem_cgroup *memcg, bool tree, > return; > > /* > - * The in-kernel users only care about the reclaim efficiency > - * for this @memcg rather than the whole subtree, and there > - * isn't and won't be any in-kernel user in a legacy cgroup. > + * Only two combinations have a consumer: > + * cgroup v2 + tree=false -> in-kernel socket pressure > + * cgroup v1 + tree=true -> userspace eventfds (memory.pressure_level) > + * Skip the other two: nothing consumes the result. > */ > - if (!cgroup_subsys_on_dfl(memory_cgrp_subsys) && !tree) > + if ((!cgroup_subsys_on_dfl(memory_cgrp_subsys) && !tree) || > + (cgroup_subsys_on_dfl(memory_cgrp_subsys) && tree)) > return; I had already acked this one, with a half serious suggestion to make this if (cgroup_subsys_on_dfl(memory_cgrp_subsys) == tree) return; Anyway, no strong feelings. If nobody agrees, Acked-by: Johannes Weiner