From patchwork Tue Feb 9 17:46:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 12078679 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,URIBL_BLOCKED, 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 ACC55C433E0 for ; Tue, 9 Feb 2021 17:47:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 30F0764EB6 for ; Tue, 9 Feb 2021 17:47:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 30F0764EB6 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 B904A6B006E; Tue, 9 Feb 2021 12:47:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B1A866B0070; Tue, 9 Feb 2021 12:47:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9BD2C6B0071; Tue, 9 Feb 2021 12:47:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0205.hostedemail.com [216.40.44.205]) by kanga.kvack.org (Postfix) with ESMTP id 875976B006E for ; Tue, 9 Feb 2021 12:47:13 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 4F24C8245571 for ; Tue, 9 Feb 2021 17:47:13 +0000 (UTC) X-FDA: 77799460746.12.baby59_5305c9127609 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id 31330181D13B3 for ; Tue, 9 Feb 2021 17:47:13 +0000 (UTC) X-HE-Tag: baby59_5305c9127609 X-Filterd-Recvd-Size: 5685 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by imf42.hostedemail.com (Postfix) with ESMTP for ; Tue, 9 Feb 2021 17:47:12 +0000 (UTC) Received: by mail-pl1-f178.google.com with SMTP id s15so10145773plr.9 for ; Tue, 09 Feb 2021 09:47:12 -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=jMTd+AsX3BHmetJX1pSMFbMyduyVUPUtb+au9yZ0BQ8=; b=fb+LVYBoz1sAntMs28140vW8hhrBN9G2hhhUfuOAnPJDxB2NSshgpMJ9J2i5x+VN/f BTgbNHrvx+hIDQtkNqkxrQpE3Tx5105FsVMdgmnt9RYit5nYtD5kpLh6YjiuKqaaouID yLqsMwMoqWVaFX9IdBU1mODZD3wpmOajuHzlG3sshZrFWqywgoUXOPNhXKCeA8LPVWvd jMn7avn64DoAZsd80tsvoI7buryToQAvZMMKvo/S+CLifa3FY7g46diyVh+iqrpww0SV MNpazR9nSH9XVe5Cn0ItFLN/oAKCPr6VyBQmvX7aQZvEhoMsuaagEYlQZpDpYa67c+US ptUg== 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=jMTd+AsX3BHmetJX1pSMFbMyduyVUPUtb+au9yZ0BQ8=; b=Cb7/OMrftimLLSmE44DXRyaSpiUopxAgqdi7OKgLjCBBfAE9d1LXS8/BLTYXJWOOJp dW0D7LftF5qLDtUNg9SpjtSJwSyr5LyDEAFOg8JkPZKJNzYdQGJjfk/lEc8yYWMHCETH BqXdhUPckh6gl8jFSRQyy4brhxQZpYeG3dh3oMjFLwtX1oAgwck+OLB9QYTIybb1dGTc /JM/HYf4UhYCm0u11X0lXdKl5KQl7RHz7lnKbiz0ocoVMmM4KPYi87W/AkgG5Gn33oOT t4VqPAN6rpUIthMKE76mOfvkiRAPgHN5Rf/4lzuYAL58RT+a8ShqA8tzq5yZWG27fDo/ /Phg== X-Gm-Message-State: AOAM531x6DSRGpxKv2IL8G5dJiI0SQIZKmW2z/RDpAWfDuAIlDTYK72B 2PgOHGXkoArmopt0BofykdI= X-Google-Smtp-Source: ABdhPJwaqafmo1fqnOIsjZW/57shfRny1c9eDctpoMFQE7YXYsnfdumP7ICN/Kp3/hMsG89JqypTSg== X-Received: by 2002:a17:902:a383:b029:e0:10e6:6ed7 with SMTP id x3-20020a170902a383b02900e010e66ed7mr22633037pla.5.1612892831486; Tue, 09 Feb 2021 09:47:11 -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 j1sm22260929pfr.78.2021.02.09.09.47.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Feb 2021 09:47:10 -0800 (PST) From: Yang Shi To: guro@fb.com, ktkhai@virtuozzo.com, vbabka@suse.cz, 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: [v7 PATCH 04/12] mm: vmscan: remove memcg_shrinker_map_size Date: Tue, 9 Feb 2021 09:46:38 -0800 Message-Id: <20210209174646.1310591-5-shy828301@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210209174646.1310591-1-shy828301@gmail.com> References: <20210209174646.1310591-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: Both memcg_shrinker_map_size and shrinker_nr_max is maintained, but actually the map size can be calculated via shrinker_nr_max, so it seems unnecessary to keep both. Remove memcg_shrinker_map_size since shrinker_nr_max is also used by iterating the bit map. Acked-by: Kirill Tkhai Signed-off-by: Yang Shi Acked-by: Vlastimil Babka --- mm/vmscan.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index e4ddaaaeffe2..641077b09e5d 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -185,8 +185,10 @@ static LIST_HEAD(shrinker_list); static DECLARE_RWSEM(shrinker_rwsem); #ifdef CONFIG_MEMCG +static int shrinker_nr_max; -static int memcg_shrinker_map_size; +#define NR_MAX_TO_SHR_MAP_SIZE(nr_max) \ + (DIV_ROUND_UP(nr_max, BITS_PER_LONG) * sizeof(unsigned long)) static void free_shrinker_map_rcu(struct rcu_head *head) { @@ -247,7 +249,7 @@ int alloc_shrinker_maps(struct mem_cgroup *memcg) return 0; down_write(&shrinker_rwsem); - size = memcg_shrinker_map_size; + size = NR_MAX_TO_SHR_MAP_SIZE(shrinker_nr_max); for_each_node(nid) { map = kvzalloc_node(sizeof(*map) + size, GFP_KERNEL, nid); if (!map) { @@ -265,12 +267,13 @@ int alloc_shrinker_maps(struct mem_cgroup *memcg) static int expand_shrinker_maps(int new_id) { int size, old_size, ret = 0; + int new_nr_max = new_id + 1; struct mem_cgroup *memcg; - size = DIV_ROUND_UP(new_id + 1, BITS_PER_LONG) * sizeof(unsigned long); - old_size = memcg_shrinker_map_size; + size = NR_MAX_TO_SHR_MAP_SIZE(new_nr_max); + old_size = NR_MAX_TO_SHR_MAP_SIZE(shrinker_nr_max); if (size <= old_size) - return 0; + goto out; if (!root_mem_cgroup) goto out; @@ -287,7 +290,7 @@ static int expand_shrinker_maps(int new_id) } while ((memcg = mem_cgroup_iter(NULL, memcg, NULL)) != NULL); out: if (!ret) - memcg_shrinker_map_size = size; + shrinker_nr_max = new_nr_max; return ret; } @@ -320,7 +323,6 @@ void set_shrinker_bit(struct mem_cgroup *memcg, int nid, int shrinker_id) #define SHRINKER_REGISTERING ((struct shrinker *)~0UL) static DEFINE_IDR(shrinker_idr); -static int shrinker_nr_max; static int prealloc_memcg_shrinker(struct shrinker *shrinker) { @@ -337,8 +339,6 @@ static int prealloc_memcg_shrinker(struct shrinker *shrinker) idr_remove(&shrinker_idr, id); goto unlock; } - - shrinker_nr_max = id + 1; } shrinker->id = id; ret = 0;