From patchwork Wed Jan 27 23:33: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: 12051215 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 2AB9DC433DB for ; Wed, 27 Jan 2021 23:34:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B6E3E64DCE for ; Wed, 27 Jan 2021 23:34:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B6E3E64DCE 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 CB4EF6B0072; Wed, 27 Jan 2021 18:34:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C3DE76B0073; Wed, 27 Jan 2021 18:34:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AE1C46B0074; Wed, 27 Jan 2021 18:34:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0096.hostedemail.com [216.40.44.96]) by kanga.kvack.org (Postfix) with ESMTP id 95AD26B0072 for ; Wed, 27 Jan 2021 18:34:01 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 58FF3181AEF39 for ; Wed, 27 Jan 2021 23:34:01 +0000 (UTC) X-FDA: 77753160282.24.lead90_5605a122759b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin24.hostedemail.com (Postfix) with ESMTP id 3B52A1A4A0 for ; Wed, 27 Jan 2021 23:34:01 +0000 (UTC) X-HE-Tag: lead90_5605a122759b X-Filterd-Recvd-Size: 5550 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Wed, 27 Jan 2021 23:34:00 +0000 (UTC) Received: by mail-pl1-f172.google.com with SMTP id 31so2043604plb.10 for ; Wed, 27 Jan 2021 15:34: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=65bxltQ5JyyivvvnTuxpyri2gVYu+eURJIDc8089YFI=; b=fF/4lvKdCeIWSpDsS59C71/1pkx5orm4veM66Uq59nJjBqNxFLFJiO1FFck57I6rg+ kFTyXYD/RvF9uSoP+TJpeDbb++3BEcWLvxpQbyseTcvDccweUbooPirPVUfeUtXOUToL oGkxd99AYI4VyVsgsIpbJTzwfIixg2ABX0z+8ddBIgWfIjnFVpGDQ9Z2fAD6/v01hAjA 1e/27ekiV+R9rDAj6lVzyWU5lWCB5gBcIOJi/DVEDZHSo/qm2GxS8F610GHfAMC/b/ZQ BqQm4/uEdh7tRXGiwL/8cOOea3R7vj1RIyo4BxRwn5EjX2fkJlhlCMnH0krkQ+eyLgHs /w+g== 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=65bxltQ5JyyivvvnTuxpyri2gVYu+eURJIDc8089YFI=; b=ucTWHXXePign1xedHEBvDcw+nxHSHnxZOK0KF3VdQMvmyjpbCAkeOoFfRNMFa+kJMX c0FwsrCXfJBMEQZ4EQkBsSXT45KapIKozjakYRVTXINarI8AyX3PXC31+pEHQ/Q9WBVu 1JuWzXlVRsZ9HUUXCePSCuYsKBbEXtd7rWMJtPndi+A0fRAMleKuo5fX5oUqNYJMty+q j1J1QPNfuLeCDaeBSvCgUaem7qc/pne7g6AHM904f/eez6FanDM2gK4nMS1VtXR7BOpj O/48V1BUVjCvoPuQ7qG4SnnoKV8q0HzD+w62PyhFfv+Ti7r+MfnQJyppd2zY/6tgrTo3 UfzQ== X-Gm-Message-State: AOAM533ZF63q7RZvz5u6zjHalG4kpnm26CyieHaUzWznpB/fd1cOzyZO qKLim7UxhQ9Efasf0lodWO0= X-Google-Smtp-Source: ABdhPJyEROsqkycAYaLMggreyUDXfEmKv4d5fu9Tu67KGSVlcjm+y4TKGJ/ZQPQKP4WS1C3zBGyMrg== X-Received: by 2002:a17:90a:12c4:: with SMTP id b4mr7896770pjg.98.1611790440132; Wed, 27 Jan 2021 15:34: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 124sm3498648pfd.59.2021.01.27.15.33.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Jan 2021 15:33: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: [v5 PATCH 04/11] mm: vmscan: remove memcg_shrinker_map_size Date: Wed, 27 Jan 2021 15:33:38 -0800 Message-Id: <20210127233345.339910-5-shy828301@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210127233345.339910-1-shy828301@gmail.com> References: <20210127233345.339910-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 | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index d3f3701dfcd2..847369c19775 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 free_shrinker_map_rcu(struct rcu_head *head) { @@ -248,7 +247,7 @@ int alloc_shrinker_maps(struct mem_cgroup *memcg) return 0; down_write(&shrinker_rwsem); - size = memcg_shrinker_map_size; + size = (shrinker_nr_max / BITS_PER_LONG + 1) * sizeof(unsigned long); for_each_node(nid) { map = kvzalloc_node(sizeof(*map) + size, GFP_KERNEL, nid); if (!map) { @@ -266,12 +265,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 = (new_nr_max / BITS_PER_LONG + 1) * sizeof(unsigned long); + old_size = (shrinker_nr_max / BITS_PER_LONG + 1) * sizeof(unsigned long); if (size <= old_size) - return 0; + goto out; if (!root_mem_cgroup) goto out; @@ -286,9 +286,10 @@ static int 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; + shrinker_nr_max = new_nr_max; return ret; } @@ -321,7 +322,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) { @@ -338,8 +338,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;