From patchwork Thu Nov 26 04:30:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Education Directorate X-Patchwork-Id: 11932665 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83A12C56202 for ; Thu, 26 Nov 2020 04:30:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BCDE221973 for ; Thu, 26 Nov 2020 04:30:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rhGPry1K" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BCDE221973 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B46F06B006E; Wed, 25 Nov 2020 23:30:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AF72D6B0070; Wed, 25 Nov 2020 23:30:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9E6E26B0071; Wed, 25 Nov 2020 23:30:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0169.hostedemail.com [216.40.44.169]) by kanga.kvack.org (Postfix) with ESMTP id 86D716B006E for ; Wed, 25 Nov 2020 23:30:38 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 3A6908249980 for ; Thu, 26 Nov 2020 04:30:38 +0000 (UTC) X-FDA: 77525293356.07.cause72_03082282737c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin07.hostedemail.com (Postfix) with ESMTP id 1B4D31803F9AE for ; Thu, 26 Nov 2020 04:30:38 +0000 (UTC) X-HE-Tag: cause72_03082282737c X-Filterd-Recvd-Size: 5086 Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Thu, 26 Nov 2020 04:30:37 +0000 (UTC) Received: by mail-pf1-f195.google.com with SMTP id w202so487779pff.10 for ; Wed, 25 Nov 2020 20:30:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=yJUU5zPnHSa/d1ghamCaE7uTjS8uvSUcD1ZMgD7THn4=; b=rhGPry1KeO0XQ0Ea4f/caiPL961sC4KR0teOa1lj1z8nqG4Q+Kk8LV5csGg3/laz9o gYRJOclfnGxDC2r7An5IWleu35hQVt9zMKl9mFDAqEEFllgxACsoZl28mzM6JUdR61Hx Te1G5s/0LmkIZGYzsWW6mtnNvYBdTVm4ImQMsaNv7+d8kbiXom6KIoVh/ijSmYXoLZ5E wMYmxqOYRFDTrIxLWhcevWCqq6bmxi5+AgD862n6PUvuSnCnao9aCnqXmq3+rsacDUO0 haH1nKHbjyxxd7DJ/HRki6KyxjVC5TQisHtY4jP8r0eWg2zw8vtyq6kHi42s5oKvTLvl Rrjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=yJUU5zPnHSa/d1ghamCaE7uTjS8uvSUcD1ZMgD7THn4=; b=LbITk9hS1d+nENbYd0oy5XhRojF1ZYG/91CoIQPNbpqY4exacUV2VUt3xffxHiuuH8 FcpHI4u9XMQ8gcH3olzGhu8KUaKvPHJAPMw1kQgWu2Hl7yU/25Yt2bogIeYWgOCAqWV9 XvF3fg7NRScQ1U+8kr8stiHvf6iotDuea9TKz46F09URtqD7pGecsAWnwPSB7hetCJAD J3AMENbzBPlj3ijQYTx/YGRdwCce1S5JQ6OtDbCzzJjr8Asr77IfQPFoWBRMZEjMj9xL R767PW+GZgnY5uBUt/gypZ+Oei/ptFP+G5m8vxUqfpATp/BGgZWfj16OeZpHwxi5VmG3 jmAQ== X-Gm-Message-State: AOAM531cpcGWh3yjR90vtYqaODOX83Q3DbuBlSfIllucgiSSMRTjjXOq vzvEt0w+GC4bgKnOxSX+Taj0nuJon1bmrsfaVPM= X-Google-Smtp-Source: ABdhPJyuirVeyVuuiv0xqreJac51f5la0YThey08/8jvjK84QeskwgqAJterfSDn0rfgca2NWe6uRg== X-Received: by 2002:a17:90b:a4c:: with SMTP id gw12mr1425938pjb.96.1606365035764; Wed, 25 Nov 2020 20:30:35 -0800 (PST) Received: from localhost.localdomain (61-68-227-232.tpgi.com.au. [61.68.227.232]) by smtp.gmail.com with ESMTPSA id g3sm3256688pfr.145.2020.11.25.20.30.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 20:30:34 -0800 (PST) From: Balbir Singh To: linux-mm@kvack.org, mhocko@kernel.org Cc: hannes@cmpxchg.org, vdavydov.dev@gmail.com, Balbir Singh Subject: [PATCH] mm/list_lru: dont make them memcg aware if kmem is disabled Date: Thu, 26 Nov 2020 15:30:23 +1100 Message-Id: <20201126043023.377343-1-bsingharora@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 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: When alloc_super() allocates list_lrus for dentries and inodes they are made memcg aware if KMEM is compiled in, we should also check if kmem was disabled at runtime. This overhead is about 32 bytes extra per possible nodes per caller of list_lru_init() Signed-off-by: Balbir Singh --- include/linux/memcontrol.h | 6 ++++++ mm/list_lru.c | 9 +++++++++ mm/memcontrol.c | 9 +++++++++ 3 files changed, 24 insertions(+) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 4a4df9a23a8b..4285741a855d 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -1636,6 +1636,7 @@ static inline bool memcg_kmem_enabled(void) return static_branch_likely(&memcg_kmem_enabled_key); } +extern bool cgroup_kmem_disabled(void); static inline int memcg_kmem_charge_page(struct page *page, gfp_t gfp, int order) { @@ -1691,6 +1692,11 @@ static inline bool memcg_kmem_enabled(void) return false; } +static inline bool cgroup_kmem_disabled(void) +{ + return false; +} + static inline int memcg_cache_id(struct mem_cgroup *memcg) { return -1; diff --git a/mm/list_lru.c b/mm/list_lru.c index 5aa6e44bc2ae..478386aa9852 100644 --- a/mm/list_lru.c +++ b/mm/list_lru.c @@ -439,6 +439,15 @@ static int memcg_init_list_lru(struct list_lru *lru, bool memcg_aware) { int i; + /* + * Override memcg_aware here, otherwise callers + * will allocate memcg aware lru's and that wastes + * memory and the amount can scale with the number of + * nodes and caller contexts. + */ + if (cgroup_kmem_disabled()) + memcg_aware = false; + lru->memcg_aware = memcg_aware; if (!memcg_aware) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 15f2396f1605..8edf3ada8f4e 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -99,6 +99,15 @@ static bool do_memsw_account(void) return !cgroup_subsys_on_dfl(memory_cgrp_subsys) && !cgroup_memory_noswap; } +/* + * NOTE: This is not the logical opposite of what + * memcg_kmem_enabled() does + */ +bool cgroup_kmem_disabled(void) +{ + return cgroup_memory_nokmem; +} + #define THRESHOLDS_EVENTS_TARGET 128 #define SOFTLIMIT_EVENTS_TARGET 1024