Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp3274312ioo; Tue, 24 May 2022 18:28:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwsPBzs3xkCuEWuOVqnDu9J4j5rFiQiC0NThv/O73ZgOT+JwgB9x5aoMUeV3uFTd4YmNfQV X-Received: by 2002:a17:902:c412:b0:161:af8b:f472 with SMTP id k18-20020a170902c41200b00161af8bf472mr29720841plk.56.1653442118157; Tue, 24 May 2022 18:28:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653442118; cv=none; d=google.com; s=arc-20160816; b=rVgp1g/QnC1MA6VB/0HTtfz0QwLEDgBzo0/dFt/VUsxQu+K8SJggavX5wSTJ6e7wP9 e6dCAQ3OFI0EsBzdWOCcJu3LPQTnpPJReSaUbZQBE1ILelr2zuA1WgUU02snG5yU+7bL ff6yQWCujVe/nqrwfq03JC6sWcl9nX+XXvGwXr/9AzwlyvRzi7mRdDUOKkPOvybb0xVq XWqnnuaboMZvzkxY/MKL06C2bduENguDZE1xfcUtemOonuLcuEyA0s4MQ8yczW9r7jQJ e5yOp8aaq4/8ZjMvXCZ5X87HT9YGnXpB7g8SjdymE0shcXSI4AhhQYlmHEbG56o+cM/z jVvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=HDX84FFeFcjSflCNx/dYP2mOlMAVfBYz8NXog7/4cdA=; b=Rst9ZqXURME0p+zKo4A+VkR5OSQtm+CqeOjlDrUxonssV3j8qjtRLGF6QfiGs2BP1P CkFWS8qVplfFfA8f3AThqZwCOeOJnMtCHNOvqPKvMnTJdf6pieHCwdxdfO7uinyKitMQ rw15iX6o+RLQ7mWrLTpcg6kFd/LHXoJjz9bVku+WOBNxUt4JBakySDRjDQFCaI5fVvXc Kuj8/wpMw2w8cFenny2HHaSCu/esmlKCv7Vskjuyc7p6p1PGNWV2lTaHMWV1zaQGXtsc m47C1/qmL6FiYUP7uHCSIBLk/dOzn61EbiTI7F/YXNlFfCAcZa8vGIDmfg/YIbPS/tsQ /rQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=kCGVsnok; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k14-20020a170902ce0e00b0015d1ef2dd92si16536553plg.47.2022.05.24.18.28.22; Tue, 24 May 2022 18:28:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@gmail.com header.s=20210112 header.b=kCGVsnok; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238271AbiEXQic (ORCPT + 99 others); Tue, 24 May 2022 12:38:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233418AbiEXQia (ORCPT ); Tue, 24 May 2022 12:38:30 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02ADAE023; Tue, 24 May 2022 09:38:30 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id q4so16302460plr.11; Tue, 24 May 2022 09:38:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=HDX84FFeFcjSflCNx/dYP2mOlMAVfBYz8NXog7/4cdA=; b=kCGVsnokeKe36OuduWxziv0q3V3zFewTgyZ8ZcYnQUMh2yWCS/RhP0lulH2745OHxm TrBc6V/3T6oYEPYvu5h636CXl8ymu9t7NmarcjASamefGZ4C2xBhz1sSRShLQIscFrol SdtK9pnKzB15c5ABS9qP2+hTL02S/SN0vH6P3XmGP31V9lmgMiI2ERYE/I8qxBDERClb Hhs5dxeS6k/FQYmSM39bCFrWO9ZZnkGqhrhloxdQazHOMAuyrDJy6UO5YV69TM5zVQoU BFEfJxAetRO6IJW85qZLE7PEi6cq6J0yoHLfInuG+l3jAld2BtEEjg7ifGyWhUiq0H9q 9HEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=HDX84FFeFcjSflCNx/dYP2mOlMAVfBYz8NXog7/4cdA=; b=1/R0DOUWgjsz3lwPGr/2Z6ubpl+svHfHtycrOYxoxeZgE6gSCY9lB7OoYRzKLWLeQN AF8v85ilnQ1aaQqw2gnf/qPbJhGAwQAnPcWQYwSavzsG+KauDaXLIZDI7HLQZIF3Hl08 8h/8rrzM48u2KFlO3vMNde3DmNktiTI7KH77WNquLzdk9sTcROBrrEM+CfkgeRgxs76o dQmUMRBsASz/XKB4JiONCMJWY5htfz245f+Z/nkDlOHsLtRsKbE/H2xcLovxwvqMTfxI 468/9ko6Q9wpW7K0LjCAWFFZCcwU1mK+w33SAAC9EQ/4XwboQp1QSb5MimcdlS4GAiTP BO3g== X-Gm-Message-State: AOAM533X+jzOqvk25zFj0H+3RdpPNAKaILJPK4iZmRHdDwnSTQo36Wxo s2nxxBB83STRCzFWLpmP7Gk= X-Received: by 2002:a17:903:288:b0:15f:a13:dfd5 with SMTP id j8-20020a170903028800b0015f0a13dfd5mr28525273plr.55.1653410309327; Tue, 24 May 2022 09:38:29 -0700 (PDT) Received: from [10.67.48.245] ([192.19.223.252]) by smtp.googlemail.com with ESMTPSA id v6-20020a63b946000000b003c14af5063fsm6808077pgo.87.2022.05.24.09.38.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 24 May 2022 09:38:28 -0700 (PDT) Message-ID: <7682977b-5929-890a-3a18-662fbfcede5c@gmail.com> Date: Tue, 24 May 2022 09:38:27 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: [PATCH] MIPS: Rewrite `csum_tcpudp_nofold' in plain C Content-Language: en-US To: "Maciej W. Rozycki" , Thomas Bogendoerfer Cc: Paul Cercueil , Nathan Chancellor , Tiezhu Yang , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org References: From: Florian Fainelli In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,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-kernel@vger.kernel.org On 5/22/22 13:48, Maciej W. Rozycki wrote: > Recent commit 198688edbf77 ("MIPS: Fix inline asm input/output type > mismatch in checksum.h used with Clang") introduced a code size and > performance regression with 64-bit code emitted for `csum_tcpudp_nofold' > by GCC, caused by a redundant truncation operation produced due to a > data type change made to the variable associated with the inline > assembly's output operand. > > The intent previously expressed here with operands and constraints for > optimal code was to have the output operand share a register with one > inputs, both of a different integer type each. This is perfectly valid > with the MIPS psABI where a register can hold integer data of different > types and the assembly code used here makes data stored in the output > register match the data type used with the output operand, however it > has turned out impossible to express this arrangement in source code > such as to satisfy LLVM, apparently due to the compiler's internal > limitations. > > There is nothing peculiar about the inline assembly `csum_tcpudp_nofold' > includes however, though it does choose assembly instructions carefully. > > Rewrite this piece of assembly in plain C then, using corresponding C > language operations, making GCC produce the same assembly instructions, > possibly shuffled, in the general case and sometimes actually fewer of > them where an input is constant, because the compiler does not have to > reload it to a register (operand constraints could be adjusted for that, > but the plain C approach is cleaner anyway). > > Example code size changes are as follows, for a 32-bit configuration: > > text data bss total filename > 5920480 1347236 126592 7394308 vmlinux-old > 5920480 1347236 126592 7394308 vmlinux-now > 5919728 1347236 126592 7393556 vmlinux-c > > and for a 64-bit configuration: > > text data bss total filename > 6024112 1790828 225728 8040668 vmlinux-old > 6024128 1790828 225728 8040684 vmlinux-now > 6023760 1790828 225728 8040316 vmlinux-c > > respectively, where "old" is with the commit referred reverted, "now" is > with no change, and "c" is with this change applied. > > Signed-off-by: Maciej W. Rozycki > --- > Hi, > > I have visually inspected code produced and verified this change to boot > with TCP networking performing just fine, both with a 32-bit and a 64-bit > configuration. Sadly with the little endianness only, because in the > course of this verification I have discovered the core card of my Malta > board bit the dust a few days ago, apparently in a permanent manner, and I > have no other big-endian MIPS system available here to try. How about QEMU is not that a viable option for testing big/little endian configurations? -- Florian