Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp36846742rwd; Tue, 11 Jul 2023 06:30:41 -0700 (PDT) X-Google-Smtp-Source: APBJJlFnt7zKD9z8wOUguMtPFHLMS/YQOoj/+vVigWsS8i6pPEfelNi2fAyvmV21Z61IGcqAd/54 X-Received: by 2002:aa7:d052:0:b0:51e:2a56:91d6 with SMTP id n18-20020aa7d052000000b0051e2a5691d6mr13926243edo.19.1689082240836; Tue, 11 Jul 2023 06:30:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689082240; cv=none; d=google.com; s=arc-20160816; b=cJL1gs6gUEDFKe9NE0faGNgZnJyoulf+0muHDP8fpKlZK/RiKfkt89M64Mkgn3k45k /VVMTtXL+Vuc7RZPPkC3T9c2ZzRaKO0cYO0jYwIXn2cOGjMMCiOwRMb8ZQZ63nE7/qZG yNFM64X6BI448/H5SeO8J2+XqpQDnzkn+ZVFvxSIwry4wJBi4QAUGDLvPrriL55CxUsK bAB21/ShinUlzyOnXFMUIoJ3+UZHuFsUM6aDbXlLCzgkSXOv6yZURumItSh1l2MjcEzs mSQCtCACtNf46moCsatY0i0kH2z8CK/OQ5oEU4J4JWPC2bIJs8VShpldooXn96gBuSt0 wCvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=dmg9w9P3JYlTE5YF/tdSGmQe9gMk9DKIlFnuajmtraM=; fh=XbhlKJRa7JNhDgoO2uVs5JNmiT6lhAyKdnI7Usccxpc=; b=X/CTHz4ISpMq2vLAFEXN4+HneX5cV9CfsftA8OOT5gbnHk4t7pHK7BZ4n6xAwhlMgA 4vIgmh4HqAPm3L1egGS2ihKBUEp/XdLQ0knyZs+eqwDG3upcYMdf2rQ2bru82SW1V80t ISEQKD2tJq6TAITog/IzxDF5yAqWYZygqgjmdfRwQyLVw604q4jbP3Nu6xsQihKoGkc0 VDzYvrIhINQZLZ4UVU3rQZ7fOJOxspkgDWV3cO/5dbLEqD37+LP7nbGdDPnf9SNM9mw2 K/gnal/u1/HhgqKEQS4FqxfNqW2HWuAfODiTaJVaSa7pWdTN3/YAxa5ZsBeEEq6DOabF qKhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=MQ5ty+Ms; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m6-20020aa7d346000000b0051da389c522si2057806edr.610.2023.07.11.06.30.15; Tue, 11 Jul 2023 06:30:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=MQ5ty+Ms; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231309AbjGKMmr (ORCPT + 99 others); Tue, 11 Jul 2023 08:42:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229983AbjGKMmq (ORCPT ); Tue, 11 Jul 2023 08:42:46 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90B9DB8 for ; Tue, 11 Jul 2023 05:42:21 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-6687466137bso3740570b3a.0 for ; Tue, 11 Jul 2023 05:42:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1689079341; x=1691671341; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=dmg9w9P3JYlTE5YF/tdSGmQe9gMk9DKIlFnuajmtraM=; b=MQ5ty+Ms9xq2Gf8tT1u5KINp7LbCz3vSzcp6PPkar1PjXy2UOGDAONbcJWbI+E3Z1E ikZ8U8ait2Sr5BYSdZ0mnqv3UujdxGaHwIDateSlAtRLzEgup9mGA8YcL/qo1k0FBGy/ FtozdxhzC6z10cVS8YU1HM4+O48pgEHDp5kJRIJNhHnzy5o1QbbQV3vpzByt9eoJCZRF j8KrPcF99ChxD4ntqNGXPWk8MUCnNrtMqO4RYfasM8ZE8cbOScyeoYS5plADx8+31TVK GOG7vI2PVHSpTcdBFa0p7rhtBHE39/Z0gT8Ap6MdmyXF7tQb0/Zbshyqv+rLDj6qHTCL oBZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689079341; x=1691671341; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=dmg9w9P3JYlTE5YF/tdSGmQe9gMk9DKIlFnuajmtraM=; b=jY74HIVQ5IQDnSaTXdQ56mjarURkxhSQoh/EhbVn/TP82cuwARLwTgLZNHKQtqwRb6 8w3DF7QICkzlHL0Kv4EMsJ0yjWhXMZihXOIrnz21K/Ku/tYjyYZy1G6EiYkos0WTd6In FTKIOkJOgcIQ705q0JLr/LQ20X1WBlayxhu4DbLGwdOS/cbAa1sQ9lxfr20bOQ7eIXPp Rkl8SemEXtpAYBal3hcLKqmOH47cQYahE/wZGLoeRaFHSuTWqgfURM3CcPBWQEW4Mbl3 vGZU2bIBEe6+fm0K2lurNeNws++3kZVpcEZQAooHj2mv0OoC+LqbQSnlaHLp5O5NHwBb JwRw== X-Gm-Message-State: ABy/qLYhJrUF6Phea2vb/xJ/7alKmFm4cS8Utdw+3UiO3c1e7Qz73o10 3CyDi8fk5v1HxieJofcu89Anrw== X-Received: by 2002:a05:6a20:3948:b0:127:8833:cce3 with SMTP id r8-20020a056a20394800b001278833cce3mr15034530pzg.8.1689079341001; Tue, 11 Jul 2023 05:42:21 -0700 (PDT) Received: from C02DV8HUMD6R.bytedance.net ([203.208.167.147]) by smtp.gmail.com with ESMTPSA id d27-20020a63735b000000b0055c0508780asm1512222pgn.73.2023.07.11.05.42.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jul 2023 05:42:20 -0700 (PDT) From: Abel Wu To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , David Ahern , Yosry Ahmed , "Matthew Wilcox (Oracle)" , Yu Zhao , Kefeng Wang , Yafang Shao , Kuniyuki Iwashima , Martin KaFai Lau , Alexander Mikhalitsyn , Breno Leitao , David Howells , Jason Xing , Xin Long Cc: Abel Wu , Michal Hocko , Alexei Starovoitov , linux-kernel@vger.kernel.org (open list), netdev@vger.kernel.org (open list:NETWORKING [GENERAL]), cgroups@vger.kernel.org (open list:CONTROL GROUP - MEMORY RESOURCE CONTROLLER (MEMCG)), linux-mm@kvack.org (open list:CONTROL GROUP - MEMORY RESOURCE CONTROLLER (MEMCG)) Subject: [PATCH RESEND net-next 1/2] net-memcg: Scopify the indicators of sockmem pressure Date: Tue, 11 Jul 2023 20:41:43 +0800 Message-Id: <20230711124157.97169-1-wuyun.abel@bytedance.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now there are two indicators of socket memory pressure sit inside struct mem_cgroup, socket_pressure and tcpmem_pressure. When in legacy mode aka. cgroupv1, the socket memory is charged into a separate counter memcg->tcpmem rather than ->memory, so the reclaim pressure of the memcg has nothing to do with socket's pressure at all. While for default mode, the ->tcpmem is simply not used. So {socket,tcpmem}_pressure are only used in default/legacy mode respectively. This patch fixes the pieces of code that make mixed use of both. Signed-off-by: Abel Wu --- include/linux/memcontrol.h | 4 ++-- mm/vmpressure.c | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 5818af8eca5a..5860c7f316b9 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -1727,8 +1727,8 @@ void mem_cgroup_sk_alloc(struct sock *sk); void mem_cgroup_sk_free(struct sock *sk); static inline bool mem_cgroup_under_socket_pressure(struct mem_cgroup *memcg) { - if (!cgroup_subsys_on_dfl(memory_cgrp_subsys) && memcg->tcpmem_pressure) - return true; + if (!cgroup_subsys_on_dfl(memory_cgrp_subsys)) + return !!memcg->tcpmem_pressure; do { if (time_before(jiffies, READ_ONCE(memcg->socket_pressure))) return true; diff --git a/mm/vmpressure.c b/mm/vmpressure.c index b52644771cc4..22c6689d9302 100644 --- a/mm/vmpressure.c +++ b/mm/vmpressure.c @@ -244,6 +244,14 @@ void vmpressure(gfp_t gfp, struct mem_cgroup *memcg, bool tree, if (mem_cgroup_disabled()) 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. + */ + if (!cgroup_subsys_on_dfl(memory_cgrp_subsys) && !tree) + return; + vmpr = memcg_to_vmpressure(memcg); /* -- 2.37.3