From patchwork Fri Jul 9 00:05:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 12366347 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=-22.0 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT, USER_IN_DEF_DKIM_WL 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 B4688C07E96 for ; Fri, 9 Jul 2021 00:05:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4D75B61466 for ; Fri, 9 Jul 2021 00:05:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4D75B61466 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id F28FD6B006C; Thu, 8 Jul 2021 20:05:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ED9396B0070; Thu, 8 Jul 2021 20:05:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D7A0B6B0071; Thu, 8 Jul 2021 20:05:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0020.hostedemail.com [216.40.44.20]) by kanga.kvack.org (Postfix) with ESMTP id A468A6B006C for ; Thu, 8 Jul 2021 20:05:14 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id DD52382EDA62 for ; Fri, 9 Jul 2021 00:05:13 +0000 (UTC) X-FDA: 78341104506.27.08272CD Received: from mail-qt1-f202.google.com (mail-qt1-f202.google.com [209.85.160.202]) by imf12.hostedemail.com (Postfix) with ESMTP id 9311910000AB for ; Fri, 9 Jul 2021 00:05:13 +0000 (UTC) Received: by mail-qt1-f202.google.com with SMTP id 100-20020aed206d0000b029024ea3acef5bso4612106qta.12 for ; Thu, 08 Jul 2021 17:05:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=HcLnGXZfaeqCi0d4EsoaKKelu1NS9rMOMY3OT5HTNvs=; b=c+KFF36BFzAWbZ1ZqezCaWKkP9YnbQF8Z1exFWSQlGnsvkb6rwZgB5lPB6tZRCFSL/ 2e79NSQQsiyezU4RQCDxHfPlWsi6YTf1z98QAYFY+FNDZcHcFLisxhJYYm4MuhClcr0L iTSQFrSE/fJlNePefffT+DV0/KtGATS+VIhreboD6UhWQOtO+fHKucBKP4tNtAzuF6xN hRNEZI2oOI1CO5qUjzjj1hpxFivEdX9lLsZCgXvkSRwcRNX/xdPl8MChwTtLcO46X1eS 6fmZYbxdNiwjfzfpzpNsDnt2sAPjYdsxhv2xWGbbsMAsuE8RvJqEwhZ3g/XB/JdF/JD6 u4hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=HcLnGXZfaeqCi0d4EsoaKKelu1NS9rMOMY3OT5HTNvs=; b=bORRiKxTs0M3fcMtorCRwquDkQpDZ8npc6BYUfcIH/9anyIUnmIU+EopTuiRvEa62x A3iQdP5t/w4/eSj4dvW/yZl1VmtrCNqlY5jLH/tRsxdp/xlercb1Jw+Uhrdbkv76Ls8a LDTA8XQhXFOlPaq204bXlOvT0jSNP4BqVBXGVRmorfwHZUKi6sZxZEIc6edUEVrJUVrx ji2n7YxBfWDBWrklovJoxRO4lAAcVH8GsQImreANMaZ2Nphmr77y8T5AeabLQ1mL7UvG l6w3yMhFrigC+KWrh0HHeV4ENJcaBSJ/3N6YXwlI4q8mupMO7JOSwrwiwumqPc3VH4ou lFUA== X-Gm-Message-State: AOAM533JxjyKd+BoA7vLCetOOFztAKluzulKbp7yw9TtMHFM2svEjB5Z gC5LVKCIUrWHqG3RgzpAqpuQeRAlYA0= X-Google-Smtp-Source: ABdhPJxpJbxIb/dIrslIBgNbMwn5YMXFsuNdJZ78tyu+64fXmFt5F1yZxOQNBOstcwSLciAbleba+fdVpQ8= X-Received: from surenb1.mtv.corp.google.com ([2620:15c:211:200:7a7f:fa1f:71a4:365b]) (user=surenb job=sendgmr) by 2002:a05:6214:1c1:: with SMTP id c1mr23668712qvt.37.1625789112724; Thu, 08 Jul 2021 17:05:12 -0700 (PDT) Date: Thu, 8 Jul 2021 17:05:06 -0700 Message-Id: <20210709000509.2618345-1-surenb@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.32.0.93.g670b81a890-goog Subject: [PATCH 0/3] mm, memcg: Optimizations to minimize overhead when memcgs are disabled From: Suren Baghdasaryan To: tj@kernel.org Cc: hannes@cmpxchg.org, mhocko@kernel.org, vdavydov.dev@gmail.com, akpm@linux-foundation.org, shakeelb@google.com, guro@fb.com, songmuchun@bytedance.com, shy828301@gmail.com, alexs@kernel.org, alexander.h.duyck@linux.intel.com, richard.weiyang@gmail.com, vbabka@suse.cz, axboe@kernel.dk, iamjoonsoo.kim@lge.com, david@redhat.com, willy@infradead.org, apopple@nvidia.com, minchan@kernel.org, linmiaohe@huawei.com, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, kernel-team@android.com, surenb@google.com X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 9311910000AB Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=c+KFF36B; spf=pass (imf12.hostedemail.com: domain of 3uJLnYAYKCIk574r0ot11tyr.p1zyv07A-zzx8npx.14t@flex--surenb.bounces.google.com designates 209.85.160.202 as permitted sender) smtp.mailfrom=3uJLnYAYKCIk574r0ot11tyr.p1zyv07A-zzx8npx.14t@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Stat-Signature: x35kthun9jfcrae5aatg4qxijh7r4r4s X-HE-Tag: 1625789113-288738 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: Disabling memcgs on Android from kernel command-line because important due to new requirements for all vendors to share the same kernel config and because some vendors use memcgs while others don't. The ones who don't, have to disable memcgs via "cgroup_disable=memory" kernel command-line option and we would like to minimize the cost of disabling memcgs this way vs disabling CONFIG_MEMCG. This patchset is focused on minimizing performance costs of this option. When running pft test with memcgs disabled via CONFIG_MEMCG=n vs "cgroup_disable=memory" command-line option, we measured ~6% drop in the average pagefault/sec rate with stddev of ~2%. The results were obtained by running pft test 1500 times and averaging the results on an 8-core ARM64 Android device with system services stopped, performance governor and enabling only Big or Little cores in one test to minimize the noise. Using perf, a number of relatively high-cost areas were identified where extra operations can be minimized. The patchset consists of a number of optimisations gradually reducing this regression. Patches are applied incrementally while testing and recording the impact for each one: 6.01% with vanilla cgroup_disable vs CONFIG_MEMCG=n 3.87% after patch #1 adding mem_cgroup_disabled checks vs CONFIG_MEMCG=n 3.49% after patch #2 inlining mem_cgroup_{charge/uncharge} vs CONFIG_MEMCG=n 2.48% After patch #3 inlining swap-related functions vs CONFIG_MEMCG=n I kept them separate because they vary in their "impact vs readability cost" and I'm not sure which ones pass the acceptable threashold. Suren Baghdasaryan (3): mm, memcg: add mem_cgroup_disabled checks in vmpressure and swap-related functions mm, memcg: inline mem_cgroup_{charge/uncharge} to improve disabled memcg config mm, memcg: inline swap-related functions to improve disabled memcg config include/linux/memcontrol.h | 54 ++++++++++++++++++++++++++++++++++---- include/linux/swap.h | 26 +++++++++++++++--- mm/memcontrol.c | 52 +++++------------------------------- mm/swapfile.c | 2 +- mm/vmpressure.c | 7 ++++- 5 files changed, 86 insertions(+), 55 deletions(-)