Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp25632037rwd; Sun, 2 Jul 2023 21:52:16 -0700 (PDT) X-Google-Smtp-Source: APBJJlEXTlZYHfaRM83+e9FlJnqFIdT9Jh69Fj4XGsdZ+Frpjz5tqcOlb6hbPYS4fz24U8DatCw1 X-Received: by 2002:a17:903:1c9:b0:1b8:76cb:3e50 with SMTP id e9-20020a17090301c900b001b876cb3e50mr6222152plh.47.1688359936388; Sun, 02 Jul 2023 21:52:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688359936; cv=none; d=google.com; s=arc-20160816; b=sDge180Bai/NJysMYca3uqnWQ9fW3iizSIZmoqle7ZXojvcMd7vtMvAaKY0UMgNzXf i25JwhYpAu7LP1mvfn9joTvo/SC3L+mzXQpcuhsK2VNUoQo7TRBGLMWxelK6W0E/kCXR eweNbr+v1RvunmT/vj+RnbTPQybsFpcbMmuT72aZgvhQQR2VxDMRJnH/EUIoXwC9+OGg rj762THGd3tRufz0i6sknL+mEOMKkO7beVwvd3wLuwtV/3c70bBrlsNJKBCAiGmUeD+t 5O2xB1ODzMDEPLKEuyWmPhXWwiqot5aYZd6wr+Eh+QiSUe+a6Au/AXWqxO7aKhtcq2UU bfug== 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=h/EZ7h6UxhORQqlIGJ3v2FQ5d3ZomNwIfwZHBLA3srU=; fh=R5lvQGTOWsNa6g0ikAYqVRgrHZTdAoXUy/53IP8UQ4s=; b=WLWeVbWtngPJyaBIHBhD1aACPo1fY6w968CVCZkAIl45QmgjzaMl3LbJ+OtJ25YUsP yh4OykKtPg2vCGiOrXvl/7arMiY/c9OCD738JYljea1jtBWOQD0myRXfBG7Q3dAKovKf 6K6r33Nv98DzTLzvSHcrGj3ZOZM2LJ9/l5w7/xYf3Sjhr8ruY9sc2YK/k/njQk05c/4U FzxveGSA9fEcp70vPUc+gkrlJD0Xzre9soG2D8lYIs8XD7WybS9KsP2CDMcSNaq5ImEw nD6VxBduhFPnc2pbRosGyIapQ84Cy1y2RaAllKv7/Zr6trgtE9MCQz2RJseOCJIu0tfI Jr8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=xZIPht5Z; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=jlexXMYR; 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 b11-20020a170903228b00b001b88b6ac66csi3329777plh.467.2023.07.02.21.51.53; Sun, 02 Jul 2023 21:52:16 -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=xZIPht5Z; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=jlexXMYR; 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 S229481AbjGCEsY (ORCPT + 99 others); Mon, 3 Jul 2023 00:48:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229504AbjGCEsW (ORCPT ); Mon, 3 Jul 2023 00:48:22 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E0811AB for ; Sun, 2 Jul 2023 21:48:18 -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 1B47E218E0; Mon, 3 Jul 2023 04:48:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1688359692; 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=h/EZ7h6UxhORQqlIGJ3v2FQ5d3ZomNwIfwZHBLA3srU=; b=xZIPht5ZfimLdBEQ60lvCKlazR+MN6nwmLg0nP0gC452uEA/kLG96Zm6UAkwfjZi1aiWPe FfxwtKWipC1fzRoQmxrvd66a2Pq/l8T2fjxwl/2zDwN70+GjMuzPNxw5foRLFbmgTZXJ0g j6j7htykJAVKftab+s/v+7iGuarf6dw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1688359692; 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=h/EZ7h6UxhORQqlIGJ3v2FQ5d3ZomNwIfwZHBLA3srU=; b=jlexXMYRTp1s53W3Ar6i+Zfna0Q79W5NUPiHH8VcNUoy70QFyAc88AMYOXo4LXLKcYjMaf pj7eadwJH/FOyIBw== 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 CDC2D13276; Mon, 3 Jul 2023 04:48:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id YZ7GHwpTomROEAAAMHmgww (envelope-from ); Mon, 03 Jul 2023 04:48:10 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 From: "NeilBrown" To: "Chuck Lever" Cc: linux-nfs@vger.kernel.org, "Chuck Lever" Subject: Re: [PATCH RFC 0/4] Encode NFSv4 attributes via a branch table In-reply-to: <168808788945.7728.6965361432016501208.stgit@manet.1015granger.net> References: <168808788945.7728.6965361432016501208.stgit@manet.1015granger.net> Date: Mon, 03 Jul 2023 14:48:07 +1000 Message-id: <168835968730.8939.17203263812842647260@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,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 On Fri, 30 Jun 2023, Chuck Lever wrote: > 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. Tomatoes or stars .... it is a hard choice :-) I wonder what the compiler does with this code. If it unrolls the loop and inlines the functions - which it probably can do as the array of pointers is declared const - you end up with much the same result as the current code. And I wonder where the compiler puts the code in each conditional now. If it assumes an if() is unlikely, then it would all be out-of-line which sounds like part of your goal (or maybe just a nice-to-have). If the compiler does, or can be convinced to, do the unroll and inline and unlikely optimisations, then I think I'd give this a goal star. I guess in practice some of the attributes are "likely" and many are "unlikely". With the current code we could easily annotate that if we wanted to and thought (or measured) there was any value. With the looping code we cannot really annotate the likelihood of each. The code-generation idea is intriguing. Even if we didn't reach that goal, having the code highly structured as though it were auto-generated would be no bad thing. Thanks, NeilBrown