From patchwork Tue Jul 11 12:41:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Wu X-Patchwork-Id: 13308647 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C64E9C0015E for ; Tue, 11 Jul 2023 12:42:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3CCCE6B0071; Tue, 11 Jul 2023 08:42:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 37BAB6B0074; Tue, 11 Jul 2023 08:42:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 21C6B6B0075; Tue, 11 Jul 2023 08:42:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 0DFC66B0071 for ; Tue, 11 Jul 2023 08:42:26 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 5F2B4140215 for ; Tue, 11 Jul 2023 12:42:25 +0000 (UTC) X-FDA: 80999294250.16.7A0FCC6 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by imf02.hostedemail.com (Postfix) with ESMTP id 9642480006 for ; Tue, 11 Jul 2023 12:42:22 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=MQ5ty+Ms; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf02.hostedemail.com: domain of wuyun.abel@bytedance.com designates 209.85.210.172 as permitted sender) smtp.mailfrom=wuyun.abel@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689079343; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=dmg9w9P3JYlTE5YF/tdSGmQe9gMk9DKIlFnuajmtraM=; b=SkDkSp6x/NrwSzZIEeO5YCdWS8XJL+G/SKv9G0dOoGA/19/nJSvjhUjH80bOnlpaUcoLCL eHuFMAZAHZKPXjUaDibaKZiM4LalHwUoSAjgXEF/eJXdPvbU0scsdMW4EsPGxwotwE5tvw PMdIlwKBsQ/IXsDtZUVD8E5nrn/93hs= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=MQ5ty+Ms; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf02.hostedemail.com: domain of wuyun.abel@bytedance.com designates 209.85.210.172 as permitted sender) smtp.mailfrom=wuyun.abel@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689079343; a=rsa-sha256; cv=none; b=YqMKmoiFLl6E5+3BU7cp9TBH7+NplMYrJVjBNW+PELgz1ySlPUBN7PJqAhSsKVFACb8lHI /A1TPKcXboutVnxXWU6eSGf+FwlhpbvAk0eQaSa0OLPLi4BQjxtLcz6bZ2uGaudHCK2owt EZc5hoLdQ0jOr1Z8B2AG6shm9kuFCf4= Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-66767d628e2so3725813b3a.2 for ; Tue, 11 Jul 2023 05:42:22 -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=R2sQlONteFHm7ZQ/QAewX0PzH9Eq4irgV/tbNiZCshXDIGyAd0visipsTPqBMXCcGQ thXaylsmvXX/yFIdojiObel4CIDcSZ/ibdYdG1ymxash0r4Or4yjKLvFJDBG3XrsmSPr GccZZgKDZ2vvhoU4L6G0nXS4sMd1AZEbPj4ZoLxNea9OQor83YzVgoGD8enTT28yH0QN 7TORV930FFZEqHqMqwmRyikUGwyWPQljJDYB+t7hUvT6hCWWp3fP9SSMVGWVvEvB8k0b 7yYl2Vcqy+W4smBzdShzb47hijXwdppgjC3nqbZK0l4eCFTCT0RHmlCUVDz5DsATWy7S 6f6g== X-Gm-Message-State: ABy/qLaQyNBVzvu+kk9nlm2KWTVLvMn1csD5JmZwrVzoRPypMRSBS5pf iXTvY4UGDo7J8OMkwqEUOggFlQ== X-Google-Smtp-Source: APBJJlHySXBwiacKDORZhjNJUBjRrtdwMto4+SpJ1LfQJNYde55u+zkHIULuNxcqHK6dl79az4tI4A== 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 X-Rspamd-Queue-Id: 9642480006 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: h9t5e9ghcrioybq67pfx1pgi784zc9zs X-HE-Tag: 1689079342-182318 X-HE-Meta: U2FsdGVkX1+36AD67EmgvbdvzSVTywGreWfZYGwPcbAEhwjCZGNnayBvzWmDpV/7BtwuyaJgOfMLSHUYbv0loL1EOSp2CsctxsUZcz0uvLc9wDgPYKI5W25wiaqW0u2QWklWSqi0GEZQGfMT7Yg7LMkI3uIGXLlmB0N2HxVdKCBS4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Mu0XwsBKX7LaL7Iq7izdcXM5mgvdljz/zRa50= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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); /*