From patchwork Mon Dec 14 22:37:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 11973299 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 687B4C4361B for ; Mon, 14 Dec 2020 22:37:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1889E22509 for ; Mon, 14 Dec 2020 22:37:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1889E22509 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 AD6686B0072; Mon, 14 Dec 2020 17:37:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A3A0B6B0073; Mon, 14 Dec 2020 17:37:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7EE316B0074; Mon, 14 Dec 2020 17:37:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0141.hostedemail.com [216.40.44.141]) by kanga.kvack.org (Postfix) with ESMTP id 683C16B0072 for ; Mon, 14 Dec 2020 17:37:58 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 2DBCA3634 for ; Mon, 14 Dec 2020 22:37:58 +0000 (UTC) X-FDA: 77593351836.03.wind73_59007342741e Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id 145F028A4E8 for ; Mon, 14 Dec 2020 22:37:58 +0000 (UTC) X-HE-Tag: wind73_59007342741e X-Filterd-Recvd-Size: 4869 Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Mon, 14 Dec 2020 22:37:57 +0000 (UTC) Received: by mail-pf1-f194.google.com with SMTP id q22so13148486pfk.12 for ; Mon, 14 Dec 2020 14:37:57 -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=SadIRfB1ozL+BvgNvi56acGK40sGczeZRbLfcOjsgUI=; b=Mc+/YW20XwmOUSCsmjbxlbhWLn0udfDF1hb/tFJNMCo26ixOoN4By9QolVjs97PCec OsGBYh8BNUOvZrxJdfXaWJP7hwH9ofY7oommJ7G+EXI5WXBBZv9A1gWNQb6wYY/Gu8Pr y7qK59t7ZdEHMj/A29Kbg2Stu7UteCZvXBPx5QN5VjvG55neVSTwoUcRrRZATYVQq1+j sLl+9sM+yMHaC339qQHpau96kBWG90pfG+0EVfBmEmFcjatC2mX+U2j2Hx7L9vbXdaGX SiBpXoYwWKsqJoqzhFhgjkjALrzhvgF9hunAQTYfmtDdbvm42WW6Ll9PO/QZK02jtOSv frGg== 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=SadIRfB1ozL+BvgNvi56acGK40sGczeZRbLfcOjsgUI=; b=SO1DTH7Py0wO3QrSvjJhM5Lz8fp1fL4SAcBoPuXpRjUxjF6gcrSxOrix71QxqVVYub aB5fEv5BcRIxDOf1c2/OF+OK2tMv+nRgPOctkXAT9NdWGlnTuu4aGRvsX5qaxefJ/zjg rGpEJ7i3gD+srlVWffkv1seWI8LPpw6IP/3D+GjWhcPXC0Xah80Nhi+zQH0cxONpF7VU m+nbr7lWYRoIvUGLKIQuyTmbRBWrn+gDhmMe4upCdKKrwtFooJJG0UXS6OoQxH4FLEpi Am0kSHO+BDoyBNwtXF7cr0WMdaoOEi6L2WONFRgauB87Ffihm3hIpjSrR1BNhdoZSfKa pp7g== X-Gm-Message-State: AOAM532/hbz7GuRupnf1Sr/dfQrZuolthB+Puv/grFzOQDbCmt4sH54F 6elX6HtEapCCjzAIqct9ogY= X-Google-Smtp-Source: ABdhPJxLNoStEmuqK/WqKcnP4+Gjaztl1jLEFeEywadhkRJ+a/8qnPy/51MZKB/GCDpJoTDGEkDQVQ== X-Received: by 2002:a05:6a00:1596:b029:19d:96b8:6eab with SMTP id u22-20020a056a001596b029019d96b86eabmr25860773pfk.38.1607985476760; Mon, 14 Dec 2020 14:37:56 -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 d4sm20610758pfo.127.2020.12.14.14.37.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 14:37:55 -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: [v2 PATCH 7/9] mm: vmscan: don't need allocate shrinker->nr_deferred for memcg aware shrinkers Date: Mon, 14 Dec 2020 14:37:20 -0800 Message-Id: <20201214223722.232537-8-shy828301@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201214223722.232537-1-shy828301@gmail.com> References: <20201214223722.232537-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 bce8cf44eca2..8d5bfd818acd 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;