Message ID | 20230727080502.77895-12-zhengqi.arch@bytedance.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1CD2C00528 for <linux-mm@archiver.kernel.org>; Thu, 27 Jul 2023 08:08:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8F4A06B0075; Thu, 27 Jul 2023 04:08:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8A57D6B0083; Thu, 27 Jul 2023 04:08:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 76D766B0085; Thu, 27 Jul 2023 04:08:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 693936B0075 for <linux-mm@kvack.org>; Thu, 27 Jul 2023 04:08:08 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 4B3FF1604B3 for <linux-mm@kvack.org>; Thu, 27 Jul 2023 08:08:08 +0000 (UTC) X-FDA: 81056663856.02.FB012C7 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by imf02.hostedemail.com (Postfix) with ESMTP id 775378001A for <linux-mm@kvack.org>; Thu, 27 Jul 2023 08:08:05 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=abLX7f3+; spf=pass (imf02.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.179 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690445285; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=f+zNYaRC7WOrXvS9MeEiQUBTAQfjLjc/pgN/esuhj34=; b=tBYhwKkMEimHfvhzEVrBGNT7Qjgmc6oXPyu02U2i1RsQsupwU6nIREPg1smYK1pDMDABOB QDF4Q3vH8RPayApgYQIJzBKQhaTsXGdsexoko4fXK2fxlzcSSwBDiDGY5Ckjjzh5BbXV1i FisbxYifW3v1Wa9FO4lafteGtulycfM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690445285; a=rsa-sha256; cv=none; b=CR9amtZzONcC16CVW2lHt0UmWv7mObuOwNte65t/ipERSY0f9SyQIxZLHBzwB1nhaoD9o+ oyossa66HZy+BABrNHHu4Dizlwh6evrHk1txWrdKY6wMcdpt1ARy49/xcByLNrDuZPqdU1 Cj4+q2a/WFF20KQ6sjsxgntH4V6Tays= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=abLX7f3+; spf=pass (imf02.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.179 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-682eef7d752so203596b3a.0 for <linux-mm@kvack.org>; Thu, 27 Jul 2023 01:08:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1690445284; x=1691050084; 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=f+zNYaRC7WOrXvS9MeEiQUBTAQfjLjc/pgN/esuhj34=; b=abLX7f3+1Jx7z4l7fMDPHLPoRZGZ9R0nM8ns3oWVX7aiHujgqPmDptRXrf7K4N1NV7 iafFd1vKgmMytglgpeByIm2etm8PBx6nYdrahZ4g0/dxHWR3bRoC5c0K2oAToNHdR0rs G85XXQ+OMNSfgkQPICGhKu4AFUznJk92yyLKwDX6t68bXy1Y1afxgcqF2Hrs2hRsS8Pi 1cVGQ/135Rq8DHs2i32YJ/uaSpZLHmMFkQEdBwI9bGEy1fU1/6Py8qR+g4Mw2XtURfuH rP2vSQAfzwsm7AmoQxkWOyj1kIWSKeW+aRYJEV/VwcFYAz1pgMCM8AVBtPjE13HITA/4 GS9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690445284; x=1691050084; 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=f+zNYaRC7WOrXvS9MeEiQUBTAQfjLjc/pgN/esuhj34=; b=iEZe8OuxdiPwzFyzNASE0nsn+3EiqXWMMeEeu4brPMuD2kYajhemxlXBqAYELaLGIQ 6bFcv+gfQ77oUZXsgAUKFyj12dklZlOcbPgFtRnU6pIwM1OF2cuUGQvTU5O3V2aSrgla ZeiYw9GgoK0C6bgdlR1kit8ji4Fkj0FlFiJmaWIntsPrkwhhpWJfpY8t8h2WfhzZyrlu f1YR9PqnO40I0LW/JHFJHvCIsmEH8+K6DkZ30PgpC/hxqTLsBFyUxEeGf7FCmJG6txNB 29hApmD9mBLFDp69SeBnKUqMOg5Q1BJlfcWFU53YgnTfPG6UU7/tbZU5G079i+jEbp58 nvZw== X-Gm-Message-State: ABy/qLYmxUiOpsfN1kN7AufCKcyZs0+igV6LwVRT4nwDgE1YNA4JyZ6r m0A5hRvSPUR0M3tdNPrCs6hOGw== X-Google-Smtp-Source: APBJJlHpYZMPheHhGtAzh7w//Dgf2VgsvvziRNiT4CodVVfE3Y9RoyQKb/hEjPAgUidNi6thlhXB+g== X-Received: by 2002:a05:6a20:4286:b0:12d:77e:ba3 with SMTP id o6-20020a056a20428600b0012d077e0ba3mr6418674pzj.0.1690445284151; Thu, 27 Jul 2023 01:08:04 -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.07.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 01:08:03 -0700 (PDT) From: Qi Zheng <zhengqi.arch@bytedance.com> 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 <zhengqi.arch@bytedance.com>, Muchun Song <songmuchun@bytedance.com> Subject: [PATCH v3 11/49] f2fs: dynamically allocate the f2fs-shrinker Date: Thu, 27 Jul 2023 16:04:24 +0800 Message-Id: <20230727080502.77895-12-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-Stat-Signature: qgp43dcmmb6jmes6dejqdki1mpyaynpi X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 775378001A X-Rspam-User: X-HE-Tag: 1690445285-129936 X-HE-Meta: U2FsdGVkX1/TjgcvAQIajFqZs2KKZjn71kCttUF1qGmfbT/EtP72ATH8M5MEg5+PEKgNKo1DPDevavG/3Ke7GkzPoYVGQM2MdjnHLy+xwTjn/MhkbvSycFOIpse8OnJQN7XG+AXYzcCuqphX8FT7RrP4/Lz2Qol3Dv4aNpOD0vPhnCTkqN+UyV5W3gACR2XqaoOHn0s/MYnbxYykQ13BmtUDRKtM7mcEO8H/6LICze2ng4coq7TmbLG/UV9Z8FuKgWhvgtOg8J2OIKQICM8pFf3MtpYnO66nq7P0mOT3zMufzI7hIduiNcaSNEqDYisfStOKPxrB6N8ZIcf8xaM2c/2m0sbDoaUre286Yksrgp6I5UfbPUGG1bddTuQzIRA4zLnxDLuskAWHWrr4tJRrBttDBPw/vb8RElb6VQiHMmxtla3aq5dgzlV5iER4kH/35N+ClU0ySjErA6iyd6VJGsvTR5QakIxZ38prwKrKQJfRulJs83yPQgmkoKw93GvH0yhT0pmcezEgng3JiFC4lcyv38XnoRvhM2TxxIqxfYzmeowGqUuDpnjhd4yNdWSCsj2zWlD1JtMAJsFys8w6R1u8ElU7QixebUsG4Y9wm8wLGXAaLlRfWSMqNfaFKw6xXzL7kkxSeMalIyPMJBAVp1V3hMeRwWaPfhLEhSv0ep0Y3n4+KxdrGV4d+BdalT17Gi5dN2VgZkCRX/dx7A3weR7dPAE4Yv5nzc6aG5AY9Qz+n+CT22eigy/VBo7AZSF2yQInfyBkZS02Pg3OVATvLsE9OINoHPiZNVUNNMjdNbnwI1lCCqVkm53XmOf/PzkrpvIhvh9CoQt4b45I4ZB+fB65cTA9MQo+xZ9mKBO8aa3BDlUSVQsikTsJpDO6O50ysuSb6gZ2syCSIxbYV8GlPy+FCqazZje3LXmAgBWkjjHi5dyngaIME3jPtJHtGTOYfYy7+8aH/H4XjJcof8B 9YxePQhZ cBzh5RmVRTHnR2R15lTBW07upp+t1Fod9v3icNva8f/Bzk3Uy0+/C5zyn7XW9hK9KKD+evjpmHyZFlUGOt4dD4LK4nLaTngnwI5m/4ISzNdui2dSsB0LItV34lHZnNFzp7lmpx40u5ABS+oSQQc07uF950GzvGPtNMMInDkXXYuvdXKozKrOWv0P+PNpQ7i8yTsJnS5xD/g9Zrf/pjN+f021IbwXCmaWKnS/UF2RKTyNM3GHgyJEYrxFuVjBzeOr0oF6My4F1N7YdpHelnAvY494PmXhWGsAK5zi47q9YcsMD73er+f9RaVqQ6OYLLeb5BxiPcRiNN/4Mz72KZDz3vS08ErBsVhl88wHsK0TS5vP6e6ie2xfwgra7jB9nY9AucAxB6HTDMdjzTNW4k7i+QjJ654sIEiIxq8ol 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: <linux-mm.kvack.org> |
Series |
use refcount+RCU method to implement lockless slab shrink
|
expand
|
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index a123f1378d57..9200b67aa745 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -83,11 +83,27 @@ void f2fs_build_fault_attr(struct f2fs_sb_info *sbi, unsigned int rate, #endif /* f2fs-wide shrinker description */ -static struct shrinker f2fs_shrinker_info = { - .scan_objects = f2fs_shrink_scan, - .count_objects = f2fs_shrink_count, - .seeks = DEFAULT_SEEKS, -}; +static struct shrinker *f2fs_shrinker_info; + +static int __init f2fs_init_shrinker(void) +{ + f2fs_shrinker_info = shrinker_alloc(0, "f2fs-shrinker"); + if (!f2fs_shrinker_info) + return -ENOMEM; + + f2fs_shrinker_info->count_objects = f2fs_shrink_count; + f2fs_shrinker_info->scan_objects = f2fs_shrink_scan; + f2fs_shrinker_info->seeks = DEFAULT_SEEKS; + + shrinker_register(f2fs_shrinker_info); + + return 0; +} + +static void f2fs_exit_shrinker(void) +{ + shrinker_free(f2fs_shrinker_info); +} enum { Opt_gc_background, @@ -4937,7 +4953,7 @@ static int __init init_f2fs_fs(void) err = f2fs_init_sysfs(); if (err) goto free_garbage_collection_cache; - err = register_shrinker(&f2fs_shrinker_info, "f2fs-shrinker"); + err = f2fs_init_shrinker(); if (err) goto free_sysfs; err = register_filesystem(&f2fs_fs_type); @@ -4982,7 +4998,7 @@ static int __init init_f2fs_fs(void) f2fs_destroy_root_stats(); unregister_filesystem(&f2fs_fs_type); free_shrinker: - unregister_shrinker(&f2fs_shrinker_info); + f2fs_exit_shrinker(); free_sysfs: f2fs_exit_sysfs(); free_garbage_collection_cache: @@ -5014,7 +5030,7 @@ static void __exit exit_f2fs_fs(void) f2fs_destroy_post_read_processing(); f2fs_destroy_root_stats(); unregister_filesystem(&f2fs_fs_type); - unregister_shrinker(&f2fs_shrinker_info); + f2fs_exit_shrinker(); f2fs_exit_sysfs(); f2fs_destroy_garbage_collection_cache(); f2fs_destroy_extent_cache();