Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3695700pxj; Tue, 15 Jun 2021 06:46:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKXajxfGcToANNObW3+CWU8NBkL95sUdbVMX8GAsoh2Xs9o3hlVrd1IdOld4M3oePQvmrD X-Received: by 2002:a17:906:149a:: with SMTP id x26mr21455520ejc.41.1623764817546; Tue, 15 Jun 2021 06:46:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623764817; cv=none; d=google.com; s=arc-20160816; b=EdmpH41NXHzw1ZDDbpUbp1dTTXVanNOHHvaRMjt751TYXOnphnrZqAhPt9QAIchrd4 WVtNsplRrNCkBWFDJfDVAtaJ7uDiyKAu/svE8ugu7DEjsosc9+ZOlNggtEo3tytFuAeh ovcvRvpmzFU5Q1hx8EXxbxaePlmeaNegRxecAQP+dW+lQrQCV6uMlREjXsT/kjKxxFoY YCD4fn8EZZCJrjmr+BlipXgfdSSbMp6FudGYxdS+l0T1b1IX6IN4uQil1ryt/XiBBruH U2+NIeZnGwDio/xjKmrSXIHYj9vpWuhFuzmFeGdKpqpEgz+7uMwooc2iTH/HbT/n4Hcd IeIA== 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=7UULkM9VpH3Wm7vWsgwZVD3p39+NvKKLXs8u9XWsGBo=; b=lmrGgtMjwEONi/kcm/+Esr+kmG7HV5wpuosh9Lv61waQkFbvudweW+YgD+OfAcvSxB 3kV6dZFYltjwmY9wQhMtOuFUrxCm/CbvydXabZDfNon13OcEnxHLZr9SA9y4i6Wqn904 wY3mjDKLFExrH0MgvEQk2CYd2mXx4toSPJtCwC+kkckgCcIppD7mC/201L9wPG36W8w0 Qz6aYSz6yNJpJ28TpBGJPxh5Srmq3IswUcJxR23CcJHqa5BvjMHGYrVxoUTdol32aIBB bLIBAAehxkMKCSg4BHLiDfU60qdGBNi27FQIs7zkvHOHVQFQJKt6dxJuU1IstakPwyCT sLjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=Oq4u01Z1; 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 b24si14145557edr.577.2021.06.15.06.46.30; Tue, 15 Jun 2021 06:46:57 -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=Oq4u01Z1; 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 S230444AbhFONrd (ORCPT + 99 others); Tue, 15 Jun 2021 09:47:33 -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-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