From patchwork Sun Jun 25 14:28:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Wu X-Patchwork-Id: 13291999 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 1BEE9EB64DC for ; Sun, 25 Jun 2023 14:29:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1FB4E6B0071; Sun, 25 Jun 2023 10:29:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1ABDC6B0072; Sun, 25 Jun 2023 10:29:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 04CCF6B0074; Sun, 25 Jun 2023 10:29:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id E5ED26B0071 for ; Sun, 25 Jun 2023 10:29:22 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id B0CE9C04F8 for ; Sun, 25 Jun 2023 14:29:22 +0000 (UTC) X-FDA: 80941502964.13.55CAE49 Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com [209.85.210.46]) by imf29.hostedemail.com (Postfix) with ESMTP id 0723A120005 for ; Sun, 25 Jun 2023 14:29:19 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=eG2+tYqW; spf=pass (imf29.hostedemail.com: domain of wuyun.abel@bytedance.com designates 209.85.210.46 as permitted sender) smtp.mailfrom=wuyun.abel@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687703361; a=rsa-sha256; cv=none; b=7BK0YFeS+/WJC5GsuRJPMSpNQY9RUl/Cc9uIvFEc9haX2V4PV48Rjg70ZknTkzlBY7S0Cs WWK56XeaWKSauRBtzPl+JBC/NWLQT5R/lw/HRRF3+Xruj1wxgAxbjWk0LCOpqE6uAW3FoV yIgOk3ISrSKCKrGFz6GmH41Dlzk5va4= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=eG2+tYqW; spf=pass (imf29.hostedemail.com: domain of wuyun.abel@bytedance.com designates 209.85.210.46 as permitted sender) smtp.mailfrom=wuyun.abel@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687703361; 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=TGKSvilmZgPJXmejRM2lBTN0K9/2tgMZGylX16m+j6g=; b=34lpEc9C5Lyl+lIGDEXmgz3PX6W5pK3ZID35tdvj0sIu3xGlsBOm87KokF1DNvjdHjgQYa /blf3axtyvysXz5j1gKnvJ0BVUjVM+rlZKXgacE45vxlWp6enh6v7GdlP05RWE77j/s/a/ pfwmplGqieWdFr0B06g2uvzdhXpzsRQ= Received: by mail-ot1-f46.google.com with SMTP id 46e09a7af769-6b74b37fbe0so73344a34.1 for ; Sun, 25 Jun 2023 07:29:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1687703359; x=1690295359; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=TGKSvilmZgPJXmejRM2lBTN0K9/2tgMZGylX16m+j6g=; b=eG2+tYqWkPkRCKS2RqWlEWAPeVeLRLXmJgJx4B9MSOk2J+FsmkJeEiMFUA6KvpbbCr 89LyphI33da0F/giPdABa5kExZR8OYAsgy2vh6TTPohdM7/mDDY59lwOBYhzfAZGp30D 05pvyoXfP1v6weRD8GBJFn77jPCHxgvEBe4tRKrmVB99zADfpEQj9rgiQSB4nWZARxBJ iugI3imnns3+ApJ9CMskLtS5DWhnJubAU58LcP/z9QP9bpnq/Uer7js5m5TVx2r4pZLD 9dBPFp5TTAK7U6Hbyi7hFev30VCCcg47CUJ0RupDMTD90mAWngVaaxqxkRgiGVjgjUqd gIpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687703359; x=1690295359; 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=TGKSvilmZgPJXmejRM2lBTN0K9/2tgMZGylX16m+j6g=; b=c/IhCHo9gaAu4TDvEHOBJnyAkGA4tcd5VKjrERKh9ff+t4huRigRp26QJI758GscJZ 7CuxPxP32VZWlN2UXj3HbMiDn1jAGUE2WsnDb7nNeOwbikD4woD+cvhV9cHnrs5Zhf5j ilY2EDrojVYALNnow82KrlxRhAEBdvcZCmW/yAsjEqVn7PFQ/LFh7IviHJqbpehCptA7 F3FkR4ls9D+Ubymk0qZksk/THyR/1P+WHwisQa0wajYxxDgasfAG81iolDPvKmLqc55P oXJc3im3JdUwJDbKK3uuADGDPzf75mkRc3VQZmJoFF3n1lv7Zp83LaUhE8kYAxj2idze vlAQ== X-Gm-Message-State: AC+VfDyGbgmcF7/nWCol/L/o9kjN7pgvtDrsCzDDd112178U15cehMzh SWJEa0RCUt/qP49xwmjPvoYJsw== X-Google-Smtp-Source: ACHHUZ5ORDdc7sTEUz6Kzs7YToDfn6ptrUe/hYZt5RefjV2u7D3+JoGbfaDk2v3JXbuijopR6K45tQ== X-Received: by 2002:a05:6808:3098:b0:398:55ff:1fb8 with SMTP id bl24-20020a056808309800b0039855ff1fb8mr33372212oib.37.1687703358696; Sun, 25 Jun 2023 07:29:18 -0700 (PDT) Received: from C02DV8HUMD6R.bytedance.net ([203.208.167.146]) by smtp.gmail.com with ESMTPSA id 29-20020a17090a195d00b0025ef39c0f87sm2980744pjh.0.2023.06.25.07.29.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Jun 2023 07:29:18 -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 , Abel Wu , Kuniyuki Iwashima , Alexei Starovoitov , Martin KaFai Lau , Alexander Mikhalitsyn , Breno Leitao , David Howells , Jason Xing , Xin Long Cc: Michal Hocko , 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 net-next 1/2] net-memcg: Scopify the indicators of sockmem pressure Date: Sun, 25 Jun 2023 22:28:10 +0800 Message-Id: <20230625142820.47185-1-wuyun.abel@bytedance.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 0723A120005 X-Stat-Signature: 3sg5wuia3539itd5jfzi63nr9tb84upb X-Rspam-User: X-HE-Tag: 1687703359-710225 X-HE-Meta: U2FsdGVkX19Rrs6z+9715WjFRVvn1KVhnYf+2KaZbPQ11ZkAdT2KeuNI2pUsDj2HADHzVXq+Z+qZhYlnwawskbmtvPjnI+qcJQaP4h1Ixa7JSkSX0Qcb7TfMRpq2Q/U4sSp/q2MW0U11ImgRqQDKs8dAxPnYXZrNyTgirM50ypmlNeVDGoMNyOECsp683/Nnfg+Tt1Da2+uBKSqhTG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9id3MUyniA4C8oqXPcmwyFMpHdI1sbYJdTEvy6zfj5D7ILqwbBm3oO/ADA/KJqOdd/H7C+3pfEvQmZxlmgbQu6QoC9jrGxu7fVkT4BIETtS8IkuOPFgwcFdNmELdYOeTH8ZirMfWRjFwhApfXv/V1jVMJ5edfiX/e4opOfD13duzAdxUyf9fBfO4hTOgPmaWIqHX/W0QuBKC9DW2KIW5RphbT168e9keoCuVm5TtsWODGInNEh3AHhzcGQokpJwaheeio1nPg9MaUEWosuhonLASIqiIOWTbMAXIWTTrhVmM64foFDJDMC7yPCPOCAbfAlHy4fzz8sRFfxw53teKAylnBIdyi8xdl1Rc0RXg0sOC+219PVtZP6IWXzGDGJ+193GtF64bhFMyjqi+qD+FJ8IcSA7tU4oevkSs7iK72fF8JPzJ3alr8raM/TRtnUbME7PA4ZHlQlND3DwTZ7vev9Wzw72V25V8Swu95jH+F3D0CM3k0PKQ2c/PmTMkiXNxJnbFrHZR3jEeGgllHaYpHGkkw63O1+7LQAHZ/zAB2IJMzj9T3mTFDqNNdE+OaZLStRqBH++CWNHz87oRApwjj3bZD474HCVSykGC2CNepo1/7T8bgF3NhY8m2LqpQDhauwiNEE1SUqZgoJXMsXMS7kTR9KiUX6M+Lrjsofxpbl65q0s5awSuHPhBe44 40IjB9gY 6U8S8xjRD5BdaaDCzbhvL9HaIWNawB3tQ0tcZbYtSu7Bxc4RKywCkkHohvq9mW9gMuN2QJJ3jCDahgD90Ybhnv1JfFaGs8M8nfkyVApfsFW4qbv5dMcc3pIjYxHH6/X/cKtQPM7ELJS7dD4Zsw02y48MHKsTIpq1V1O3rtTPWje4r4exNChPUuqBRqQ7wNAOmJm1HkKRnmGtI5YrOLmLSNy1HbCp1xOoWcN2sULSgXtZSGlPUXIHSpdU1pZZ661kiatrE4aSTcGqGAm5YA4Y/1jPDN0SV6LTz04w8hPZE+I= 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 222d7370134c..9b1b536b4ec9 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -1743,8 +1743,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); /* From patchwork Sun Jun 25 14:28:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Wu X-Patchwork-Id: 13292000 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 701A7EB64DC for ; Sun, 25 Jun 2023 14:29:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BC04B6B0072; Sun, 25 Jun 2023 10:29:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B48ED6B0074; Sun, 25 Jun 2023 10:29:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9E9966B0075; Sun, 25 Jun 2023 10:29:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 908C06B0072 for ; Sun, 25 Jun 2023 10:29:39 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 64D69AFA7E for ; Sun, 25 Jun 2023 14:29:39 +0000 (UTC) X-FDA: 80941503678.01.AF50D80 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by imf14.hostedemail.com (Postfix) with ESMTP id 91B26100003 for ; Sun, 25 Jun 2023 14:29:37 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=R76JOrQ1; spf=pass (imf14.hostedemail.com: domain of wuyun.abel@bytedance.com designates 209.85.216.49 as permitted sender) smtp.mailfrom=wuyun.abel@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687703377; a=rsa-sha256; cv=none; b=PPvSGgrfKrV50JlF+fyO0un1FGYecjcTWKcl6U7Px1l9P78rsB2ZAkqHi6p0H9jKmzt7oz rR06gpVEc6+xQqqoQihpA92r/oiOXtKK9rWfUIclUBbNU2BabGZEsFbruh4veSee41ySnP 5SF2psXWvxfNtRbOm89/EnDYjXdqr3k= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=R76JOrQ1; spf=pass (imf14.hostedemail.com: domain of wuyun.abel@bytedance.com designates 209.85.216.49 as permitted sender) smtp.mailfrom=wuyun.abel@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687703377; 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:in-reply-to:references:references:dkim-signature; bh=VJ3Ti/D8S3EnbGsOdGwNu9kTjaPf3p14ktWAeREbOBA=; b=m01hJ5S1BWX7zwDB5wtY8ynboLWwodhzuTSHmlyugt1yCtlDFzzEyJBul3jy2+0M8iofhw 8vnoBFYeYcNCHrXeqqH9g+9m6xm/K55TLTgrQr7qcTqWkuRqYcqp83wj3nHePa8oyXUiMO JhpqC4ZEpu8NRmMmwlsVmJu9VmMZVCg= Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-262e839647eso356049a91.2 for ; Sun, 25 Jun 2023 07:29:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1687703376; x=1690295376; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VJ3Ti/D8S3EnbGsOdGwNu9kTjaPf3p14ktWAeREbOBA=; b=R76JOrQ1dPo/73QodWvkhogr6Xt3xbQEkJkqTXvgiKUM710so38qio0hXQtzJsCbye O64gRUD8e4b7zMBLCa8BCFkjiCVBuoelt8Lz44yLSCENsHauLJ5VAqcybrk7HI43XjZJ xw1A0f0eaZzKR/Ar36Kqyfhr3MjK8BgRBvHCT8PoFVrsUtlG8ClolFEc1xl4ajF7FpQ4 jG1bDDFxEkF4PmsG5MN5jtqcIgZemQAg42B1hTpu7CQnS5UpXJ+RqiyD5oKIhLIk3DKX 7lQZBR+vpTUq2cMa25g5g10YhFZV5+0w3BEdk2HvIp0mOd/DI175m+zpOf8KM/i3awwh RfiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687703376; x=1690295376; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VJ3Ti/D8S3EnbGsOdGwNu9kTjaPf3p14ktWAeREbOBA=; b=P2oOdeV7EhfA8vUxGZD7SGCIOsWGGJhe3OTjaMs6dtEJuC+aYl2y2gwNy1puTHyigV qBCfqrvT2Lzkpg+q/w/+u16rshbjBw1POrGTbJcG9/t5uIwzm+91/HoUn2fhlNkWe1Ac sDZcbUbfDA31voZHVsjblu64JkmLIYDtNeZ0t0o3dRhuwsDzL3PrTP7+IO7ZN913uIFa N+3EjzLwstG3K+P2TJHPpIzwkkGAINq0c4orUAEiwOQAhsYcOys/fIpPQ1TSkC4WdTsT m9vbG0ACNI0nONQ3kxYBUqQTJXITjQ54Yh5G+Bg6Q/896+ItplgcYgkii4/nXHa/jmG7 vXvQ== X-Gm-Message-State: AC+VfDx4is8kZGMfuvGWEZ6XWRCyq0E52NqZpPSnE4CHmjiBrLlBApya PyJvZiIhwl7dDbcYH0NdfQOR/w== X-Google-Smtp-Source: ACHHUZ4HqtHP/zbYUeJtO1vXlwl9dfUGTA5Z2y9D1QGuKBCZoms2r2/THr49mB8kg8U5Z9mw09DG5Q== X-Received: by 2002:a17:90b:4b4c:b0:25b:eeb3:adc4 with SMTP id mi12-20020a17090b4b4c00b0025beeb3adc4mr26482189pjb.15.1687703376138; Sun, 25 Jun 2023 07:29:36 -0700 (PDT) Received: from C02DV8HUMD6R.bytedance.net ([203.208.167.146]) by smtp.gmail.com with ESMTPSA id 29-20020a17090a195d00b0025ef39c0f87sm2980744pjh.0.2023.06.25.07.29.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Jun 2023 07:29:35 -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 , Yu Zhao , "Matthew Wilcox (Oracle)" , Kuniyuki Iwashima , Martin KaFai Lau , Alexander Mikhalitsyn , Breno Leitao , David Howells , Jason Xing , Xin Long Cc: Abel Wu , Michal Hocko , 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 net-next 2/2] net-memcg: Remove redundant tcpmem_pressure Date: Sun, 25 Jun 2023 22:28:11 +0800 Message-Id: <20230625142820.47185-2-wuyun.abel@bytedance.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20230625142820.47185-1-wuyun.abel@bytedance.com> References: <20230625142820.47185-1-wuyun.abel@bytedance.com> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 91B26100003 X-Stat-Signature: fa8eetz7en5hercwi67ty5yfj5ddbnb1 X-Rspam-User: X-HE-Tag: 1687703377-968872 X-HE-Meta: U2FsdGVkX19fbX0qXtrKOO2h9r5CR3yytj68kAEHgR91oqXfnRA3Wex7Eb9axzIyVnzEsvFG5f1x2rbjA6epViLiYjeMIvHfA7SeP/9pLflBh4sxE8oCOtFcwKTmVAksXQUrxwEwcjSqUK/Tl7B5BuPUPgFLQROiv6VfpptY6g4yitjnD3rG5rbCJ2B65A1KKAmq+PLBKh3uwMK96IZp0DOusEct+vvQeV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G7mGqMcSgVRTQjrtZ1lTbm0oQGxlk4kvBPiAbFtlZrm37rrRSn7kDY1srpMYzOq8IY98SM+Qg137PjTXewDWSxuD1xF7Lr8cEM6ZVzDbbaEjTc2yAub869+9ZMvMbpci7H7p7qjB92/YwOiIe68rHbZ8O19RIuX7p6y0DMJCnJ2lUSm+Z80AewTgh8dG4XD8r3Jg9WTKUBc8oSc96g1+QvVdJu842T+ZxWmdrTcwBBlgyYYYWi9vaDuxJpokjl0r6Z42w08WcMP58GFP3PZwFJ3MxjEIfssWuWifkTz/gpQLbOnuj2cpN1ZHPARjAnKuduXYDcaXtZPGNkrDWUBDLkXYaxOC8wybGjZ8IA7FmLpq0TXPeZTD7kss0IHixaGcT+bcaepWPz/tK+EELVhQmwd57jfwRrCC7BDUH9ku11Zwb01xgg8edLn/kFc0oPMDh6U6yPMZuVNGdVZfqujcRQfpimpPXyiafaR4lam5SM8BTKP2WvuT7wj/TEZOSQqOZu5OGcIY+Uwj1Ipu7XU11zpZPYd/jabv91UAEvLry9amLa/v2nXE0J0bxucqdUmqVT19T5OpWJaD+IUWb/JWUJ/luZ9k7n34wMoph50agNiWkLe3VvDyDfLlq4aWlL1cPZ1v6x/S0m80F373ahIdCGB8yPhhxiDfxnQVCJ2 X9ZZC2K5 DQ2w1L4mCb79ijhY/nxqlSdBOLOezSiTtVGa1lVAnfZPK22XyJRfVd6MwEBDOofbppVxPq+M56B4DDY70ai/y43iQw3xU37i5RurdF5FC6kP8bjlNFcyXL9xMT2no4iIOw2UHO0/SKhFUWur7PvcIrSCsxsxcqUdo2jk70WKGnZj42WN9TcJrvPQWQgxmJTI7Dmb5DyKqmJ7smjershpR2xGq0LmgH20DtjA5GoVXbRAZyov8PpMiTEZc3YN8atsbKcw7PVxlQdBV6jE/Az3fWinliYTVTLox/t4P56LGQpQ9WYjYRaY0+9bLdW4shDe 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: As {socket,tcpmem}_pressure are only used in default/legacy mode respectively, use socket_pressure instead of tcpmem_pressure in all kinds of cgroup hierarchies. Signed-off-by: Abel Wu --- include/linux/memcontrol.h | 3 +-- mm/memcontrol.c | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 9b1b536b4ec9..05e9fb5fa08d 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -288,7 +288,6 @@ struct mem_cgroup { /* Legacy tcp memory accounting */ bool tcpmem_active; - int tcpmem_pressure; #ifdef CONFIG_MEMCG_KMEM int kmemcg_id; @@ -1744,7 +1743,7 @@ 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)) - return !!memcg->tcpmem_pressure; + return !!memcg->socket_pressure; do { if (time_before(jiffies, READ_ONCE(memcg->socket_pressure))) return true; diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 4b27e245a055..76c4e5c6e558 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -7337,10 +7337,10 @@ bool mem_cgroup_charge_skmem(struct mem_cgroup *memcg, unsigned int nr_pages, struct page_counter *fail; if (page_counter_try_charge(&memcg->tcpmem, nr_pages, &fail)) { - memcg->tcpmem_pressure = 0; + memcg->socket_pressure = 0; return true; } - memcg->tcpmem_pressure = 1; + memcg->socket_pressure = 1; if (gfp_mask & __GFP_NOFAIL) { page_counter_charge(&memcg->tcpmem, nr_pages); return true;