From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7D58C48BE5 for ; Tue, 15 Jun 2021 13:45:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A5F3461439 for ; Tue, 15 Jun 2021 13:45:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231179AbhFONrf (ORCPT ); Tue, 15 Jun 2021 09:47:35 -0400 Received: from linux.microsoft.com ([13.77.154.182]:37894 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230208AbhFONr3 (ORCPT ); Tue, 15 Jun 2021 09:47:29 -0400 Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) by linux.microsoft.com (Postfix) with ESMTPSA id 9BF3420B6AEE; Tue, 15 Jun 2021 06:45:24 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 9BF3420B6AEE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1623764724; bh=7UULkM9VpH3Wm7vWsgwZVD3p39+NvKKLXs8u9XWsGBo=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Oq4u01Z10/CBCJu1HPj1Vvu1ftm2kYNH8idZjB5WxkhgjgnbVMq39iDdAuuSQLAKZ VpLVpJEDIigDfAepMNu7TJYWdwBEnpDnzMtuRsyP711OYly94uxU2aKOYJp+2iOD13 muGQXPdC0UaG2FxC5mIDCKB+7DBU9tQHsbH7EBnM= Received: by mail-pg1-f170.google.com with SMTP id w31so8981943pga.6; Tue, 15 Jun 2021 06:45:24 -0700 (PDT) X-Gm-Message-State: AOAM531vgRD2KSxrHohSGbWTI+4qqhm4tf4GxHppwEDyTSeik/fwiDDT 1N3bQ2ZTd6+YLPf6CK0LoESRwNXlFVL9ITMPLrM= X-Google-Smtp-Source: ABdhPJyzNMA1hikc4GzmgcUaRxwOH9kITpR2EgDgak8cpnVdiiCAfUiybdtEp1A5PpHdPahqGVJBiDJhevSMLxRuI3Q= X-Received: by 2002:a63:1703:: with SMTP id x3mr22496302pgl.421.1623764724145; Tue, 15 Jun 2021 06:45:24 -0700 (PDT) MIME-Version: 1.0 References: <20210615023812.50885-1-mcroce@linux.microsoft.com> <20210615023812.50885-2-mcroce@linux.microsoft.com> <6cff2a895db94e6fadd4ddffb8906a73@AcuMS.aculab.com> <1632006872b04c64be828fa0c4e4eae0@AcuMS.aculab.com> In-Reply-To: <1632006872b04c64be828fa0c4e4eae0@AcuMS.aculab.com> From: Matteo Croce Date: Tue, 15 Jun 2021 15:44:48 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/3] riscv: optimized memcpy To: David Laight Cc: Bin Meng , "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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 15, 2021 at 3:18 PM David Laight wrote: > > From: Bin Meng > > Sent: 15 June 2021 14:09 > > > > On Tue, Jun 15, 2021 at 4:57 PM David Laight wrote: > > > > ... > > > I'm surprised that the C loop: > > > > > > > + for (; count >= bytes_long; count -= bytes_long) > > > > + *d.ulong++ = *s.ulong++; > > > > > > ends up being faster than the ASM 'read lots' - 'write lots' loop. > > > > I believe that's because the assembly version has some unaligned > > access cases, which end up being trap-n-emulated in the OpenSBI > > firmware, and that is a big overhead. > > Ah, that would make sense since the asm user copy code > was broken for misaligned copies. > I suspect memcpy() was broken the same way. > > I'm surprised IP_NET_ALIGN isn't set to 2 to try to > avoid all these misaligned copies in the network stack. > Although avoiding 8n+4 aligned data is rather harder. > That's up to the network driver, indeed I have a patch already for the BeagleV one: https://lore.kernel.org/netdev/20210615012107.577ead86@linux.microsoft.com/T/ > Misaligned copies are just best avoided - really even on x86. > The 'real fun' is when the access crosses TLB boundaries. > -- per aspera ad upstream