From nobody Wed Nov 27 21:38:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=bytedance.com ARC-Seal: i=1; a=rsa-sha256; t=1690445472; cv=none; d=zohomail.com; s=zohoarc; b=GTS7IBHG2Q0X7Dfi4nXb+286mbwsldQn77QoELO9ov5nQgAraK4R/4/jDQvko9TR/anuN2wqyl7ZL7Q25UnKAk0DEIUCAGejZ3RyMYN//KdYKMtxnCgII9fk6DIvDiOBhSGsKGDELddH/fCQsbXAkY8D7mobx3iyuMPAWxGlJUw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690445472; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uDu/4z0sff3MNLq2Hem41DvJLtW9HR7Ht2OY0+o3IBw=; b=TG6PLj1ppyhkCWIVnkhAJ8QCkYV2eTJz7+zcMR70EjzPCuilCY6wj5wn3v8qkHnnZMZQuw6dMOCMSC7MsFdKhrq6WOiO+qYZfUHAtWt22VGSqQjAf3sK6gMHfwmCUwOIKQVwzYS3cElU5MZAM2nk+UGSe3Gn0rS8Xa850C3Gvlg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1690445472979475.77403898079626; Thu, 27 Jul 2023 01:11:12 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.570859.893199 (Exim 4.92) (envelope-from ) id 1qOw4v-0000i7-2G; Thu, 27 Jul 2023 08:10:33 +0000 Received: by outflank-mailman (output) from mailman id 570859.893199; Thu, 27 Jul 2023 08:10:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOw4u-0000i0-Vh; Thu, 27 Jul 2023 08:10:32 +0000 Received: by outflank-mailman (input) for mailman id 570859; Thu, 27 Jul 2023 08:10:32 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOw4u-0005Vh-6J for xen-devel@lists.xenproject.org; Thu, 27 Jul 2023 08:10:32 +0000 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [2607:f8b0:4864:20::436]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 0cf55329-2c55-11ee-8613-37d641c3527e; Thu, 27 Jul 2023 10:10:30 +0200 (CEST) Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-686f74a8992so77879b3a.1 for ; Thu, 27 Jul 2023 01:10:30 -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) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 0cf55329-2c55-11ee-8613-37d641c3527e 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=h8x7d0IF7UOBd6HFjTCgoZYhJ7nelUszyK0cM5JGe4S5iZlGVERlJnOHfqpH7JNSAo Tg0Ku9E6ijTzooB7sWQ7qlxLkwLw9RZ6QVYuSu6oeQmYb05FeDZ0nf9z047K9BOvGyEW gufeyhyXu4XJGtAhbl28rCpt8uok9ILwJlLK5YK1L7Ov3Zz3vyTm3LfUcyIqcFjQ8zOc 1HWdvU9PLs7lLd+D91C9HYFDkcnzx8JhWNlKF5nF5Tpi/rgESja90b3zg82MmoOnb6ij 3/lLjwmicErKkgBOy0lHRb4dNZFsC42BJLkzi5sCB3q7fGQUNF4qVUj60LPWjbwtuDq5 4FXw== X-Gm-Message-State: ABy/qLajoh3MWymY/TKOPJyDYYAzT7FJqA6gQQrQ2s+Ohli279wuCi++ IkHZoinxNYA3R69GLWPtPRBCTg== X-Google-Smtp-Source: APBJJlHGswV8UzzwdSNooBFOlXCa2QxTNwcJjWEIeOA/B6KtVME+e61/tgitLanHgBraDSTbcyHPAw== 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) 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: quoted-printable X-ZohoMail-DKIM: pass (identity @bytedance.com) X-ZM-MESSAGEID: 1690445479834100005 Content-Type: text/plain; charset="utf-8" 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); } =20 -static struct shrinker workingset_shadow_shrinker =3D { - .count_objects =3D count_shadow_nodes, - .scan_objects =3D scan_shadow_nodes, - .seeks =3D 0, /* ->count reports only fully expendable nodes */ - .flags =3D 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; =20 static int __init workingset_init(void) { + struct shrinker *workingset_shadow_shrinker; unsigned int timestamp_bits; unsigned int max_order; - int ret; + int ret =3D -ENOMEM; =20 BUILD_BUG_ON(BITS_PER_LONG < EVICTION_SHIFT); /* @@ -797,17 +791,24 @@ static int __init workingset_init(void) pr_info("workingset: timestamp_bits=3D%d max_order=3D%d bucket_order=3D%u= \n", timestamp_bits, max_order, bucket_order); =20 - ret =3D prealloc_shrinker(&workingset_shadow_shrinker, "mm-shadow"); - if (ret) + workingset_shadow_shrinker =3D shrinker_alloc(SHRINKER_NUMA_AWARE | + SHRINKER_MEMCG_AWARE, + "mm-shadow"); + if (!workingset_shadow_shrinker) goto err; + ret =3D __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 =3D count_shadow_nodes; + workingset_shadow_shrinker->scan_objects =3D 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; } --=20 2.30.2