Message ID | 20230727080502.77895-23-zhengqi.arch@bytedance.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a985:0:b0:3e4:2afc:c1 with SMTP id t5csp956383vqo; Thu, 27 Jul 2023 02:00:11 -0700 (PDT) X-Google-Smtp-Source: APBJJlEV3Mz7Y8PiT6X1z5YbMoJ6PktEDWzNaZjsmouRY8wVHGBnp48QMpS7Cy13600PAQbz3FcN X-Received: by 2002:a17:907:7613:b0:992:528:abe with SMTP id jx19-20020a170907761300b0099205280abemr1482859ejc.53.1690448411348; Thu, 27 Jul 2023 02:00:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690448411; cv=none; d=google.com; s=arc-20160816; b=SCX0NxcagpeB0g5NnRwUSKRLEiZkopAIi279N/rbHZ/WJRZtSPYaEoseG42mhBbYnX hRESNdlvhPWMs94Xfbifm0lAR7yl1jKXq2/FBjtBYics814b1wQ03zHw7eqymd4o4PBs jcRThbwzCUX9tYORf+QnGjCrrqNF360FBIfBa7eyxTpyFcqGdpwyVhFIIj80HLyhIrfp dnUsKQgV5qxb9hP1ziBaT7wqD4tYA+yqVkgHAlM3ZzVBSCx92hGo7SLqA7VW5KsRhyNF axyzBeuA2Dcjs9O7UJNM51HQCdvommbYfIK6I0LyNK2aJ4T6F2lmsmiDc0aufCIe6WtA pCGA== 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=PYuXWIGRd3SDQUNwBNnDU/RFUGkEJd0z6ud/pRWhp58=; fh=NxkGAd430gburLVd9IjvP+jLcLBa8IzZa5IqPWgCN1g=; b=oOTtHWRuNiHOYwXkTY6+idlP09lSTCeVdAmOvmO7L0TScpW78l9EUdnn7kXDh8tq2m 3Zyi+HAtCawqhiS2Zr7MzGYAtvFg27E8wcQRHI1XIbd2W+nlHAH09zIWFMw789UE8ZbE CONzm+iR+dP2D9JUuP/4EY8hh7cr3HtyJiTlMV7RZWaXRPloLMiHBLiYeCHd/yuaHaHO Xzy1Rmkxk6utChVyQuRBekwd/nPHKWOrk3Miy5KlbifmoFTmYSGstv6gmXtjXwCmBB1G QwRA90OTi7IRbKCRVBDQzL9m+oqeXIbuJo5Syi4sXQhY7IypQxMM7Kh1OHkXoDJEr2qI RJ7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=T9ifvBS7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qn14-20020a170907210e00b0099b4985e4d5si691197ejb.451.2023.07.27.01.59.47; Thu, 27 Jul 2023 02:00:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=T9ifvBS7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S234567AbjG0IVB (ORCPT <rfc822;hanasaki@gmail.com> + 99 others); Thu, 27 Jul 2023 04:21:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234251AbjG0ISq (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 27 Jul 2023 04:18:46 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 938886A41 for <linux-kernel@vger.kernel.org>; Thu, 27 Jul 2023 01:10:51 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-686f74a8992so77840b3a.1 for <linux-kernel@vger.kernel.org>; Thu, 27 Jul 2023 01:10:51 -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=EGlVYZGzQdOiFWgsfuXmlSEjiS8HqmcDmYrVeRlz3J/r49wnWip9DCUyjay26B0Oh6 g63xPV7h7oTZiR3hyETbTaJcBxUplcvp4WptMAegiIOBwwfrilHORfJKpqtibc9G8HyE fGqf/qgjKioWek0jaGxYLA4M3yAw0miotk808ck88PXOKmyl2+xKmw0+p4JB/UjxyzRa R3E8oPiqKjuJucba3Wg4UAleANkTvP4j78GA2UU31VlPKD1VxW5yhRowQGLL/iDqAzey yLmzBJJ3T+Xi2UzC05jMiNOrmNyhRUipt23iWApqnSjOudt/iGLzktgayIY0aouUhDVg HHqQ== X-Gm-Message-State: ABy/qLbKmtGvIGG0e7+EufcsCRqHvEAlW1j2EoDPA/2kx1udxWupZyDl sEDECqceYAKVUjE0qFYHKk34dw== 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 <zhengqi.arch@bytedance.com> 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 <zhengqi.arch@bytedance.com>, Muchun Song <songmuchun@bytedance.com> 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 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_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772563633425317487 X-GMAIL-MSGID: 1772563633425317487 |
Series |
use refcount+RCU method to implement lockless slab shrink
|
|
Commit Message
Qi Zheng
July 27, 2023, 8:04 a.m. UTC
Use new APIs to dynamically allocate the sunrpc_cred shrinker. Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com> Reviewed-by: Muchun Song <songmuchun@bytedance.com> --- net/sunrpc/auth.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
Comments
On 2023/7/27 16:04, Qi Zheng wrote: > Use new APIs to dynamically allocate the sunrpc_cred shrinker. > > Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com> > Reviewed-by: Muchun Song <songmuchun@bytedance.com> > --- > 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) Here should set err to -ENOMEM, will fix. > 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); > }
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); }