From patchwork Wed Dec 2 18:27:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 11946705 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 6D8DAC71155 for ; Wed, 2 Dec 2020 18:28:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DD74022249 for ; Wed, 2 Dec 2020 18:28:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DD74022249 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 46F6C6B0071; Wed, 2 Dec 2020 13:28:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3CD426B0072; Wed, 2 Dec 2020 13:28:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 26E386B0073; Wed, 2 Dec 2020 13:28:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0061.hostedemail.com [216.40.44.61]) by kanga.kvack.org (Postfix) with ESMTP id 0F7886B0071 for ; Wed, 2 Dec 2020 13:28:02 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id BEF4E1EFD for ; Wed, 2 Dec 2020 18:28:01 +0000 (UTC) X-FDA: 77549176362.20.party71_4c0ba14273b5 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin20.hostedemail.com (Postfix) with ESMTP id A3CE1180C07AB for ; Wed, 2 Dec 2020 18:28:01 +0000 (UTC) X-HE-Tag: party71_4c0ba14273b5 X-Filterd-Recvd-Size: 4804 Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Wed, 2 Dec 2020 18:28:01 +0000 (UTC) Received: by mail-pj1-f65.google.com with SMTP id o7so1438296pjj.2 for ; Wed, 02 Dec 2020 10:28:00 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=nkAj+kfHLpRV/jrsXiaGZp9Y0zC5JrRi0VSe75y5/ok=; b=mFFs1yr0iQTTA94bdtdkPFC5iIeeiXvamHuI6dQajmLDW8uGAAoqBp0Lco3wkWfx9X XgJ97GBMEc2SMDjQPCj+a5M07Gh39FRvnOmmvwjmF1+esdeCTOYDHpJ9B1vdKIIVhiVL cxZ2ENAG7T2UE3wDBTh1PYjNJRdmB1+Y/KukMvEL/zwL7J/XVwCcZaZBJC+zR5/xVc52 ELrSZNt13NL5slziBmuUUaYzyR3dBL0T55R1IcembCzKHT+z/H8uz5Swh1XykgYqXNxo H840U2OiFmjZnLoc2uPad4qAR41nfo846N8h8Fd5P2oP2YpqAVUTqJuvqR2XhfmcJ5VI CvnQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=nkAj+kfHLpRV/jrsXiaGZp9Y0zC5JrRi0VSe75y5/ok=; b=BZYN2ZSk4LNSvCSsPSk3Wh420YJAIX64jxr9luqGKxee/x+pAHLD4zwyrgXdtWjAvR OdGwmTdx17qcj2PCNMmZy524EZrPtyKDQz/muCRnGidR9KgY8lzwYd8aHY+eV2lotvvo VcAP9NJ1ECgvOfbvYJK+9+0VaPTlynFr+sfw+KAizZD8I+sII3DbNSBkaPyKverM0YdL ler7kXBNJ8jqPv3gFM2xztz0+PkAMxGyLsRmiZCTpJ0M53tfEQxMTp3KJKF1y3bA48hw v+Ph1fVI3or9OuPfxVzg7gysI6yWGd9gwRyhS0fJW8Ur6QN9CD8FrqETILA3kpsm1s3P iwXA== X-Gm-Message-State: AOAM531tWQKsoSPCzmpRgH7dEvKmuA268cpRRCSHIdA+i1b6DGCHwWjx hmaOnT7C/jqORh1NS/Befvg= X-Google-Smtp-Source: ABdhPJysUUGeVaOYuNGBSl2GIw5j+IQLduO6JMDdjjacV2utahIR7URRPrC/8JjUx772SiJV7yEvWw== X-Received: by 2002:a17:90b:1945:: with SMTP id nk5mr1107509pjb.30.1606933680300; Wed, 02 Dec 2020 10:28:00 -0800 (PST) Received: from localhost.localdomain (c-73-93-239-127.hsd1.ca.comcast.net. [73.93.239.127]) by smtp.gmail.com with ESMTPSA id c6sm396906pgl.38.2020.12.02.10.27.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2020 10:27:59 -0800 (PST) From: Yang Shi To: guro@fb.com, ktkhai@virtuozzo.com, shakeelb@google.com, david@fromorbit.com, hannes@cmpxchg.org, mhocko@suse.com, akpm@linux-foundation.org Cc: shy828301@gmail.com, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 7/9] mm: vmscan: don't need allocate shrinker->nr_deferred for memcg aware shrinkers Date: Wed, 2 Dec 2020 10:27:23 -0800 Message-Id: <20201202182725.265020-8-shy828301@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201202182725.265020-1-shy828301@gmail.com> References: <20201202182725.265020-1-shy828301@gmail.com> 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: Now nr_deferred is available on per memcg level for memcg aware shrinkers, so don't need allocate shrinker->nr_deferred for such shrinkers anymore. Signed-off-by: Yang Shi --- mm/vmscan.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index d569fdcaba79..5fd57060fafd 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -420,7 +420,15 @@ unsigned long lruvec_lru_size(struct lruvec *lruvec, enum lru_list lru, int zone */ int prealloc_shrinker(struct shrinker *shrinker) { - unsigned int size = sizeof(*shrinker->nr_deferred); + unsigned int size; + + if (is_deferred_memcg_aware(shrinker)) { + if (prealloc_memcg_shrinker(shrinker)) + return -ENOMEM; + return 0; + } + + size = sizeof(*shrinker->nr_deferred); if (shrinker->flags & SHRINKER_NUMA_AWARE) size *= nr_node_ids; @@ -429,26 +437,18 @@ int prealloc_shrinker(struct shrinker *shrinker) if (!shrinker->nr_deferred) return -ENOMEM; - if (shrinker->flags & SHRINKER_MEMCG_AWARE) { - if (prealloc_memcg_shrinker(shrinker)) - goto free_deferred; - } - return 0; - -free_deferred: - kfree(shrinker->nr_deferred); - shrinker->nr_deferred = NULL; - return -ENOMEM; } void free_prealloced_shrinker(struct shrinker *shrinker) { - if (!shrinker->nr_deferred) + if (is_deferred_memcg_aware(shrinker)) { + unregister_memcg_shrinker(shrinker); return; + } - if (shrinker->flags & SHRINKER_MEMCG_AWARE) - unregister_memcg_shrinker(shrinker); + if (!shrinker->nr_deferred) + return; kfree(shrinker->nr_deferred); shrinker->nr_deferred = NULL;