Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp1477985rdh; Fri, 27 Oct 2023 16:11:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFF+hj4liDK/369R9Wi8z0tSYCKeXfT4uk/Et1Ba5UE2mdkaJJsajLKtUQD4cM2PY+nM/Wn X-Received: by 2002:a05:690c:fc3:b0:59b:65d4:4d73 with SMTP id dg3-20020a05690c0fc300b0059b65d44d73mr4765545ywb.27.1698448273531; Fri, 27 Oct 2023 16:11:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698448273; cv=none; d=google.com; s=arc-20160816; b=CBBbjHRSARn4PmHwYjA6wpGpa2SxUN4bAhYeq/gFPuFXIBuidIiKU2E5GlX3/CwReu t6FzXnKKD/9voh60lAC5flIMp2YQrhLxeBVMzTdQwRG31OmR6hjaflhmPWg3HhmmTF/p UhDQuXcjc1xds48Ld3POvaxOxgfTliiwaTYuKk1R6Voc1vHb3+KHqQ0acQSKkTqz6Z0u 017rO7qQIFC13vAnBaFWOE7Va1K8H/bX0VgE38TSmUduP4x/FLTtvz3OfL+98e1q8GVJ HfvxdhjX6MEHA07x9QQ5ktpWBJF1Woc/01LPRT/k6Gk32kDR+RsLS8H5GrkjuPM+gGJg u6tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Aiw3atUCBnwgKNjOyjIprjoAJkJHCnLAHdffktGkr7w=; fh=mZpzoj7DuFKDTL0pme+XpUIk6D9/XM2SLlhUWu3EnaA=; b=nP3QTPz9CNZaunFy9QdDaz0xX4eBfsR/Fy73JHkAZbHdjWwGKgqNSuAWIe84jrlLlO 0/TWFG8fQYZfWAbrPgoKhHItxlMeocx6yEtbx76wVdT1gWpPGuLAUxg4poOsJgRO3Jhu SQV2RQHOwOpdNFTylJCampxe7X8J1ewj0f7Sehm3TYotYXVIv7bTvOyARpBKYopGtxRi W60IptB7F8W1tXFg57fukc1jpB2W4o2Z1B1Lo7Aypg/ylTox5XIfMz/EN0CXZzRSc10Y zuIvJyN+d8Sq9HVnVgVwWbvHxsfx2Oa3IcG25QCkhujClZTefMdz5NgYLND8TxjzASd/ ydsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=jEeP1Vub; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id w124-20020a817b82000000b0059bce05d922si3490372ywc.84.2023.10.27.16.11.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 16:11:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=jEeP1Vub; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 0A8208240F4C; Fri, 27 Oct 2023 16:11:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235148AbjJ0XK7 (ORCPT + 99 others); Fri, 27 Oct 2023 19:10:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230451AbjJ0XK6 (ORCPT ); Fri, 27 Oct 2023 19:10:58 -0400 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [IPv6:2a03:a000:7:0:5054:ff:fe1c:15ff]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6780C1AA; Fri, 27 Oct 2023 16:10:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Aiw3atUCBnwgKNjOyjIprjoAJkJHCnLAHdffktGkr7w=; b=jEeP1VubOumA8I5tSAeXitLq9S XIjPJuii+LyAYcPZzu/YyatcPaREiQsauZJpKoDR8tKyT6Ry5XSpXFU7MnpsF5aF0pnga1UiB12O9 blIxP8KjQ8abli6qVNuqcpd09O9gvHbqO8ADxmPKJHqhfeQwjvX6vWeOXcBBJDfx0PH8yWGzHxfna 09cFAhe45cuJAfv31j2naLwl81N6OvJLVjsbZDDdY96DlRwu7uSWsqY7A/SIDbx6dNUI+8Fmwsq2I 3A0oRt+eyWSv5DJs6Jvslfb/QF96Kyg4bbcmV1c9fz9cl9p25bnoedefZPNeN6OAosGDVOzuw6ZHx UdsrziBg==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1qwVyO-006mQG-2S; Fri, 27 Oct 2023 23:10:36 +0000 Date: Sat, 28 Oct 2023 00:10:36 +0100 From: Al Viro To: Charlie Jenkins Cc: Palmer Dabbelt , Conor Dooley , Samuel Holland , David Laight , Xiao Wang , Evan Green , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Paul Walmsley , Albert Ou , Arnd Bergmann Subject: Re: [PATCH v8 1/5] asm-generic: Improve csum_fold Message-ID: <20231027231036.GM800259@ZenIV> References: <20231027-optimize_checksum-v8-0-feb7101d128d@rivosinc.com> <20231027-optimize_checksum-v8-1-feb7101d128d@rivosinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231027-optimize_checksum-v8-1-feb7101d128d@rivosinc.com> Sender: Al Viro X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 27 Oct 2023 16:11:11 -0700 (PDT) On Fri, Oct 27, 2023 at 03:43:51PM -0700, Charlie Jenkins wrote: > /* > * computes the checksum of a memory block at buff, length len, > * and adds in "sum" (32-bit) > @@ -31,9 +33,7 @@ extern __sum16 ip_fast_csum(const void *iph, unsigned int ihl); > static inline __sum16 csum_fold(__wsum csum) > { > u32 sum = (__force u32)csum; > - sum = (sum & 0xffff) + (sum >> 16); > - sum = (sum & 0xffff) + (sum >> 16); > - return (__force __sum16)~sum; > + return (__force __sum16)((~sum - ror32(sum, 16)) >> 16); > } Will (~(sum + ror32(sum, 16))>>16 produce worse code than that? Because at least with recent gcc this will generate the exact thing you get from arm inline asm...