From nobody Wed Nov 27 21:50:05 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=1690445896; cv=none; d=zohomail.com; s=zohoarc; b=BNLEnM+BV5NlCPCJ0nsKLWWS2Zt+TC3xfv2+Gi7Qqi/jig2OEWYhz4p1wcGTxl/Wa2anhrxMAv5pkB5SO3TwJhSmnggbQMfuiCvaTyD2djpTriHHL0AYIKkmGmmiNI7O1al3KfY1jusykV3k1AWRQ9nb1Wi4AsU+Bs+Jh+bPYus= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690445896; 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=XxxR7cKF9GXj8MC2HKPXqv6o5/ypcgPst5/afOqmqdU=; b=MhPqPcIOJM/c6zNKXxEtCzBka2be8c81ewrQhNE7aQ3hrMcl1U9YDa4UVF2vJFG3nIsGn2jmO60BG1Y8iiQIcAsD/xSASDD1/0AlKMvnHwuWpb/UT/fR7YqNbpna52qZpfiUqdpPTFPlZAjYTuh7sVyBKhGCsdqcCwrZIHAesPI= 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 1690445896808702.6717198492071; Thu, 27 Jul 2023 01:18:16 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.570911.893491 (Exim 4.92) (envelope-from ) id 1qOwBy-00056q-9X; Thu, 27 Jul 2023 08:17:50 +0000 Received: by outflank-mailman (output) from mailman id 570911.893491; Thu, 27 Jul 2023 08:17:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOwBw-00053I-Up; Thu, 27 Jul 2023 08:17:48 +0000 Received: by outflank-mailman (input) for mailman id 570911; Thu, 27 Jul 2023 08:17:45 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOw3W-0001DS-OQ for xen-devel@lists.xenproject.org; Thu, 27 Jul 2023 08:09:06 +0000 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [2607:f8b0:4864:20::436]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id daad8221-2c54-11ee-b247-6b7b168915f2; Thu, 27 Jul 2023 10:09:06 +0200 (CEST) Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-682ae5d4184so170865b3a.1 for ; Thu, 27 Jul 2023 01:09:06 -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.08.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 01:09:04 -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: daad8221-2c54-11ee-b247-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1690445345; x=1691050145; 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=XxxR7cKF9GXj8MC2HKPXqv6o5/ypcgPst5/afOqmqdU=; b=f78FOiI4CNId+Ml2PzU7mY1IxHereBLlHPf7s7X8Gy+u8ge3z2zcNtZJbXgkJ1G/QR Bypsj3Qfs4NqFk8L9OHPUra+lfok5RS+DDluwPHI9kxnAJLSgVKbtyU1LC00kLM6jzmr VkgjJJoznrUMJZqGeb8qVz0Juy94c4XL4Hr58JZjfVBDwwW2089Gloj9mnDr01+e3vie ATN8u6YkhMkKc+i92NbP56LSIJl/sZe4eRd/+9U9Zz62iXDekK8cKEfr5HTH0aUYxIkr BT13YNvigorKsMJZpm5Ugf1VrzOLWJZerOzcVEByhulhpkn1iKJBA5Dz0oLwz2cUXQdL iC6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690445345; x=1691050145; 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=XxxR7cKF9GXj8MC2HKPXqv6o5/ypcgPst5/afOqmqdU=; b=ZqWGaJ7ZJO8HJDnSUkn1nVtorDYYt/Mt2v0eu9BIBHbGnH7hVgu9i+eBjPupZA52nW hUxHD9HclXjcAyuJRiDRZfoYIkey3e5/m5ULp//PQY+nBnCc3TImOFBiKWJGO/a0ovnJ bOYbuxO71upTeyN906zOy/yPvMHBngaecRRhgVI5TanFOaM+jQe4NsgTuCIl/FEjFIBC WtOSKGJ0NfESfpe1PvQBrWXN7BAvKbF6+zAJUvpgVgvPAlEUqp0nJQIggRoe2BIzcDVR 60lAPxqredmYr0+5iEzAyaYhqAhnBQiHua3kdbglfUOiz2czP3rRbrzvKoecZMhSkYsh AUtA== X-Gm-Message-State: ABy/qLaRH6e0VZddnGgjvwfd7c6pPPGtAAyQSRObX7fK58YraIPQtJYi 9rkNnaxb5+okiPMOrzkeTz1Jiw== X-Google-Smtp-Source: APBJJlFoKDsbKkERIQGnm+LFaFeLpxhRzI1EaDrRxfTAKZLr632PKwn78Yey2tH1KRLEMSWua5HIxg== X-Received: by 2002:a05:6a00:4a10:b0:686:b990:560f with SMTP id do16-20020a056a004a1000b00686b990560fmr4379620pfb.2.1690445344746; Thu, 27 Jul 2023 01:09:04 -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 , Muchun Song Subject: [PATCH v3 16/49] nfsd: dynamically allocate the nfsd-filecache shrinker Date: Thu, 27 Jul 2023 16:04:29 +0800 Message-Id: <20230727080502.77895-17-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: 1690445897164100001 Content-Type: text/plain; charset="utf-8" Use new APIs to dynamically allocate the nfsd-filecache shrinker. Signed-off-by: Qi Zheng Reviewed-by: Muchun Song --- fs/nfsd/filecache.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c index ee9c923192e0..872eb9501965 100644 --- a/fs/nfsd/filecache.c +++ b/fs/nfsd/filecache.c @@ -521,11 +521,7 @@ nfsd_file_lru_scan(struct shrinker *s, struct shrink_c= ontrol *sc) return ret; } =20 -static struct shrinker nfsd_file_shrinker =3D { - .scan_objects =3D nfsd_file_lru_scan, - .count_objects =3D nfsd_file_lru_count, - .seeks =3D 1, -}; +static struct shrinker *nfsd_file_shrinker; =20 /** * nfsd_file_cond_queue - conditionally unhash and queue a nfsd_file @@ -746,12 +742,18 @@ nfsd_file_cache_init(void) goto out_err; } =20 - ret =3D register_shrinker(&nfsd_file_shrinker, "nfsd-filecache"); - if (ret) { - pr_err("nfsd: failed to register nfsd_file_shrinker: %d\n", ret); + nfsd_file_shrinker =3D shrinker_alloc(0, "nfsd-filecache"); + if (!nfsd_file_shrinker) { + pr_err("nfsd: failed to allocate nfsd_file_shrinker\n"); goto out_lru; } =20 + nfsd_file_shrinker->count_objects =3D nfsd_file_lru_count; + nfsd_file_shrinker->scan_objects =3D nfsd_file_lru_scan; + nfsd_file_shrinker->seeks =3D 1; + + shrinker_register(nfsd_file_shrinker); + ret =3D lease_register_notifier(&nfsd_file_lease_notifier); if (ret) { pr_err("nfsd: unable to register lease notifier: %d\n", ret); @@ -774,7 +776,7 @@ nfsd_file_cache_init(void) out_notifier: lease_unregister_notifier(&nfsd_file_lease_notifier); out_shrinker: - unregister_shrinker(&nfsd_file_shrinker); + shrinker_free(nfsd_file_shrinker); out_lru: list_lru_destroy(&nfsd_file_lru); out_err: @@ -891,7 +893,7 @@ nfsd_file_cache_shutdown(void) return; =20 lease_unregister_notifier(&nfsd_file_lease_notifier); - unregister_shrinker(&nfsd_file_shrinker); + shrinker_free(nfsd_file_shrinker); /* * make sure all callers of nfsd_file_lru_cb are done before * calling nfsd_file_cache_purge --=20 2.30.2