Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4839414rdb; Fri, 15 Sep 2023 14:04:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEnu2YtwCyAcMx1YJp9KDfi9V8DaMa2KqkmrVvgvfTSKR4Ke/ASJHEE3XoY1h9qdkZGZdd+ X-Received: by 2002:a05:6a20:12d1:b0:134:135c:5a23 with SMTP id v17-20020a056a2012d100b00134135c5a23mr6945011pzg.18.1694811867135; Fri, 15 Sep 2023 14:04:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694811867; cv=none; d=google.com; s=arc-20160816; b=Pa8azDxvYMUei9aCBnczLaCK4F80zlKHYdCPCcI9g3DZlINH/eztTWcWTiMVMupN7g hHzb6/XlQxPO7roibplDFStn1dcpGoZNEnpRIxoTwXyhKPL4UUffFntakW+pYoGYpZTR Rj6nOMPfaCMkNMVHfQ80xc6/7fvDLNX3q3gxwNtSEEpLrXH+HZu8lOMc5QbXS2E0iqYO ubtWHl1clDEps3cHCEMiDcXfoUYsKbIXU8r3RSnWBV6ePkXFWU+2wxpBqaQ52vJSgFZT /EWk4EHBHm2m70b2UB9hnWBBaYBunr8+t82whGgsPzMliZ6UgM1jWJcsP6qtnZEAdiW5 ilMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Th8NoXT19fs06IrPnES4vcAsMrYG/0js4/EA9rEsqpw=; fh=vrXue3HNekBLAIYZZU1Ekd2BKy48UDfvKHSKqZu3QXI=; b=BkkonQImqkSsocdpy+pGU3nPFF9AYDNyqI/+qg7LYW2VKJ7snWhDBhtaY21IzLsuku su/3AU/7B4A8LTvFRvCs3SEPl7Tjm9HBPQoM6PJd08H1a5ceMsVd1xi/FzxtktRse5yX MFNV+ElXxBr/7EuvHEUFNCSL7qDKLE/U1bg2AEg0+dcCJO924V1l8Bsks5FmAlJmkKha LYuWa2Gjb0p7KkjD/8d9mHVEyexZve/JS/3bPxrN0BhHmcIISvPAYepxcmon8Y5/egAY +iH+6z+atvs/r6PfgoPc3T3O+J7OU7/zxoeKs4dnS7hW796HQydwpyAHDBAlqezHlv1N sciw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=GKq65H6J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id w70-20020a638249000000b005706961d4d2si3681220pgd.463.2023.09.15.14.04.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 14:04:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=GKq65H6J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 8CAF8837BE46; Fri, 15 Sep 2023 08:46:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236284AbjIOPpy (ORCPT + 99 others); Fri, 15 Sep 2023 11:45:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236309AbjIOPp2 (ORCPT ); Fri, 15 Sep 2023 11:45:28 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A7FFE78 for ; Fri, 15 Sep 2023 08:45:23 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1bf57366ccdso24649435ad.1 for ; Fri, 15 Sep 2023 08:45:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1694792722; x=1695397522; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Th8NoXT19fs06IrPnES4vcAsMrYG/0js4/EA9rEsqpw=; b=GKq65H6JA1W1dliPy/GlfT3r1SP7qTE17EPxUtrIs2pfoR/f13wgNjmV+SDHXdfXSl 4EMqNtHTwGs7Zt/xKWaQt4FQbWpcj39uMOQ3vqlov3os3IL+OTQgJk6SaN4ZuJau+rwY rAQH1YqhB+arZAAcDLZJJABkvQ2UmO8+iYZfsqDF0ZekpRJOMsIMjmvGbdHBVR0rd1BS rYj7+h75RX+rOGPEILwCVry3FMwj/D/ofM7m3HQPsVjDjFuO4doz8tcJ5faXro3f28YJ +jxCYYux5nQUpAhUQ+fHcuoQ5McagiadShN9aloBazXQsfp5JT0BdLWMLqlqIBV+k6ya R3Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694792722; x=1695397522; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Th8NoXT19fs06IrPnES4vcAsMrYG/0js4/EA9rEsqpw=; b=HxhsOx6ag4bF1XsoHi9maW/xryHQyLnLAxjGmVtl3dSDtiGGkzn4cUx3ez28W5vXIy uMJIeXLbjxAaQYVtWjIFVbpP/JXoDbqWpmDEPag/8wNUDIs2VBGIp2kOWYxY5UfyV9vF 5wsZZY5NqfqOwWNaN5N5+g77BOTL3VbjcbbLNPFxTtWRyy2MO3ebroFthahKYJ7Qgk7f ES9nV87kitGQ+zG7fXfH8MBuoWxATEsNGhzdirzdUKL1hp434emNZulUkTp2GFomnLAl yevqpngW29bjc7CtNlAt3U4paONKkD2ypF74dQ/SkVVINZkClzU+Zjj9CCkrpvjzWBsj y5+A== X-Gm-Message-State: AOJu0YwT33muF7KxiZ7g07E0tGmtti7xk2aWkKaklmnDi2PJZnZCrxJS TheIiWHTe1hyWcoRFEhb5CUD+Q== X-Received: by 2002:a17:902:ea0b:b0:1c3:9928:7b28 with SMTP id s11-20020a170902ea0b00b001c399287b28mr7149415plg.6.1694792722551; Fri, 15 Sep 2023 08:45:22 -0700 (PDT) Received: from ghost ([50.168.177.76]) by smtp.gmail.com with ESMTPSA id u6-20020a170902b28600b001b672af624esm3640532plr.164.2023.09.15.08.45.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 08:45:22 -0700 (PDT) Date: Fri, 15 Sep 2023 11:45:19 -0400 From: Charlie Jenkins To: David Laight Cc: Palmer Dabbelt , Conor Dooley , Samuel Holland , "linux-riscv@lists.infradead.org" , "linux-kernel@vger.kernel.org" , Paul Walmsley , Albert Ou Subject: Re: [PATCH v5 1/4] asm-generic: Improve csum_fold Message-ID: References: <20230914-optimize_checksum-v5-0-c95b82a2757e@rivosinc.com> <20230914-optimize_checksum-v5-1-c95b82a2757e@rivosinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=2.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_SBL_CSS, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.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 (morse.vger.email [0.0.0.0]); Fri, 15 Sep 2023 08:46:42 -0700 (PDT) On Fri, Sep 15, 2023 at 07:29:23AM +0000, David Laight wrote: > From: Charlie Jenkins > > Sent: 15 September 2023 04:50 > > > > This csum_fold implementation introduced into arch/arc by Vineet Gupta > > is better than the default implementation on at least arc, x86, arm, and > > riscv. Using GCC trunk and compiling non-inlined version, this > > implementation has 41.6667%, 25%, 16.6667% fewer instructions on > > riscv64, x86-64, and arm64 respectively with -O3 optimization. > > Nit-picking the commit message... > Some of those architectures have their own asm implementation. > The arm one is better than the C code below, the x86 ones aren't. I can clean up the commit message to be more accurate. > > I think that only sparc32 (carry flag but no rotate) and > arm/arm64 (barrel shifter on every instruction) have versions > that are better than the one here. > > Since I suggested it to Charlie: > > Reviewed-by: David Laight > > > > > Signed-off-by: Charlie Jenkins > > --- > > include/asm-generic/checksum.h | 5 +---- > > 1 file changed, 1 insertion(+), 4 deletions(-) > > > > diff --git a/include/asm-generic/checksum.h b/include/asm-generic/checksum.h > > index 43e18db89c14..adab9ac4312c 100644 > > --- a/include/asm-generic/checksum.h > > +++ b/include/asm-generic/checksum.h > > @@ -30,10 +30,7 @@ extern __sum16 ip_fast_csum(const void *iph, unsigned int ihl); > > */ > > static inline __sum16 csum_fold(__wsum csum) > > { > > - u32 sum = (__force u32)csum; > > You'll need to re-instate that line to stop sparse complaining. I will add that back, thanks. - Charlie > > > - sum = (sum & 0xffff) + (sum >> 16); > > - sum = (sum & 0xffff) + (sum >> 16); > > - return (__force __sum16)~sum; > > + return (__force __sum16)((~csum - ror32(csum, 16)) >> 16); > > } > > #endif > > > > > > -- > > 2.42.0 > > - > Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK > Registration No: 1397386 (Wales)