Message ID | 20230807110936.21819-11-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 80D48C04A94 for <linux-mm@archiver.kernel.org>; Mon, 7 Aug 2023 11:12:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1BDC36B0072; Mon, 7 Aug 2023 07:12:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 16D8A6B007B; Mon, 7 Aug 2023 07:12:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 05C388D0002; Mon, 7 Aug 2023 07:12:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id EB2436B0072 for <linux-mm@kvack.org>; Mon, 7 Aug 2023 07:12:07 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id C0247120A0E for <linux-mm@kvack.org>; Mon, 7 Aug 2023 11:12:07 +0000 (UTC) X-FDA: 81097044294.30.FE4A2FE Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by imf29.hostedemail.com (Postfix) with ESMTP id EC71F12001B for <linux-mm@kvack.org>; Mon, 7 Aug 2023 11:12:05 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b="Xc/b9RVe"; spf=pass (imf29.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.215.173 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=1691406726; 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=2qNGhCyBYRkIC+KqhUj1bienmPbnCoyI88yux10rL0c=; b=2g8dS6NAXH70ZBTobyCCmKBezoTcGUbqcWCqbmyXLncRlz8jlSLYE0BWggJdQ3nvwe1cle pBVI1K5MwaN/eMPfit8FpZAKciVLph1AF6OHvJRpSGqw9xP2zPZLpPp6rWgX0XEi8BtRBR lqNjC1cAAR0NEyaqYDikGdHt01JhYrQ= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b="Xc/b9RVe"; spf=pass (imf29.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.215.173 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=1691406726; a=rsa-sha256; cv=none; b=wniaKph+TsFtoiNtmIF7AB9MmU9DicW0nvFLfKY4+Zt7gXNSPYHc9xnLcYSt3xP8vP10bQ foLHgGTjhP99EsRWiOAncFP8YkMPa6aBtYIr5ohZSllAF0SjhL78wB0cQlBF8uN0WnM+gZ 10+mavTD49ty8IFyWHn8Gg25RMhWESs= Received: by mail-pg1-f173.google.com with SMTP id 41be03b00d2f7-55b5a37acb6so361939a12.0 for <linux-mm@kvack.org>; Mon, 07 Aug 2023 04:12:05 -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=TpCjOawhgxedr7zEQCx7Q+q/jV9rTtMRJACnfgjfbCVc2LuIBaNUQ0zd2VlrSgDNAB 0U/0aN0BGz1vNa0Xt/PK6s8efPkshk1v8Qdg07MbhSbxzjiOqznmpxy5UaSOdPQjDSYE ngVvKPH4qLX8oRy8c1ogzwtkB23FmRQZjdPBzlumV8mbedf2T2K7XR/77gJV4CS+/g0y ibCNb6J6CYQlnOV/cNCc+bGMyFxv4SrrXy5E9rwToD82NEtdYhcFuokNIaQjEFs1LuhT jYfilDU27VI9TmplFUKLPv2qAMXBMPcDpqqLWkQ3eF8BR7RlEmi67J3LHHIqUeQPpOvW 9Yaw== X-Gm-Message-State: AOJu0YzCgZIuJxDXuoE5z7klrmE1GpcPUQruBCUk9yGvTFwFWsZk9Lro aiS/WZ7ZCw/t75RExVbfT416zQ== X-Google-Smtp-Source: AGHT+IH0i+Trkswf5ZN/Zo/hyk0nSAkeHBCb5cnTJePkF3I+vCqNyDS8fjeM0LPIBtSn2h3E1rmPDQ== 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-Rspamd-Queue-Id: EC71F12001B X-Rspam-User: X-Stat-Signature: j7r47oy9gmgtu3p5k16tyk7x5kh79o65 X-Rspamd-Server: rspam01 X-HE-Tag: 1691406725-470877 X-HE-Meta: U2FsdGVkX18MRs20yj58Qaqmv4CZEjnXUvpmur6gMUrY0HlMoprS3kc0KMmpolfUL3kWqFiWBGXLnkuE41aIcrWXsRhBnzC773a5wmDDobX1kyvTKGObpenNaGUnwXxD2zFiVR36c2yXT43j2pJgriCB3PcOdSQbcF6R0OzbsXo8pPuBnTSUQdfFiCCbXoGYGk6n7+FlFy+Osen43t8b2dpnu7cbgWRJf50m44Y/S4hj25583f2w7tNC1+K8ivyJCuUDTVzWAYjCp15gasu/9d/wcSgeqTA47tzdWG800WMtxLXxAUvXY4b6meKKpVBbDgNZ7QyOoT73eDR2P7z/rnewSe1daaWJ9ubKYSKx9nkHH/+1WZxJJiyrUgB+EcQVm9cuph1y6BkrpSG6+kpJbYcMFvJhzJMqT1KY5Jc0P7FhixdfFZqpQnlRT3FR3gv+vTYDDoo4duRzQ7hhVzhPHIQcR+Ps+aSQmX3ClQD4OBkeo7m1YUi+IO5R3kLAx3IZIyoBh+6oG2bq7i6PXSVxa4x+LxWs9KJnjJ6L+nZAisgY6tMgU+E+Arm/z4UGOVFBP+9Sw4rIFbb+SWEvei3YXrGv6nZJ3gNYbDDUjQMDx2B/UX2U/BCdaRX3HqLo05TvQCoN0zj3+20lNXcvrGevHyCsK5PzTOCsEpnJuQ8yQ62wsayAu0rPizAuoYevPst/AYWH8vzDTKZx1DPt1c6/Js0IBgdbgZcwX1KnKH82vHUby0Oy0OztNy+3y/IJ8vz62FMfCKAmf9tyl2RwxnsXxlFPFGtGBCm+MNpweqyio1IWd4yXV3DMwxz5wXW6Rysfb7tn+22wx8U3kF5ydq3sYSOQOqEckb8/AGvvX5hVk8LFopkSyeZ4obafi0DNf5gqjIVRWmhj/ECTn4mqPtUDlH70BJnSr+0Ic58hNJfK6gcnyO3xs0O9rpMpKhYyKPgPC/VUtScvKTc+e9DEAF7 3SDCaBnK AN1rglc36GPbpr3nabykjVNFv8KLEEHRhOi0pS4obg9AcqbrYjHjXE4d1WuKSxa9Oe2L1ZRWmm8hUeEdRKFefqElWyt7QxhjWFhxlaQxj8w3TVlRaROSlAi1qK1oStRwicjVzWq6bBVDrxi4Qc9ieGg8S/EMySGEF+aJogq9iciGgNh6zIZh89iJVMdsnjqApttBHm6MZsL9hbuDC+h5ml4xHlI9xrbIeSoGGdnyX2CkpUmgaibyMUTBa6tgNFyk1RJQdadLVe+URd8CVDcmp87uja6xvSj1YZA9G5E/I5K8BZDG5Cv6+KcFj+MvTMocZUuDaBYuM85wYVoDdiM5vnBgMa5MbsO16RhyGS96dZI0YEOFw8zqsDULR8SknmDk30IXKVOEX7D81NoAd1CgqZTBKsCCQtItURTJW 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 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();