From nobody Thu Dec 18 04:42:13 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39A6BC3DA6F for ; Thu, 24 Aug 2023 03:45:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239726AbjHXDpj (ORCPT ); Wed, 23 Aug 2023 23:45:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239610AbjHXDpH (ORCPT ); Wed, 23 Aug 2023 23:45:07 -0400 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1EBB10F2 for ; Wed, 23 Aug 2023 20:44:41 -0700 (PDT) Received: by mail-oi1-x22f.google.com with SMTP id 5614622812f47-3a8586813cfso655320b6e.0 for ; Wed, 23 Aug 2023 20:44:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1692848681; x=1693453481; 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=lY6Vi/2E/8aKoDMoFhdgeDuzJGEBhcHcwJKxLN5aRm4=; b=gHtaEy0lF74Ntkso7g4C6I/YE4P2dpDs+7amPy7WakPzh2kjSvMiiaFri5oP5OIPtC BfsgxJG3dolAaeJ2n+Yhq2chgoukBpNASEoJSTjbYwJljlwjXrNh9kx520+RsCMTFI9a cZRaUUBTw/fsxlcCpVpRSbHKngHy3yg6ERr+RLU72xkk0Hn+mGlF4r5SkkNhy/H1qmC/ 4YbOWxnFhSSxA3RyOpAdhS6L/9ifNoZvavLY3HZvYg4yrEZzgzD6jn7exa/rpKElUHVR rTIHwS9nbuifcIi3X9sduJyAWlvrWQdqWxFvFKFyC4rdXuEY8eTaAP0iyvcMIEJFSAPS QpDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692848681; x=1693453481; 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=lY6Vi/2E/8aKoDMoFhdgeDuzJGEBhcHcwJKxLN5aRm4=; b=LscyiYPePNNkOAWD1krMgTrdChybYpJc+SodT/J7uJoBbxws6BDB5DH73hKN7vfIGl gdWgNeQ/smUlIEDxOEK6AQ3Ityes+5iQVrHd5AXYVgC9z1O3Ft12y1jSKnoimFRVh1yf SC4xNPgSfhn7O5TTFvPS4XShytQdqxTv/a60uWrKKw8wKNmzldKdkf/a73L6tX1i65JL uQLnLqh8lD8hkVIDKYVi3Qs3968wdF4fqL2nmOIugD8XhXPXKR0sTIqUVkXUlQ1nPNxt DTj+AIl8HJeWbSvXo3VuvRf5HBvGQz74uNzeCNyVw1yNTNqzUyQgKHB7WttwQj4/Wvoz fHIg== X-Gm-Message-State: AOJu0YyQGzR6r/erKJqZpbxm9idjgIF1s2sWPyDSfiGQzWfQJpAOXX7l /48rZi35mei1LGQiF9ZLu4mnFQ== X-Google-Smtp-Source: AGHT+IGSn8aXVXktFOZZa/BcVGbtb8f6zEZDLrwOYj68DXtiQe8FLStK6m/pgQCqQbi7Z2XDHrDQOQ== X-Received: by 2002:a05:6808:30a7:b0:3a7:2eb4:ce04 with SMTP id bl39-20020a05680830a700b003a72eb4ce04mr17475307oib.5.1692848680931; Wed, 23 Aug 2023 20:44:40 -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.44.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Aug 2023 20:44:40 -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 , Gao Xiang , Chao Yu , Yue Hu , Jeffle Xu , linux-erofs@lists.ozlabs.org Subject: [PATCH v5 06/45] erofs: dynamically allocate the erofs-shrinker Date: Thu, 24 Aug 2023 11:42:25 +0800 Message-Id: <20230824034304.37411-7-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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Use new APIs to dynamically allocate the erofs-shrinker. Signed-off-by: Qi Zheng Reviewed-by: Muchun Song CC: Gao Xiang CC: Chao Yu CC: Yue Hu CC: Jeffle Xu CC: linux-erofs@lists.ozlabs.org Reviewed-by: Chao Yu Reviewed-by: Gao Xiang --- 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 shrinke= r *shrink, return freed; } =20 -static struct shrinker erofs_shrinker_info =3D { - .scan_objects =3D erofs_shrink_scan, - .count_objects =3D erofs_shrink_count, - .seeks =3D DEFAULT_SEEKS, -}; +static struct shrinker *erofs_shrinker_info; =20 int __init erofs_init_shrinker(void) { - return register_shrinker(&erofs_shrinker_info, "erofs-shrinker"); + erofs_shrinker_info =3D shrinker_alloc(0, "erofs-shrinker"); + if (!erofs_shrinker_info) + return -ENOMEM; + + erofs_shrinker_info->count_objects =3D erofs_shrink_count; + erofs_shrinker_info->scan_objects =3D erofs_shrink_scan; + erofs_shrinker_info->seeks =3D DEFAULT_SEEKS; + + shrinker_register(erofs_shrinker_info); + + return 0; } =20 void erofs_exit_shrinker(void) { - unregister_shrinker(&erofs_shrinker_info); + shrinker_free(erofs_shrinker_info); } #endif /* !CONFIG_EROFS_FS_ZIP */ --=20 2.30.2