From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f41.google.com (mail-qv1-f41.google.com [209.85.219.41]) (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 6FB22426EB6 for ; Mon, 29 Jun 2026 16:46:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782751613; cv=none; b=tUIqLGjf/2uKwvB1qTwrQGmpXpNdBJKdaEOYTSltk8BkAytlsYfOUeD5H34DxOrPNGnvClDaXvzHWR9WMoJd1lv6uTZAB+Gc0+wPDTw0bAlKgo+naU01xSZBPM1y1jwj8Jlr/0FSy67DTbFDpEsO9F9Ok9rtTp8d+0YKUqGG3sw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782751613; c=relaxed/simple; bh=ptq7Syil39hVyfMYJ48eR9dJk5CwLCr5yU3GHoVLfYI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=jRUPJ06GT7BoiNnYYY+J57FwOOqz94QXG9abx8ngUEkrgp5NsR4vjtXnHEFtpzFSuniP6BvKmTlM7XkWeDynvK8BeJX0KlzxZw+YnKf8V/bh75l45TUCwqN5QfgrArzyPrxyYh+/KosybdzbPeuZBe4BbtI7qXZkU2SJR5noOPk= 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=PgBLFNE4; arc=none smtp.client-ip=209.85.219.41 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="PgBLFNE4" Received: by mail-qv1-f41.google.com with SMTP id 6a1803df08f44-8ee43b3e5abso19798046d6.3 for ; Mon, 29 Jun 2026 09:46:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg.org; s=google; t=1782751610; x=1783356410; 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=QLTKwJp3RBteUfuxO7WvjdZmuJysuHNgbxLJdR4kETU=; b=PgBLFNE4A8KyaPDU9yyi2SXskYEKAUpg9WmfDVXwJV4Q3ErIfEavmJoGSty+rx8KEJ qxChNTqwlxEPdxqabag4ujwwYl1PqqR3xqOJ1H21d232bDv2JeQI3pNMx4sHgvr0cUwa yoV6o6nFs6Dgm0qGIKKTLAHJ94UApz6Hjv8wGjiwa4xL7QuQ14WNWOlthwqM4LnoQkYf z1wrYcznZcKQgr9LjzXkSazUQhbZoruOLAWBUgp3pJyr6B2fByw9VtFFPBF/BZHhCxJn 9vz00FnA+81nIlzKxLWx/n4ehbZHS9J18mBHsCiVZi1inr55dX3LPeLxQzOgHShbZM+F 7eqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782751610; x=1783356410; 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=QLTKwJp3RBteUfuxO7WvjdZmuJysuHNgbxLJdR4kETU=; b=Qgh2mB0XJwLEz5JgGOBBe3YRGgxjYFTUX5m1oHTpgCLQQzuDn7q0qjlJKB0YTgSV+o sd2pp7Ro/tfEtTtpg8iB9nX2m2pP3S57ndqo+wXCD2AdaoKedfjcvfGydsGfAaf35gx+ JW9KiOcVt6KJp5ZGjoX7rOFQ2YEpfNINApgzmRkSLQd8LcSjy00iAj8kZ8d8XOw5Mv92 /ufvcxHoW6cTRfHyZ3UiCGJOvu4/qa7ZfPGHSSKVhal4K54HDG+UoS1VPPbFIyBEQ6C4 4t8UYhc2nEDyqUYmhHDXEyr9/t+46NL1PpqWjlGCyKCDgpbaYBg6WLJLN52ALmRuHzbU HGcA== X-Forwarded-Encrypted: i=1; AHgh+Rq57cITA2tkrm7e4Q0+rIyE/Y+yeTW29IZP0eDuEMaD/pNeDMKUJbZKNf3whlHhDL89bDs32EQ1n4D9YuA=@vger.kernel.org X-Gm-Message-State: AOJu0Yxe+2OZzpWbhLcU/L2zmEtDbGO6RBaPq0OO8RD3PAlImGINQUDg Tx5PcKTQTAoWIeqRZN0ctCAHpQmyI/bchzMQZX5pEKuViINFJ3y5uZ3ao/2Kh9GVQdV0/3CN9W1 Tz3RUOQI= X-Gm-Gg: AfdE7clZfB0Mc+XabMU3QIbuTSolsO2PQaDgcydH0fid46UMdcn5/lrwOX4o5PsSGGg z0hzeBG6SwL+lRwTkLAeS31DAZvc+JkgJZvMP42IknVvTaoUXUqZzjR0YMi99HK0e5zoFbBVL3/ YpDxyuCMFTdKF04EBaCr2ZsXs0k6ezYnglK8aE1S/S99cS/Q4A45Pt/prbqGA9bVdG0q/07j8Ys yqUfy+CX1z8ko2+G+taIBCTDzyrv9TGj7ghf9TupHX5JxhFDsa5pQL5BRblcZbBRFCuZDsI9wYp 1k8Z5P1s8y3C37kd0+MvhcjS53AxHE3bt8H1vFLRbhBKNottNZchYAADywRcClSS42B80z1OK8v c1g4xoEveNrhIvzjBjbRSpjicFkTx3IkQFyLIQxf1QoyQ3yJof2/6D9ycwYtx+QHnobDhkH3cKW yB++7Ei2yIyTGzoYv9DsVp8w== X-Received: by 2002:a05:6214:2f0c:b0:8ea:fb8c:2e0a with SMTP id 6a1803df08f44-8f1bb32d8camr916936d6.28.1782751610148; Mon, 29 Jun 2026 09:46:50 -0700 (PDT) Received: from localhost ([2603:7001:f100:500:365a:60ff:fe62:ff29]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8f1a3580949sm2835136d6.21.2026.06.29.09.46.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2026 09:46:49 -0700 (PDT) Date: Mon, 29 Jun 2026 12:46:45 -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 v2 1/2] mm/vmpressure: skip tree=true accounting on cgroup v2 Message-ID: References: <20260629130042.2649505-1-usama.arif@linux.dev> <20260629130042.2649505-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: <20260629130042.2649505-2-usama.arif@linux.dev> On Mon, Jun 29, 2026 at 05:59:36AM -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 Acked-by: Johannes Weiner > --- > 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; if (cgroup_subsys_on_dfl(memory_cgrp_subsys) == tree) return;