From mboxrd@z Thu Jan 1 00:00:00 1970 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=-23.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,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 35F64C07E9A for ; Mon, 12 Jul 2021 15:55:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B2D8D61221 for ; Mon, 12 Jul 2021 15:55:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B2D8D61221 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 708266B0092; Mon, 12 Jul 2021 11:55:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6DF986B00A1; Mon, 12 Jul 2021 11:55:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5A7F96B00AB; Mon, 12 Jul 2021 11:55:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0064.hostedemail.com [216.40.44.64]) by kanga.kvack.org (Postfix) with ESMTP id 3334D6B0092 for ; Mon, 12 Jul 2021 11:55:13 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 4A4F3824999B for ; Mon, 12 Jul 2021 15:55:12 +0000 (UTC) X-FDA: 78354384864.05.C47C8AD Received: from mail-yb1-f179.google.com (mail-yb1-f179.google.com [209.85.219.179]) by imf03.hostedemail.com (Postfix) with ESMTP id 0589630002DB for ; Mon, 12 Jul 2021 15:55:11 +0000 (UTC) Received: by mail-yb1-f179.google.com with SMTP id i18so29666961yba.13 for ; Mon, 12 Jul 2021 08:55:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=+R+buwilcZJPqYitjTRHvClHpz5qW+7Zf9f3EMnGV/A=; b=hWvlM8rao4P3XGZzXkW/CYN7nJSLsBhLSfupdLB5AO4qrn9z8yU7lpr8/r4p/673D6 /84v/MB7BpZbegwEzPtqiOm9hiaTI/lfnQbByU0WqKSQ/gpJF4rM3bt2GRnE3GshSpus T1tCCsMBfLcsieo7Rq4IYZxBCPFqZiXITsFIAS9L9EA9z8mA+JScy9XTDpeJ8m67VRyT 6tLWTeoTNFClUrp/K1/7BgZJSU5pd47rmVOxKwmSvSMeQkalxfJ6AfI130ptNl2BZIfB VjN5D7QfyGWhr/Etgc6eqMMtpZNDWZzhkIZ8IfsEOnEFdKSDUOf0UQaOBmzwiMQDqTzO jzew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=+R+buwilcZJPqYitjTRHvClHpz5qW+7Zf9f3EMnGV/A=; b=K/Xh2EdCLhnhzt1JU46flwd9J0r7zPcyJmBfm4SjlyeoLihU00LxhvFCW3ppTQsIiN 7XQvx4IyuGzUxe0ZvnE5+KrS/LIveBB1TSfVZ6ydwCmF5nElE00QuRb1yE4hX1/817on vNyuI+dsJpshSA7gueWL8vQXZaZt4DnfV+/G1XUa5xEgF2FepTpd22gFZSBWilNaejvq oE6JOL2OWa041nEC3K7vS7EaynvbKz1+bSaNkHhPhrnNEfhIGTTEH585pGqOLNU8D64Z MfuzBTpmFqSUmaZZ9x4U/ZpZhtCBccpNL+E0CXJBjepKAN30VxQTHpL82mq75vCBfkQ/ gHFw== X-Gm-Message-State: AOAM531f71LSElSP0/LCRQfV5FnG65V3Y3kIxB9qJLQh6Ui7xWOvwcQl 8p6w0y7eFRPK9N5OcgCPoMLOjSQUJFN52kXiukvGuw== X-Google-Smtp-Source: ABdhPJwYCwwkIxqyAnX/UFeRx6Wa0DRpesQ2VcFQV1sU270R6xtrFjabQwm5pRt/7PtBPpTZjZNbnupdWJEbiVrHeqg= X-Received: by 2002:a25:4102:: with SMTP id o2mr62993247yba.23.1626105311117; Mon, 12 Jul 2021 08:55:11 -0700 (PDT) MIME-Version: 1.0 References: <20210710003626.3549282-1-surenb@google.com> In-Reply-To: From: Suren Baghdasaryan Date: Mon, 12 Jul 2021 08:55:00 -0700 Message-ID: Subject: Re: [PATCH v3 1/3] mm, memcg: add mem_cgroup_disabled checks in vmpressure and swap-related functions To: Michal Hocko Cc: Tejun Heo , Johannes Weiner , vdavydov.dev@gmail.com, Andrew Morton , Shakeel Butt , Roman Gushchin , songmuchun@bytedance.com, Yang Shi , alexs@kernel.org, richard.weiyang@gmail.com, Vlastimil Babka , Jens Axboe , Joonsoo Kim , David Hildenbrand , Matthew Wilcox , apopple@nvidia.com, Minchan Kim , Miaohe Lin , LKML , cgroups mailinglist , linux-mm , kernel-team Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 0589630002DB X-Stat-Signature: dd11ojxkiaoehangx9ppthyg1d4xy7yx Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=hWvlM8ra; spf=pass (imf03.hostedemail.com: domain of surenb@google.com designates 209.85.219.179 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (policy=reject) header.from=google.com X-HE-Tag: 1626105311-723014 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: On Mon, Jul 12, 2021 at 12:11 AM Michal Hocko wrote: > > On Fri 09-07-21 17:36:24, Suren Baghdasaryan wrote: > > Add mem_cgroup_disabled check in vmpressure, mem_cgroup_uncharge_swap a= nd > > cgroup_throttle_swaprate functions. This minimizes the memcg overhead i= n > > the pagefault and exit_mmap paths when memcgs are disabled using > > cgroup_disable=3Dmemory command-line option. > > This change results in ~2.1% overhead reduction when running PFT test > > What is PFT test? Christoph Lamenter=E2=80=99s pagefault tool (https://lkml.org/lkml/2006/8/29/294). I'll add the link in the description for clarity. > > > comparing {CONFIG_MEMCG=3Dn, CONFIG_MEMCG_SWAP=3Dn} against {CONFIG_MEM= CG=3Dy, > > CONFIG_MEMCG_SWAP=3Dy, cgroup_disable=3Dmemory} configuration on an 8-c= ore > > ARM64 Android device. > > > > Signed-off-by: Suren Baghdasaryan > > Reviewed-by: Shakeel Butt > > Acked-by: Johannes Weiner > > Acked-by: Michal Hocko Thanks! > > Thanks! > > > --- > > mm/memcontrol.c | 3 +++ > > mm/swapfile.c | 3 +++ > > mm/vmpressure.c | 7 ++++++- > > 3 files changed, 12 insertions(+), 1 deletion(-) > > > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > > index ae1f5d0cb581..a228cd51c4bd 100644 > > --- a/mm/memcontrol.c > > +++ b/mm/memcontrol.c > > @@ -7305,6 +7305,9 @@ void mem_cgroup_uncharge_swap(swp_entry_t entry, = unsigned int nr_pages) > > struct mem_cgroup *memcg; > > unsigned short id; > > > > + if (mem_cgroup_disabled()) > > + return; > > + > > id =3D swap_cgroup_record(entry, 0, nr_pages); > > rcu_read_lock(); > > memcg =3D mem_cgroup_from_id(id); > > diff --git a/mm/swapfile.c b/mm/swapfile.c > > index 1e07d1c776f2..707fa0481bb4 100644 > > --- a/mm/swapfile.c > > +++ b/mm/swapfile.c > > @@ -3778,6 +3778,9 @@ void cgroup_throttle_swaprate(struct page *page, = gfp_t gfp_mask) > > struct swap_info_struct *si, *next; > > int nid =3D page_to_nid(page); > > > > + if (mem_cgroup_disabled()) > > + return; > > + > > if (!(gfp_mask & __GFP_IO)) > > return; > > > > diff --git a/mm/vmpressure.c b/mm/vmpressure.c > > index d69019fc3789..9b172561fded 100644 > > --- a/mm/vmpressure.c > > +++ b/mm/vmpressure.c > > @@ -240,7 +240,12 @@ static void vmpressure_work_fn(struct work_struct = *work) > > void vmpressure(gfp_t gfp, struct mem_cgroup *memcg, bool tree, > > unsigned long scanned, unsigned long reclaimed) > > { > > - struct vmpressure *vmpr =3D memcg_to_vmpressure(memcg); > > + struct vmpressure *vmpr; > > + > > + if (mem_cgroup_disabled()) > > + return; > > + > > + vmpr =3D memcg_to_vmpressure(memcg); > > > > /* > > * Here we only want to account pressure that userland is able to > > -- > > 2.32.0.93.g670b81a890-goog > > -- > Michal Hocko > SUSE Labs