From patchwork Thu Jul 27 08:04:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13329210 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 1C03EC04E69 for ; Thu, 27 Jul 2023 08:10:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9E0BE6B008C; Thu, 27 Jul 2023 04:10:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 990F36B0092; Thu, 27 Jul 2023 04:10:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 859128D0001; Thu, 27 Jul 2023 04:10:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 799956B008C for ; Thu, 27 Jul 2023 04:10:20 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 54557C0513 for ; Thu, 27 Jul 2023 08:10:20 +0000 (UTC) X-FDA: 81056669400.22.F3D8CE8 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by imf19.hostedemail.com (Postfix) with ESMTP id 6B3421A0015 for ; Thu, 27 Jul 2023 08:10:18 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=T9ifvBS7; spf=pass (imf19.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.181 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=1690445418; a=rsa-sha256; cv=none; b=vfyHjXY8wFrJ4aUCrZv1YJXH3GRnMykyhLToE6XHadUzhMEoR8YjetfHEbVQAHJvrqHz7c 8kAI56cmUeIlQIMDa6xXZXQdywk97U5sQMIFhPkHMjzCFM9AAY8BdhyPY3fKrLN2vIrXLY Wq5eR8gX5JaitJnG8ImABQp4IS6jOew= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=T9ifvBS7; spf=pass (imf19.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.181 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=1690445418; 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=PYuXWIGRd3SDQUNwBNnDU/RFUGkEJd0z6ud/pRWhp58=; b=CnrdebGAfCi9Hb2Op058pXsugPLNk7o+ubXMU8PH9yHhz0/lf0CbMNnj1OpMu0JFs6FeyS Tkm5bWPS/8f10q7A81Pv/HWYbSvYRL2qMIUD2s+b8oYOndcfTJ+DRskcAP73i+V+QTCpzx KGQ3DCAfkkdRi7g8ky9gclcU/LkMEks= Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-686f74a8992so77842b3a.1 for ; Thu, 27 Jul 2023 01:10:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1690445417; x=1691050217; 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=PYuXWIGRd3SDQUNwBNnDU/RFUGkEJd0z6ud/pRWhp58=; b=T9ifvBS7grSXMXHZ+aFeKzum6pF3H2DhLFdohTJRx7vF7szcBG6tJ5VPINqCVu3pCX FmubTvt88b5ysMWaYtFibatbXMnoo6Jib8lbo65gbMoj4iY6HbdoFrEeXgYSqYC9Jqe0 PGHsLAS4RpAPQjTV72r0GtDUpuZ/ybvTZ9EZC90EXosh65ardfAALzeVYgFduHUdYxNh uE3GuwKiv2CyHXolQ3XZqpbE7oSyCW4E0iZzkXVJZoTlkXjievgPAGhg1+Kv8s/E0hIi dyIaavdNWwWhQNwuCKJwqWG502/DMJOkmwjObTrka2ckcmNrtUCmvsEGY2FZ9fmQFWZZ aE4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690445417; x=1691050217; 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=PYuXWIGRd3SDQUNwBNnDU/RFUGkEJd0z6ud/pRWhp58=; b=RswEv6NSszGU5SXSk7SHoJLczvERGHOOr3rqCEAvOzRnF1DO/IhLI2v3op1Bs4lBGV ZaeJ1/6Hu9IVLlM53zwr5RZYXY8amNNluh5/+7E2O5oX+Ic5ARS94CYBWJZnjRwsfTnO 9za5eilcuG9Vgq5wbZdU96v46xwGSdIjd8QILpCHH1fI9DmfNZ4KVGdSfsuowBAEX0aH RopYNPI6eBolcMgcYnXcJYb5kWCqZcobiUhD9YZgYtPKnNJM/J0yaINQibijNuPP2gyR F9sCILBgvwDjipv96RCYU1QZbr9tsFWpN7rv7mqHoeF+epmol+ZzQ4utqZyYu9kO5YBS bbgA== X-Gm-Message-State: ABy/qLZn8sY7DrZGRgW/RaLnPiGdopCIsMYINugz2EVGZRquPEjJeH7n Mh6wda/KJWiaP2+Ze6l6zNgW4w== X-Google-Smtp-Source: APBJJlFP1iLC566NPrkWwKL0iKI9L1P+4s+IlmNKaBmXVe5HE8WAAvDQ5uBELCFt4/l7YPuEeyQdfQ== X-Received: by 2002:a05:6a21:7882:b0:123:3ec2:360d with SMTP id bf2-20020a056a21788200b001233ec2360dmr5970181pzc.5.1690445417252; Thu, 27 Jul 2023 01:10:17 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.147]) by smtp.gmail.com with ESMTPSA id j8-20020aa78d08000000b006828e49c04csm885872pfe.75.2023.07.27.01.10.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 01:10:16 -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, 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 v3 22/49] sunrpc: dynamically allocate the sunrpc_cred shrinker Date: Thu, 27 Jul 2023 16:04:35 +0800 Message-Id: <20230727080502.77895-23-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230727080502.77895-1-zhengqi.arch@bytedance.com> References: <20230727080502.77895-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 6B3421A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2ROJAMLn9ceDZb9OSqMp9pfMpCmO/x5d9GRusSyV+LiiaJ54RGXg4Osk3GQl6D/qmBlm7v75sKXvylMMjxrtIQ1Tn/U9ImV/+zmKlqt6DL+ZHU7NxUk9eM/RcyrGeQfDmo8Y2s8NNV/Jx5pmdXDhoj/oKvYH/kfdk5poauSfkeOM7GVAvhWobCle+UUlbkkFTMQwdJAHuY1sLdowj3914dSeesCMErQf6QmwVUZsjI/rU9S1kjIu77zks3DR7mPNCW9/NWgwlr1PHhBv2uMPgaNOedbWLq3erjDeAacr/fv/JwyhrXHRA9vK70bqgZShm2btCuXQ1dpaU7dEj7TPiXrXy47yk47ObqnSQgIhj5/z8YBEC6bRZx2y56mNc95dZgHlDlmvFEfgoXM0va2QJF7Rrcv/fMW4bieh9YB6cllkvfvHLne6xvZu9oXzu6ENGI601mWtFUE+Lyy4nei43Iw== 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 sunrpc_cred shrinker. Signed-off-by: Qi Zheng Reviewed-by: Muchun Song --- net/sunrpc/auth.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c index 2f16f9d17966..6b898b1be6f5 100644 --- a/net/sunrpc/auth.c +++ b/net/sunrpc/auth.c @@ -861,11 +861,7 @@ rpcauth_uptodatecred(struct rpc_task *task) test_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags) != 0; } -static struct shrinker rpc_cred_shrinker = { - .count_objects = rpcauth_cache_shrink_count, - .scan_objects = rpcauth_cache_shrink_scan, - .seeks = DEFAULT_SEEKS, -}; +static struct shrinker *rpc_cred_shrinker; int __init rpcauth_init_module(void) { @@ -874,9 +870,16 @@ int __init rpcauth_init_module(void) err = rpc_init_authunix(); if (err < 0) goto out1; - err = register_shrinker(&rpc_cred_shrinker, "sunrpc_cred"); - if (err < 0) + rpc_cred_shrinker = shrinker_alloc(0, "sunrpc_cred"); + if (!rpc_cred_shrinker) goto out2; + + rpc_cred_shrinker->count_objects = rpcauth_cache_shrink_count; + rpc_cred_shrinker->scan_objects = rpcauth_cache_shrink_scan; + rpc_cred_shrinker->seeks = DEFAULT_SEEKS; + + shrinker_register(rpc_cred_shrinker); + return 0; out2: rpc_destroy_authunix(); @@ -887,5 +890,5 @@ int __init rpcauth_init_module(void) void rpcauth_remove_module(void) { rpc_destroy_authunix(); - unregister_shrinker(&rpc_cred_shrinker); + shrinker_free(rpc_cred_shrinker); }