From patchwork Tue Jan 5 22:58:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 12000463 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 3D46BC433E0 for ; Tue, 5 Jan 2021 22:58:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CFCBF22E00 for ; Tue, 5 Jan 2021 22:58:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CFCBF22E00 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 5FD188D00BD; Tue, 5 Jan 2021 17:58:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5ABB58D006E; Tue, 5 Jan 2021 17:58:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4513D8D00BD; Tue, 5 Jan 2021 17:58:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0053.hostedemail.com [216.40.44.53]) by kanga.kvack.org (Postfix) with ESMTP id 292FE8D006E for ; Tue, 5 Jan 2021 17:58:55 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id E06683629 for ; Tue, 5 Jan 2021 22:58:54 +0000 (UTC) X-FDA: 77673238188.17.word38_610adf6274dc Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id C8821180D0185 for ; Tue, 5 Jan 2021 22:58:54 +0000 (UTC) X-HE-Tag: word38_610adf6274dc X-Filterd-Recvd-Size: 5089 Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) by imf46.hostedemail.com (Postfix) with ESMTP for ; Tue, 5 Jan 2021 22:58:54 +0000 (UTC) Received: by mail-pg1-f175.google.com with SMTP id i5so898183pgo.1 for ; Tue, 05 Jan 2021 14:58:54 -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=Tp6nvSnYfrzas6KqqlhHOeDbjFx3dmjGnjHn57+Ml3M=; b=PyPds34cq+wU8WRce7eiKrTHVg4GL0fiJGZFtk6LMlqEKH+nyE7Fhz06jcvZRyPtBk SXhTYB9blJzG2KdJybceWKTb4YDswXlPgl3+AevqIKkvN+DqtKgprLV9vo/GAfhTMCIM O6oBzeUXmWibHUWsgztMowdInRXjYHZ6zTyLq9/TbWrY4Yw+wmjhJGpfheFRA5zBOdrE Luq9/kyI1G3ESeXwrinAPZejWjoXUWXPOLUwbwfIWf20Cx7ryPM+WLgXzFe9Iml/yM45 SX5gPCNVw/Subk6EGZgiYnpomhUGMIoA4BNXAklySPPJ5rxchEIJ9Y7UdlMD2nvHCUHy l1xQ== 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=Tp6nvSnYfrzas6KqqlhHOeDbjFx3dmjGnjHn57+Ml3M=; b=ZQ3x/vNicgXp5OeLFDCNNChcIv34OcAxbb3J0SWgwkUzpJ2we5FHNw5A3+QUw18px7 /oYo1cM1ubVeKGt2xO58wJCjVn+UfgbpXSb9FcUADyxmr5tzDEhLCb6VS4YFkrlvtR6U F/yBDqGPgGj1oA9GZ8bQAzUeD/s6XKUU1C9ohdqO7C4/4l28bvAR7jI9SX/9dGfJ47QX GiVbouZQwad03bsVRCl8zPZnWQIA6YtAwAQcZx+5DK/OItJ9dxBfVcnajiICfdIZ/FXv bQBt27vfflndDBEc6vcKDRXG/13oux4sxZaB8P/Nz02j8iAzT87MXikzvTAcM0TZhfNx BllA== X-Gm-Message-State: AOAM531OSQkrqkjSWi+zCrXJRcCsXvqpAR9DOmYLXEs1VvHXu89D/wnt mpCARDbSb1N/QNkwP9oKXNU= X-Google-Smtp-Source: ABdhPJzb6Ix4JjXnWhJWl2DmIhFwzSRpr9MVjwmdlocKRbwrUon4tQzHVJKvCNxw+akSjZj81zWglQ== X-Received: by 2002:a63:da4f:: with SMTP id l15mr1397712pgj.22.1609887533410; Tue, 05 Jan 2021 14:58:53 -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 fw12sm244233pjb.43.2021.01.05.14.58.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 14:58:52 -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: [v3 PATCH 04/11] mm: vmscan: remove memcg_shrinker_map_size Date: Tue, 5 Jan 2021 14:58:10 -0800 Message-Id: <20210105225817.1036378-5-shy828301@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210105225817.1036378-1-shy828301@gmail.com> References: <20210105225817.1036378-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 --- mm/vmscan.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index ddb9f972f856..8da765a85569 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -185,8 +185,7 @@ static LIST_HEAD(shrinker_list); static DECLARE_RWSEM(shrinker_rwsem); #ifdef CONFIG_MEMCG - -static int memcg_shrinker_map_size; +static int shrinker_nr_max; static void memcg_free_shrinker_map_rcu(struct rcu_head *head) { @@ -248,7 +247,7 @@ int memcg_alloc_shrinker_maps(struct mem_cgroup *memcg) return 0; down_read(&shrinker_rwsem); - size = memcg_shrinker_map_size; + size = DIV_ROUND_UP(shrinker_nr_max, BITS_PER_LONG) * sizeof(unsigned long); for_each_node(nid) { map = kvzalloc(sizeof(*map) + size, GFP_KERNEL); if (!map) { @@ -269,7 +268,7 @@ static int memcg_expand_shrinker_maps(int new_id) struct mem_cgroup *memcg; size = DIV_ROUND_UP(new_id + 1, BITS_PER_LONG) * sizeof(unsigned long); - old_size = memcg_shrinker_map_size; + old_size = DIV_ROUND_UP(shrinker_nr_max, BITS_PER_LONG) * sizeof(unsigned long); if (size <= old_size) return 0; @@ -286,10 +285,8 @@ static int memcg_expand_shrinker_maps(int new_id) goto out; } } while ((memcg = mem_cgroup_iter(NULL, memcg, NULL)) != NULL); -out: - if (!ret) - memcg_shrinker_map_size = size; +out: return ret; } @@ -321,7 +318,6 @@ void memcg_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) {