From patchwork Mon Sep 11 09:44:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13379060 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 62474EE7FF4 for ; Mon, 11 Sep 2023 09:46:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D7D1C6B01A2; Mon, 11 Sep 2023 05:46:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D2D286B01A3; Mon, 11 Sep 2023 05:46:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BF6516B01A4; Mon, 11 Sep 2023 05:46:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id AA0846B01A2 for ; Mon, 11 Sep 2023 05:46:05 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 7D830140915 for ; Mon, 11 Sep 2023 09:46:05 +0000 (UTC) X-FDA: 81223835490.01.4D578E6 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by imf15.hostedemail.com (Postfix) with ESMTP id AE68FA002A for ; Mon, 11 Sep 2023 09:46:03 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=FRT1mdaK; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf15.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.178 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=1694425563; 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=vEaLNFUhwmRxiNXJvWOPc9Z79QJgQluJlkgX3lFWQho=; b=WWBKaW05W0O4mpw9NGK604PEOUpUThVsEcR6JYhlpeSCaFwlAuic2nNwP3/Bp/61f73NsK esacxDFGBf/DTya57L1oNJs3I3ahfG4id8eTNr6AtsY0Cm3mfMYLG4k+i0gKbJzo2/v1mH 8/MTWz0TeAg/VHunsLoaykj3EzCaAjA= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=FRT1mdaK; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf15.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.178 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694425563; a=rsa-sha256; cv=none; b=jc6KxTkKa5WwFkgCUAk6Ak1eY6t1pG0O4mrXR907OpTbkJ7B18u8OhhFw4VcSpt7feudCz DeffpyHhQCXWYlFC8nfcY76io4I7TqSxxrLTynxFkgFm87jVNrWuEabaX2N1Xc0EJVnSW8 3t7GBIxjZqvjOYJ2OVSQm/iBjr29xZk= Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1c39500767aso6231415ad.0 for ; Mon, 11 Sep 2023 02:46:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1694425562; x=1695030362; 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=vEaLNFUhwmRxiNXJvWOPc9Z79QJgQluJlkgX3lFWQho=; b=FRT1mdaK2MGgfH5WPxE322qQ8W4/DTrbxHzm+FPeHRKwbyxJOKSxxJQ7cM4bvDROs4 M8EM/ffAAWdAYKoTPAxeGHRnK97RYe1h4WzgRguB7tZHP8NPt4tTBdwjOjmNEsajmF78 bv3xr/VeILARpEL+g5qpoPRAwwf63EYxHVqxCwuDfyOJ7UCiNts78qCVV9UXhCUtk/MM oA8aXhjDivkbvBxmIoSbM4jRHTxkJQjxaDxkrf8NqpHPCzDylIDkLG/ROoAbepyEkFVm d6OddgPrM4jQO/w67sYmtBuh1sna95lF3GbeXEgr347PdV9efrnmA+oYvQid8wFAKcQL K13A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694425562; x=1695030362; 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=vEaLNFUhwmRxiNXJvWOPc9Z79QJgQluJlkgX3lFWQho=; b=A5yKjDW9NpzeTvMS8BZC2QErkwdlobJzlyjgwwDx/pyA5pVnD5RgwIBvHS+eGFPlGh ME5XXa5k1JaI9rjaw8SvpjfTxQOuB9WNEpraWC1uNEXxFjASfR0hiTNdyogBX3hsmANr r36HS3RYJuhDKf/JaEOyTOQmMZx7EXU6uRG8hU5EYfEh2v9qfh3AYf9Tkv1A6IAsFe/A RuYvy5A6dQHaMOs8U7wQxaXXhr9L7rXeJmov4CBlP8tqhrNmsys//nZBtR4K5dx9gtzg S8bm3qqGa1FUvKLNV17UXg6Sw8aSJZeeEzixATQG8L6hlb85cYii0RosnEf62f7fn8Fg 5/kQ== X-Gm-Message-State: AOJu0Yx+N1det2MRQxyugGYwNE6plP+327BO5a2xd1jbLwlvkOksZivb 4UnBkRx6LRRt+pnSZa08nb2UGg== X-Google-Smtp-Source: AGHT+IEEe7OKLpAjWZ6ZHMp4sopalHLkAI6pc9tZjZALl4cTsdDgpaoyKPO/MAR6mRgsc+S+sQMbZw== X-Received: by 2002:a17:903:3386:b0:1c3:8dbe:aecb with SMTP id kb6-20020a170903338600b001c38dbeaecbmr8865820plb.2.1694425562720; Mon, 11 Sep 2023 02:46:02 -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.45.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 02:46:02 -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 , Chao Yu , Gao Xiang , Yue Hu , Jeffle Xu , linux-erofs@lists.ozlabs.org Subject: [PATCH v6 06/45] erofs: dynamically allocate the erofs-shrinker Date: Mon, 11 Sep 2023 17:44:05 +0800 Message-Id: <20230911094444.68966-7-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-Rspam-User: X-Stat-Signature: kpo8z4fcp4rb563kxymcuamzwq7dds6r X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: AE68FA002A X-HE-Tag: 1694425563-516538 X-HE-Meta: U2FsdGVkX196mUXdAKMRkYC32MTtKD/6cEOLUptL/2uhBt/H64BJgl98u2Tk5ldtA5VaOXkLO6G0eYksZvjZXjXSVHRapfzEpiTVfkS/qgZOanZIjg8FmPpVvIIyaVIX/ON+6XnDdOPHOimsuu36cscSp4MfU6mPo0YUDrstskQrLr/D1mz68CqpTejz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S91TRIJYdjUuzTr06g83IDsz35OTAfpMtEwzfX6n9yd2gqc454va/aKvKIFHPrM9S0gKAhFCNa0amgF+cnO6+RWAz2USeNRsn3BKetJ/TEHbGYZ4ULWA1nFp3iejnnZSdw1fKdG5HHO3evTLzNu0zVDKhllcypdEJqsl1JCCHxFA70yiTOJmHfpG7MX6UV/e4+NyvWJxHa7sS74MMYGqzj9Y10b4Pgkq8V97hsBNb/g0CTsHlYdk9BKUykgJh1y3iV8aKnu5Edj1pY2jKyERfvLLZJQ7hR31f6E3x9w4g/vAFB+jwlKa5W3sgvbhPkbp9BcnSPsR/aNAtC2AVH4nLfTpmqEVAtMJ3gjKN4jA= 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 erofs-shrinker. Signed-off-by: Qi Zheng Reviewed-by: Muchun Song Reviewed-by: Chao Yu Reviewed-by: Gao Xiang CC: Yue Hu CC: Jeffle Xu CC: linux-erofs@lists.ozlabs.org --- fs/erofs/utils.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/fs/erofs/utils.c b/fs/erofs/utils.c index cc6fb9e98899..e9c25cd7b601 100644 --- a/fs/erofs/utils.c +++ b/fs/erofs/utils.c @@ -270,19 +270,24 @@ static unsigned long erofs_shrink_scan(struct shrinker *shrink, return freed; } -static struct shrinker erofs_shrinker_info = { - .scan_objects = erofs_shrink_scan, - .count_objects = erofs_shrink_count, - .seeks = DEFAULT_SEEKS, -}; +static struct shrinker *erofs_shrinker_info; int __init erofs_init_shrinker(void) { - return register_shrinker(&erofs_shrinker_info, "erofs-shrinker"); + erofs_shrinker_info = shrinker_alloc(0, "erofs-shrinker"); + if (!erofs_shrinker_info) + return -ENOMEM; + + erofs_shrinker_info->count_objects = erofs_shrink_count; + erofs_shrinker_info->scan_objects = erofs_shrink_scan; + + shrinker_register(erofs_shrinker_info); + + return 0; } void erofs_exit_shrinker(void) { - unregister_shrinker(&erofs_shrinker_info); + shrinker_free(erofs_shrinker_info); } #endif /* !CONFIG_EROFS_FS_ZIP */