Message ID | 20230727080502.77895-12-zhengqi.arch@bytedance.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a985:0:b0:3e4:2afc:c1 with SMTP id t5csp976635vqo; Thu, 27 Jul 2023 02:43:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlEBleZCg2qfkWBj2GI27QDJ6CfGRYguzztypg/1IIlOSwuxQp3Zv4lpWcbubrWgmx9olFUs X-Received: by 2002:a17:906:73d0:b0:99b:d178:f05f with SMTP id n16-20020a17090673d000b0099bd178f05fmr1398818ejl.71.1690450982299; Thu, 27 Jul 2023 02:43:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690450982; cv=none; d=google.com; s=arc-20160816; b=dFLzGRlqtMOBwo557swG/9yzKKlhzC3KJwo0EzetH3wFZ6v7hAYijVHSnQmXCJoEEi C82N+N6bwd0+dSTFyCPozSPxm1EoI13g5l2NCjT8J96Pugoq8QJXxfE96P8gjJIPr/lu L4dGkdQSpYQjn0KDmfhl3axr0v8PTIWvi+skj3T0r6i0ymETunfDtsCigXsMPc99TKFx Kb1ITZ+R0qlcCiASNQqOowK0OopGYg0ekTWGbyP57dA1LH3UylCB+QGVSLYm81QXL5mf xVGGzi6Sp4hnBRzxRegWc9Oz73OXO0KxthKwRG2rDtxTE3H23BRTQC9Q/YSV58QrLssP YmyA== 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=f+zNYaRC7WOrXvS9MeEiQUBTAQfjLjc/pgN/esuhj34=; fh=NxkGAd430gburLVd9IjvP+jLcLBa8IzZa5IqPWgCN1g=; b=TgwtsT/hlnB3Ijskc27LxnAvf/I6n6t71LVdp7+zJvoP5JrB/5ZxqdRu4afQLmo4AG c8NVayG8qlrYMBhVEFh7om9g1zQw0CdQ/gxjo1+EVTbXNda16qIfEwnqI48euOu6MZLL GSWJXBABkZ5X9K8C6KJ+KEeUdryhlOsnHqG9aVRrj6netcK5KgF1rwi5SbPcIVZbSD4w g0OeGo7hVNpnENe+Z5aVyeuBn17eKARcY3QvoW/N+rFVkTK4yIl/ggZSeshqBoy4qx3j 3zn4RcxIsWqdohNah1uFmivglul0mrfxX5OvwwvDWLLdCcMUJuRf6+KwWosVcmlPlwn+ bleQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=UV9nrUId; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g11-20020a170906594b00b00992b55d152esi711298ejr.242.2023.07.27.02.42.38; Thu, 27 Jul 2023 02:43:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=UV9nrUId; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S231665AbjG0Iha (ORCPT <rfc822;hanasaki@gmail.com> + 99 others); Thu, 27 Jul 2023 04:37:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234279AbjG0Ig7 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 27 Jul 2023 04:36:59 -0400 Received: from mail-oa1-x2f.google.com (mail-oa1-x2f.google.com [IPv6:2001:4860:4864:20::2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC5DC7AA0 for <linux-kernel@vger.kernel.org>; Thu, 27 Jul 2023 01:20:27 -0700 (PDT) Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-1bb701d39ddso184192fac.0 for <linux-kernel@vger.kernel.org>; Thu, 27 Jul 2023 01:20:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1690446026; x=1691050826; 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=UV9nrUIdL69f8nf2oXmA0BBRi03QhS7x4OjDWSUunG2xMdBziON6b/oPFkBj1KGz6l zQbkdDYs5+ShHPDX5WScDWLGAmMpHuUV3bfvkiDR9RqVAfdCoBAF+k3U2IhOa/ZdGA3m ChkDHdMJuA3rrgdpjISYmNBecN4LJMIAxx9lMJpiOrSHPIa+UqJ7uwciCO6yMVtBAZgf f050BldJTGbsJPZcThpHgziPqJnclt3L1Uv5Dl6NMfs5xKNagYUsU7rVYYA5pVX9jKjJ ylF09B0e49VsY2SNtTA0020pH0cy0DsDN+jy7WPM36nLqf6rJNCP9jAjVBD3mZjwsB15 2KbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690446026; x=1691050826; 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=Gn8LrydflFhN8RgyjmTn771fhRPS9dnvXa6plCu07PJlwqa/5Mi618M03IoHSWs9e6 BinvSxOW04Th5wbXHgs4JujHI07ATfA6c/B6bftwraVnSuPi8Y9J0S8REUomvIy7dwv/ yyT/75UHwK7sssuzfVp57WNC5G2Z9eeXyUQUrUjY3y6VymAeVAIWVGyFOyzvM5F00IXz evvixjroSefTjIjhCPnVmHKRjDBiKI+VWmehnfj6YS+hhZiBj3UR+dTRn9YnimUYxS68 9J6fgU/e4wBvOUPSk8qPfTGM/zEHKLr+oyHfcAf9d81ZxJVEzfpFnEBdTHqVboKmOMF1 i9rQ== X-Gm-Message-State: ABy/qLYDoyOcF9dOCgXcOPPYHjUA9ZxiEbFzcfXBV/eXwm7CSuyztg/J 1rg1E06tdepsEYMwUgOWgk/7rvrziOnn/o/kuYU= 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-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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772566328963736578 X-GMAIL-MSGID: 1772566328963736578 |
Series |
use refcount+RCU method to implement lockless slab shrink
|
|
Commit Message
Qi Zheng
July 27, 2023, 8:04 a.m. UTC
Use new APIs to dynamically allocate the f2fs-shrinker. Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com> Reviewed-by: Muchun Song <songmuchun@bytedance.com> --- 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 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();