Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1141755rwb; Tue, 4 Oct 2022 16:19:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM76MGzNxearqnnsHcMrCaqf101IBmzWfTn213LKYtOvZ+s4xLyaWInf0Y6A8ffk1KH3w43L X-Received: by 2002:a17:907:7e8c:b0:78d:7ff:a1c6 with SMTP id qb12-20020a1709077e8c00b0078d07ffa1c6mr5365330ejc.371.1664925592272; Tue, 04 Oct 2022 16:19:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664925592; cv=none; d=google.com; s=arc-20160816; b=0QnzBzeRJakkOEx9r+BCGrYxx2KTKOEmqBzbuzU9v/yndAKUfSRouM9JU/1+KGuDsM 0hwdbOElUtjQITzDtGC74Fng45ixentmU3yV3+0Gndk1sQYlKexncp7Mw/Llodwd9Pjy mbQowuZnZvjt+1ODn8UcnzzF5Q1LhRt/i+C+s7A1n2qCFjH0aK3yVqpJfVQ8JmjqoLzz sT+hTLaJzqYkNUtp7XA6Hi9EKOXi8oUpy4ZT0C/rEP0TcHn8H5ylWQWl7F9/l2q+NiCr IEpJgFqvMwOo4VK7oJqfMC+wNE67BKs6qETPnFW05Xn1L5ug1gQACb6JIOJeqr2rNmDe RxrQ== 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=lZI6xtemsVCF5yBriFGUIYAln0eHjioIoffaHM8ZfFI=; b=GpS8/2x2qJx2+XG/i1TYsiyPEtjlnpuxtr0Xi2+UssGRf1OA4aJbHflLvDfmgaIS06 2+kCOwa27fnhWNwlDlf7IHaK9N4SzjWmsuFGGsRXTdY1Ysar3QzWWJzEwEvUYR2TqiFU TIBvQaSK4b7wudrwBmECySO8v5KOKVc5kwWXS4nbkW9ghVdKQIVDE1h2gaYVaHVGNbzx kGd+Ndc9NoOz7mDLwsmI20f3WKIl3IuLSqz9WT9dCjup4cmE1CBY/CnG1gJNASW3fNDU xMdb44XMFx2jVvqxlHbhaK5C06aN7srtLwggq3NXNZRychipDa9kUJIbo3SYUH87x08M jxHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=WdEbhFEW; 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 d15-20020aa7ce0f000000b0045902845795si5787463edv.557.2022.10.04.16.19.17; Tue, 04 Oct 2022 16:19:52 -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=WdEbhFEW; 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 S230095AbiJDXGq (ORCPT + 99 others); Tue, 4 Oct 2022 19:06:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230116AbiJDXGX (ORCPT ); Tue, 4 Oct 2022 19:06:23 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E56727B33 for ; Tue, 4 Oct 2022 16:06:15 -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 8C04E218E8; Tue, 4 Oct 2022 23:06:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1664924774; 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=lZI6xtemsVCF5yBriFGUIYAln0eHjioIoffaHM8ZfFI=; b=WdEbhFEWoRdMf0TcXjTvMZQPfNwj8yvWkdjSankNnMdi3lWvydyxOJj28hFC+EsAaBFk3U E+hrOxYFSaXmmF+K2jVkql+a7/YCUsnPfR5j5+jRqxfU5afZYryYwoOr/MEoY5rcLlHN0l Q99RWASzus/prR4Xs9bvUZiN5Tml6nA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1664924774; 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=lZI6xtemsVCF5yBriFGUIYAln0eHjioIoffaHM8ZfFI=; b=HrFAUpz2TJDTvRtPlyELnwzEdcdPw0N88pej3WFOrw30ztUdpw6mL9ykW7nF8Z43S32eNi MvZp3OmF/m5w/IAw== 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 64778139D2; Tue, 4 Oct 2022 23:06:13 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id lxqsB2W8PGN6NwAAMHmgww (envelope-from ); Tue, 04 Oct 2022 23:06:13 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 From: "NeilBrown" To: "Chuck Lever III" Cc: "Jeff Layton" , "Linux NFS Mailing List" Subject: Re: [PATCH v3] nfsd: rework hashtable handling in nfsd_do_file_acquire In-reply-to: <4FF85113-6F17-4F3C-AD31-E2472A988618@oracle.com> References: <20221003113436.24161-1-jlayton@kernel.org>, , <166483484979.14457.9448463531121052564@noble.neil.brown.name>, <4FF85113-6F17-4F3C-AD31-E2472A988618@oracle.com> Date: Wed, 05 Oct 2022 10:06:07 +1100 Message-id: <166492476800.14457.10230243127842792324@noble.neil.brown.name> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 Wed, 05 Oct 2022, Chuck Lever III wrote: > > > On Oct 3, 2022, at 6:07 PM, NeilBrown wrote: > > > > On Tue, 04 Oct 2022, Chuck Lever III wrote: > >> > >>> On Oct 3, 2022, at 7:34 AM, Jeff Layton wrote: > >>> > >>> nfsd_file is RCU-freed, so we need to hold the rcu_read_lock long enough > >>> to get a reference after finding it in the hash. Take the > >>> rcu_read_lock() and call rhashtable_lookup directly. > >>> > >>> Switch to using rhashtable_lookup_insert_key as well, and use the usual > >>> retry mechanism if we hit an -EEXIST. Eliminiate the insert_err goto > >>> target as well. > >> > >> The insert_err goto is there to remove a very rare case from > >> the hot path. I'd kinda like to keep that feature of this code. > > > > ???? > > The fast path in the new code looks quite clean - what concerns you? > > Maybe a "likely()" annotation can be used to encourage the compiler to > > optimise for the non-error path so the error-handling gets moved > > out-of-line (assuming it isn't already), but don't think the new code > > needs that goto. > > It's an instruction cache footprint issue. > > A CPU populates its instruction cache by reading instructions from > memory in bulk (some multiple of the size of the cacheline). I > would like to keep the instructions involved with very rare cases > (like this one) out-of-line so they do not clutter the CPU's > instruction cache. > > Unfortunately the compiler on my system has decided to place this > snippet of code right before the out_status: label, which defeats > my intention. Don't you hate that!!!! On the unpatched code, if I put a "likely" annotation on the assumed common case: if (likely(!nf)) { nf = new; goto open_file; } then the open_file code is placed immediately after the rhashtable_lookup_get_insert_key(). This supports my suggestion that likely/unlikely annotations are better at controlling code placement than source-code placement. I've thought for a while that those annotations should be optimise_for() and optimise_against() or similar. That is what is being requested. NeilBrown