Message ID | 20230807110936.21819-11-zhengqi.arch@bytedance.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp1402100vqr; Mon, 7 Aug 2023 05:11:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEL4yuSKEg7aPrcIxhlk7Ehx5o20OHslu+iMi7ifUJhztjMO9XmeoCUyHqttKAJKKs1bUX1 X-Received: by 2002:a17:907:7786:b0:997:865a:77e3 with SMTP id ky6-20020a170907778600b00997865a77e3mr2165470ejc.11.1691410291818; Mon, 07 Aug 2023 05:11:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691410291; cv=none; d=google.com; s=arc-20160816; b=iDXb/OmL93BQcCg4FCnKpbrUgXcvJBhvokUdJFPJtdsHAd4Y+gNrEMW6jdTfcG/DJw 4VhnHBJiV6IQPL8YnHtki8RYXzgHRzQP5GRWB2W3bUilXkUVQ7EwYOg/PY9+c5kszdW1 eeVnSOb5I5JU8I0Q+D+kFUmXVX083Mfhk+TFWeQajr+Mxc/rYVObJaa1YqL9/JdoCEWZ XA/y0YIDZHnAFV/q0PN/p4ScgtJuMlHSQM6D0LHm+mHY1SQ0uB/91Ru1Y4YDawc6o872 F1KxekLUzwc5QLtNni5g85fb+r2kXR1FmW527oFI33CZHKL2JYrpjffPvWF2SLVusuj4 WZNw== 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=2qNGhCyBYRkIC+KqhUj1bienmPbnCoyI88yux10rL0c=; fh=JwrRg0ndXrpURY0vwDVMB2JxbP/kKK+/sa4yghEeBpo=; b=EVK9TaAy8bsvdjBeWVP8s0GOtt2ntchP9saFCeXz54fF3b+Fy9FoAn8ILQaud/FO8W WljtjQQSVJe6aD8DczaNmWBPCqPB95taJJjB4ThKygij7CyDDEM4uFrltk1btC+ykyrm 2FI4oA6zwxZDDyKQvRfq1RH9m2B+Ojid+wqp6w1UaRV+ow/F2kOtJWGOI+V/IxqmgHvm vHEt67VWcyhQ+kPtmLIz6ip4kKpKflWF3GHGQfWnQG6qogRoge5Q6ILapgm9HGj113MC F/W+fGZq1565MyrEp1HfEhSHxPbOBJUQzMc0WH4uBgLTwNe4gTFxmZWsB6UdsVbZ6cGH oWdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b="Xc/b9RVe"; 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 o16-20020a170906601000b009930c0374basi472277ejj.632.2023.08.07.05.11.07; Mon, 07 Aug 2023 05:11:31 -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="Xc/b9RVe"; 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 S231269AbjHGLN7 (ORCPT <rfc822;aaronkmseo@gmail.com> + 99 others); Mon, 7 Aug 2023 07:13:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232048AbjHGLNa (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 7 Aug 2023 07:13:30 -0400 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37DF0210C for <linux-kernel@vger.kernel.org>; Mon, 7 Aug 2023 04:12:43 -0700 (PDT) Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-55b5a37acb6so361949a12.0 for <linux-kernel@vger.kernel.org>; Mon, 07 Aug 2023 04:12:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1691406725; x=1692011525; 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=2qNGhCyBYRkIC+KqhUj1bienmPbnCoyI88yux10rL0c=; b=Xc/b9RVeZGabBZRzbFnLG60A3XcuysnQbX8QDB63xQh9Qsy33GgzK9r54ssZ8BRYsv Zo1icyrpegHwV8KMFlNuxd6Vv7rJh2g9STB5A/Cyu6q4WM+YLxsvvmbNVVdkSntCluNl It/PLVMY+sHjh9niVg4dAEeIOr6EcMWhtMnuFdCY7H6/MC8Iz/ZfTZnLr8OJnSIA36e9 mmNGX7xKmI8VWlsJYDncO9Zq/rF2h1OiOCACwI0xXgbsWIREHFfM5CkS8NCDLLHpFGlK JETB4OwnLh2lGmaSIFNM9gd2qMpLx0zP9hut1e08UtN8MQU5ZK62c3ni+xnuk2sIAfG7 kkXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691406725; x=1692011525; 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=2qNGhCyBYRkIC+KqhUj1bienmPbnCoyI88yux10rL0c=; b=K6PvTmrl9ZkAUcy/VuZH8JLZJCtdmLfjhJn/5vCc6VSPtY2gwI6jwROY0EUHHLOxdk tK2aWfOTiC6/WAL9B5ytXctVrSuo03hFRuq0qlQMQPhSUeM4sMMZeslZw27IPjCcGdiw cpzHYRhukVIJpwpoPl3drNqpXfcCxmmqa0sHk7LYDrnpw1k6ZxWGPoq6tOq/lxEmM3We tCHZ4hFMdwEucNZYU6OFFYX/kyMLeqfaOVu5RUrffIMOGwb0rpvbaz7YhV2uXQwJve/I fUWc6Pl88dd4ftJ1M2rfZoSA2VoM7AdYN+xwtEPxHemLOaom4yq17MMzDa3fnb4iAPex Ut0A== X-Gm-Message-State: AOJu0YwGcrrmam0IgYd46zAAKJ7dFya1Gu0DhqtWiNWl2a9ieWjX1+PR 7Jri5k0iP5JcLt71jj4E18oOKA== X-Received: by 2002:a17:90a:2909:b0:269:5bf7:d79c with SMTP id g9-20020a17090a290900b002695bf7d79cmr2210453pjd.1.1691406724771; Mon, 07 Aug 2023 04:12:04 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.146]) by smtp.gmail.com with ESMTPSA id y13-20020a17090aca8d00b0025be7b69d73sm5861191pjt.12.2023.08.07.04.11.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 04:12:04 -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, simon.horman@corigine.com, dlemoal@kernel.org 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 v4 10/48] f2fs: dynamically allocate the f2fs-shrinker Date: Mon, 7 Aug 2023 19:08:58 +0800 Message-Id: <20230807110936.21819-11-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230807110936.21819-1-zhengqi.arch@bytedance.com> References: <20230807110936.21819-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_BLOCKED, SPF_HELO_NONE,SPF_NONE 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: 1773572238343692061 X-GMAIL-MSGID: 1773572238343692061 |
Series |
use refcount+RCU method to implement lockless slab shrink
|
|
Commit Message
Qi Zheng
Aug. 7, 2023, 11:08 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 aa1f9a3a8037..9092310582aa 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, @@ -4940,7 +4956,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); @@ -4985,7 +5001,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: @@ -5017,7 +5033,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();