From patchwork Mon Sep 11 09:44:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13379068 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 B72DAEE57DF for ; Mon, 11 Sep 2023 09:47:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5B7156B01F3; Mon, 11 Sep 2023 05:47:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 565F36B01F4; Mon, 11 Sep 2023 05:47:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4605D6B01F5; Mon, 11 Sep 2023 05:47:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 319A26B01F3 for ; Mon, 11 Sep 2023 05:47:18 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 0E78E1CA407 for ; Mon, 11 Sep 2023 09:47:18 +0000 (UTC) X-FDA: 81223838556.12.26A62C2 Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by imf08.hostedemail.com (Postfix) with ESMTP id 47097160023 for ; Mon, 11 Sep 2023 09:47:15 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=PgBekoGx; spf=pass (imf08.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.216.41 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=1694425635; 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=4NJRoYJvtB3JAQ6HjBpWzHn90j4fvohvXnELHULg3ZY=; b=XbNhZbdlAkr63R4w2wVUq6DKHFys7RfIWHOWIUnaSlBOsBL3eiF9z22bH58OFheI0FMI2E koWQFUtSQEd7JrLZntoT7SWPcEHrNFzpkDxMQcq1UlkuCCjrUjMp08jnGxMnYoXY1K+za/ oCJ1FH1+CJ9RlBckQTdBfeHxmQy2I9E= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694425635; a=rsa-sha256; cv=none; b=2nJTXc7WDBFYw/a8abIZOBf6nh8olYDb3iZV7jMXB9s/lEmj3g1/jWtg5c/Tcpt9aGan5D QivbHnKMCp+otmMzyxQ3zTEwuwzfSz/K38K56wfIz9g/Ll+5z+/3BSRXybhhLPE/OBuNJR PYi511SPRSUcKL/Jd9IKscnOnnFyuec= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=PgBekoGx; spf=pass (imf08.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.216.41 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-2684e225a6cso580089a91.1 for ; Mon, 11 Sep 2023 02:47:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1694425634; x=1695030434; 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=4NJRoYJvtB3JAQ6HjBpWzHn90j4fvohvXnELHULg3ZY=; b=PgBekoGxO6AziXcRWNgpDPQXEwwttTpz2Fp807uz0wU1lb06yEWcfqg6uWHiD6KL+m 70bD4zElnhxUcSRfxX5lMCBqSwPHS7nJzaaydTRfPV5Drx8rfZCr8n6bue+dkBayyzJp 9RcR6RkiV6EvqJpuf2R6EHX1TVcUsSRnWG28icXvmaSjovZ3Wiq7PARmHmJEisnZPIPH T/5tqkfjrYawm5o2U0t0Ewb8Y/26LL4xF9vOSOalwCB1RTbHRMv4YYyQ7SnY8lfHLvLH ZTdb//YnjZfR6Sz4JFLoo7jAfFSs9k+h/k829OMakNlCXIF5XBJOX+ZrmVlsHOlWnUxn +QBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694425634; x=1695030434; 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=4NJRoYJvtB3JAQ6HjBpWzHn90j4fvohvXnELHULg3ZY=; b=XfAqDtwty7/E2+XEjyNtVCVQ0ytI9WIAvDrmJtGLH1uQ+xK03zDwTrc4JMSNSJRTwX yzIdP6sDgf2bA+LJgmbzbzg5+vo4ZMYaWWXW3yFel2WSWRiXjbjsdDc62N4XMpk3tXjR mTK1Hsvr10GIpd+uSEWNKD8gs5qcG0digT7i4rJaBIM7aTjj8k5UOGsD78v1eq3PnPRt LlOlVjc6nqAZEFGH2ju5cT4zTGOujesMmoQogq+SShFBzhm3iHabcZosIqSgFot11IEV 01ScrPi0lalqO3AOAgBCReLPWNHRyi+0J1LiqcsceY7zqY5l7rQxHSWOpuAHDhogUiVg dSkg== X-Gm-Message-State: AOJu0YwBFvWFulDlAGZGoBRJg4ICjDp74RRqrq/wCdJhpRZn5W6jnnmf n6V2a9i+KoooiEq3eV1w2vDULQ== X-Google-Smtp-Source: AGHT+IHGrhLYQcHrSOL/A0AfShLW1GL1aOG0gH1s0a/WptYINVPGtQZkcxOK/Zv27+cAk2ggUFIjmg== X-Received: by 2002:a17:90a:9bc4:b0:273:e4a7:ce72 with SMTP id b4-20020a17090a9bc400b00273e4a7ce72mr6446431pjw.3.1694425634193; Mon, 11 Sep 2023 02:47:14 -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.47.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 02:47:13 -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 , Richard Weinberger , linux-mtd@lists.infradead.org Subject: [PATCH v6 14/45] ubifs: dynamically allocate the ubifs-slab shrinker Date: Mon, 11 Sep 2023 17:44:13 +0800 Message-Id: <20230911094444.68966-15-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 X-Rspamd-Queue-Id: 47097160023 X-Rspam-User: X-Stat-Signature: 7kkepsd48f9h8dtkz7bmpc3kaw9hrhus X-Rspamd-Server: rspam03 X-HE-Tag: 1694425635-660495 X-HE-Meta: U2FsdGVkX18TEwm8yoLMZPuM3epZ/Tc8MksyD1t03mh3rqkPsk1YoBo2J/R5i5Lq8TSYSaQ+9slQiaxlEtnI9dHy2Gt3IoQOb1zcYQ/f/KavCx0Kr2eI5lTemYA1EvjtqoQRZhBeyYK/vc68ZSEHU8uxrrDEntR6LxF72G7baBIOCCMqPb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4kkNIaJjp57uZ5fDhrodDFs3jMBXEQXjm7ElmlD96U+n8cCmC4xcHfPH6qW+AjturOdLJBPxbGUmGS8IGxSPmYanU1Uh+fjm3bmUDrYoSHBMdDFZf2uMLx5YC/+DCpLX8nVVW7XjxnnUal051xeDwMzkwHKc2YMWeQBeG6FEoWoZbF4UZ297iIMOzQnPStBGvLDyZPcpSAylrjzIFScVTe3S9o2en4hWeO/b3Q8k 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 ubifs-slab shrinker. Signed-off-by: Qi Zheng Reviewed-by: Muchun Song CC: Richard Weinberger CC: linux-mtd@lists.infradead.org --- fs/ubifs/super.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index b08fb28d16b5..96f6a9118207 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -54,11 +54,7 @@ module_param_cb(default_version, &ubifs_default_version_ops, &ubifs_default_vers static struct kmem_cache *ubifs_inode_slab; /* UBIFS TNC shrinker description */ -static struct shrinker ubifs_shrinker_info = { - .scan_objects = ubifs_shrink_scan, - .count_objects = ubifs_shrink_count, - .seeks = DEFAULT_SEEKS, -}; +static struct shrinker *ubifs_shrinker_info; /** * validate_inode - validate inode. @@ -2373,7 +2369,7 @@ static void inode_slab_ctor(void *obj) static int __init ubifs_init(void) { - int err; + int err = -ENOMEM; BUILD_BUG_ON(sizeof(struct ubifs_ch) != 24); @@ -2439,10 +2435,15 @@ static int __init ubifs_init(void) if (!ubifs_inode_slab) return -ENOMEM; - err = register_shrinker(&ubifs_shrinker_info, "ubifs-slab"); - if (err) + ubifs_shrinker_info = shrinker_alloc(0, "ubifs-slab"); + if (!ubifs_shrinker_info) goto out_slab; + ubifs_shrinker_info->count_objects = ubifs_shrink_count; + ubifs_shrinker_info->scan_objects = ubifs_shrink_scan; + + shrinker_register(ubifs_shrinker_info); + err = ubifs_compressors_init(); if (err) goto out_shrinker; @@ -2467,7 +2468,7 @@ static int __init ubifs_init(void) dbg_debugfs_exit(); ubifs_compressors_exit(); out_shrinker: - unregister_shrinker(&ubifs_shrinker_info); + shrinker_free(ubifs_shrinker_info); out_slab: kmem_cache_destroy(ubifs_inode_slab); return err; @@ -2483,7 +2484,7 @@ static void __exit ubifs_exit(void) dbg_debugfs_exit(); ubifs_sysfs_exit(); ubifs_compressors_exit(); - unregister_shrinker(&ubifs_shrinker_info); + shrinker_free(ubifs_shrinker_info); /* * Make sure all delayed rcu free inodes are flushed before we