Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp21583231rwd; Thu, 29 Jun 2023 19:06:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4YRzaRasdKAlSxXvoj+ogSgPJyzELf5q1Zmw6+/DlgM7CXzSe6mGJlrZf1MbyxkZFANkby X-Received: by 2002:a05:6870:aa89:b0:1ad:3e11:a291 with SMTP id gr9-20020a056870aa8900b001ad3e11a291mr2038872oab.7.1688090768485; Thu, 29 Jun 2023 19:06:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688090768; cv=none; d=google.com; s=arc-20160816; b=MkBB46RuuqtJ0iqMMtauumX9WCQ/DRBRZ1f05SZAHp4jOqTlmiV43crCCA7xGf4eKp MSf8A8EOVi2n+o2QOx1LsQm0Td4h3WYXEqNPfq/NnLmqFey9sLhfq4sqe2vhLcTuyVi2 BE3CfQLHT7LByH7LaH2WPnGtHRiXZr7Gue0/DdjRwVNyjgbbxrLCFqv6gaqgAa11Aeai Ji+6MNA/KMKBKdvR2q+xqZKWUbjC6DEBCvSrQM3Z1VmVFEM8AmA20PS7KXsNVKH2w3Ot HLgmJbq0VE4eIPncj3EBqH015LhRxcx3fP131BgyJvzStSr1xXM98NsifDxPZKvAVHb0 JixQ== 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 :user-agent:message-id:date:cc:to:from:subject:dkim-signature; bh=o6N3YYuCNrZW29UQrIbw+Lsoj0t/erHbNsbqXvoZNko=; fh=v8a13lpFSZWlL4AptTEJnmXnlqoWXhGCGCgvrcnCT9I=; b=Shgu3OCvQU2i2E+4qYClCzU880H5JOyn+VNI/8JfG/uCRKcq0N2C75Ru2e3rgglJrS g+A92WjLDyEtcjG45AodaXeIRO93wGvzXKEEqCoYGz3+1aXxIgUfo/U3cG0U7cbLJbY4 AZNbV3AWI2fH/W5a9BZjc9MFmzFT7w+3QYpUkcYt4W5dtPeXdQlgL48Mb7iSqKJFIqOA kM12cjUVvmPtpc/zHDQsw5dgATET4kG7W7Rdfs6jKzm/homJcYuVKkSZdbN02UgISH53 inAN5QfUvNh/1uKYb102SreZTkci/4zn7jlvmmyvwy6/pfU+HQIgEZOm1PhR6LN+K2Ab aDbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=O8yO0mGz; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mg20-20020a17090b371400b0025bd9dac5f1si13377083pjb.28.2023.06.29.19.05.53; Thu, 29 Jun 2023 19:06:08 -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=@kernel.org header.s=k20201202 header.b=O8yO0mGz; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230410AbjF3Bei (ORCPT + 99 others); Thu, 29 Jun 2023 21:34:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230013AbjF3Beh (ORCPT ); Thu, 29 Jun 2023 21:34:37 -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 13495297C for ; Thu, 29 Jun 2023 18:34:37 -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 928596167C for ; Fri, 30 Jun 2023 01:34:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C525DC433C8; Fri, 30 Jun 2023 01:34:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688088876; bh=gtfuKL4TUbbreWWbDDa3lEkKawRkzxGB7nJ/ihRfX/c=; h=Subject:From:To:Cc:Date:From; b=O8yO0mGzvKMIqjR0Q9BRwWk/EiXtUSwFFIL298f6xYBbfZt6ycC3AhlirBBrPsM82 C4UbkUggcfc9rj/NPPJdT8NDkeJohKhql0e2IN8tjkMRPxhmuDMsY8kYfhI7ScD+ER SHJdEn7kdzgtn1/hR0bmP1FFWmjQ7DkG+tT6hQQHFCYV3w2jT/G/5DZnuHmkuhQ8q4 zZfNwEZSCmSbbyIfVhqMNJWFpLTRP9plxOfMv19NjRcafmTtB6Y/BF3A53D9AZCLhT LNOWZA1rjX3nkMYaYDqq0cSRFekC3KC05sCbg35HxAqpgeby2GLD8YXL70j51EL9fL xY+mYiaPwFG8Q== Subject: [PATCH RFC 0/4] Encode NFSv4 attributes via a branch table From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Thu, 29 Jun 2023 21:34:34 -0400 Message-ID: <168808788945.7728.6965361432016501208.stgit@manet.1015granger.net> User-Agent: StGit/1.5 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 Here's something just for fun. I've converted nfsd4_encode_fattr4() to use a bitmask loop, calling an encode helper for each attribute to be encoded. Rotten tomatoes and gold stars are both acceptible. I was hoping for a bit of a performance gain because encode_fattr4 is called so very often, but there was not much difference at all. The main benefit here is the hard scope boundary for each of the separate attribute encoders -- that makes for safer code that is easier to reason about, and might even be more straightforward to convert to machine-generated code, if we ever want to do that. And notably it will automatically encode the attributes in bitmask order. There are a few readability improvements that could be done, like defining meaningfully-named macros for the bit positions. The ones we have now are not directly usable for table indices. It might get us another step closer to the XDR specification if we could find a way to encode the whole bitmask in a single loop. --- Chuck Lever (4): NFSD: Add struct nfsd4_fattr_args NFSD: Encode attributes in WORD0 using a bitmask loop NFSD: Encode attributes in WORD1 using a bitmask loop NFSD: Encode attributes in WORD2 using a bitmask loop fs/nfsd/nfs4xdr.c | 1089 +++++++++++++++++++++++++++------------------ 1 file changed, 657 insertions(+), 432 deletions(-) -- Chuck Lever