Received: by 2002:ac8:45c5:0:b0:405:464a:c27a with SMTP id e5csp997048qto; Thu, 27 Jul 2023 01:22:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlEhWnJJepGOrg6Gtl5OHHUccBDAV41ZuQ3w7IIwdcJxSW/2A57x1+7MkF+GuRvHYnCnK0Kv X-Received: by 2002:a17:902:7d83:b0:1b3:d608:899a with SMTP id a3-20020a1709027d8300b001b3d608899amr3955733plm.68.1690446137713; Thu, 27 Jul 2023 01:22:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690446137; cv=none; d=google.com; s=arc-20160816; b=UUvIQzuBKabarjlfUZ713ef4a8kabmor/WJc7CAJKXfBiqNLU1EZy6SvdKNxrY4/gQ 8i2yOZtYvrxbasiRuMyPQV/U0IkHqZdVLUQ5rOIq0hO9gTPUH03oPPavjeDIKMuJ/U8m dVxi/+5vrtVfWhvTpzPyqL7Voz9ARMljOPltpNR9Dvj5wFWNv0QgH/JqE8FpY6J8UXnA s2uQo0jsTCg3BvkBGbejsgJPFvYs4JeGTZakx1X3TV8pFKw1u9dBVXSjVPKZucYy+6Q6 eZNG4GZwurOh3q2wzrHKOzPkZg+WfwTgFAdPceKA7PN7knG/h8/BHP2mZedhqh79ACiY +mpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uDu/4z0sff3MNLq2Hem41DvJLtW9HR7Ht2OY0+o3IBw=; fh=3lDHiAuENCYj3gWFb2bYij2cH/UC7c23rwbOpuSBNc8=; b=dbxIhb1EIGbg003HBKsZ1HOa9EZIo+DhEyQahX+qxjmTYb+Kzr1EQIK17Qimjbl/F1 EobfcjoUkxJgtWcrKRfK9/VIN667S1Ja3bj4FIEfoNK4kFuJ1F8DbxzuUKUlyNY1pM1r oc//F7GIrkctVDV/uab3o43+AGnCPNV2n7fMi5x2KHxxclDZfakVXfQC/EnU/iMv5t7x uooQN6bZKMnpYPL2nNz3m+bewyGjG6PdfHg8WZfQACQWJtPJou9xjynrB4sfY+YSJOvN avQdCkGQhCePZ4EQ30P0QQNzyUPTMAZuKyTdFmZF9QBqMeOWIbVaBAlhfCNKJ7za3t5z sVTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=iVGfsyXk; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s9-20020a170902ea0900b001bbc6846a21si983998plg.429.2023.07.27.01.22.03; Thu, 27 Jul 2023 01:22:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=iVGfsyXk; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233663AbjG0IU2 (ORCPT + 99 others); Thu, 27 Jul 2023 04:20:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234292AbjG0IS5 (ORCPT ); Thu, 27 Jul 2023 04:18:57 -0400 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC5C249FC for ; Thu, 27 Jul 2023 01:11:00 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-66d6a9851f3so168180b3a.0 for ; Thu, 27 Jul 2023 01:11:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1690445429; x=1691050229; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uDu/4z0sff3MNLq2Hem41DvJLtW9HR7Ht2OY0+o3IBw=; b=iVGfsyXkMcKNuSj4S4+ETT1e5FnNKRSLwcupS7aKQrOa2P/cg11EPb/fa7MepSVN0c souD70V3XZBCWCF1GY2G8kOBoazYK/GwCZP5iJVITEwRi2CFhPhtCnmN6NHRYDRfscjM ei11bn/3SqGlS2cI+uWxsIZ60GgV8/Th1+KRHAcGdOM/vcClXnAdg9IcKu5dXKtmCkaz 1Uv1368bMlurEfH1GvebpNgAfjlYTQWl+OVWRYv+SAitVhKYxMqk7I6vstlqXAV5ZTFg 13mCns35aGRuj+msRJnkqY3lYp1C9AqbhcZNDVttxslcFzKIxthPN+0g8mDIqHh31rTQ XhNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690445429; x=1691050229; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uDu/4z0sff3MNLq2Hem41DvJLtW9HR7Ht2OY0+o3IBw=; b=l6T02oKJW/FpijPyYgX6fkiIO3QtY48nO7dUuTe/I+OI6VbMzr8PEWMYKo2fJUhtdt eVA+QkZzIDupX00PkWTvlmQOo1Zv5KCf9tZVfkq49uUGh2dGd5aquSsbOE1rfYSIinMT SN61znZLwFlo69X4RoreK/Yo18QIzkKjZf1hjeuVByJ5WfpkgNAymmAAguDwWn+pq3Eo 5a/66lyQbg9SqrPX/G8sWA7fQELsfzXzkddHDvPk/FUtHbka0lHJxe6O2I6ecPoT8Die 0KLuXksWN/6db+aYIswS1ovs7mleCIudXFLshoJB82XA+aHQG1apAzAmjh/+0NT+R8P1 1GFA== X-Gm-Message-State: ABy/qLa5upxfRQvxeI75dsgqXIqiwq/ynl38j6I9IsjXXSQchJm3lGaS CY6Ub47d56xSnHBPx3af741VOg== X-Received: by 2002:a05:6a20:1595:b0:137:30db:bc1e with SMTP id h21-20020a056a20159500b0013730dbbc1emr5696433pzj.3.1690445429121; Thu, 27 Jul 2023 01:10:29 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.147]) by smtp.gmail.com with ESMTPSA id j8-20020aa78d08000000b006828e49c04csm885872pfe.75.2023.07.27.01.10.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 01:10:28 -0700 (PDT) From: Qi Zheng To: akpm@linux-foundation.org, david@fromorbit.com, tkhai@ya.ru, vbabka@suse.cz, roman.gushchin@linux.dev, djwong@kernel.org, brauner@kernel.org, paulmck@kernel.org, tytso@mit.edu, steven.price@arm.com, cel@kernel.org, senozhatsky@chromium.org, yujie.liu@intel.com, gregkh@linuxfoundation.org, muchun.song@linux.dev Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org, linux-erofs@lists.ozlabs.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nfs@vger.kernel.org, linux-mtd@lists.infradead.org, rcu@vger.kernel.org, netdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, dm-devel@redhat.com, linux-raid@vger.kernel.org, linux-bcache@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, linux-btrfs@vger.kernel.org, Qi Zheng Subject: [PATCH v3 23/49] mm: workingset: dynamically allocate the mm-shadow shrinker Date: Thu, 27 Jul 2023 16:04:36 +0800 Message-Id: <20230727080502.77895-24-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230727080502.77895-1-zhengqi.arch@bytedance.com> References: <20230727080502.77895-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Use new APIs to dynamically allocate the mm-shadow shrinker. Signed-off-by: Qi Zheng --- mm/workingset.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/mm/workingset.c b/mm/workingset.c index da58a26d0d4d..3c53138903a7 100644 --- a/mm/workingset.c +++ b/mm/workingset.c @@ -763,13 +763,6 @@ static unsigned long scan_shadow_nodes(struct shrinker *shrinker, NULL); } -static struct shrinker workingset_shadow_shrinker = { - .count_objects = count_shadow_nodes, - .scan_objects = scan_shadow_nodes, - .seeks = 0, /* ->count reports only fully expendable nodes */ - .flags = SHRINKER_NUMA_AWARE | SHRINKER_MEMCG_AWARE, -}; - /* * Our list_lru->lock is IRQ-safe as it nests inside the IRQ-safe * i_pages lock. @@ -778,9 +771,10 @@ static struct lock_class_key shadow_nodes_key; static int __init workingset_init(void) { + struct shrinker *workingset_shadow_shrinker; unsigned int timestamp_bits; unsigned int max_order; - int ret; + int ret = -ENOMEM; BUILD_BUG_ON(BITS_PER_LONG < EVICTION_SHIFT); /* @@ -797,17 +791,24 @@ static int __init workingset_init(void) pr_info("workingset: timestamp_bits=%d max_order=%d bucket_order=%u\n", timestamp_bits, max_order, bucket_order); - ret = prealloc_shrinker(&workingset_shadow_shrinker, "mm-shadow"); - if (ret) + workingset_shadow_shrinker = shrinker_alloc(SHRINKER_NUMA_AWARE | + SHRINKER_MEMCG_AWARE, + "mm-shadow"); + if (!workingset_shadow_shrinker) goto err; + ret = __list_lru_init(&shadow_nodes, true, &shadow_nodes_key, - &workingset_shadow_shrinker); + workingset_shadow_shrinker); if (ret) goto err_list_lru; - register_shrinker_prepared(&workingset_shadow_shrinker); + + workingset_shadow_shrinker->count_objects = count_shadow_nodes; + workingset_shadow_shrinker->scan_objects = scan_shadow_nodes; + + shrinker_register(workingset_shadow_shrinker); return 0; err_list_lru: - free_prealloced_shrinker(&workingset_shadow_shrinker); + shrinker_free(workingset_shadow_shrinker); err: return ret; } -- 2.30.2