From patchwork Thu Aug 24 03:42:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13363440 Return-Path: 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 DB695C71145 for ; Thu, 24 Aug 2023 03:44:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 81C83280076; Wed, 23 Aug 2023 23:44:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7CD028E0011; Wed, 23 Aug 2023 23:44:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 69505280076; Wed, 23 Aug 2023 23:44:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 581038E0011 for ; Wed, 23 Aug 2023 23:44:53 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 302F9B19D8 for ; Thu, 24 Aug 2023 03:44:53 +0000 (UTC) X-FDA: 81157606866.01.D23C1E0 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by imf06.hostedemail.com (Postfix) with ESMTP id 5F50B180028 for ; Thu, 24 Aug 2023 03:44:51 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=L5s18IvP; spf=pass (imf06.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.174 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692848691; a=rsa-sha256; cv=none; b=VAVwJ3seNp2ml2Xu9lXR4MpW7TtfbbVHjb9OReQ+9xVrdMMN+ChRwwoY2tRuQ4jr3p2fw5 ldes4mW/BE5q6TptjpOoh+YzmF+717x245TTF5JVmII7J5/efkOZPsTVYvDcDqNnf8o68g yjzU+EolkzQHv461gLAvbCYSSL97Thw= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=L5s18IvP; spf=pass (imf06.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.174 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=1692848691; 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=RH+UWxgsfED4SOG31SRsciPnOVwoHjCv5sMnfhtq6Bc=; b=pI+RFaBriKiQv9Ios2JZ+FO/bZ5Ji7k9u5TVEYjjv265ZFGZHxsyEFKWrU6cCR91t6ocP2 YIgcBdJMKZNAf4yHn1RjIVrxGM7+ArPnlNuyiUsnKn5o30mDxcG3gaqIZzqz034KG+XL7U elo7uOXSa5t53QempiO65NYvMspfojQ= Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-68a4dab8172so654882b3a.0 for ; Wed, 23 Aug 2023 20:44:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1692848690; x=1693453490; 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=RH+UWxgsfED4SOG31SRsciPnOVwoHjCv5sMnfhtq6Bc=; b=L5s18IvPmkO1Yi1aX8xoUBVbVs+NYj2wes5Iop5itsw/50mmjZRe3mo5xjdm+YoYr+ LilfHyHML7A/wtK+y3tmj6oJnO9F477J4r8ASwXsJMy1GqlaxC/IRlgArGQhd91MGOHK 3A/nIh3uIHjjesEmVDhRjQQGnpOSt+ZUZIXZCdxBGM+Ld1QW0fUX6EUASA/OZvpRDifX PZxVf/aQ+feX6zs1fU4hK4chLezuy6pKGNDjYDnCsIRpGw/8fLGUh1PWhw7uWepXLMd7 7iamIzVc5Mglw5KEkqKNqjKvoDX13NmQ/PUea91yy3q87XQGMlCFJxJ4OLm3P8rzsoMA cazw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692848690; x=1693453490; 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=RH+UWxgsfED4SOG31SRsciPnOVwoHjCv5sMnfhtq6Bc=; b=Rf11julAD0UTRI8KnD4pZe9qfFobnHyTDn1zOWtty8LA6mEL1KRtHPAxj1ohQOcUU6 n99ZIayP3nwiL/lRu+ICRMIJtBY6FfU8zS6steZBqxNL8pvKqlsmZ46tdWOs/HmxPm+S v8xGQu08vEs+IWkRrFBun6XJEzHuLNMC2F7Acfrnx32UkmAdTUUbfy9vdndCeWXK3kER /sTu5KdBmxVw0FDYhL+iE9+Y9Ljw3SwE1k2o4o7y5oxj+a4dUnO9IDkrnATwOOEC57J+ FsZfdxjK3uj7GMdoe7iJxPdfOvYaKPosf76y53ROirl/tZIDlQnF3CnEEUuFkAntIwlg olWw== X-Gm-Message-State: AOJu0Ywzm11pbTFCV758Qg4yj0szDpO1iWwBPwtIGiWHC8bVKPiVu6FV aVH+wVnJlMq2kyBjoD+K9d+xwQ== X-Google-Smtp-Source: AGHT+IGADDIb7FS/BEzlD2NDaSR5lL9y4k3FkTUBZvyAz9qvN4bXZycSD4+PZlpH8/QgOFEsYt18oQ== X-Received: by 2002:a05:6a00:1d85:b0:68a:6cec:e538 with SMTP id z5-20020a056a001d8500b0068a6cece538mr7248281pfw.3.1692848690333; Wed, 23 Aug 2023 20:44:50 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.146]) by smtp.gmail.com with ESMTPSA id t6-20020a63b246000000b005579f12a238sm10533157pgo.86.2023.08.23.20.44.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Aug 2023 20:44:49 -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, linux-fsdevel@vger.kernel.org, Qi Zheng , Muchun Song , Jaegeuk Kim , Chao Yu , linux-f2fs-devel@lists.sourceforge.net Subject: [PATCH v5 07/45] f2fs: dynamically allocate the f2fs-shrinker Date: Thu, 24 Aug 2023 11:42:26 +0800 Message-Id: <20230824034304.37411-8-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230824034304.37411-1-zhengqi.arch@bytedance.com> References: <20230824034304.37411-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 5F50B180028 X-Stat-Signature: c5czofj1q7enpmr1j8hbdcchccro176b X-Rspam-User: X-HE-Tag: 1692848691-162720 X-HE-Meta: U2FsdGVkX19BTGebOYiSQGToGY2fPplt34iFSBnzs/0PVMVMoJqAaRrD4WkJnUu77OcuaTPt9wqu3+QIcWaZAlTyagEgAK2QcEjYM9s/J17P2XwBnXR1AypPw38YPL/LGV60EDqsCsZHz/BJE7TGXxNLOpTpyA+LTtx+oX1D6Mcklfihcs8JvdK/+Qm6GmtjOhf1p5g7V5ra2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fC1EqzI9RsX2Mq+x6Frb5RMwaG7+R5GX8uwNFboOo7gVEqxPw8tmhU5Ch1xKLyyDKmCA6eyrx9kjqkSK2o0h6gw4Xi5Xh4YhHTKH2raa38d6I+R/o8yce+vrfv9hDwiPIr/BhC56Jrc4hysdurEOQSd2GfRZQTjzBRk8F+98+AtYDrDzrwzFkDhQc02Bf5Y2nUO6keMD7/6W6MypPkLbswiMxBq0qoUQ== 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: Use new APIs to dynamically allocate the f2fs-shrinker. Signed-off-by: Qi Zheng Reviewed-by: Muchun Song CC: Jaegeuk Kim CC: Chao Yu CC: linux-f2fs-devel@lists.sourceforge.net Reviewed-by: Chao Yu --- fs/f2fs/super.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 050f4f8ee8f5..86047da85856 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, @@ -4944,7 +4960,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); @@ -4989,7 +5005,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: @@ -5021,7 +5037,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();