From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeff Layton Date: Mon, 24 Jul 2023 08:17:39 -0400 Subject: [Cluster-devel] [PATCH v2 34/47] nfsd: dynamically allocate the nfsd-client shrinker In-Reply-To: <20230724094354.90817-35-zhengqi.arch@bytedance.com> References: <20230724094354.90817-1-zhengqi.arch@bytedance.com> <20230724094354.90817-35-zhengqi.arch@bytedance.com> Message-ID: <01e8445d033314b6d9cd67bece74ca1c3ce89945.camel@kernel.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Mon, 2023-07-24 at 17:43 +0800, Qi Zheng wrote: > In preparation for implementing lockless slab shrink, use new APIs to > dynamically allocate the nfsd-client shrinker, so that it can be freed > asynchronously using kfree_rcu(). Then it doesn't need to wait for RCU > read-side critical section when releasing the struct nfsd_net. > > Acked-by: Chuck Lever > Signed-off-by: Qi Zheng > --- > fs/nfsd/netns.h | 2 +- > fs/nfsd/nfs4state.c | 20 ++++++++++++-------- > 2 files changed, 13 insertions(+), 9 deletions(-) > > diff --git a/fs/nfsd/netns.h b/fs/nfsd/netns.h > index ec49b200b797..f669444d5336 100644 > --- a/fs/nfsd/netns.h > +++ b/fs/nfsd/netns.h > @@ -195,7 +195,7 @@ struct nfsd_net { > int nfs4_max_clients; > > atomic_t nfsd_courtesy_clients; > - struct shrinker nfsd_client_shrinker; > + struct shrinker *nfsd_client_shrinker; > struct work_struct nfsd_shrinker_work; > }; > > diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c > index 3339177f8e2f..c7a4616cd866 100644 > --- a/fs/nfsd/nfs4state.c > +++ b/fs/nfsd/nfs4state.c > @@ -4388,8 +4388,7 @@ static unsigned long > nfsd4_state_shrinker_count(struct shrinker *shrink, struct shrink_control *sc) > { > int count; > - struct nfsd_net *nn = container_of(shrink, > - struct nfsd_net, nfsd_client_shrinker); > + struct nfsd_net *nn = shrink->private_data; > > count = atomic_read(&nn->nfsd_courtesy_clients); > if (!count) > @@ -8125,12 +8124,17 @@ static int nfs4_state_create_net(struct net *net) > INIT_WORK(&nn->nfsd_shrinker_work, nfsd4_state_shrinker_worker); > get_net(net); > > - nn->nfsd_client_shrinker.scan_objects = nfsd4_state_shrinker_scan; > - nn->nfsd_client_shrinker.count_objects = nfsd4_state_shrinker_count; > - nn->nfsd_client_shrinker.seeks = DEFAULT_SEEKS; > - > - if (register_shrinker(&nn->nfsd_client_shrinker, "nfsd-client")) > + nn->nfsd_client_shrinker = shrinker_alloc(0, "nfsd-client"); > + if (!nn->nfsd_client_shrinker) > goto err_shrinker; > + > + nn->nfsd_client_shrinker->scan_objects = nfsd4_state_shrinker_scan; > + nn->nfsd_client_shrinker->count_objects = nfsd4_state_shrinker_count; > + nn->nfsd_client_shrinker->seeks = DEFAULT_SEEKS; > + nn->nfsd_client_shrinker->private_data = nn; > + > + shrinker_register(nn->nfsd_client_shrinker); > + > return 0; > > err_shrinker: > @@ -8228,7 +8232,7 @@ nfs4_state_shutdown_net(struct net *net) > struct list_head *pos, *next, reaplist; > struct nfsd_net *nn = net_generic(net, nfsd_net_id); > > - unregister_shrinker(&nn->nfsd_client_shrinker); > + shrinker_unregister(nn->nfsd_client_shrinker); > cancel_work(&nn->nfsd_shrinker_work); > cancel_delayed_work_sync(&nn->laundromat_work); > locks_end_grace(&nn->nfsd4_manager); Acked-by: Jeff Layton From mboxrd@z Thu Jan 1 00:00:00 1970 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 us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3996BC07E8C for ; Tue, 25 Jul 2023 06:43:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690267399; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=AmvdQDiEM1dyDvk+Yl3jbeCQk6tgs7RKhB7BT7RmxRc=; b=CX0EnrBig5T+VpyUxcarAiA3wywvgf0AOAiHhNinGvoJpZw6Z1BtI3ip8bsE1QwqOP63bq pgd0QaGB89YycoaTVhkM+3BwMAY4yfzqZHvTjU775/FdQ050CZcEydVqiOmXycieaxuIav FoJSiL4kwD30E6P7+WyA5i1aiLnHd4U= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-466-IpRZ5JgYPk2SQIxz0B5Qzw-1; Tue, 25 Jul 2023 02:43:07 -0400 X-MC-Unique: IpRZ5JgYPk2SQIxz0B5Qzw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D6AC2185A7BC; Tue, 25 Jul 2023 06:42:49 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id C40F1C57965; Tue, 25 Jul 2023 06:42:49 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 31F5C19543B1; Tue, 25 Jul 2023 06:42:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B0B3F194658D for ; Mon, 24 Jul 2023 12:24:59 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 69BF21454146; Mon, 24 Jul 2023 12:24:59 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 60C33140E952 for ; Mon, 24 Jul 2023 12:24:59 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 419508564EF for ; Mon, 24 Jul 2023 12:24:59 +0000 (UTC) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-384-t8KzQ0o7O7SGgvk2UHdZ0A-1; Mon, 24 Jul 2023 08:24:57 -0400 X-MC-Unique: t8KzQ0o7O7SGgvk2UHdZ0A-1 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 21BA160F6A; Mon, 24 Jul 2023 12:17:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE84DC433C7; Mon, 24 Jul 2023 12:17:40 +0000 (UTC) Message-ID: <01e8445d033314b6d9cd67bece74ca1c3ce89945.camel@kernel.org> From: Jeff Layton To: Qi Zheng , 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 Date: Mon, 24 Jul 2023 08:17:39 -0400 In-Reply-To: <20230724094354.90817-35-zhengqi.arch@bytedance.com> References: <20230724094354.90817-1-zhengqi.arch@bytedance.com> <20230724094354.90817-35-zhengqi.arch@bytedance.com> User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mailman-Approved-At: Tue, 25 Jul 2023 06:42:42 +0000 Subject: Re: [dm-devel] [PATCH v2 34/47] nfsd: dynamically allocate the nfsd-client shrinker X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm@vger.kernel.org, dri-devel@lists.freedesktop.org, virtualization@lists.linux-foundation.org, linux-mm@kvack.org, dm-devel@redhat.com, linux-mtd@lists.infradead.org, x86@kernel.org, cluster-devel@redhat.com, xen-devel@lists.xenproject.org, linux-ext4@vger.kernel.org, linux-arm-msm@vger.kernel.org, rcu@vger.kernel.org, linux-bcache@vger.kernel.org, linux-raid@vger.kernel.org, linux-nfs@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-xfs@vger.kernel.org, Chuck Lever , linux-fsdevel@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-btrfs@vger.kernel.org Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Mon, 2023-07-24 at 17:43 +0800, Qi Zheng wrote: > In preparation for implementing lockless slab shrink, use new APIs to > dynamically allocate the nfsd-client shrinker, so that it can be freed > asynchronously using kfree_rcu(). Then it doesn't need to wait for RCU > read-side critical section when releasing the struct nfsd_net. > > Acked-by: Chuck Lever > Signed-off-by: Qi Zheng > --- > fs/nfsd/netns.h | 2 +- > fs/nfsd/nfs4state.c | 20 ++++++++++++-------- > 2 files changed, 13 insertions(+), 9 deletions(-) > > diff --git a/fs/nfsd/netns.h b/fs/nfsd/netns.h > index ec49b200b797..f669444d5336 100644 > --- a/fs/nfsd/netns.h > +++ b/fs/nfsd/netns.h > @@ -195,7 +195,7 @@ struct nfsd_net { > int nfs4_max_clients; > > atomic_t nfsd_courtesy_clients; > - struct shrinker nfsd_client_shrinker; > + struct shrinker *nfsd_client_shrinker; > struct work_struct nfsd_shrinker_work; > }; > > diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c > index 3339177f8e2f..c7a4616cd866 100644 > --- a/fs/nfsd/nfs4state.c > +++ b/fs/nfsd/nfs4state.c > @@ -4388,8 +4388,7 @@ static unsigned long > nfsd4_state_shrinker_count(struct shrinker *shrink, struct shrink_control *sc) > { > int count; > - struct nfsd_net *nn = container_of(shrink, > - struct nfsd_net, nfsd_client_shrinker); > + struct nfsd_net *nn = shrink->private_data; > > count = atomic_read(&nn->nfsd_courtesy_clients); > if (!count) > @@ -8125,12 +8124,17 @@ static int nfs4_state_create_net(struct net *net) > INIT_WORK(&nn->nfsd_shrinker_work, nfsd4_state_shrinker_worker); > get_net(net); > > - nn->nfsd_client_shrinker.scan_objects = nfsd4_state_shrinker_scan; > - nn->nfsd_client_shrinker.count_objects = nfsd4_state_shrinker_count; > - nn->nfsd_client_shrinker.seeks = DEFAULT_SEEKS; > - > - if (register_shrinker(&nn->nfsd_client_shrinker, "nfsd-client")) > + nn->nfsd_client_shrinker = shrinker_alloc(0, "nfsd-client"); > + if (!nn->nfsd_client_shrinker) > goto err_shrinker; > + > + nn->nfsd_client_shrinker->scan_objects = nfsd4_state_shrinker_scan; > + nn->nfsd_client_shrinker->count_objects = nfsd4_state_shrinker_count; > + nn->nfsd_client_shrinker->seeks = DEFAULT_SEEKS; > + nn->nfsd_client_shrinker->private_data = nn; > + > + shrinker_register(nn->nfsd_client_shrinker); > + > return 0; > > err_shrinker: > @@ -8228,7 +8232,7 @@ nfs4_state_shutdown_net(struct net *net) > struct list_head *pos, *next, reaplist; > struct nfsd_net *nn = net_generic(net, nfsd_net_id); > > - unregister_shrinker(&nn->nfsd_client_shrinker); > + shrinker_unregister(nn->nfsd_client_shrinker); > cancel_work(&nn->nfsd_shrinker_work); > cancel_delayed_work_sync(&nn->laundromat_work); > locks_end_grace(&nn->nfsd4_manager); Acked-by: Jeff Layton -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel From mboxrd@z Thu Jan 1 00:00:00 1970 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 E591DC001DF for ; Mon, 24 Jul 2023 12:18:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229738AbjGXMSS (ORCPT ); Mon, 24 Jul 2023 08:18:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229456AbjGXMSS (ORCPT ); Mon, 24 Jul 2023 08:18:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32FCA170D; Mon, 24 Jul 2023 05:17:47 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8A55C61124; Mon, 24 Jul 2023 12:17:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE84DC433C7; Mon, 24 Jul 2023 12:17:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690201064; bh=QrEpSq7cPtZ3cWIhHPElPK38cx6jwtPbdBU+j7U7fKM=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=lFo5/uyfnIZhAXSNnfYH/zs0wLPvsdGmMHFPu1gPwZUyuOP10nfFnm2e23E9mVHox RPTdsfQNauiU49m1hBahLSzV9+gtG/J7umAiMCAj2AameE5Kr8rrBCOJ9W6HPjIMkc lBp1NfEAIBufJmTKwy4+ZdRStOdLezK2HhFQXgRbYXDnNec/zH0oZOEiZUwOk3URR0 CwbOA3I9uES6cdgV2JXRUz8O/MvIwDzgSFlH2Jg5PAfwuqtmwK87bHc16vNtVYlbJG hfzmJLudml4J90E2WDeTwJcjuLZaZewiSQ45z8+KBeEkpGI5axaDFLzZmilBUDvalQ cGU58i/dTyQGA== Message-ID: <01e8445d033314b6d9cd67bece74ca1c3ce89945.camel@kernel.org> Subject: Re: [PATCH v2 34/47] nfsd: dynamically allocate the nfsd-client shrinker From: Jeff Layton To: Qi Zheng , 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, Chuck Lever Date: Mon, 24 Jul 2023 08:17:39 -0400 In-Reply-To: <20230724094354.90817-35-zhengqi.arch@bytedance.com> References: <20230724094354.90817-1-zhengqi.arch@bytedance.com> <20230724094354.90817-35-zhengqi.arch@bytedance.com> Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bcache@vger.kernel.org On Mon, 2023-07-24 at 17:43 +0800, Qi Zheng wrote: > In preparation for implementing lockless slab shrink, use new APIs to > dynamically allocate the nfsd-client shrinker, so that it can be freed > asynchronously using kfree_rcu(). Then it doesn't need to wait for RCU > read-side critical section when releasing the struct nfsd_net. >=20 > Acked-by: Chuck Lever > Signed-off-by: Qi Zheng > --- > fs/nfsd/netns.h | 2 +- > fs/nfsd/nfs4state.c | 20 ++++++++++++-------- > 2 files changed, 13 insertions(+), 9 deletions(-) >=20 > diff --git a/fs/nfsd/netns.h b/fs/nfsd/netns.h > index ec49b200b797..f669444d5336 100644 > --- a/fs/nfsd/netns.h > +++ b/fs/nfsd/netns.h > @@ -195,7 +195,7 @@ struct nfsd_net { > int nfs4_max_clients; > =20 > atomic_t nfsd_courtesy_clients; > - struct shrinker nfsd_client_shrinker; > + struct shrinker *nfsd_client_shrinker; > struct work_struct nfsd_shrinker_work; > }; > =20 > diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c > index 3339177f8e2f..c7a4616cd866 100644 > --- a/fs/nfsd/nfs4state.c > +++ b/fs/nfsd/nfs4state.c > @@ -4388,8 +4388,7 @@ static unsigned long > nfsd4_state_shrinker_count(struct shrinker *shrink, struct shrink_contro= l *sc) > { > int count; > - struct nfsd_net *nn =3D container_of(shrink, > - struct nfsd_net, nfsd_client_shrinker); > + struct nfsd_net *nn =3D shrink->private_data; > =20 > count =3D atomic_read(&nn->nfsd_courtesy_clients); > if (!count) > @@ -8125,12 +8124,17 @@ static int nfs4_state_create_net(struct net *net) > INIT_WORK(&nn->nfsd_shrinker_work, nfsd4_state_shrinker_worker); > get_net(net); > =20 > - nn->nfsd_client_shrinker.scan_objects =3D nfsd4_state_shrinker_scan; > - nn->nfsd_client_shrinker.count_objects =3D nfsd4_state_shrinker_count; > - nn->nfsd_client_shrinker.seeks =3D DEFAULT_SEEKS; > - > - if (register_shrinker(&nn->nfsd_client_shrinker, "nfsd-client")) > + nn->nfsd_client_shrinker =3D shrinker_alloc(0, "nfsd-client"); > + if (!nn->nfsd_client_shrinker) > goto err_shrinker; > + > + nn->nfsd_client_shrinker->scan_objects =3D nfsd4_state_shrinker_scan; > + nn->nfsd_client_shrinker->count_objects =3D nfsd4_state_shrinker_count; > + nn->nfsd_client_shrinker->seeks =3D DEFAULT_SEEKS; > + nn->nfsd_client_shrinker->private_data =3D nn; > + > + shrinker_register(nn->nfsd_client_shrinker); > + > return 0; > =20 > err_shrinker: > @@ -8228,7 +8232,7 @@ nfs4_state_shutdown_net(struct net *net) > struct list_head *pos, *next, reaplist; > struct nfsd_net *nn =3D net_generic(net, nfsd_net_id); > =20 > - unregister_shrinker(&nn->nfsd_client_shrinker); > + shrinker_unregister(nn->nfsd_client_shrinker); > cancel_work(&nn->nfsd_shrinker_work); > cancel_delayed_work_sync(&nn->laundromat_work); > locks_end_grace(&nn->nfsd4_manager); Acked-by: Jeff Layton From mboxrd@z Thu Jan 1 00:00:00 1970 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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3737AC001DF for ; Mon, 24 Jul 2023 12:17:59 +0000 (UTC) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=lFo5/uyf; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4R8fLs3fcfz301f for ; Mon, 24 Jul 2023 22:17:57 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=lFo5/uyf; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=139.178.84.217; helo=dfw.source.kernel.org; envelope-from=jlayton@kernel.org; receiver=lists.ozlabs.org) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4R8fLh2dNrz2yLP for ; Mon, 24 Jul 2023 22:17:48 +1000 (AEST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 21BA160F6A; Mon, 24 Jul 2023 12:17:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE84DC433C7; Mon, 24 Jul 2023 12:17:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690201064; bh=QrEpSq7cPtZ3cWIhHPElPK38cx6jwtPbdBU+j7U7fKM=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=lFo5/uyfnIZhAXSNnfYH/zs0wLPvsdGmMHFPu1gPwZUyuOP10nfFnm2e23E9mVHox RPTdsfQNauiU49m1hBahLSzV9+gtG/J7umAiMCAj2AameE5Kr8rrBCOJ9W6HPjIMkc lBp1NfEAIBufJmTKwy4+ZdRStOdLezK2HhFQXgRbYXDnNec/zH0oZOEiZUwOk3URR0 CwbOA3I9uES6cdgV2JXRUz8O/MvIwDzgSFlH2Jg5PAfwuqtmwK87bHc16vNtVYlbJG hfzmJLudml4J90E2WDeTwJcjuLZaZewiSQ45z8+KBeEkpGI5axaDFLzZmilBUDvalQ cGU58i/dTyQGA== Message-ID: <01e8445d033314b6d9cd67bece74ca1c3ce89945.camel@kernel.org> Subject: Re: [PATCH v2 34/47] nfsd: dynamically allocate the nfsd-client shrinker From: Jeff Layton To: Qi Zheng , 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 Date: Mon, 24 Jul 2023 08:17:39 -0400 In-Reply-To: <20230724094354.90817-35-zhengqi.arch@bytedance.com> References: <20230724094354.90817-1-zhengqi.arch@bytedance.com> <20230724094354.90817-35-zhengqi.arch@bytedance.com> Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) MIME-Version: 1.0 X-BeenThere: linux-erofs@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development of Linux EROFS file system List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm@vger.kernel.org, dri-devel@lists.freedesktop.org, virtualization@lists.linux-foundation.org, linux-mm@kvack.org, dm-devel@redhat.com, linux-mtd@lists.infradead.org, x86@kernel.org, cluster-devel@redhat.com, xen-devel@lists.xenproject.org, linux-ext4@vger.kernel.org, linux-arm-msm@vger.kernel.org, rcu@vger.kernel.org, linux-bcache@vger.kernel.org, linux-raid@vger.kernel.org, linux-nfs@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-xfs@vger.kernel.org, Chuck Lever , linux-fsdevel@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-btrfs@vger.kernel.org Errors-To: linux-erofs-bounces+linux-erofs=archiver.kernel.org@lists.ozlabs.org Sender: "Linux-erofs" On Mon, 2023-07-24 at 17:43 +0800, Qi Zheng wrote: > In preparation for implementing lockless slab shrink, use new APIs to > dynamically allocate the nfsd-client shrinker, so that it can be freed > asynchronously using kfree_rcu(). Then it doesn't need to wait for RCU > read-side critical section when releasing the struct nfsd_net. >=20 > Acked-by: Chuck Lever > Signed-off-by: Qi Zheng > --- > fs/nfsd/netns.h | 2 +- > fs/nfsd/nfs4state.c | 20 ++++++++++++-------- > 2 files changed, 13 insertions(+), 9 deletions(-) >=20 > diff --git a/fs/nfsd/netns.h b/fs/nfsd/netns.h > index ec49b200b797..f669444d5336 100644 > --- a/fs/nfsd/netns.h > +++ b/fs/nfsd/netns.h > @@ -195,7 +195,7 @@ struct nfsd_net { > int nfs4_max_clients; > =20 > atomic_t nfsd_courtesy_clients; > - struct shrinker nfsd_client_shrinker; > + struct shrinker *nfsd_client_shrinker; > struct work_struct nfsd_shrinker_work; > }; > =20 > diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c > index 3339177f8e2f..c7a4616cd866 100644 > --- a/fs/nfsd/nfs4state.c > +++ b/fs/nfsd/nfs4state.c > @@ -4388,8 +4388,7 @@ static unsigned long > nfsd4_state_shrinker_count(struct shrinker *shrink, struct shrink_contro= l *sc) > { > int count; > - struct nfsd_net *nn =3D container_of(shrink, > - struct nfsd_net, nfsd_client_shrinker); > + struct nfsd_net *nn =3D shrink->private_data; > =20 > count =3D atomic_read(&nn->nfsd_courtesy_clients); > if (!count) > @@ -8125,12 +8124,17 @@ static int nfs4_state_create_net(struct net *net) > INIT_WORK(&nn->nfsd_shrinker_work, nfsd4_state_shrinker_worker); > get_net(net); > =20 > - nn->nfsd_client_shrinker.scan_objects =3D nfsd4_state_shrinker_scan; > - nn->nfsd_client_shrinker.count_objects =3D nfsd4_state_shrinker_count; > - nn->nfsd_client_shrinker.seeks =3D DEFAULT_SEEKS; > - > - if (register_shrinker(&nn->nfsd_client_shrinker, "nfsd-client")) > + nn->nfsd_client_shrinker =3D shrinker_alloc(0, "nfsd-client"); > + if (!nn->nfsd_client_shrinker) > goto err_shrinker; > + > + nn->nfsd_client_shrinker->scan_objects =3D nfsd4_state_shrinker_scan; > + nn->nfsd_client_shrinker->count_objects =3D nfsd4_state_shrinker_count; > + nn->nfsd_client_shrinker->seeks =3D DEFAULT_SEEKS; > + nn->nfsd_client_shrinker->private_data =3D nn; > + > + shrinker_register(nn->nfsd_client_shrinker); > + > return 0; > =20 > err_shrinker: > @@ -8228,7 +8232,7 @@ nfs4_state_shutdown_net(struct net *net) > struct list_head *pos, *next, reaplist; > struct nfsd_net *nn =3D net_generic(net, nfsd_net_id); > =20 > - unregister_shrinker(&nn->nfsd_client_shrinker); > + shrinker_unregister(nn->nfsd_client_shrinker); > cancel_work(&nn->nfsd_shrinker_work); > cancel_delayed_work_sync(&nn->laundromat_work); > locks_end_grace(&nn->nfsd4_manager); Acked-by: Jeff Layton From mboxrd@z Thu Jan 1 00:00:00 1970 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 lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C416CC001DE for ; Mon, 24 Jul 2023 12:17:59 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1qNuVh-0000l6-35; Mon, 24 Jul 2023 12:17:57 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1qNuVf-0000kx-CS for linux-f2fs-devel@lists.sourceforge.net; Mon, 24 Jul 2023 12:17:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=MIME-Version:Content-Transfer-Encoding:Content-Type :References:In-Reply-To:Date:Cc:To:From:Subject:Message-ID:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=xzLHOlmF+CIoF0WI8Vm/YOZazXEsf4Ui2aFePuMd4C8=; b=C23ZYUFRW5J8LMIso7Rx6VhFGE n6D2UmAbwxNuNAWlpNTOJZ2HDMxt+C0GcD5lV40QE6hlOLOqjoiE2xqpGXzS2O43UosWv/8qEIOm7 KL5cs8emXd6dUdRBkCuX1QDC5fd59LsqxhpfTyhtAwXh0ZfRrsd9INsDaZkQqLVZh6nE=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=MIME-Version:Content-Transfer-Encoding:Content-Type:References: In-Reply-To:Date:Cc:To:From:Subject:Message-ID:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=xzLHOlmF+CIoF0WI8Vm/YOZazXEsf4Ui2aFePuMd4C8=; b=Hmx40vgD2YmF7LD6aS5hGaK2d9 X3aEN3eA4nnsmwk5fnDqR3D7+JUXwtSLQT/qXAHhsrmv3au+R3701gZX8QXLHlxLj0Xyv4SnrWHgT Fet7JH48z7zYo+IVj8Lkr0a4ZGF81u38IqhI9abOHDnRJcqOz2Erz4lrjfasARiL1Z0k=; Received: from dfw.source.kernel.org ([139.178.84.217]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1qNuVc-000VvH-B5 for linux-f2fs-devel@lists.sourceforge.net; Mon, 24 Jul 2023 12:17:55 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 21BA160F6A; Mon, 24 Jul 2023 12:17:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE84DC433C7; Mon, 24 Jul 2023 12:17:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690201064; bh=QrEpSq7cPtZ3cWIhHPElPK38cx6jwtPbdBU+j7U7fKM=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=lFo5/uyfnIZhAXSNnfYH/zs0wLPvsdGmMHFPu1gPwZUyuOP10nfFnm2e23E9mVHox RPTdsfQNauiU49m1hBahLSzV9+gtG/J7umAiMCAj2AameE5Kr8rrBCOJ9W6HPjIMkc lBp1NfEAIBufJmTKwy4+ZdRStOdLezK2HhFQXgRbYXDnNec/zH0oZOEiZUwOk3URR0 CwbOA3I9uES6cdgV2JXRUz8O/MvIwDzgSFlH2Jg5PAfwuqtmwK87bHc16vNtVYlbJG hfzmJLudml4J90E2WDeTwJcjuLZaZewiSQ45z8+KBeEkpGI5axaDFLzZmilBUDvalQ cGU58i/dTyQGA== Message-ID: <01e8445d033314b6d9cd67bece74ca1c3ce89945.camel@kernel.org> From: Jeff Layton To: Qi Zheng , 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 Date: Mon, 24 Jul 2023 08:17:39 -0400 In-Reply-To: <20230724094354.90817-35-zhengqi.arch@bytedance.com> References: <20230724094354.90817-1-zhengqi.arch@bytedance.com> <20230724094354.90817-35-zhengqi.arch@bytedance.com> User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) MIME-Version: 1.0 X-Headers-End: 1qNuVc-000VvH-B5 Subject: Re: [f2fs-dev] [PATCH v2 34/47] nfsd: dynamically allocate the nfsd-client shrinker X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm@vger.kernel.org, dri-devel@lists.freedesktop.org, virtualization@lists.linux-foundation.org, linux-mm@kvack.org, dm-devel@redhat.com, linux-mtd@lists.infradead.org, x86@kernel.org, cluster-devel@redhat.com, xen-devel@lists.xenproject.org, linux-ext4@vger.kernel.org, linux-arm-msm@vger.kernel.org, rcu@vger.kernel.org, linux-bcache@vger.kernel.org, linux-raid@vger.kernel.org, linux-nfs@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-xfs@vger.kernel.org, Chuck Lever , linux-fsdevel@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-btrfs@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net On Mon, 2023-07-24 at 17:43 +0800, Qi Zheng wrote: > In preparation for implementing lockless slab shrink, use new APIs to > dynamically allocate the nfsd-client shrinker, so that it can be freed > asynchronously using kfree_rcu(). Then it doesn't need to wait for RCU > read-side critical section when releasing the struct nfsd_net. > > Acked-by: Chuck Lever > Signed-off-by: Qi Zheng > --- > fs/nfsd/netns.h | 2 +- > fs/nfsd/nfs4state.c | 20 ++++++++++++-------- > 2 files changed, 13 insertions(+), 9 deletions(-) > > diff --git a/fs/nfsd/netns.h b/fs/nfsd/netns.h > index ec49b200b797..f669444d5336 100644 > --- a/fs/nfsd/netns.h > +++ b/fs/nfsd/netns.h > @@ -195,7 +195,7 @@ struct nfsd_net { > int nfs4_max_clients; > > atomic_t nfsd_courtesy_clients; > - struct shrinker nfsd_client_shrinker; > + struct shrinker *nfsd_client_shrinker; > struct work_struct nfsd_shrinker_work; > }; > > diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c > index 3339177f8e2f..c7a4616cd866 100644 > --- a/fs/nfsd/nfs4state.c > +++ b/fs/nfsd/nfs4state.c > @@ -4388,8 +4388,7 @@ static unsigned long > nfsd4_state_shrinker_count(struct shrinker *shrink, struct shrink_control *sc) > { > int count; > - struct nfsd_net *nn = container_of(shrink, > - struct nfsd_net, nfsd_client_shrinker); > + struct nfsd_net *nn = shrink->private_data; > > count = atomic_read(&nn->nfsd_courtesy_clients); > if (!count) > @@ -8125,12 +8124,17 @@ static int nfs4_state_create_net(struct net *net) > INIT_WORK(&nn->nfsd_shrinker_work, nfsd4_state_shrinker_worker); > get_net(net); > > - nn->nfsd_client_shrinker.scan_objects = nfsd4_state_shrinker_scan; > - nn->nfsd_client_shrinker.count_objects = nfsd4_state_shrinker_count; > - nn->nfsd_client_shrinker.seeks = DEFAULT_SEEKS; > - > - if (register_shrinker(&nn->nfsd_client_shrinker, "nfsd-client")) > + nn->nfsd_client_shrinker = shrinker_alloc(0, "nfsd-client"); > + if (!nn->nfsd_client_shrinker) > goto err_shrinker; > + > + nn->nfsd_client_shrinker->scan_objects = nfsd4_state_shrinker_scan; > + nn->nfsd_client_shrinker->count_objects = nfsd4_state_shrinker_count; > + nn->nfsd_client_shrinker->seeks = DEFAULT_SEEKS; > + nn->nfsd_client_shrinker->private_data = nn; > + > + shrinker_register(nn->nfsd_client_shrinker); > + > return 0; > > err_shrinker: > @@ -8228,7 +8232,7 @@ nfs4_state_shutdown_net(struct net *net) > struct list_head *pos, *next, reaplist; > struct nfsd_net *nn = net_generic(net, nfsd_net_id); > > - unregister_shrinker(&nn->nfsd_client_shrinker); > + shrinker_unregister(nn->nfsd_client_shrinker); > cancel_work(&nn->nfsd_shrinker_work); > cancel_delayed_work_sync(&nn->laundromat_work); > locks_end_grace(&nn->nfsd4_manager); Acked-by: Jeff Layton _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 56F84C0015E for ; Mon, 24 Jul 2023 12:17:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Date:Cc:To:From:Subject:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4wWC2Y/UqzM5DhGspqJ21KFDSL4M4wyahkNUaUz72Nc=; b=zKdvIz9Fcj06EB bpZ1OmAUBMDC6WryTFpImjDN61q4FPLrmX6HWaP1WM6elAnoroOAvQHtDF/qOkWwLp+4urIdto67I u8053KcYIFzjhW93O2qYSEtzhueCXf4J2Xj4nwXx+g4Z6H2yCNe1MDw8wB2ECQNAIA1x09yLS4ivF KIEsdIFEOBxQ7qI8oDo1fBX5G+V7cbbUySRK1Mz5vaj+OFwWK4ShB2Mjj2uwHs7AlEJvHuJTiWjkO ag+xZm/80uB8od8K54sk29YsqhQo5RNtUmGgIcmPjriDGtUKs4loeBByFv55vlWNI/yXw+Ie8JB0C HRPT1sMKTyybode6Dgig==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qNuVY-004CWD-32; Mon, 24 Jul 2023 12:17:48 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qNuVW-004CVH-0G for linux-mtd@lists.infradead.org; Mon, 24 Jul 2023 12:17:47 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 21BA160F6A; Mon, 24 Jul 2023 12:17:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE84DC433C7; Mon, 24 Jul 2023 12:17:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690201064; bh=QrEpSq7cPtZ3cWIhHPElPK38cx6jwtPbdBU+j7U7fKM=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=lFo5/uyfnIZhAXSNnfYH/zs0wLPvsdGmMHFPu1gPwZUyuOP10nfFnm2e23E9mVHox RPTdsfQNauiU49m1hBahLSzV9+gtG/J7umAiMCAj2AameE5Kr8rrBCOJ9W6HPjIMkc lBp1NfEAIBufJmTKwy4+ZdRStOdLezK2HhFQXgRbYXDnNec/zH0oZOEiZUwOk3URR0 CwbOA3I9uES6cdgV2JXRUz8O/MvIwDzgSFlH2Jg5PAfwuqtmwK87bHc16vNtVYlbJG hfzmJLudml4J90E2WDeTwJcjuLZaZewiSQ45z8+KBeEkpGI5axaDFLzZmilBUDvalQ cGU58i/dTyQGA== Message-ID: <01e8445d033314b6d9cd67bece74ca1c3ce89945.camel@kernel.org> Subject: Re: [PATCH v2 34/47] nfsd: dynamically allocate the nfsd-client shrinker From: Jeff Layton To: Qi Zheng , 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, Chuck Lever Date: Mon, 24 Jul 2023 08:17:39 -0400 In-Reply-To: <20230724094354.90817-35-zhengqi.arch@bytedance.com> References: <20230724094354.90817-1-zhengqi.arch@bytedance.com> <20230724094354.90817-35-zhengqi.arch@bytedance.com> User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230724_051746_227845_E2F64DDF X-CRM114-Status: GOOD ( 16.52 ) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-mtd" Errors-To: linux-mtd-bounces+linux-mtd=archiver.kernel.org@lists.infradead.org On Mon, 2023-07-24 at 17:43 +0800, Qi Zheng wrote: > In preparation for implementing lockless slab shrink, use new APIs to > dynamically allocate the nfsd-client shrinker, so that it can be freed > asynchronously using kfree_rcu(). Then it doesn't need to wait for RCU > read-side critical section when releasing the struct nfsd_net. > > Acked-by: Chuck Lever > Signed-off-by: Qi Zheng > --- > fs/nfsd/netns.h | 2 +- > fs/nfsd/nfs4state.c | 20 ++++++++++++-------- > 2 files changed, 13 insertions(+), 9 deletions(-) > > diff --git a/fs/nfsd/netns.h b/fs/nfsd/netns.h > index ec49b200b797..f669444d5336 100644 > --- a/fs/nfsd/netns.h > +++ b/fs/nfsd/netns.h > @@ -195,7 +195,7 @@ struct nfsd_net { > int nfs4_max_clients; > > atomic_t nfsd_courtesy_clients; > - struct shrinker nfsd_client_shrinker; > + struct shrinker *nfsd_client_shrinker; > struct work_struct nfsd_shrinker_work; > }; > > diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c > index 3339177f8e2f..c7a4616cd866 100644 > --- a/fs/nfsd/nfs4state.c > +++ b/fs/nfsd/nfs4state.c > @@ -4388,8 +4388,7 @@ static unsigned long > nfsd4_state_shrinker_count(struct shrinker *shrink, struct shrink_control *sc) > { > int count; > - struct nfsd_net *nn = container_of(shrink, > - struct nfsd_net, nfsd_client_shrinker); > + struct nfsd_net *nn = shrink->private_data; > > count = atomic_read(&nn->nfsd_courtesy_clients); > if (!count) > @@ -8125,12 +8124,17 @@ static int nfs4_state_create_net(struct net *net) > INIT_WORK(&nn->nfsd_shrinker_work, nfsd4_state_shrinker_worker); > get_net(net); > > - nn->nfsd_client_shrinker.scan_objects = nfsd4_state_shrinker_scan; > - nn->nfsd_client_shrinker.count_objects = nfsd4_state_shrinker_count; > - nn->nfsd_client_shrinker.seeks = DEFAULT_SEEKS; > - > - if (register_shrinker(&nn->nfsd_client_shrinker, "nfsd-client")) > + nn->nfsd_client_shrinker = shrinker_alloc(0, "nfsd-client"); > + if (!nn->nfsd_client_shrinker) > goto err_shrinker; > + > + nn->nfsd_client_shrinker->scan_objects = nfsd4_state_shrinker_scan; > + nn->nfsd_client_shrinker->count_objects = nfsd4_state_shrinker_count; > + nn->nfsd_client_shrinker->seeks = DEFAULT_SEEKS; > + nn->nfsd_client_shrinker->private_data = nn; > + > + shrinker_register(nn->nfsd_client_shrinker); > + > return 0; > > err_shrinker: > @@ -8228,7 +8232,7 @@ nfs4_state_shutdown_net(struct net *net) > struct list_head *pos, *next, reaplist; > struct nfsd_net *nn = net_generic(net, nfsd_net_id); > > - unregister_shrinker(&nn->nfsd_client_shrinker); > + shrinker_unregister(nn->nfsd_client_shrinker); > cancel_work(&nn->nfsd_shrinker_work); > cancel_delayed_work_sync(&nn->laundromat_work); > locks_end_grace(&nn->nfsd4_manager); Acked-by: Jeff Layton ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/