Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5124727pxj; Tue, 22 Jun 2021 15:58:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytJwzPCVS0tVu0u22pcAQEScIJk8oEwQQhSvyewewjfpSSGSTgXCZMv930C/pFMn1Vejwy X-Received: by 2002:a05:6402:1911:: with SMTP id e17mr4666412edz.36.1624402681289; Tue, 22 Jun 2021 15:58:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624402681; cv=none; d=google.com; s=arc-20160816; b=iGraNHVLgSHvpchaLbq4zrfQ+9bdOQIsve31bASiuy+DA1Zl5+MBTx7s3klWeMz4R1 ZBOA7ZK1h9J2xdRYDnvMmCiKQSSUnDHSqnpYWHOPtlHRmKHDMaoxGhw/+a0JX30pRCiJ 0LDq5e8Rj8TJ1tp78HIxLZ48jgcBlUAlB4j0Ge0KDMl6zk0TOLpWYh4xgfYl3HhC5R0B GpO218dw7vkT7sLoiOeUDO1I218CtnDuMNIDuhnOaV3+mhbqL6FnHJsdEB5FNrzRBRnN hHQkqp8XCkD+HXXE3oCEvTt15qHtLrHQajllfjA2cQBeQEbNm0ZGpcrnODE7iOth9bEt Bl0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature:dkim-filter; bh=Tl/MqcbHnp8xGqeWdgRroSBwVZt7wf+ch9P7/tROCwQ=; b=nyzS2exRe9nyi+J+PHusywJkdLo0brDYibW4WwqkwoQbISdv+GqKNcHuVkSGlIpIkQ aRH7EkR+w6w0TfGAHlnvcWvqbk2871xV738/ZQMofN0704k9w/sJM3TYCRlpxvFEp/Jx ZjKGQ8SEAKaN/faklBpk9Jnw/WvYoBDIL/O0VzbNN5rmw5pjpn5MPwjQrfyFmsEOXFXm 5sBcJI3UH1XmR4Iqk6Hey8ZgK20n1bhyLd6qaTIRuT2li2SxsqMR+/kNe/bPT5fO/bDV y0DPi/9yNbm1/ZVKBgElgbQR7pPYKYPtYq1Rdb8yzSoK3bHiFTaPD9d6EIQcqvvrh42G 8Ynw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=HS9Z03ml; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dc28si7683275edb.169.2021.06.22.15.57.38; Tue, 22 Jun 2021 15:58:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=HS9Z03ml; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230185AbhFVW43 (ORCPT + 99 others); Tue, 22 Jun 2021 18:56:29 -0400 Received: from linux.microsoft.com ([13.77.154.182]:55326 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229873AbhFVW42 (ORCPT ); Tue, 22 Jun 2021 18:56:28 -0400 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by linux.microsoft.com (Postfix) with ESMTPSA id E0F4E20B7178; Tue, 22 Jun 2021 15:54:11 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com E0F4E20B7178 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1624402451; bh=Tl/MqcbHnp8xGqeWdgRroSBwVZt7wf+ch9P7/tROCwQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=HS9Z03mla6AcYrNF8e9t4BhRj+ZqxeC0m28b60MnUtCj5BoPxHGcsrgbvI85JV5fc rzTdN5SWGtvDovnJNq0tw5dGdwYPNiBE/uicd+MaewLpbxcEn8U5+10vccqWQbJzkZ YAF53lKJbJZpAjE1iAx3GJtvPELzKqTs/I74L2CQ= Received: by mail-pj1-f53.google.com with SMTP id z3-20020a17090a3983b029016bc232e40bso108979pjb.4; Tue, 22 Jun 2021 15:54:11 -0700 (PDT) X-Gm-Message-State: AOAM532qD5KkFuocTtLhJcZX5tN5HoycC0Owtu4a6yERs9RxtSduXLB2 bSaVeSkR+lDn3fCOo8/pq/KVfjsfeqL8YlUgZFw= X-Received: by 2002:a17:90a:1e82:: with SMTP id x2mr6352268pjx.11.1624402451512; Tue, 22 Jun 2021 15:54:11 -0700 (PDT) MIME-Version: 1.0 References: <20210617152754.17960-1-mcroce@linux.microsoft.com> <20210617152754.17960-2-mcroce@linux.microsoft.com> <17bb90eef20145cd9cca1b8e72a514ad@AcuMS.aculab.com> In-Reply-To: <17bb90eef20145cd9cca1b8e72a514ad@AcuMS.aculab.com> From: Matteo Croce Date: Wed, 23 Jun 2021 00:53:35 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 1/3] riscv: optimized memcpy To: David Laight Cc: Christoph Hellwig , "linux-riscv@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "linux-arch@vger.kernel.org" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Atish Patra , Emil Renner Berthing , Akira Tsukamoto , Drew Fustini , Bin Meng , Guo Ren Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 22, 2021 at 10:19 AM David Laight wrote: > > From: Christoph Hellwig > > Sent: 21 June 2021 15:27 > ... > > > + for (next = s.ulong[0]; count >= bytes_long + mask; count -= bytes_long) { > > > > Please avoid the pointlessly overlong line. And (just as a matter of > > personal preference) I find for loop that don't actually use a single > > iterator rather confusing. Wjy not simply: > > > > next = s.ulong[0]; > > while (count >= bytes_long + mask) { > > ... > > count -= bytes_long; > > } > > My fist attack on long 'for' statements is just to move the > initialisation to the previous line. > Then make sure there is nothing in the comparison that needs > to be calculated every iteration. > I suspect you can subtract 'mask' from 'count'. > Giving: > count -= mask; > next = s.ulong[0]; > for (;; count > bytes_long; count -= bytes_long) { > This way we'll lose the remainder, as count is used at the end to copy the leftover. Anyway, both bytes_long and mask are constant, I doubt they get summed at every cycle. > Next is to shorten the variable names! > > David > -- per aspera ad upstream