From patchwork Thu Aug 24 03:42:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13363447 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 9F73EC71145 for ; Thu, 24 Aug 2023 03:45:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3B0F1280086; Wed, 23 Aug 2023 23:45:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 360A98E0011; Wed, 23 Aug 2023 23:45:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 228BF280086; Wed, 23 Aug 2023 23:45:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 11AAC8E0011 for ; Wed, 23 Aug 2023 23:45:54 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id DE7BF1201A1 for ; Thu, 24 Aug 2023 03:45:53 +0000 (UTC) X-FDA: 81157609386.18.836A723 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by imf16.hostedemail.com (Postfix) with ESMTP id 0BD0518000F for ; Thu, 24 Aug 2023 03:45:51 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=f2vdVUxr; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf16.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.172 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=1692848752; 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=txor78tbBDUbFlDeMsr+ZFPB/YYvYFMci1CkfHTVP5Y=; b=WMXDKQe6RGpJc3givkvgY1ayxQ/cHnPOO/jfXpmN+WcTToPLale13VG9oHybsIBme383eh MY6i9lVycyHAtLZDgysrPXWCLT/344TAq/VfoHoqvbHfnJsNfpCmZ7pjd4EENY0RX9nhFD r+1ijD0qq9hpAx9vXIAZRwdo4bhO1ek= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=f2vdVUxr; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf16.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.172 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692848752; a=rsa-sha256; cv=none; b=Ll7mVihwSf7O7NMO32H7SUyhDpKfWum5or/0SB2dKuGyEP6qepoE5UTuF08mtIFbr+eKAg OJC3NVCeWLKHC5bSEkkS3T+f5jPstq0kZEJRAJaDdXHv4ggum30h69NPyyD2IPqUxh5oP9 QDhZVknzfyfNCvOI9t+J2EMCQuiUvPY= Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-68a32506e90so1062317b3a.1 for ; Wed, 23 Aug 2023 20:45:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1692848751; x=1693453551; 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=txor78tbBDUbFlDeMsr+ZFPB/YYvYFMci1CkfHTVP5Y=; b=f2vdVUxrd53niqhHN3lu7O/qQCjl9NcyQMCaxNn5T6viuJuL5MKYfAonmu/gm5BijH nC5Wpi4a7PWBB7q8tUPiP0oHBb2PXMLT03b/6gYrtmaZCnd6Mt+uzRWvKmEXemtjQCQG ZqOtchTpFwMV/kb2DFtC6mLoj+uRINLATigvC/sQxB1HuNKMTQhQNfDZaNKW7QuCPmlO ar3szccuZEbmvlHzXFE8IKU2droLxg3xvWMPq6hPvSFYUp81Eg8+xfvSTACAFhtcNIz4 psn56S58o40IpPO+R5N36OuNZcU3R6vH+0jY7JcoeFkHzXkKohk/Mg5hsgTkh16avUea DzSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692848751; x=1693453551; 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=txor78tbBDUbFlDeMsr+ZFPB/YYvYFMci1CkfHTVP5Y=; b=DFt4BZF8Gr8RC0BwjoJazctvZchgz6QSTZbl+ww0cnjoikL59Q3kMrE34M5OjpO33r Hd+SB8I8Ut23pOjDbqBPdY/AXIB4dwK3kisDS/NW43T6PZU+EFoyTzTuFEGhinvNVOcd ox9Ojxn4MHp2R2C0S9mDOAi8Lifnb6R+J3yNWq9KfeA7CLDoJAuCZNW5jEK6KApNroo7 v9UjaJU6oNOe1V9ivZqly0w/lo70zOckw89AuvjlcTsJvXkbS/5Yh9GLidSjEiOz69vx v8gjuFag/dREk190qN7dr/e1MPXMb8Ivr2bqQ8E8To0D7H+tn/RMLgOWnq1TIgcsNwZ6 H5Jw== X-Gm-Message-State: AOJu0YzyP9PuyVXpnNQDnu9UWIqxynprq81QDTlXKYJ08URAUFD3cv1n gMU2WY28bJzR6kmqGA+HsEzYBw== X-Google-Smtp-Source: AGHT+IEvg2+/eMxtzAUOdXGTx3O6wsmWYf8GYszkDdU34p+/e066zZfZMwabjJVp+KFh4Fxn8XPDyg== X-Received: by 2002:a05:6a00:1d87:b0:67f:8ef5:2643 with SMTP id z7-20020a056a001d8700b0067f8ef52643mr15497296pfw.2.1692848751025; Wed, 23 Aug 2023 20:45:51 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.146]) by smtp.gmail.com with ESMTPSA id t6-20020a63b246000000b005579f12a238sm10533157pgo.86.2023.08.23.20.45.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Aug 2023 20:45:50 -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 v5 14/45] ubifs: dynamically allocate the ubifs-slab shrinker Date: Thu, 24 Aug 2023 11:42:33 +0800 Message-Id: <20230824034304.37411-15-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230824034304.37411-1-zhengqi.arch@bytedance.com> References: <20230824034304.37411-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 0BD0518000F X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 1wiefzbrga6znjzfkbintatbj8pr867m X-HE-Tag: 1692848751-476031 X-HE-Meta: U2FsdGVkX19TK/DeImZ+P9URxYN1W7q80OBiu1XIXwUToPYYWx4z/Zzo5XNCXDZSjrGsoaXiNc/ew2+QGoN4FCdFsGWJ4kkGsE9jsfDK17spzlWVOA5WCyDXZmSTGd0YPPlFMWfIK4YAiRp5UzDEbaeGj+CU61UvkoRvObdUU9z3q3+SajbVqctOd/drL3pyW1ysyExp6EmKw0GeGSjG31Oah/Z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pu4HzJ2dd8+a3NT+Q4jubR6iLxW1FoG1yp8BUncr6Bn+furQpeV6qiR78Wq0FCGKSHjx0g/bo/wWJa/Ad3fySujwA+jlTOO3Q9y465+db8Syo+AHFqJ+/6Rhg8DJOk/0DMRasgJM++HU27IXoifCH//ZBh8Uq3p42oI1xrA 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 | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index b08fb28d16b5..c690782388a8 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,16 @@ 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; + ubifs_shrinker_info->seeks = DEFAULT_SEEKS; + + shrinker_register(ubifs_shrinker_info); + err = ubifs_compressors_init(); if (err) goto out_shrinker; @@ -2467,7 +2469,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 +2485,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