Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp7627795rwi; Mon, 24 Oct 2022 17:55:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4jbKe0TDnsamtC3EIq34Qx9qQ6DwwAqMt0FMSspxSdcE1RV+EHKFcUMs0V2oUPz5L0+GSm X-Received: by 2002:a17:907:1629:b0:79d:aa05:3783 with SMTP id hb41-20020a170907162900b0079daa053783mr15839683ejc.637.1666659354613; Mon, 24 Oct 2022 17:55:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666659354; cv=none; d=google.com; s=arc-20160816; b=bQ5SjCzUdvcdSRRa66fVI8iJSUMiYH8d2x7jQ/sLKgBLhZgTozm6u6uuoASiGErzWl r1/ap4gUkUxKeXosaw8LiA5zrTmEac4Z5vAPca7Q7Usdb9wv+j7gmbQchh0E2VZ4ahYk cqA5Nj3ewNg+GbRAFL7Lh8AksA/lfBy5eQUP/wuLFU4ZwtXWOxjog4iVF24HVwrVSwp/ 7o4IPdLje5OgZEpDFG56vAumn/GXkcOhr6XaAulgSpMwRBu7jeQanRQFGcvFwS/FRM8o Z/A8umLzC+CmfexeX6g3L3YdKPn6rdXj0wHFMtLuJGrazXQpUlz3BJMk1k5Sh0NrIk14 27+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:references:in-reply-to:subject :cc:to:from:mime-version:content-transfer-encoding:dkim-signature :dkim-signature; bh=/KN0ki/2NsOxvcRxLp93JxPYxpoL0JusvlwKW+z8Ya4=; b=UI5aOTDx4lzIjw3+Mvh4EER9ogSxp29IAMQrrOy5Eve1qoLLZD9kXYpB2ftcx+nejP /iWutElMcQOExafE+0zhW/95BKZe+XT7zzfO7vGHJfUhZXrDr6+IyiToGpwDAeC8R4Y7 ptrK40eNttqZ4LZ1SnUQc7q949vP2j+PiMQjM4xEC/fbqrEOkip4L6uZ2Vzq5rj0FWJQ SHQAk68DG3Y8aXUzfvBUVPDHrOtdfwG6FZ9qQhNGgmZjr+UxPAajg7wNSa8OUzTN5FVm BuHNBljsltlXoy5y2l6B6fAZJbfG2EygMzLIkTnsLoiSCLl2vQTHh369kaIs1TJO2pnU l7oA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=JDGl1EEY; dkim=neutral (no key) header.i=@suse.de; 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=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t11-20020a1709063e4b00b0078def5c29e6si1132551eji.531.2022.10.24.17.55.28; Mon, 24 Oct 2022 17:55:54 -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=@suse.de header.s=susede2_rsa header.b=JDGl1EEY; dkim=neutral (no key) header.i=@suse.de; 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=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231167AbiJYAyo (ORCPT + 99 others); Mon, 24 Oct 2022 20:54:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231244AbiJYAyR (ORCPT ); Mon, 24 Oct 2022 20:54:17 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00CD51BA1ED for ; Mon, 24 Oct 2022 16:37:40 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 5888F21E59; Mon, 24 Oct 2022 23:37:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1666654659; h=from:from:reply-to: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; bh=/KN0ki/2NsOxvcRxLp93JxPYxpoL0JusvlwKW+z8Ya4=; b=JDGl1EEYEyLEIpJRWV2TGibQyi4SEYYUYgoyxypKnRf98QwtAimLJ7oqBhNd5tmcLhS6oi VDGA1yhtJ/zhOfPx1ep2NmkyAmoXWZWVINjvtt7hIsgGBW2aBZeUsjnYJAv+PtcEM0kSBA MHOngWLMfyOfyP/k1NR/Ydqnn38VMkc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1666654659; h=from:from:reply-to: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; bh=/KN0ki/2NsOxvcRxLp93JxPYxpoL0JusvlwKW+z8Ya4=; b=8MdvoAez+NYCa0uWbrg96YzwjopreF6vYU+y5KfrNbjdOXWgwBLjPh5jsA6wdoGb2YfJAJ nEqdwYDOBHL9GdBA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 7379C13A79; Mon, 24 Oct 2022 23:37:38 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id j4UVC8IhV2P9JgAAMHmgww (envelope-from ); Mon, 24 Oct 2022 23:37:38 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 From: "NeilBrown" To: "Chuck Lever" Cc: linux-nfs@vger.kernel.org Subject: Re: [PATCH v5 12/13] NFSD: Allocate an rhashtable for nfs4_file objects In-reply-to: <166665108857.50761.11874625810370383309.stgit@klimt.1015granger.net> References: <166664935937.50761.7812494396457965637.stgit@klimt.1015granger.net>, <166665108857.50761.11874625810370383309.stgit@klimt.1015granger.net> Date: Tue, 25 Oct 2022 10:37:34 +1100 Message-id: <166665465494.12462.9078997979555811271@noble.neil.brown.name> X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS 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 On Tue, 25 Oct 2022, Chuck Lever wrote: > Introduce the infrastructure for managing nfs4_file objects in an > rhashtable. This infrastructure will be used by the next patch. >=20 > Signed-off-by: Chuck Lever > --- > fs/nfsd/nfs4state.c | 23 ++++++++++++++++++++++- > fs/nfsd/state.h | 1 + > 2 files changed, 23 insertions(+), 1 deletion(-) >=20 > diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c > index abed795bb4ec..681cb2daa843 100644 > --- a/fs/nfsd/nfs4state.c > +++ b/fs/nfsd/nfs4state.c > @@ -44,7 +44,9 @@ > #include > #include > #include > +#include > #include > + > #include "xdr4.h" > #include "xdr4cb.h" > #include "vfs.h" > @@ -721,6 +723,18 @@ static unsigned int file_hashval(const struct svc_fh *= fh) > =20 > static struct hlist_head file_hashtbl[FILE_HASH_SIZE]; > =20 > +static struct rhltable nfs4_file_rhltable ____cacheline_aligned_in_smp; > + > +static const struct rhashtable_params nfs4_file_rhash_params =3D { > + .key_len =3D sizeof_field(struct nfs4_file, fi_inode), > + .key_offset =3D offsetof(struct nfs4_file, fi_inode), > + .head_offset =3D offsetof(struct nfs4_file, fi_rlist), > + > + /* Reduce resizing churn on light workloads */ > + .min_size =3D 256, /* buckets */ Every time I see this line a groan a little bit. Probably I'm groaning at rhashtable - you shouldn't need to have to worry about these sorts of details when using an API... but I agree that avoiding churn is likely a good idea. Where did 256 come from? Would PAGE_SIZE/sizeof(void*) make more sense (though that is 512). How much churn is too much? The default is 4 and we grow at >75% and shrink at <30%, so at 4 entries the table would resize to 8, and that 2 entries it would shrink back. That does sound like churn. If we choose 8, then at 7 we grow to 16 and at 4 we go back to 8. If we choose 16, then at 13 we grow to 32 and at 9 we go back to 16. If we choose 64, then at 49 we grow to 128 and at 39 we go back to 64. The margin seems rather narrow. May 30% is too high - 15% might be a lot better. But changing that might be difficult. So I don't have a good recommendation, but I don't like magic numbers. Maybe PAGE_SIZE/sizeof(void*) ?? But either way Reviewed-by: NeilBrown Thanks, NeilBrown > + .automatic_shrinking =3D true, > +}; > + > /* > * Check if courtesy clients have conflicting access and resolve it if pos= sible > * > @@ -8023,10 +8037,16 @@ nfs4_state_start(void) > { > int ret; > =20 > - ret =3D nfsd4_create_callback_queue(); > + ret =3D rhltable_init(&nfs4_file_rhltable, &nfs4_file_rhash_params); > if (ret) > return ret; > =20 > + ret =3D nfsd4_create_callback_queue(); > + if (ret) { > + rhltable_destroy(&nfs4_file_rhltable); > + return ret; > + } > + > set_max_delegations(); > return 0; > } > @@ -8057,6 +8077,7 @@ nfs4_state_shutdown_net(struct net *net) > =20 > nfsd4_client_tracking_exit(net); > nfs4_state_destroy_net(net); > + rhltable_destroy(&nfs4_file_rhltable); > #ifdef CONFIG_NFSD_V4_2_INTER_SSC > nfsd4_ssc_shutdown_umount(nn); > #endif > diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h > index e2daef3cc003..190fc7e418a4 100644 > --- a/fs/nfsd/state.h > +++ b/fs/nfsd/state.h > @@ -546,6 +546,7 @@ struct nfs4_file { > bool fi_aliased; > spinlock_t fi_lock; > struct hlist_node fi_hash; /* hash on fi_fhandle */ > + struct rhlist_head fi_rlist; > struct list_head fi_stateids; > union { > struct list_head fi_delegations; >=20 >=20 >=20