Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp2885216rwo; Mon, 24 Jul 2023 02:55:19 -0700 (PDT) X-Google-Smtp-Source: APBJJlGxBUB6vBlYb/FtNdT4YJ/pn/OM8NN/fuXmfkLrq3FS0gfPlDRIzs4ofDU7ZLlu2LabQWF1 X-Received: by 2002:a05:6512:2390:b0:4fd:d538:b97b with SMTP id c16-20020a056512239000b004fdd538b97bmr5836782lfv.29.1690192519632; Mon, 24 Jul 2023 02:55:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690192519; cv=none; d=google.com; s=arc-20160816; b=iXzqmoV/1c4LE3Z5iVKihrrSGmBFWHH7xUCYFOlHJa6eYTthprCRcR5VML/qYTi7qL fnUjccx5a/UBvbUbIGWlsJY2WlKymraoHP+D+/E3WxNS0ml9aWVKLuetDKuKdXB/MkhU a3WGUs/ikANZCiJKGHK+yYwpMK7fzjUEcUBTEm3RSay+8G+zJEYe6iK1mF0ZNAYE3dFN ++R2tKhLps8bW/OCN8DEIiM6RfFt8IGeHjb7xHJcM1BZAd2s/dR3Ly8wULcgvUJmq+Yx 0Edz3xJ8UZ57pGFw/Frj7bDwKwvlmIou+aHc5pekt9yKjXIff+qEI02qkIhJiHFqTfWm 9BFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3CXd5cxT7BQDd98tt8oaC0MvbTuhoGV4WCiM7GrnKVE=; fh=3lDHiAuENCYj3gWFb2bYij2cH/UC7c23rwbOpuSBNc8=; b=lYIiahlC3gVKk7daAyeI2U5IH+cutYTpYJ/CEf+bS7d+wZ1v0N77qirnHeu2xQAyWh D4EMT6EbaQDTUNXdbaYvQwNtAnpQ6z37npyaSCPLZt4Dw8rMtXQg/fk99Zqp5Mg6+KTL eTy6X8pm25vYIq7ysbIts4gPOeBi/hxtaOwMqj/KlWWueUFJ4d3NKKY0HjlBEOebKqfr WM3OWbfp+/BZSx0kmq8r0PvnnkIX8NKOcQlj2hNX7y288QBCGsnC5umqkeo/GTixbqip VRqYc5YiYbjXg8OwogQb0kkzXujE7nRj/krfFTMBSTfdkaKQ7p8EmPrWfzI9ugYorwz1 OVnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=Om2j7Eq4; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e6-20020a17090681c600b00992bfd14c42si5901213ejx.949.2023.07.24.02.54.54; Mon, 24 Jul 2023 02:55:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=Om2j7Eq4; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232676AbjGXJyS (ORCPT + 99 others); Mon, 24 Jul 2023 05:54:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233122AbjGXJxv (ORCPT ); Mon, 24 Jul 2023 05:53:51 -0400 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0946C4C0B for ; Mon, 24 Jul 2023 02:49:52 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1b867f9198dso8898445ad.0 for ; Mon, 24 Jul 2023 02:49:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1690192146; x=1690796946; 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=3CXd5cxT7BQDd98tt8oaC0MvbTuhoGV4WCiM7GrnKVE=; b=Om2j7Eq4b1zO3xdV6jpRgZNyxXUYFkRHVqkn+q5W951pJcNCyyCCfcFLMOexVrickD J4ocoN591zedkzE2l/xp9SKWxYNmVY9krcCZp1enxIDkg3AuGZslR02ZNhQ4EqRsU2HZ PP0+JI5GQi1EzLTs4k94q0v4nCvWQ/wpATlpWJHquPmCZ9F29qdBLMIvq7n3uMU0LBE+ S5G8d6zEmU4sF3lI0zmYqBRm2zlIoJryhG+DWOUkdilD+QmzqjFCVIDjtSm2UD8IjhcW 4f3Go/NoxA8FuaENkugEjSaXcGkVRUNsilnpPO5VZgwHu2urEIWQPvH/FMxPOeDNA9uj omeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690192146; x=1690796946; 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=3CXd5cxT7BQDd98tt8oaC0MvbTuhoGV4WCiM7GrnKVE=; b=E/QEHfUr/xXpRTiWlSlAPqWeBswUV1YvG2sU0nPd9RK2pGe1JkCFUL4aF9KFp90i9+ Q1hpUwiA2WHo6lqumcqZ/+rEwFQuwgDsXKof01/k+g79/nr4yDbeuXCXOi4XyfK1ztGp de7LbszlBx2iAg8k8VhfxA+1DIKSJ7tzhLyzuS421rAKV03qJFTpPSC8TxzO9gKMISXO /2vQhnWZnIRoIoBQ2chd/ivg7bL7RsMNRwD3m+kZX3UAQMY5OVssy/VSeCa2Ot9usKTh ly8e2vj75sLXfg9t2oAD/cQC2gankDjoWJoWimG8sXKUlG8+9RljgiiQMZ4SaqhyNkh1 ALBA== X-Gm-Message-State: ABy/qLbYw4c3RIWDFcFQTu15reFR03KvBRoT3CZW5mdSXjqlp3rdobSe BIldmIN1BBNLI2m4Ts6wAaXV6w== X-Received: by 2002:a17:902:e80a:b0:1b8:50a9:6874 with SMTP id u10-20020a170902e80a00b001b850a96874mr12324079plg.5.1690192146760; Mon, 24 Jul 2023 02:49:06 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.147]) by smtp.gmail.com with ESMTPSA id d5-20020a170902c18500b001bb20380bf2sm8467233pld.13.2023.07.24.02.48.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jul 2023 02:49:06 -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 Subject: [PATCH v2 20/47] sunrpc: dynamically allocate the sunrpc_cred shrinker Date: Mon, 24 Jul 2023 17:43:27 +0800 Message-Id: <20230724094354.90817-21-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230724094354.90817-1-zhengqi.arch@bytedance.com> References: <20230724094354.90817-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Use new APIs to dynamically allocate the sunrpc_cred shrinker. Signed-off-by: Qi Zheng --- 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..74e40c8a512d 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_unregister(rpc_cred_shrinker); } -- 2.30.2