Message ID | 20230911094444.68966-8-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 C28CAEEB57E for <linux-mm@archiver.kernel.org>; Mon, 11 Sep 2023 09:46:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 651826B01A4; Mon, 11 Sep 2023 05:46:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6021C6B01A5; Mon, 11 Sep 2023 05:46:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4F0966B01A6; Mon, 11 Sep 2023 05:46:14 -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 3FECB6B01A4 for <linux-mm@kvack.org>; Mon, 11 Sep 2023 05:46:14 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 179F3C0990 for <linux-mm@kvack.org>; Mon, 11 Sep 2023 09:46:14 +0000 (UTC) X-FDA: 81223835868.19.5943C06 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by imf05.hostedemail.com (Postfix) with ESMTP id 4A48510001A for <linux-mm@kvack.org>; Mon, 11 Sep 2023 09:46:12 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=hKx3SgbS; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf05.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.182 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694425572; 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=r2z5ZP0td7rQio33ZrusFB6X25vGZrzEp4fIJ4zc7l4=; b=lQc8TRQsuNRhElfz9a1o3IT4zA3Tfk0FMrfOGgt9zbKgY5+8Haf1Zvzto2rpPAnvXYL9cw C1jfNDw9L2UruSY1ilPtl6xosaVVTJPsjhVd8a0I6OK1guk62tFn0gWS6cJeF1Ms82Pe6q qZfU/9zolyF5B9hNn35lwg1Xer6BeTU= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=hKx3SgbS; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf05.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.182 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694425572; a=rsa-sha256; cv=none; b=4YUSN5cINJJRprkpE7OlRAbP0lV7DMkEn7SIzkx5oHy3vrqslp49n1rYQorLJMWMdWxldY Z7ULCqMA2r9Cw5czh/SMDu+5Friq8T3w50wLyX/FnbLl33Z0n50uzYx6MeiTK8z3vmNUSh TwECBXpFHXdSwLmZ+DpUASKR6VyKs10= Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-1c0efe0c4acso7083805ad.0 for <linux-mm@kvack.org>; Mon, 11 Sep 2023 02:46:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1694425571; x=1695030371; darn=kvack.org; 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=r2z5ZP0td7rQio33ZrusFB6X25vGZrzEp4fIJ4zc7l4=; b=hKx3SgbSvfplEurPK6tcgp92qjxOE87V4hdlh0k0eIJnhqAqooz8ev6zNK9UEe2Nvg EVWyyxQNpCcvhJynj+KwO/NsXsVBgLdLm8+xeSOHNQojGvfZwKetSNsVOpP7Cpr+eFw1 bfqgJT2vO+J42H4u3fRxWvG49GRPztyjEe0wKeHbbXOKgcGlyDmQ+bJqvVes6DJ4bg5i /DsDWzdudMGTux0zBfm71JLzyspS2i9zEY88Dj251HIfjX8vuSuG7mNka/XPbJSxawpm TCvwxpzPNRSalEJGQ+0xpYbL5fYqRKYwC+ZukoX9mmMSI4jI3QDyIpPEc9CMDz0lnLL2 3fVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694425571; x=1695030371; 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=r2z5ZP0td7rQio33ZrusFB6X25vGZrzEp4fIJ4zc7l4=; b=RkzlSeO3uq8vMbw9q5Pavqpw2LlRMSgBGF52BVw8qF75p9BPAqq0isdaqZBNe9hklg C27xGQkYIz1UT9fFAIlWiMZJg6RdVrB0NbiL+9vudShppk8qKckSIiVTEhH3Yv6z8eRs LI4xIDEB9bZiuY5mAMH9F9AQ/z4S6pQRQ3opOqmKQo2hPD1PGUFi5z7ndJmcmr/ryETW ApeqIokTnu9ahm8Bw/058+hBQLWin+/KHTInrkq5cNJJpvt0JTCc7WRjqk/5SVBj4ufP ZNxed+EvdESL0zZ2CZYoazgM99e0LxalTbUdLliSmL39zjHnlVPDtYQpMZLk0jah+rdT fyxg== X-Gm-Message-State: AOJu0YweIkOFUUYiZnefBNWi/LdUkCHhjLx3mHdUHxV+gTQJTnje8UZx /ZBtUn7mBnZrKSQUB+lompd0AA== X-Google-Smtp-Source: AGHT+IGMazOb/vYj+YAbB56aNimJAjHvQ95oEZj3vNPDNUhDjsPyS/sjYbZ6xZxadrVaoBmmMuhKhg== X-Received: by 2002:a17:902:da92:b0:1b8:2ba0:c9a8 with SMTP id j18-20020a170902da9200b001b82ba0c9a8mr11823440plx.2.1694425571312; Mon, 11 Sep 2023 02:46:11 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.146]) by smtp.gmail.com with ESMTPSA id az7-20020a170902a58700b001bdc2fdcf7esm5988188plb.129.2023.09.11.02.46.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 02:46:10 -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, linux-fsdevel@vger.kernel.org, Qi Zheng <zhengqi.arch@bytedance.com>, Muchun Song <songmuchun@bytedance.com>, Chao Yu <chao@kernel.org>, Jaegeuk Kim <jaegeuk@kernel.org>, linux-f2fs-devel@lists.sourceforge.net Subject: [PATCH v6 07/45] f2fs: dynamically allocate the f2fs-shrinker Date: Mon, 11 Sep 2023 17:44:06 +0800 Message-Id: <20230911094444.68966-8-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230911094444.68966-1-zhengqi.arch@bytedance.com> References: <20230911094444.68966-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Stat-Signature: 17tscajazbjoxfhbu668668eh5zgtnh3 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 4A48510001A X-HE-Tag: 1694425572-8013 X-HE-Meta: U2FsdGVkX1+RmAilCJte7EwkGb3WfdVuXRF+hupzxn3/OtnJek6F0fhP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dHshc1QdZaVVDpVHIuy81gwEtDWzJKt4AxaWoYX15tZXBBWfid6fYmesNEwOnYtKJyQIL84VVBn1K9gKThxtcm9Y08TSnnFSOyjBt16H0PoD18mNuwgUQFhOTqnfbf+Sqy8EIpfi+MJcB6N7xcx/FUt6eEIuytncBcb3+SRwipfmw1wqBQLym29nzeTBbbPx0keiU9VqedrobKPp1e0M8drRarWOiRsMuUMokaowrBE8mTIrwBuWa8P+QVQoUL72ZvXQsFu+Ot9MYbfBDrrZYqGMz/YOthANMH9yQTu/Kmta/fROJ9pC1iX6hbXSDc6mO2aLU8tycAlV9BRhvOjOWZtScwGoAyPT1pkzLQumQ== 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 a8c8232852bb..fe25ff9cebbe 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -83,11 +83,26 @@ 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; + + shrinker_register(f2fs_shrinker_info); + + return 0; +} + +static void f2fs_exit_shrinker(void) +{ + shrinker_free(f2fs_shrinker_info); +} enum { Opt_gc_background, @@ -4944,7 +4959,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 +5004,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 +5036,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();