From patchwork Wed Feb 3 17:20:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 12064887 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 191B9C433E0 for ; Wed, 3 Feb 2021 17:21:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8E54C64DA1 for ; Wed, 3 Feb 2021 17:21:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8E54C64DA1 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 163466B0071; Wed, 3 Feb 2021 12:21:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0ED636B0072; Wed, 3 Feb 2021 12:21:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F1D506B0073; Wed, 3 Feb 2021 12:21:14 -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 DAD886B0071 for ; Wed, 3 Feb 2021 12:21:14 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 23655362A for ; Wed, 3 Feb 2021 17:21:14 +0000 (UTC) X-FDA: 77777622468.28.bells01_380383c275d5 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id 6242A6C2C for ; Wed, 3 Feb 2021 17:21:13 +0000 (UTC) X-HE-Tag: bells01_380383c275d5 X-Filterd-Recvd-Size: 5636 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by imf43.hostedemail.com (Postfix) with ESMTP for ; Wed, 3 Feb 2021 17:21:12 +0000 (UTC) Received: by mail-pf1-f176.google.com with SMTP id f63so228476pfa.13 for ; Wed, 03 Feb 2021 09:21: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=jGo1wZIt/fCsKVzxBYv264UFJPxmYGbYaCbSnPwe2l4=; b=vh7uA7u67PDDrYGZSYLwqb7USds8nfHkUzW09yhUIYOG1uHAEAoqqzzvBTMxaNrGJp BHm4T1Yd5hHzpIreZVDVorSzUu0BK/i/JMCoVChOz1Aii8fX2P7gycxDwf2YJOn6IvwM J1TyoHF/7lEDhBAtvAVpzepcaP+E9TD+NzP6OTYM43LnEpSPGmtmP1iduHYTHxzrhKzo a2XVhUy9WazceAk/apQK0ZAhVdhm+QJQdHH1Skd1n2XPKwxAOEkv34+y5Y31DZtMlgcf SmhDvmz44toTKe+o6sGY5cGmf7FMAvFEoytv1hlsQT8Wki5mG+8UfNdwcdLvUMEVEB+J wMAQ== 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=jGo1wZIt/fCsKVzxBYv264UFJPxmYGbYaCbSnPwe2l4=; b=We4B0Q5jw6GU5jTszPTVqsIQQKqVNdupHSN23uXjG+RQUy2AfMdpJDaOJMqWHArioa M2SOqEJwb5b+KB0IowNbu9q0VT1AixlwzRzJUqWxp1Gm2GsiTCOGIAXi0WFAh/zGXxnn rH3vqbp8gwGHyZCH8XSd8bLEfgvw8RJhMOv9dS80VyIJuI8xd42CLGICE8KfoQdUeGdh 7m7gOuVzQzbM3gTEpx6j9xKwSBow6DiIwbayEJizj5AYU0U6F9uePbo0iZXaP+DvviuN PJqgpsyxyGbF4im1ElPAmoSG1VGxwEjBaPgk0ShBDNHuP5p7gPGzAlWzopEwRxu+fNd7 t2aw== X-Gm-Message-State: AOAM531rqFo5JBeCsUdiUCAJzc6BLCidQkm5gZxvJ8nRRpfbFFPb+E6I t8H4x3awLlL7y70luU02DkI= X-Google-Smtp-Source: ABdhPJzVaNXDkSSog60kMfbrB19ALynz5XcuMkn6xrdACF5Gn2BkoSfmP0yMQI/oQwzIph4vEgw6BQ== X-Received: by 2002:a62:528c:0:b029:19e:4a39:d9ea with SMTP id g134-20020a62528c0000b029019e4a39d9eamr4036033pfb.20.1612372872042; Wed, 03 Feb 2021 09:21:12 -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 x21sm2368636pfn.100.2021.02.03.09.21.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Feb 2021 09:21: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: [v6 PATCH 04/11] mm: vmscan: remove memcg_shrinker_map_size Date: Wed, 3 Feb 2021 09:20:35 -0800 Message-Id: <20210203172042.800474-5-shy828301@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210203172042.800474-1-shy828301@gmail.com> References: <20210203172042.800474-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. Signed-off-by: Yang Shi Acked-by: Kirill Tkhai --- 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;