From patchwork Mon Aug 7 11:08:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13343347 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 20E9EC04A6A for ; Mon, 7 Aug 2023 11:11:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A21966B0075; Mon, 7 Aug 2023 07:11:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9D2726B007B; Mon, 7 Aug 2023 07:11:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8998B8D0002; Mon, 7 Aug 2023 07:11:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 799156B0075 for ; Mon, 7 Aug 2023 07:11:55 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 4350780909 for ; Mon, 7 Aug 2023 11:11:55 +0000 (UTC) X-FDA: 81097043790.22.727CBC7 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by imf07.hostedemail.com (Postfix) with ESMTP id 4BFBA4000E for ; Mon, 7 Aug 2023 11:11:53 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=G6tJn+16; spf=pass (imf07.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.180 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=1691406713; 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=ubpyp4SIhGXjO6/VTKiZvWjlRzyN8ANvKHVN5xSGnIw=; b=UsYu9UD+P3UURnOovXFh+TF9r8nYoe1UrmLMEXYuuVxFyJmnv6DpIVXIjHgZSIFgV0lyS4 KyXJPt7ht00/X9yqebXivHncpUkavhEvstk1gx4QgIF1rZ2mLeDoKmdqI+Zq+B2TDyKfOy ehk19JinUES528BVP7uLCG5RhzuFNmk= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=G6tJn+16; spf=pass (imf07.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.180 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=1691406713; a=rsa-sha256; cv=none; b=RXHDVV3VkfCgdPcqS7uO8IdoLTPZ9avNjk1tTEdQjueWij7T7eM2EdGpvFHUVbJsz+VDhs MZetXjXd7JJ+L2zlQIE3mHrU4PPwzchHgV0pMP5DOwWEC6JnUVB6hdPqJuV7sI+ZrXo/1l cRv4eB+cNYHxgJnJ4PopfTi0PRQGy2M= Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-1bb91c20602so9342295ad.0 for ; Mon, 07 Aug 2023 04:11:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1691406712; x=1692011512; 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=ubpyp4SIhGXjO6/VTKiZvWjlRzyN8ANvKHVN5xSGnIw=; b=G6tJn+16QVti2qtu2hqYljseIE/XGpe1Yhsul4LFU6R/aCDAM7lceOlES83Z0B/Pue 2irlih/PCzGRhADqlmxdT4ZmTPg/rDw2XT4QeZKx/Tui9xhVWAtyJogqiocaYi2mPJVJ JfsH0RSoKbpVavaYBWWtyo/mJh8W+H0WFTE4SVefHn6UoqHLIS8l90Z//i2iVib88cLh SO8x9HJ9eijOF2Obr6A8OaZNG3N0xetNtsejNB5r0CVLeObeV8ZzJa8r4m2G8/H610tO JRFiieD8eIQL4G+uzuFBv5AMDY6TbkMqFwB+fegzuV4xQGReerwz1d1NP8JNZHZ17Zsd g+Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691406712; x=1692011512; 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=ubpyp4SIhGXjO6/VTKiZvWjlRzyN8ANvKHVN5xSGnIw=; b=MF21Zb2ahhHvarvpjm0pKVGymlmJVlVVIFpSSRprjt/ZwOLtLs7w6WL2vrrByLpr0+ +3Y7vPUGv7V5yk+Wmu1PCQ8byZsBWeBLWce2oGmV04pwYQ8Def8gNUVRIaJkrcPAnoi8 89yoPetxS6vVrQSmTOGPTX2gN4mv7jHZxmhe9RvFjw3+hM429q61LLYqxcHAjnUFLhcy xdDRMcMzerrwoun+zeenwMTRAJxg47kKO0+oKtrt0pVi93Er4XeH3mtKTVwe1wdmcSl7 HgoewtEwv9xYlzWLP/Ppqog1+XOEgkagUjK5m6xSk38PevQk/koUFFaEqor7dwwiezwT kqGg== X-Gm-Message-State: ABy/qLYqiWFyMHiABqIzuPHxB1zccFkeskspBiTKo9Ttmrjbb1XTkqT6 0I38BwE6/nNnAQqTDhB+zNY/Mg== X-Google-Smtp-Source: APBJJlGAdl0ewhYUg6UhJdRJKXIwq0U3XoR/AJshcbF16xE0A4mgQC4Umc8PgwnpC/Hq6tl8ikCZEw== X-Received: by 2002:a17:902:ea04:b0:1b8:17e8:547e with SMTP id s4-20020a170902ea0400b001b817e8547emr32460173plg.1.1691406712196; Mon, 07 Aug 2023 04:11:52 -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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 04:11:51 -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, 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 , Muchun Song Subject: [PATCH v4 09/48] erofs: dynamically allocate the erofs-shrinker Date: Mon, 7 Aug 2023 19:08:57 +0800 Message-Id: <20230807110936.21819-10-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 X-Rspamd-Queue-Id: 4BFBA4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r 66Ouv8it 4VtL7t4L0XET5wcbMLTQW3JZZPEF5N+G8C8Q66vJMV03rmtqfPAKkzb3MSFhpgrN0EnWNiwmCLtN2udXqHlD2f3W71n+jmeal2JnCZv8M/Q8RJHoxj6QpfjvNOLpmgmD8qVrPhJrnYDLa3LVUYwB2noQBXGOFaoSLOVLndvpQoAEBY3FP9YA9bGcVV39gwkbDajKsmL4kbRmS6n2L7xc0zYmgNJqXKbQbmTocHugIy9UzfT5CPtdQAM7XRe5AZlAVzk3XyX0MVyFdITZJzQRb7PqiK00qd17Sqv9l4bnuLluKRuYtwLcLGhmVeJQsOjHAJ9VfE00pcAbjEF33PYfuVr6NdpE97TEnqC/e+6yVtnlzetc0W/vsArMUPisgDDU2giSxfHAcM00cn8qUMjCeToDTPqEVNYo9tV0z 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 --- fs/erofs/utils.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/fs/erofs/utils.c b/fs/erofs/utils.c index cc6fb9e98899..6e1a828e6ca3 100644 --- a/fs/erofs/utils.c +++ b/fs/erofs/utils.c @@ -270,19 +270,25 @@ 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; + erofs_shrinker_info->seeks = DEFAULT_SEEKS; + + 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 */