From patchwork Thu Jan 21 23:06:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 12037935 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 C8133C433E0 for ; Thu, 21 Jan 2021 23:06:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5278E2389F for ; Thu, 21 Jan 2021 23:06:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5278E2389F 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 A06AB6B000C; Thu, 21 Jan 2021 18:06:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9B82F6B000D; Thu, 21 Jan 2021 18:06:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8A7176B000E; Thu, 21 Jan 2021 18:06:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0155.hostedemail.com [216.40.44.155]) by kanga.kvack.org (Postfix) with ESMTP id 717F86B000C for ; Thu, 21 Jan 2021 18:06:46 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 3AF01181AF5D8 for ; Thu, 21 Jan 2021 23:06:46 +0000 (UTC) X-FDA: 77731318812.07.pie89_4f0a7be27567 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin07.hostedemail.com (Postfix) with ESMTP id 1AE67180889D1 for ; Thu, 21 Jan 2021 23:06:46 +0000 (UTC) X-HE-Tag: pie89_4f0a7be27567 X-Filterd-Recvd-Size: 5493 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Thu, 21 Jan 2021 23:06:45 +0000 (UTC) Received: by mail-pf1-f175.google.com with SMTP id t29so2445149pfg.11 for ; Thu, 21 Jan 2021 15:06:45 -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=ecr+uyWVMQYJIPC/0K3B/JrS2n6P+feKAlXvlt40fK0=; b=OfbJGr70L0LEsiZ7MaGL39F+x8jqf1HlI3cOx5jDnGeeynuSmYIdMRNKksm+7Xbb6G 391CuA3S5xAbjI3C8zxnHkgkmazfA9kK8z+E5+B4Xb9hayZm/h2SioDmY5DHGRJ6+svS 3x4o3aTYO8NdO22EWeSuMp52kr43X+WB5rucplbEZbNxVrA+neGUlJLRWSSFaHYxeLlR HAmgckMD0/txHmZqfwpOVzXotPSIxa+yaO0etz1jcjNKhKDBy3szftmNhD344/2PIU4M qv/QZpqhuNlHGkRpuRp+/dgGjXpVX7b99ua4O+Ecoe60pcvXYsqn7Yelg9VhlvZagJuj UB4A== 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=ecr+uyWVMQYJIPC/0K3B/JrS2n6P+feKAlXvlt40fK0=; b=ucK5pLLOWzQDmBr04rF30tnZUk6Lv1iCQcQySIR5CU3LpC/C51na3mo5lNGvw7wNvr ZsWc31loqLGkVVqrWt0XTr51CYyv89b2RwbHoNGx8u3YlGlrUwx3brPMs0slEfKhgTbd CB/z81/v29OAZAPdDyyfxSYRlb0f18KOAtu+AEJO8+Ti5A1yQCfZXoLux9mSebfUfI5X L+bVyzmJPq+mB3WjmvBJmnz3sF9KWp4jbSP8yH7U2LVDKRYcIogZXIQ9EeyU57rYd1N8 DobWU5z/dTTRDvzTeVdp2J646NRl3Lyq8u9IKSGaBp92DfTIGQf0/W1X1Xg30Cw26/jA FrKA== X-Gm-Message-State: AOAM533DvDlPrHdvUWmyTbPgMFA/LevdWgjdkUvrZBzea5QfCo+PQtXT uY01O/7stv3Uy5GVVa2s9YA= X-Google-Smtp-Source: ABdhPJwr0t0N81wvkWziICzoO8pyZXAIt1mXXq49BQqPpZ1o/XhNOsQ0dLrPkmS2E9OrdE0gEKa8HQ== X-Received: by 2002:a63:1b11:: with SMTP id b17mr1618542pgb.322.1611270404859; Thu, 21 Jan 2021 15:06:44 -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 y16sm6722921pfb.83.2021.01.21.15.06.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Jan 2021 15:06:44 -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: [v4 PATCH 04/11] mm: vmscan: remove memcg_shrinker_map_size Date: Thu, 21 Jan 2021 15:06:14 -0800 Message-Id: <20210121230621.654304-5-shy828301@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210121230621.654304-1-shy828301@gmail.com> References: <20210121230621.654304-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 | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index d3f3701dfcd2..40e7751ef961 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,10 +265,11 @@ 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; @@ -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;